13 #include <dynamic-graph/factory.h> 25 sensorWorldRotationSIN(
26 NULL,
"sotAngleEstimator(" + name +
27 ")::input(MatrixRotation)::sensorWorldRotation"),
28 sensorEmbeddedPositionSIN(
29 NULL,
"sotAngleEstimator(" + name +
30 ")::input(MatrixHomo)::sensorEmbeddedPosition"),
31 contactWorldPositionSIN(NULL,
32 "sotAngleEstimator(" + name +
33 ")::input(MatrixHomo)::contactWorldPosition"),
34 contactEmbeddedPositionSIN(
35 NULL,
"sotAngleEstimator(" + name +
36 ")::input(MatrixHomo)::contactEmbeddedPosition")
40 sensorWorldRotationSIN << sensorEmbeddedPositionSIN
41 << contactWorldPositionSIN
42 << contactEmbeddedPositionSIN,
43 "sotAngleEstimator(" + name +
")::output(Vector)::angles"),
47 "sotAngleEstimator(" + name +
48 ")::output(matrixRotation)::flexibility"),
52 "sotAngleEstimator(" + name +
")::output(matrixRotation)::drift"),
53 sensorWorldRotationSOUT(
56 anglesSOUT << sensorWorldRotationSIN,
57 "sotAngleEstimator(" + name +
58 ")::output(matrixRotation)::sensorCorrectedRotation"),
59 waistWorldRotationSOUT(
61 sensorWorldRotationSOUT << sensorEmbeddedPositionSIN,
62 "sotAngleEstimator(" + name +
63 ")::output(matrixRotation)::waistWorldRotation"),
64 waistWorldPositionSOUT(
66 flexibilitySOUT << contactEmbeddedPositionSIN,
67 "sotAngleEstimator(" + name +
68 ")::output(MatrixHomogeneous)::waistWorldPosition"),
69 waistWorldPoseRPYSOUT(
71 waistWorldPositionSOUT,
72 "sotAngleEstimator(" + name +
73 ")::output(vectorRollPitchYaw)::waistWorldPoseRPY")
76 jacobianSIN(NULL,
"sotAngleEstimator(" + name +
")::input()::jacobian"),
77 qdotSIN(NULL,
"sotAngleEstimator(" + name +
")::input()::qdot"),
80 jacobianSIN << qdotSIN,
81 "sotAngleEstimator(" + name +
")::output(vector)::xff_dot"),
83 xff_dotSOUT << qdotSIN,
84 "sotAngleEstimator(" + name +
")::output(vector)::qdotOUT")
108 std::string docstring;
111 " Set flag specifying whether angle is measured from sensors or " 115 " - a boolean value.\n" 118 new ::dynamicgraph::command::Setter<AngleEstimator, bool>(
123 " Get flag specifying whether angle is measured from sensors or " 127 " return a boolean value.\n" 130 new ::dynamicgraph::command::Getter<AngleEstimator, bool>(
154 sotDEBUG(35) <<
"worldestRchest = " << std::endl << worldestRchest;
157 waistRchest = waistMchest.linear();
161 waistRleg = waistMleg.linear();
163 chestRleg = waistRchest.transpose() * waistRleg;
165 worldestRleg = worldestRchest * chestRleg;
167 sotDEBUG(35) <<
"worldestRleg = " << std::endl << worldestRleg;
171 const double TOLERANCE_TH = 1e-6;
174 if ((fabs(R(0, 1)) < TOLERANCE_TH) && (fabs(R(1, 1)) < TOLERANCE_TH)) {
182 res(2) = atan2(-R(0, 2), R(0, 0));
194 Y = atan2(R(2, 0), R(2, 2));
195 Z = atan2(R(0, 1), R(1, 1));
196 if (fabs(R(2, 0)) > fabs(R(2, 2))) {
197 X = atan2(R(2, 1) * sin(Y), R(2, 0));
199 X = atan2(R(2, 1) * cos(Y), R(2, 2));
217 double cx = cos(angles(0));
218 double sx = sin(angles(0));
219 double cy = cos(angles(1));
220 double sy = sin(angles(1));
226 res(1, 0) = -sx * sy;
228 res(1, 2) = -sx * cy;
247 double cz = cos(angles(2));
248 double sz = sin(angles(2));
275 res = worldRworldest * worldestRsensor;
289 waistRchest = waistMchest.linear();
291 res = worldRsensor * waistRchest.transpose();
308 footMleg.linear() = Rflex;
309 footMleg.translation().setZero();
311 tmpRes = footMleg * legMwaist;
316 res = contactPos * tmpRes;
330 for (
int i = 0;
i < 3; ++
i) {
345 const Eigen::DenseIndex nr = J.rows(), nc = J.cols() - 6;
349 for (
int j = 0; j < nc; ++j) {
350 for (
int i = 0;
i < nr; ++
i) Ja(
i, j) = J(
i, j + 6);
354 for (
int j = 0; j < 6; ++j)
355 for (
int i = 0;
i < 6; ++
i) Jff(
i, j) = J(
i, j);
358 res = (Jff.inverse() * (Ja * dqa)) * (-1);
367 assert(dx.size() == 6);
369 const Eigen::DenseIndex nr = dq.size();
372 for (
int i = 0;
i < 6; ++
i) res(
i) = dx(
i);
dg::SignalTimeDependent< MatrixRotation, int > flexibilitySOUT
Eigen::Transform< double, 3, Eigen::Affine > SOT_CORE_EXPORT MatrixHomogeneous
virtual ~AngleEstimator(void)
dg::SignalTimeDependent< dynamicgraph::Vector, int > qdotSOUT
MatrixHomogeneous & computeWaistWorldPosition(MatrixHomogeneous &res, const int &time)
void signalRegistration(const SignalArray< int > &signals)
dg::SignalPtr< MatrixRotation, int > sensorWorldRotationSIN
#define sotDEBUGOUT(level)
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(Latch, "Latch")
MatrixRotation & computeSensorWorldRotation(MatrixRotation &res, const int &time)
MatrixRotation & computeWaistWorldRotation(MatrixRotation &res, const int &time)
dg::SignalTimeDependent< dynamicgraph::Vector, int > anglesSOUT
dg::SignalTimeDependent< MatrixHomogeneous, int > waistWorldPositionSOUT
#define sotDEBUGIN(level)
dg::SignalPtr< dynamicgraph::Vector, int > qdotSIN
dg::SignalTimeDependent< MatrixRotation, int > driftSOUT
dynamicgraph::Vector & compute_qdotSOUT(dynamicgraph::Vector &res, const int &time)
dg::SignalTimeDependent< MatrixRotation, int > sensorWorldRotationSOUT
MatrixRotation & computeDriftFromAngles(MatrixRotation &res, const int &time)
dg::SignalPtr< MatrixHomogeneous, int > contactWorldPositionSIN
Eigen::Vector3d SOT_CORE_EXPORT VectorRollPitchYaw
dynamicgraph::Vector & compute_xff_dotSOUT(dynamicgraph::Vector &res, const int &time)
dg::SignalTimeDependent< dynamicgraph::Vector, int > waistWorldPoseRPYSOUT
dynamicgraph::Vector & computeWaistWorldPoseRPY(dynamicgraph::Vector &res, const int &time)
dg::SignalTimeDependent< MatrixRotation, int > waistWorldRotationSOUT
dg::SignalPtr< MatrixHomogeneous, int > contactEmbeddedPositionSIN
dg::SignalPtr< dynamicgraph::Matrix, int > jacobianSIN
Eigen::Matrix< double, 3, 3 > SOT_CORE_EXPORT MatrixRotation
dynamicgraph::Vector & computeAngles(dynamicgraph::Vector &res, const int &time)
dg::SignalTimeDependent< dynamicgraph::Vector, int > xff_dotSOUT
dg::SignalPtr< MatrixHomogeneous, int > sensorEmbeddedPositionSIN
void addCommand(const std::string &name, command::Command *command)
AngleEstimator(const std::string &name)
MatrixRotation & computeFlexibilityFromAngles(MatrixRotation &res, const int &time)