Tesseract 0.28.4
Loading...
Searching...
No Matches
profile_plugin_factory_unit.cpp File Reference

Tesseract profile plugin factory test. More...

Functions

 EXPECT_TRUE (factory.getSearchPaths().empty())
 
 EXPECT_EQ (factory.getSearchPaths().size(), 0)
 
 EXPECT_FALSE (factory.hasPlugins())
 
 EXPECT_TRUE (factory.getFactoryData()==nullptr)
 
 EXPECT_TRUE (factory.getProfileDictionary().getAllProfileEntries().empty())
 
factory addSearchPath ("/usr/local/lib")
 
 EXPECT_EQ (factory.getSearchPaths().size(), 1)
 
factory addSearchLibrary ("tesseract_collision")
 
factory clearSearchPaths ()
 
factory clearSearchLibraries ()
 
factory setFactoryData (factory_data)
 
 EXPECT_EQ (factory_data, factory.getFactoryData())
 
 EXPECT_TRUE (map.find(ns)==map.end())
 
factory addPlugin (ns, name, pi)
 
 EXPECT_TRUE (map.find(ns) !=map.end())
 
 EXPECT_TRUE (map.at(ns).find(name) !=map.at(ns).end())
 
 EXPECT_EQ (map.find(ns) ->second.size(), 1)
 
factory addPlugin (ns, default_name, pi2)
 
 EXPECT_TRUE (map.at(ns).find(default_name) !=map.at(ns).end())
 
 EXPECT_EQ (map.find(ns) ->second.size(), 2)
 
 EXPECT_ANY_THROW (factory.removePlugin("ns_does_not_exist", default_name))
 
 EXPECT_ANY_THROW (factory.removePlugin(ns, "profile_does_not_exist"))
 
 EXPECT_TRUE (factory.create("ns_does_not_exist", default_name)==nullptr)
 
 EXPECT_TRUE (factory.create(ns, "profile_does_not_exist")==nullptr)
 
factory removePlugin (ns, default_name)
 
factory removePlugin (ns, name)
 
 EXPECT_FALSE (factory.getProfileDictionary().getAllProfileEntries().empty())
 
 EXPECT_EQ (map.size(), 2)
 
 EXPECT_TRUE (map.find("TrajOptCollisionCost") !=map.end())
 
 EXPECT_TRUE (map.at("TrajOptCollisionCost").find("DiscreteCollisionProfile") !=map.at("TrajOptCollisionCost").end())
 
 EXPECT_TRUE (map.at("TrajOptCollisionCost").find("DiscreteCollisionProfile2") !=map.at("TrajOptCollisionCost").end())
 
 EXPECT_EQ (map.find("TrajOptCollisionCost") ->second.size(), 2)
 
 EXPECT_TRUE (map.find("TrajOptCollisionConstraint") !=map.end())
 
 EXPECT_TRUE (map.at("TrajOptCollisionConstraint").find("DiscreteCollisionProfile") !=map.at("TrajOptCollisionConstraint").end())
 
 EXPECT_TRUE (map.at("TrajOptCollisionConstraint").find("DiscreteCollisionProfile2") !=map.at("TrajOptCollisionConstraint").end())
 
 EXPECT_EQ (map.find("TrajOptCollisionConstraint") ->second.size(), 2)
 
 EXPECT_TRUE (plugin !=nullptr)
 
 EXPECT_TRUE (std::dynamic_pointer_cast< TestProfile >(plugin) ->enabled)
 
 EXPECT_FALSE (std::dynamic_pointer_cast< TestProfile >(plugin) ->enabled)
 
factory saveConfig (config_filepath)
 
ProfilePluginFactory factory (config, locator)
 
ProfilePluginFactory factory (config)
 
plugin_yaml remove ("DiscreteCollisionProfile2")
 
 EXPECT_TRUE (plugin==nullptr)
 
plugin_yaml remove ("class")
 
 EXPECT_ANY_THROW (ProfilePluginFactory factory(config, locator))
 
int main (int argc, char **argv)
 

Variables

ProfilePluginFactory factory
 
auto factory_data = std::make_shared<ProfileFactoryData>()
 
const std::string ns { "TesseractCollisionCost" }
 
const std::string name { "freespace" }
 
const std::string default_name { "default" }
 
const std::string class_name { "TestProfileFactory" }
 
tesseract::common::PluginInfo pi
 
 map = factory.getPlugins()
 
tesseract::common::PluginInfo pi2
 
const std::filesystem::path config_filepath
 
tesseract::common::GeneralResourceLocator locator
 
std::string yaml_string
 
std::shared_ptr< Profileplugin = factory.create("TrajOptCollisionCost", "DiscreteCollisionProfile")
 
auto config
 
auto plugin_yaml = config["profile_plugins"]["profiles"]["TrajOptCollisionCost"]
 

Detailed Description

Tesseract profile plugin factory test.

Author
Levi Armstrong
Date
Feb 4, 2025
License
Software License Agreement (Apache License)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Variable Documentation

◆ factory

ProfilePluginFactory factory(config, locator)
Initial value:
{
A general resource loaders using environment variable.
Definition resource_locator.h:84

◆ config_filepath

const std::filesystem::path config_filepath
Initial value:
= std::filesystem::path(tesseract::common::getTempPath()) / "profile_"
"plugins_"
"export.yaml"

◆ yaml_string

std::string yaml_string
Initial value:
= R"(
profile_plugins:
search_paths:
- )" + lib_dir + R"(
search_libraries:
- tesseract_common_test_plugins
profiles:
TrajOptCollisionCost:
DiscreteCollisionProfile:
class: TestProfileFactory
config:
enabled: true
DiscreteCollisionProfile2:
class: TestProfileFactory
config:
enabled: false
TrajOptCollisionConstraint:
DiscreteCollisionProfile:
class: TestProfileFactory
config:
enabled: false
DiscreteCollisionProfile2:
class: TestProfileFactory
config:
enabled: true)"

◆ config

auto config
Initial value:
=
config_yaml[tesseract::common::ProfilesPluginInfo::CONFIG_KEY].as<tesseract::common::ProfilesPluginInfo>()
The profile plugin information structure.
Definition plugin_info.h:70