Skip to content

Commit cb719c2

Browse files
fixup
1 parent 9ed68c5 commit cb719c2

File tree

15 files changed

+549
-53
lines changed

15 files changed

+549
-53
lines changed

tesseract_collision/bullet/include/tesseract_collision/bullet/bullet_factories.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,35 @@ class BulletDiscreteBVHManagerFactory : public DiscreteContactManagerFactory
5555
public:
5656
std::unique_ptr<DiscreteContactManager> create(const std::string& name,
5757
const YAML::Node& config) const override final;
58+
59+
tesseract_common::PropertyTree schema() const override final;
5860
};
5961

6062
class BulletDiscreteSimpleManagerFactory : public DiscreteContactManagerFactory
6163
{
6264
public:
6365
std::unique_ptr<DiscreteContactManager> create(const std::string& name,
6466
const YAML::Node& config) const override final;
67+
68+
tesseract_common::PropertyTree schema() const override final;
6569
};
6670

6771
class BulletCastBVHManagerFactory : public ContinuousContactManagerFactory
6872
{
6973
public:
7074
std::unique_ptr<ContinuousContactManager> create(const std::string& name,
7175
const YAML::Node& config) const override final;
76+
77+
tesseract_common::PropertyTree schema() const override final;
7278
};
7379

7480
class BulletCastSimpleManagerFactory : public ContinuousContactManagerFactory
7581
{
7682
public:
7783
std::unique_ptr<ContinuousContactManager> create(const std::string& name,
7884
const YAML::Node& config) const override final;
85+
86+
tesseract_common::PropertyTree schema() const override final;
7987
};
8088

8189
PLUGIN_ANCHOR_DECL(BulletFactoriesAnchor)

tesseract_collision/bullet/src/bullet_factories.cpp

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,60 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
3939
#include <tesseract_collision/core/discrete_contact_manager.h>
4040
#include <tesseract_collision/core/continuous_contact_manager.h>
4141

