18 #include <pinocchio/fwd.hpp> 22 #include <dynamic-graph/factory.h> 24 #include <boost/property_tree/ptree.hpp> 37 #define PROFILE_PWM_DESIRED_COMPUTATION \ 39 #define PROFILE_DYNAMIC_GRAPH_PERIOD \ 43 #define OUTPUT_SIGNALS 58 m_initSucceeded(false),
59 m_emergency_stop_triggered(false),
60 m_is_first_iter(true),
69 "Time period in seconds (double)",
70 "URDF file path (string)",
71 "Robot reference (string)")));
76 "Time period in seconds (double)")));
82 "(string) joint name",
"(double) joint id")));
85 "setForceNameToForceId",
89 "Set map from a force sensor name to a force sensor Id",
90 "(string) force sensor name",
"(double) force sensor id")));
96 "(double) joint id",
"(double) lower limit",
97 "(double) uppper limit")));
100 "setForceLimitsFromId",
104 "(double) force sensor id",
"(double) lower limit",
105 "(double) uppper limit")));
108 "setJointsUrdfToSot",
111 "Vector of integer for mapping")));
114 "setRightFootSoleXYZ",
117 "Vector of 3 doubles")));
119 "setRightFootForceSensorXYZ",
122 "Vector of 3 doubles")));
128 "(string) Foot name",
"(string) Frame name")));
133 "(string) Hand name",
"(string) Frame name")));
138 "(string) Joint name")));
147 *
this, &ParameterServer::setParameter<bool>,
149 "ParameterValue (string format).",
150 "(string) ParameterName",
"(bool) ParameterValue")));
154 *
this, &ParameterServer::setParameter<int>,
156 "ParameterValue (string format).",
157 "(string) ParameterName",
"(int) ParameterValue")));
160 *
this, &ParameterServer::setParameter<double>,
162 "ParameterValue (string format).",
163 "(string) ParameterName",
164 "(double) ParameterValue")));
168 *
this, &ParameterServer::setParameter<std::string>,
170 "ParameterValue (string format).",
171 "(string) ParameterName",
172 "(string) ParameterValue")));
177 docCommandReturnType1<std::string>(
178 "Return the parameter value for parameter" 179 " named ParameterName.",
180 "(string) ParameterName")));
185 *
this, &ParameterServer::getParameter<int>,
186 docCommandReturnType1<int>(
"Return the parameter value for parameter" 187 " named ParameterName.",
188 "(int) ParameterName")));
193 docCommandReturnType1<double>(
194 "Return the parameter value for parameter" 195 " named ParameterName.",
196 "(double) ParameterName")));
201 *
this, &ParameterServer::getParameter<bool>,
202 docCommandReturnType1<bool>(
"Return the parameter value for parameter" 203 " named ParameterName.",
204 "(string) ParameterName")));
216 std::shared_ptr<std::vector<std::string> > listOfRobots =
219 if (listOfRobots->size() == 1)
220 localName = (*listOfRobots)[0];
222 std::ostringstream oss;
223 oss <<
"No robot registered in the parameter server list";
224 oss <<
" listOfRobots->size: " << listOfRobots->size();
225 throw ExceptionTools(ExceptionTools::ErrorCodeEnum::PARAMETER_SERVER,
236 "getJointsUrdfToSot",
239 "Vector of integer for mapping")));
243 const std::string &robotRef) {
266 const double &jointId) {
269 "Cannot set joint name from joint id before initialization!");
272 m_robot_util->set_name_to_id(jointName, static_cast<Index>(jointId));
276 const double &lq,
const double &uq) {
279 "Cannot set joints limits from joint id before initialization!");
291 "Cannot set force limits from force id before initialization!");
299 const double &forceId) {
302 "Cannot set force sensor name from force sensor id " 303 " before initialization!");
307 m_robot_util->m_force_util.set_name_to_force_id(forceName,
308 static_cast<Index>(forceId));
322 "Cannot set right foot sole XYZ before initialization!");
333 "Cannot set right foot force sensor XYZ before initialization!");
337 m_robot_util->m_foot_util.m_Right_Foot_Force_Sensor_XYZ = xyz;
341 const std::string &FrameName) {
346 if (FootName ==
"Left")
347 m_robot_util->m_foot_util.m_Left_Foot_Frame_Name = FrameName;
348 else if (FootName ==
"Right")
349 m_robot_util->m_foot_util.m_Right_Foot_Frame_Name = FrameName;
355 const std::string &FrameName) {
360 if (HandName ==
"Left")
361 m_robot_util->m_hand_util.m_Left_Hand_Frame_Name = FrameName;
362 else if (HandName ==
"Right")
363 m_robot_util->m_hand_util.m_Right_Hand_Frame_Name = FrameName;
366 "Available hand names are 'Left' and 'Right', not '" + HandName +
388 SEND_MSG(
"The specified joint name does not exist: " + name,
390 std::stringstream ss;
391 for (
long unsigned int it = 0; it <
m_robot_util->m_nbJoints; it++)
396 id = (
unsigned int)jid;
403 double jl = JL.
lower;
406 " is smaller than lower limit: " +
toString(jl),
410 double ju = JL.
upper;
413 " is larger than upper limit: " +
toString(ju),
425 os <<
"ParameterServer " <<
getName();
void setRightFootSoleXYZ(const dynamicgraph::Vector &)
CommandVoid0< E > * makeCommandVoid0(E &entity, boost::function< void(void)> function, const std::string &docString)
DirectGetter< E, T > * makeDirectGetter(E &entity, T *ptr, const std::string &docString)
bool m_emergency_stop_triggered
control loop time period
double m_dt
true if the entity has been successfully initialized
void setJoints(const dynamicgraph::Vector &)
Eigen::VectorXd::Index Index
RobotUtilShrPtr createRobotUtil(std::string &robotName)
std::string localName("robot_test")
virtual void display(std::ostream &os) const
void setForceLimitsFromId(const double &jointId, const dynamicgraph::Vector &lq, const dynamicgraph::Vector &uq)
Command related to ForceUtil.
CommandVoid1< E, T > * makeCommandVoid1(E &entity, boost::function< void(const T &)> function, const std::string &docString)
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(FeaturePosture, "FeaturePosture")
void init_simple(const double &dt)
bool isJointInRange(unsigned int id, double q)
RobotUtilShrPtr m_robot_util
void setJointLimitsFromId(const double &jointId, const double &lq, const double &uq)
std::string docCommandVoid1(const std::string &doc, const std::string &type)
ParameterServer(const std::string &name)
FilterDifferentiator EntityClassName
std::shared_ptr< std::vector< std::string > > getListOfRobots()
std::string docCommandVoid0(const std::string &doc)
void setHandFrameName(const std::string &, const std::string &)
std::string docCommandVoid3(const std::string &doc, const std::string &type1, const std::string &type2, const std::string &type3)
void init(const double &dt, const std::string &urdfFile, const std::string &robotRef)
CommandVoid3< E, T1, T2, T3 > * makeCommandVoid3(E &entity, typename CommandVoid3< E, T1, T2, T3 >::function_t function, const std::string &docString)
#define SEND_MSG(msg, type)
std::string toString(const T &v, const int precision=3, const int width=-1)
void setFootFrameName(const std::string &, const std::string &)
RobotUtilShrPtr RefVoidRobotUtil()
void setForceNameToForceId(const std::string &forceName, const double &forceId)
void setImuJointName(const std::string &)
RobotUtilShrPtr getRobotUtil(std::string &robotName)
const std::string & getName() const
#define SEND_WARNING_STREAM_MSG(msg)
void setRightFootForceSensorXYZ(const dynamicgraph::Vector &)
std::string docCommandVoid2(const std::string &doc, const std::string &type1, const std::string &type2)
CommandReturnType1< E, ReturnType, T > * makeCommandReturnType1(E &entity, boost::function< ReturnType(const T &)> function, const std::string &docString)
void addCommand(const std::string &name, command::Command *command)
void setNameToId(const std::string &jointName, const double &jointId)
Commands related to joint name and joint id.
bool isNameInRobotUtil(std::string &robotName)
std::string docDirectSetter(const std::string &name, const std::string &type)
CommandVoid2< E, T1, T2 > * makeCommandVoid2(E &entity, boost::function< void(const T1 &, const T2 &)> function, const std::string &docString)
bool convertJointNameToJointId(const std::string &name, unsigned int &id)