1111/* --------------------------------------------------------------------- */
1212/* --- INCLUDE --------------------------------------------------------- */
1313/* --------------------------------------------------------------------- */
14+
15+ /* * pinocchio is forcing the BOOST_MPL_LIMIT_VECTOR_SIZE to a specific value.
16+ This happen to be not working when including the boost property_tree
17+ library. For this reason if defined, the current value of
18+ BOOST_MPL_LIMIT_VECTOR_SIZE is saved in the preprocessor stack and unset.
19+ Once the property_tree included the pinocchio value of this variable is
20+ restored.
21+ */
22+
23+ #ifdef BOOST_MPL_LIMIT_VECTOR_SIZE
24+ #pragma push_macro("BOOST_MPL_LIMIT_VECTOR_SIZE")
25+ #define UNDEF_BOOST_MPL_LIMIT_VECTOR_SIZE
26+ #undef BOOST_MPL_LIMIT_VECTOR_SIZE
27+ #endif
28+
29+ #ifdef BOOST_MPL_LIMIT_LIST_SIZE
30+ #pragma push_macro("BOOST_MPL_LIMIT_LIST_SIZE")
31+ #define UNDEF_BOOST_MPL_LIMIT_LIST_SIZE
32+ #undef BOOST_MPL_LIMIT_LIST_SIZE
33+ #endif
34+
35+ #include < boost/property_tree/ptree.hpp>
36+
37+ #ifdef UNDEF_BOOST_MPL_LIMIT_VECTOR_SIZE
38+ #pragma pop_macro("BOOST_MPL_LIMIT_VECTOR_SIZE")
39+ #undef UNDEF_BOOST_MPL_LIMIT_VECTOR_SIZE
40+ #endif
41+
42+ #ifdef UNDEF_BOOST_MPL_LIMIT_LIST_SIZE
43+ #pragma pop_macro("BOOST_MPL_LIMIT_LIST_SIZE")
44+ #undef UNDEF_BOOST_MPL_LIMIT_LIST_SIZE
45+ #endif
46+
1447#include " boost/assign.hpp"
1548#include < dynamic-graph/linear-algebra.h>
1649#include < dynamic-graph/logger.h>
@@ -32,6 +65,25 @@ struct SOT_CORE_EXPORT JointLimits {
3265
3366typedef Eigen::VectorXd::Index Index;
3467
68+ class SOT_CORE_EXPORT ExtractJointMimics {
69+
70+ public:
71+ // / Constructor
72+ ExtractJointMimics (std::string &robot_model);
73+
74+ // / Get mimic joints.
75+ const std::vector<std::string> &get_mimic_joints ();
76+
77+ private:
78+ void go_through (boost::property_tree::ptree &pt, int level, int stage);
79+
80+ // Create empty property tree object
81+ boost::property_tree::ptree tree_;
82+ std::vector<std::string> mimic_joints_;
83+ std::string current_joint_name_;
84+ void go_through_full ();
85+ };
86+
3587struct SOT_CORE_EXPORT ForceLimits {
3688 Eigen::VectorXd upper;
3789 Eigen::VectorXd lower;
@@ -217,28 +269,61 @@ public:
217269 If parameter_name already exists the value is overwritten.
218270 If not it is inserted.
219271 */
272+ template <typename Type>
220273 void set_parameter (const std::string ¶meter_name,
221- const std::string ¶meter_value);
274+ const Type ¶meter_value) {
275+ try {
276+ typedef boost::property_tree::ptree::path_type path;
277+ path apath (parameter_name, ' /' );
278+ property_tree_.put <Type>(apath, parameter_value);
279+ } catch (const boost::property_tree::ptree_error &e) {
280+ std::ostringstream oss;
281+ oss << " Robot utils: parameter path is invalid " << ' \n '
282+ << " for set_parameter(" << parameter_name << " )\n "
283+ << e.what () << std::endl;
284+ sendMsg (oss.str (), MSG_TYPE_ERROR);
285+ return ;
286+ }
287+ }
222288
223289 /* * \brief Get a parameter of type string.
224290 If parameter_name already exists the value is overwritten.
225291 If not it is inserted.
226292 @param parameter_name: Name of the parameter
227293 Return false if the parameter is not found.
228294 */
229- const std::string &get_parameter (const std::string ¶meter_name);
230-
295+ template <typename Type>
296+ Type get_parameter (const std::string ¶meter_name) {
297+ try {
298+ boost::property_tree::ptree::path_type apath (parameter_name, ' /' );
299+ const Type &res = property_tree_.get <Type>(apath);
300+
301+ return res;
302+ } catch (const boost::property_tree::ptree_error &e) {
303+ std::ostringstream oss;
304+ oss << " Robot utils: parameter path is invalid " << ' \n '
305+ << " for get_parameter(" << parameter_name << " )\n "
306+ << e.what () << std::endl;
307+ sendMsg (oss.str (), MSG_TYPE_ERROR);
308+ }
309+ }
231310 /* * @} */
311+
312+ /* * Access to property tree directly */
313+ boost::property_tree::ptree &get_property_tree ();
314+
232315protected:
233316 Logger logger_;
234317
235318 /* * \brief Map of the parameters: map of strings. */
236319 std::map<std::string, std::string> parameters_strings_;
237320
321+ /* * \brief Property tree */
322+ boost::property_tree::ptree property_tree_;
238323}; // struct RobotUtil
239324
240325// / Accessors - This should be changed to RobotUtilPtrShared
241- typedef boost ::shared_ptr<RobotUtil> RobotUtilShrPtr;
326+ typedef std ::shared_ptr<RobotUtil> RobotUtilShrPtr;
242327
243328RobotUtilShrPtr RefVoidRobotUtil ();
244329RobotUtilShrPtr getRobotUtil (std::string &robotName);
0 commit comments