26 #include <dynamic-graph/factory.h> 30 #include <Eigen/Geometry> 31 #include <pinocchio/multibody/liegroup/special-euclidean.hpp> 36 const std::string Device::CLASS_NAME =
"Device";
41 const double &upper) {
43 assert(lower <= upper);
57 #define CHECK_BOUNDS(val, lower, upper, what, eps) \ 58 for (int i = 0; i < val.size(); ++i) { \ 59 double old = val(i); \ 60 if (saturateBounds(val(i), lower(i), upper(i)) > eps) { \ 61 std::ostringstream oss; \ 62 oss << "Robot " what " bound violation at DoF " << i << ": requested " \ 63 << old << " but set " << val(i) << '\n'; \ 64 SEND_ERROR_STREAM_MSG(oss.str()); \ 73 for (
unsigned int i = 0;
i < 4; ++
i) {
78 Device::Device(
const std::string &
n)
83 controlSIN(NULL,
"Device(" + n +
")::input(double)::control"),
84 attitudeSIN(NULL,
"Device(" + n +
")::input(vector3)::attitudeIN"),
85 zmpSIN(NULL,
"Device(" + n +
")::input(vector3)::zmp"),
86 stateSOUT(
"Device(" + n +
")::output(vector)::state")
89 velocitySOUT(
"Device(" + n +
")::output(vector)::velocity"),
90 attitudeSOUT(
"Device(" + n +
")::output(matrixRot)::attitude"),
91 motorcontrolSOUT(
"Device(" + n +
")::output(vector)::motorcontrol"),
92 previousControlSOUT(
"Device(" + n +
")::output(vector)::previousControl"),
93 ZMPPreviousControllerSOUT(
"Device(" + n +
94 ")::output(vector)::zmppreviouscontroller"),
95 robotState_(
"Device(" + n +
")::output(vector)::robotState"),
96 robotVelocity_(
"Device(" + n +
")::output(vector)::robotVelocity"),
97 pseudoTorqueSOUT(
"Device(" + n +
")::output(vector)::ptorque")
100 lastTimeControlWasRead_(0),
105 for (
int i = 0;
i < 4; ++
i) {
120 << *forcesSOUT[1] << *forcesSOUT[2] << *forcesSOUT[3]
132 std::string docstring;
136 " Set size of state vector\n" 142 " Set state vector value\n" 149 " Set velocity vector value\n" 156 "matrix homogeneous");
163 " Set the position calculous starting from \n" 164 " acceleration measure instead of velocity \n" 174 " Display information on device \n" 182 " Set the type of control input which can be \n" 183 " acceleration, velocity, or position\n" 192 " Enable/Disable sanity checks\n" 202 "vector: lower bounds",
203 "vector: upper bounds")));
209 "vector: lower bounds",
210 "vector: upper bounds")));
216 "vector: lower bounds",
217 "vector: upper bounds")));
227 const double &period) {
229 std::vector<double> control;
234 control.resize(dgControl.size());
239 for (
unsigned int i = 0;
i < dgControl.size(); ++
i) control[
i] = dgControl[
i];
240 controlOut[
"control"].setValues(control);
277 Eigen::Matrix4d _matrix4d(root);
285 q = worldMwaist.translation();
286 for (
unsigned int i = 0;
i < 3; ++
i) q(
i + 3) =
r(
i);
298 std::ostringstream oss;
300 oss <<
"Lower bound size should be " <<
controlSize_ <<
", got " 302 throw std::invalid_argument(oss.str());
305 oss <<
"Upper bound size should be " <<
controlSize_ <<
", got " 307 throw std::invalid_argument(oss.str());
314 std::ostringstream oss;
316 oss <<
"Lower bound size should be " <<
controlSize_ <<
", got " 318 throw std::invalid_argument(oss.str());
321 oss <<
"Upper bound size should be " <<
controlSize_ <<
", got " 323 throw std::invalid_argument(oss.str());
331 std::ostringstream oss;
333 oss <<
"Lower bound size should be " <<
controlSize_ <<
", got " 335 throw std::invalid_argument(oss.str());
338 oss <<
"Lower bound size should be " <<
controlSize_ <<
", got " 340 throw std::invalid_argument(oss.str());
Eigen::Transform< double, 3, Eigen::Affine > SOT_CORE_EXPORT MatrixHomogeneous
std::string docDirectGetter(const std::string &name, const std::string &type)
#define CHECK_BOUNDS(val, lower, upper, what, eps)
CommandVoid0< E > * makeCommandVoid0(E &entity, boost::function< void(void)> function, const std::string &docString)
dynamicgraph::Signal< dynamicgraph::Vector, int > robotState_
DirectGetter< E, T > * makeDirectGetter(E &entity, T *ptr, const std::string &docString)
dynamicgraph::Signal< dynamicgraph::Vector, int > pseudoTorqueSOUT
virtual void setRoot(const dynamicgraph::Matrix &root)
dynamicgraph::Vector state_
virtual void display(std::ostream &os) const
void signalRegistration(const SignalArray< int > &signals)
dynamicgraph::Signal< dynamicgraph::Vector, int > * forcesSOUT[4]
The force torque sensors.
#define sotDEBUGOUT(level)
void setControlSize(const int &size)
virtual void cmdDisplay()
void getControl(std::map< std::string, ControlValues > &anglesOut, const double &period)
void setPositionBounds(const Vector &lower, const Vector &upper)
dynamicgraph::Signal< dynamicgraph::Vector, int > ZMPPreviousControllerSOUT
The ZMP reference send by the previous controller.
dynamicgraph::Signal< dynamicgraph::Vector, int > robotVelocity_
Motor velocities.
dynamicgraph::Vector forceZero6
CommandVoid1< E, T > * makeCommandVoid1(E &entity, boost::function< void(const T &)> function, const std::string &docString)
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > controlSIN
virtual void setConstant(const T &t)
virtual void setControlInputType(const std::string &cit)
#define sotDEBUGIN(level)
std::string docCommandVoid1(const std::string &doc, const std::string &type)
void setTorqueBounds(const Vector &lower, const Vector &upper)
void setSanityCheck(const bool &enableCheck)
Eigen::Vector3d SOT_CORE_EXPORT VectorRollPitchYaw
virtual void setVelocity(const dynamicgraph::Vector &vel)
virtual void setSecondOrderIntegration()
int getControlSize() const
virtual void setNoIntegration()
void setVelocityBounds(const Vector &lower, const Vector &upper)
dynamicgraph::Signal< dynamicgraph::Vector, int > motorcontrolSOUT
The current state of the robot from the command viewpoint.
virtual void setStateSize(const unsigned int &size)
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > zmpSIN
dynamicgraph::Signal< dynamicgraph::Vector, int > previousControlSOUT
ControlInput controlInputType_
dynamicgraph::Vector velocity_
int lastTimeControlWasRead_
std::string docCommandVoid2(const std::string &doc, const std::string &type1, const std::string &type2)
void setVelocitySize(const unsigned int &size)
dynamicgraph::Signal< MatrixRotation, int > attitudeSOUT
virtual void setState(const dynamicgraph::Vector &st)
void addCommand(const std::string &name, command::Command *command)
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > attitudeSIN
dynamicgraph::Signal< dynamicgraph::Vector, int > stateSOUT
CommandVoid2< E, T1, T2 > * makeCommandVoid2(E &entity, boost::function< void(const T1 &, const T2 &)> function, const std::string &docString)
dynamicgraph::Signal< dynamicgraph::Vector, int > velocitySOUT
double saturateBounds(double &val, const double &lower, const double &upper)