42+
#include <tesseract_common/property_tree.h>
43+
4244
namespace tesseract_collision::tesseract_collision_bullet
4345
{
46+
tesseract_common::PropertyTree getConfigSchema()
47+
{
48+
using namespace tesseract_common;
49+
PropertyTree schema;
50+
{
51+
auto& prop = schema["share_pool_allocators"];
52+
prop.setAttribute(property_attribute::TYPE, property_type::BOOL);
53+
prop.setAttribute(property_attribute::DOC, "Indicate if shared pool allocators should be leverage.");
54+
prop.setAttribute(property_attribute::REQUIRED, false);
55+
prop.setAttribute(property_attribute::DEFAULT, false);
56+
}
57+
58+
{
59+
auto& prop = schema["max_persistent_manifold_pool_size"];
60+
prop.setAttribute(property_attribute::TYPE, property_type::INT);
61+
prop.setAttribute(property_attribute::DOC, "The max size for the persistent manifold pool size.");
62+
prop.setAttribute(property_attribute::MINIMUM, 0);
63+
}
64+
65+
{
66+
auto& prop = schema["max_collision_algorithm_pool_size"];
67+
prop.setAttribute(property_attribute::TYPE, property_type::INT);
68+
prop.setAttribute(property_attribute::DOC, "The max size for the persistent algorithm pool size.");
69+
prop.setAttribute(property_attribute::MINIMUM, 0);
70+
}
71+
72+
return schema;
73+
}
74+
4475
TesseractCollisionConfigurationInfo getConfigInfo(const YAML::Node& config)
4576
{
4677
if (config.IsNull())
4778
return {};
4879

80+
// Validate config
81+
tesseract_common::PropertyTree schema = getConfigSchema();
82+
schema.mergeConfig(config);
83+
schema.validate();
84+
4985
bool share_pool_allocators{ false };
50-
if (YAML::Node n = config["share_pool_allocators"])
51-
share_pool_allocators = n.as<bool>();
86+
if (const tesseract_common::PropertyTree& prop = schema.at("share_pool_allocators"))
87+
share_pool_allocators = prop.as<bool>();
5288

5389
TesseractCollisionConfigurationInfo config_info(false, share_pool_allocators);
5490

55-
if (YAML::Node n = config["max_persistent_manifold_pool_size"])
56-
config_info.m_defaultMaxPersistentManifoldPoolSize = n.as<int>();
91+
if (const tesseract_common::PropertyTree& prop = schema.at("max_persistent_manifold_pool_size"))
92+
config_info.m_defaultMaxPersistentManifoldPoolSize = prop.as<int>();
5793

58-
if (YAML::Node n = config["max_collision_algorithm_pool_size"])
59-
config_info.m_defaultMaxCollisionAlgorithmPoolSize = n.as<int>();
94+
if (const tesseract_common::PropertyTree& prop = schema.at("max_collision_algorithm_pool_size"))
95+
config_info.m_defaultMaxCollisionAlgorithmPoolSize = prop.as<int>();
6096

6197
config_info.createPoolAllocators();
6298
return config_info;
@@ -68,24 +104,32 @@ BulletDiscreteBVHManagerFactory::create(const std::string& name, const YAML::Nod
68104
return std::make_unique<BulletDiscreteBVHManager>(name, getConfigInfo(config));
69105
}
70106

107+
tesseract_common::PropertyTree BulletDiscreteBVHManagerFactory::schema() const { return getConfigSchema(); }
108+
71109
std::unique_ptr<DiscreteContactManager> BulletDiscreteSimpleManagerFactory::create(const std::string& name,
72110
const YAML::Node& config) const
73111
{
74112
return std::make_unique<BulletDiscreteSimpleManager>(name, getConfigInfo(config));
75113
}
76114

115+
tesseract_common::PropertyTree BulletDiscreteSimpleManagerFactory::schema() const { return getConfigSchema(); }
116+
77117
std::unique_ptr<ContinuousContactManager> BulletCastBVHManagerFactory::create(const std::string& name,
78118
const YAML::Node& config) const
79119
{
80120
return std::make_unique<BulletCastBVHManager>(name, getConfigInfo(config));
81121
}
82122

123+
tesseract_common::PropertyTree BulletCastBVHManagerFactory::schema() const { return getConfigSchema(); }
124+
83125
std::unique_ptr<ContinuousContactManager> BulletCastSimpleManagerFactory::create(const std::string& name,
84126
const YAML::Node& config) const
85127
{
86128
return std::make_unique<BulletCastSimpleManager>(name, getConfigInfo(config));
87129
}
88130

131+
tesseract_common::PropertyTree BulletCastSimpleManagerFactory::schema() const { return getConfigSchema(); }
132+
89133
PLUGIN_ANCHOR_IMPL(BulletFactoriesAnchor)
90134

91135
} // namespace tesseract_collision::tesseract_collision_bullet

tesseract_collision/core/include/tesseract_collision/core/contact_managers_plugin_factory.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ class DiscreteContactManagerFactory
7070
*/
7171
virtual std::unique_ptr<DiscreteContactManager> create(const std::string& name, const YAML::Node& config) const = 0;
7272

73+
/**
74+
* @brief Get the config yaml schema
75+
* @return The schema
76+
*/
77+
virtual tesseract_common::PropertyTree schema() const = 0;
78+
7379
protected:
7480
static std::string getSection();
7581
friend class boost_plugin_loader::PluginLoader;
@@ -92,6 +98,12 @@ class ContinuousContactManagerFactory
9298
virtual std::unique_ptr<ContinuousContactManager> create(const std::string& solver_name,
9399
const YAML::Node& config) const = 0;
94100

101+
/**
102+
* @brief Get the config yaml schema
103+
* @return The schema
104+
*/
105+
virtual tesseract_common::PropertyTree schema() const = 0;
106+
95107
protected:
96108
static std::string getSection();
97109
friend class boost_plugin_loader::PluginLoader;
@@ -125,6 +137,12 @@ class ContactManagersPluginFactory
125137
*/
126138
ContactManagersPluginFactory(const std::string& config, const tesseract_common::ResourceLocator& locator);
127139

140+
/**
141+
* @brief Get the schema
142+
* @return The schema
143+
*/
144+
tesseract_common::PropertyTree getSchema() const;
145+
128146
/**
129147
* @brief Add location for the plugin loader to search
130148
* @param path The full path to the directory

tesseract_collision/core/src/contact_managers_plugin_factory.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
3434
#include <tesseract_common/resource_locator.h>
3535
#include <tesseract_common/yaml_utils.h>
3636
#include <tesseract_common/yaml_extenstions.h>
37+
#include <tesseract_common/property_tree.h>
3738
#include <tesseract_collision/core/contact_managers_plugin_factory.h>
3839
#include <boost_plugin_loader/plugin_loader.hpp>
3940
#include <console_bridge/console.h>
@@ -61,6 +62,13 @@ ContactManagersPluginFactory::ContactManagersPluginFactory()
6162
boost::token_compress_on);
6263
}
6364

65+
tesseract_common::PropertyTree ContactManagersPluginFactory::getSchema() const
66+
{
67+
tesseract_common::PropertyTree schema;
68+
69+
return schema;
70+
}
71+
6472
void ContactManagersPluginFactory::loadConfig(const YAML::Node& config)
6573
{
6674
if (const YAML::Node& plugin_info = config[ContactManagersPluginInfo::CONFIG_KEY])

tesseract_collision/core/src/types.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,17 @@ void ContactManagerConfig::validate() const
399399
throw std::runtime_error("ContactManagerConfig, pair margin override type is NONE but pair collision margins "
400400
"exist!");
401401

402+
if (pair_margin_override_type != CollisionMarginPairOverrideType::NONE &&
403+
pair_margin_data.getCollisionMargins().empty())
404+
throw std::runtime_error("ContactManagerConfig, pair collision margins are empty, but pair margin override type is "
405+
"not NONE!");
406+
402407
if (acm_override_type == ACMOverrideType::NONE && !acm.getAllAllowedCollisions().empty())
403408
throw std::runtime_error("ContactManagerConfig, acm override type is NONE but allowed collision entries exist!");
409+
410+
if (acm_override_type != ACMOverrideType::NONE && acm.getAllAllowedCollisions().empty())
411+
throw std::runtime_error("ContactManagerConfig, allowed collision entries are empty, but acm override type is not "
412+
"NONE!");
404413
}
405414

406415
bool ContactManagerConfig::operator==(const ContactManagerConfig& rhs) const

tesseract_collision/fcl/include/tesseract_collision/fcl/fcl_factories.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class FCLDiscreteBVHManagerFactory : public DiscreteContactManagerFactory
3636
public:
3737
std::unique_ptr<DiscreteContactManager> create(const std::string& name,
3838
const YAML::Node& config) const override final;
39+
40+
tesseract_common::PropertyTree schema() const override final;
3941
};
4042

4143
PLUGIN_ANCHOR_DECL(FCLFactoriesAnchor)

tesseract_collision/fcl/src/fcl_factories.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <tesseract_collision/fcl/fcl_factories.h>
2828
#include <tesseract_collision/fcl/fcl_discrete_managers.h>
2929
#include <tesseract_collision/core/discrete_contact_manager.h>
30+
#include <tesseract_common/property_tree.h>
3031

3132
namespace tesseract_collision::tesseract_collision_fcl
3233
{
@@ -36,6 +37,8 @@ FCLDiscreteBVHManagerFactory::create(const std::string& name, const YAML::Node&
3637
return std::make_unique<FCLDiscreteBVHManager>(name);
3738
}
3839

40+
tesseract_common::PropertyTree FCLDiscreteBVHManagerFactory::schema() const { return {}; }
41+
3942
PLUGIN_ANCHOR_IMPL(FCLFactoriesAnchor) // LCOV_EXCL_LINE
4043

4144
} // namespace tesseract_collision::tesseract_collision_fcl

tesseract_collision/test/collision_core_unit.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ TEST(TesseractCoreUnit, ContactManagerConfigTest) // NOLINT
125125
EXPECT_ANY_THROW(config.validate()); // NOLINT
126126
}
127127

128+
{
129+
tesseract_collision::ContactManagerConfig config;
130+
config.pair_margin_override_type = tesseract_collision::CollisionMarginPairOverrideType::MODIFY;
131+
EXPECT_ANY_THROW(config.validate()); // NOLINT
132+
}
133+
128134
{
129135
tesseract_collision::ContactManagerConfig config;
130136
config.pair_margin_override_type = tesseract_collision::CollisionMarginPairOverrideType::MODIFY;
@@ -138,6 +144,12 @@ TEST(TesseractCoreUnit, ContactManagerConfigTest) // NOLINT
138144
EXPECT_ANY_THROW(config.validate()); // NOLINT
139145
}
140146

147+
{
148+
tesseract_collision::ContactManagerConfig config;
149+
config.acm_override_type = tesseract_collision::ACMOverrideType::OR;
150+
EXPECT_ANY_THROW(config.validate()); // NOLINT
151+
}
152+
141153
{
142154
tesseract_collision::ContactManagerConfig config;
143155
config.acm_override_type = tesseract_collision::ACMOverrideType::OR;

tesseract_collision/test/contact_manager_plugins.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ contact_manager_plugins:
1111
class: BulletDiscreteBVHManagerFactory
1212
BulletDiscreteSimpleManager:
1313
class: BulletDiscreteSimpleManagerFactory
14+
config:
15+
share_pool_allocators: false
1416
FCLDiscreteBVHManager:
1517
class: FCLDiscreteBVHManagerFactory
1618
continuous_plugins:
@@ -20,4 +22,6 @@ contact_manager_plugins:
2022
class: BulletCastBVHManagerFactory
2123
BulletCastSimpleManager:
2224
class: BulletCastSimpleManagerFactory
25+
config:
26+
share_pool_allocators: false
2327

tesseract_common/include/tesseract_common/plugin_info.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class access;
4545
namespace tesseract_common
4646
{
4747
struct Serialization;
48+
class PropertyTree;
4849

4950
/** @brief The Plugin Information struct */
5051
// NOLINTNEXTLINE
@@ -155,6 +156,9 @@ struct ContactManagersPluginInfo
155156
/** @brief Check if structure is empty */
156157
bool empty() const;
157158

159+
/** @brief Get the schema */
160+
static PropertyTree schema();
161+
158162
// Yaml Config key
159163
static inline const std::string CONFIG_KEY{ "contact_manager_plugins" };
160164

0 commit comments

Comments
 (0)