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

Tesseract collision contact managers factory test. More...

Functions

void runContactManagersFactoryTest (const std::filesystem::path &config_path)
 runContactManagersFactoryTest (config_path)
 runContactManagersFactoryTest (export_config_path)
 EXPECT_EQ (sp.size(), 2)
 for (auto it=search_paths.begin();it !=search_paths.end();++it)
 EXPECT_EQ (sl.size(), 2)
 EXPECT_EQ (discrete_plugins.size(), 3)
 EXPECT_EQ (continuous_plugins.size(), 2)
 FAIL ()<< "Expected plugin discovery validation to fail"
 catch (const std::runtime_error &error)
 EXPECT_FALSE (factory.getSearchPaths().empty())
 EXPECT_EQ (factory.getSearchPaths().size(), 1)
 EXPECT_EQ (factory.getSearchLibraries().size(), 2)
 EXPECT_EQ (factory.getDiscreteContactManagerPlugins().size(), 0)
 EXPECT_ANY_THROW (factory.getDefaultDiscreteContactManagerPlugin())
 EXPECT_FALSE (factory.hasDiscreteContactManagerPlugins())
factory addSearchPath ("/usr/local/lib")
factory addSearchLibrary ("tesseract_collision")
 EXPECT_EQ (factory.getSearchLibraries().size(), 3)
 EXPECT_TRUE (map.find("NotFound")==map.end())
factory addDiscreteContactManagerPlugin ("TestDiscreteManager", pi)
 EXPECT_TRUE (factory.hasDiscreteContactManagerPlugins())
 EXPECT_TRUE (map.find("TestDiscreteManager") !=map.end())
 EXPECT_EQ (factory.getDefaultDiscreteContactManagerPlugin(), "TestDiscreteManager")
factory addDiscreteContactManagerPlugin ("Test2DiscreteManager", pi2)
 EXPECT_TRUE (map.find("Test2DiscreteManager") !=map.end())
 EXPECT_EQ (factory.getDefaultDiscreteContactManagerPlugin(), "Test2DiscreteManager")
factory setDefaultDiscreteContactManagerPlugin ("TestDiscreteManager")
factory removeDiscreteContactManagerPlugin ("TestDiscreteManager")
 EXPECT_ANY_THROW (factory.removeDiscreteContactManagerPlugin("DoesNotExist"))
factory addContinuousContactManagerPlugin ("TestContinuousManager", pi)
 EXPECT_TRUE (map.find("TestContinuousManager") !=map.end())
 EXPECT_EQ (factory.getDefaultContinuousContactManagerPlugin(), "TestContinuousManager")
factory addContinuousContactManagerPlugin ("Test2ContinuousManager", pi2)
 EXPECT_TRUE (map.find("Test2ContinuousManager") !=map.end())
 EXPECT_EQ (factory.getDefaultContinuousContactManagerPlugin(), "Test2ContinuousManager")
factory setDefaultContinuousContactManagerPlugin ("TestContinuousManager")
factory removeContinuousContactManagerPlugin ("TestContinuousManager")
int main (int argc, char **argv)

Variables

std::filesystem::path config_path = file_path.parent_path() / "contact_manager_plugins.yaml"
std::filesystem::path export_config_path
tesseract::common::GeneralResourceLocator locator
ContactManagersPluginFactory factory (config, locator)
YAML::Node plugin_config = tesseract::common::loadYamlString(config, locator)
const YAML::Node & plugin_info = plugin_config["contact_manager_plugins"]
const YAML::Node & search_paths = plugin_info["search_paths"]
const YAML::Node & search_libraries = plugin_info["search_libraries"]
const YAML::Node & discrete_plugins = plugin_info["discrete_plugins"]["plugins"]
const YAML::Node & continuous_plugins = plugin_info["continuous_plugins"]["plugins"]
 try
tesseract::common::PluginInfo pi
pi class_name = "TestDiscreteManagerFactory"
 map = factory.getDiscreteContactManagerPlugins()
tesseract::common::PluginInfo pi2

Detailed Description

Tesseract collision contact managers factory test.

Author
Levi Armstrong
Date
October 25, 2021
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.

Function Documentation

◆ EXPECT_EQ() [1/2]

EXPECT_EQ ( sp. size(),
2  )
Initial value:
{
std::vector<std::string> sp = factory.getSearchPaths()

◆ EXPECT_EQ() [2/2]

EXPECT_EQ ( sl. size(),
2  )
Initial value:
{
std::vector<std::string> sl = factory.getSearchLibraries()

◆ EXPECT_TRUE()

EXPECT_TRUE ( map. find"NotFound" = =map.end())
Initial value:
{
tesseract::common::PluginInfoMap map = factory.getContinuousContactManagerPlugins()
std::map< std::string, PluginInfo > PluginInfoMap
A map of PluginInfo to user defined name.
Definition plugin_info.h:56

Variable Documentation

◆ export_config_path

std::filesystem::path export_config_path
Initial value:
= std::filesystem::path(tesseract::common::getTempPath()) / "contac"
"t_"
"manage"
"r_"
"plugin"
"s_"
"export"
".yaml"
std::string getTempPath()
Get the host temp directory path.
Definition utils.cpp:317

◆ locator

Initial value:
{
std::string config = R"(contact_manager_plugins:
search_paths:
- /usr/local/lib
search_libraries:
- tesseract_collision_bullet_factories
- tesseract_collision_fcl_factories
discrete_plugins:
default: BulletDiscreteBVHManager
plugins:
BulletDiscreteBVHManager:
class: BulletDiscreteBVHManagerFactory
BulletDiscreteSimpleManager:
class: BulletDiscreteSimpleManagerFactory
FCLDiscreteBVHManager:
class: FCLDiscreteBVHManagerFactory
continuous_plugins:
default: BulletCastBVHManager
plugins:
BulletCastBVHManager:
class: BulletCastBVHManagerFactory
BulletCastSimpleManager:
class: BulletCastSimpleManagerFactory)"

◆ try

try
Initial value:
{
ContactManagersPluginFactory factory(config, locator)
Definition contact_managers_plugin_factory.h:113