8 #ifndef __sot_core_robot_utils_H__
9 #define __sot_core_robot_utils_H__
16 #include <pinocchio/fwd.hpp>
19 #include <dynamic-graph/linear-algebra.h>
20 #include <dynamic-graph/logger.h>
21 #include <dynamic-graph/signal-helper.h>
23 #include <boost/assign.hpp>
24 #include <boost/property_tree/ptree.hpp>
50 void go_through(boost::property_tree::ptree &pt,
int level,
int stage);
53 boost::property_tree::ptree tree_;
54 std::vector<std::string> mimic_joints_;
55 std::string current_joint_name_;
56 void go_through_full();
63 ForceLimits() : upper(Vector6d::Zero()), lower(Vector6d::Zero()) {}
65 ForceLimits(
const Eigen::VectorXd &l,
const Eigen::VectorXd &u)
66 : upper(u), lower(l) {}
82 const dynamicgraph::Vector &lf,
83 const dynamicgraph::Vector &uf);
228 void sendMsg(
const std::string &msg, MsgType t = MSG_TYPE_INFO,
229 const std::string &lineId =
"");
244 template <
typename Type>
246 const Type ¶meter_value) {
248 typedef boost::property_tree::ptree::path_type path;
249 path apath(parameter_name,
'/');
250 property_tree_.put<Type>(apath, parameter_value);
251 }
catch (
const boost::property_tree::ptree_error &e) {
252 std::ostringstream oss;
253 oss <<
"Robot utils: parameter path is invalid " <<
'\n'
254 <<
" for set_parameter(" << parameter_name <<
")\n"
255 << e.what() << std::endl;
256 sendMsg(oss.str(), MSG_TYPE_ERROR);
267 template <
typename Type>
270 boost::property_tree::ptree::path_type apath(parameter_name,
'/');
271 const Type &res = property_tree_.get<Type>(apath);
274 }
catch (
const boost::property_tree::ptree_error &e) {
275 std::ostringstream oss;
276 oss <<
"Robot utils: parameter path is invalid " <<
'\n'
277 <<
" for get_parameter(" << parameter_name <<
")\n"
278 << e.what() << std::endl;
279 sendMsg(oss.str(), MSG_TYPE_ERROR);
#define SOT_CORE_EXPORT
Definition: api.hh:20
const Eigen::Ref< const Eigen::VectorXd > & ConstRefVector
Definition: matrix-geometry.hh:70
Eigen::VectorXd::Index Index
Definition: robot-utils.hh:39
std::shared_ptr< std::vector< std::string > > getListOfRobots()
const Eigen::Ref< const Eigen::MatrixXd > ConstRefMatrix
Definition: matrix-geometry.hh:72
std::shared_ptr< RobotUtil > RobotUtilShrPtr
Accessors - This should be changed to RobotUtilPtrShared.
Definition: robot-utils.hh:299
Eigen::Ref< Eigen::VectorXd > RefVector
Definition: matrix-geometry.hh:69
RobotUtilShrPtr getRobotUtil(std::string &robotName)
RobotUtilShrPtr createRobotUtil(std::string &robotName)
RobotUtilShrPtr RefVoidRobotUtil()
bool base_se3_to_sot(ConstRefVector pos, ConstRefMatrix R, RefVector q_sot)
bool isNameInRobotUtil(std::string &robotName)
Definition: abstract-sot-external-interface.hh:17
Definition: robot-utils.hh:59
Eigen::VectorXd lower
Definition: robot-utils.hh:61
ForceLimits()
Definition: robot-utils.hh:63
void display(std::ostream &os) const
Eigen::VectorXd upper
Definition: robot-utils.hh:60
ForceLimits(const Eigen::VectorXd &l, const Eigen::VectorXd &u)
Definition: robot-utils.hh:65
Definition: robot-utils.hh:71
std::map< Index, std::string > m_force_id_to_name
Definition: robot-utils.hh:74
Index get_force_id_right_foot()
Definition: robot-utils.hh:107
void set_force_id_left_foot(Index anId)
Definition: robot-utils.hh:105
Index get_id_from_name(const std::string &name)
ForceLimits cp_get_limits_from_id(Index force_id)
void set_force_id_to_limits(const Index &force_id, const dynamicgraph::Vector &lf, const dynamicgraph::Vector &uf)
Index m_Force_Id_Right_Foot
Definition: robot-utils.hh:77
std::map< std::string, Index > m_name_to_force_id
Definition: robot-utils.hh:73
Index get_force_id_left_foot()
Definition: robot-utils.hh:103
Index m_Force_Id_Left_Foot
Definition: robot-utils.hh:76
void set_force_id_right_hand(Index anId)
Definition: robot-utils.hh:101
void display(std::ostream &out) const
void set_force_id_right_foot(Index anId)
Definition: robot-utils.hh:109
Index get_force_id_right_hand()
Definition: robot-utils.hh:99
const std::string & get_name_from_id(Index idx)
void set_name_to_force_id(const std::string &name, const Index &force_id)
const ForceLimits & get_limits_from_id(Index force_id)
std::map< Index, ForceLimits > m_force_id_to_limits
Definition: robot-utils.hh:72
void create_force_id_to_name_map()
Index get_force_id_left_hand()
Definition: robot-utils.hh:95
void set_force_id_left_hand(Index anId)
Definition: robot-utils.hh:97
std::string cp_get_name_from_id(Index idx)
Definition: robot-utils.hh:127
std::string m_Right_Hand_Frame_Name
Definition: robot-utils.hh:129
std::string m_Left_Hand_Frame_Name
Definition: robot-utils.hh:128
void display(std::ostream &os) const
Definition: robot-utils.hh:30
double upper
Definition: robot-utils.hh:31
double lower
Definition: robot-utils.hh:32
JointLimits(double l, double u)
Definition: robot-utils.hh:36
JointLimits()
Definition: robot-utils.hh:34
Definition: robot-utils.hh:133
std::size_t m_nbJoints
Nb of Dofs for the robot.
Definition: robot-utils.hh:150
void set_joint_limits_for_id(const Index &idx, const double &lq, const double &uq)
Set the limits (lq,uq) for joint idx.
dynamicgraph::Vector m_dgv_urdf_to_sot
Definition: robot-utils.hh:172
std::vector< Index > m_urdf_to_sot
Map from the urdf index to the SoT index.
Definition: robot-utils.hh:147
bool config_sot_to_urdf(ConstRefVector q_sot, RefVector q_urdf)
std::map< Index, std::string > m_id_to_name
The map between id and name.
Definition: robot-utils.hh:156
const Index & get_id_from_name(const std::string &name)
void create_id_to_name_map()
bool config_urdf_to_sot(ConstRefVector q_urdf, RefVector q_sot)
HandUtil m_hand_util
Hand information.
Definition: robot-utils.hh:144
bool velocity_urdf_to_sot(ConstRefVector q_urdf, ConstRefVector v_urdf, RefVector v_sot)
Type get_parameter(const std::string ¶meter_name)
Get a parameter of type string. If parameter_name already exists the value is overwritten....
Definition: robot-utils.hh:268
std::string m_urdf_filename
URDF file path.
Definition: robot-utils.hh:170
boost::property_tree::ptree property_tree_
Property tree.
Definition: robot-utils.hh:295
void display(std::ostream &os) const
JointLimits cp_get_joint_limits_from_id(Index id)
void set_parameter(const std::string ¶meter_name, const Type ¶meter_value)
Set a parameter of type string. If parameter_name already exists the value is overwritten....
Definition: robot-utils.hh:245
bool base_urdf_to_sot(ConstRefVector q_urdf, RefVector q_sot)
void set_urdf_to_sot(const dynamicgraph::Vector &urdf_to_sot)
boost::property_tree::ptree & get_property_tree()
std::string m_imu_joint_name
The name of the joint IMU is attached to.
Definition: robot-utils.hh:162
void setLoggerVerbosityLevel(LoggerVerbosity lv)
Specify the verbosity level of the logger.
Definition: robot-utils.hh:232
bool joints_urdf_to_sot(ConstRefVector q_urdf, RefVector q_sot)
std::map< Index, JointLimits > m_limits_map
The joint limits map.
Definition: robot-utils.hh:159
bool base_sot_to_urdf(ConstRefVector q_sot, RefVector q_urdf)
void sendMsg(const std::string &msg, MsgType t=MSG_TYPE_INFO, const std::string &lineId="")
Send messages msg with level t. Add string file and line to message.
Logger logger_
Definition: robot-utils.hh:289
std::map< std::string, Index > m_name_to_id
Map from the name to the id.
Definition: robot-utils.hh:153
ForceUtil m_force_util
Forces data.
Definition: robot-utils.hh:138
LoggerVerbosity getLoggerVerbosityLevel()
Get the logger's verbosity level.
Definition: robot-utils.hh:235
std::map< std::string, std::string > parameters_strings_
Map of the parameters: map of strings.
Definition: robot-utils.hh:292
void set_urdf_to_sot(const std::vector< Index > &urdf_to_sot)
Set the map between urdf index and sot index.
const JointLimits & get_joint_limits_from_id(Index id)
void set_name_to_id(const std::string &jointName, const Index &jointId)
Set relation between the name and the SoT id.
bool joints_sot_to_urdf(ConstRefVector q_sot, RefVector q_urdf)
bool velocity_sot_to_urdf(ConstRefVector q_urdf, ConstRefVector v_sot, RefVector v_urdf)
FootUtil m_foot_util
Foot information.
Definition: robot-utils.hh:141
const std::string & get_name_from_id(Index id)
Get the joint name from its index.