14 #include <dynamic-graph/command-bind.h>
15 #include <dynamic-graph/command-getter.h>
16 #include <dynamic-graph/command-setter.h>
17 #include <dynamic-graph/command.h>
20 #include <boost/mpl/if.hpp>
21 #include <boost/type_traits/is_same.hpp>
22 #include <pinocchio/multibody/liegroup/liegroup.hpp>
30 typedef pinocchio::CartesianProductOperation<
31 pinocchio::VectorSpaceOperationTpl<3, double>,
32 pinocchio::SpecialOrthogonalOperationTpl<3, double> >
34 typedef pinocchio::SpecialEuclideanOperationTpl<3, double>
SE3_t;
37 template <Representation_t representation>
50 template <Representation_t representation>
53 oMja(NULL, CLASS_NAME +
"(" + name +
")::input(matrixHomo)::oMja"),
54 jaMfa(NULL, CLASS_NAME +
"(" + name +
")::input(matrixHomo)::jaMfa"),
55 oMjb(NULL, CLASS_NAME +
"(" + name +
")::input(matrixHomo)::oMjb"),
56 jbMfb(NULL, CLASS_NAME +
"(" + name +
")::input(matrixHomo)::jbMfb"),
57 jaJja(NULL, CLASS_NAME +
"(" + name +
")::input(matrix)::jaJja"),
58 jbJjb(NULL, CLASS_NAME +
"(" + name +
")::input(matrix)::jbJjb"),
60 CLASS_NAME +
"(" + name +
")::input(matrixHomo)::faMfbDes"),
62 CLASS_NAME +
"(" + name +
")::input(vector)::faNufafbDes"),
64 boost::bind(&
FeaturePose<representation>::computefaMfb, this, _1, _2),
65 oMja << jaMfa << oMjb << jbMfb,
66 CLASS_NAME +
"(" + name +
")::output(matrixHomo)::faMfb"),
67 q_faMfb(boost::bind(&
FeaturePose<representation>::computeQfaMfb, this, _1,
69 faMfb, CLASS_NAME +
"(" + name +
")::output(vector7)::q_faMfb"),
70 q_faMfbDes(boost::bind(&
FeaturePose<representation>::computeQfaMfbDes,
73 CLASS_NAME +
"(" + name +
")::output(vector7)::q_faMfbDes") {
75 jaMfa.setConstant(Id);
76 jbMfb.setConstant(Id);
94 using namespace dynamicgraph::command;
99 "modify the desired position to servo at current pos.",
104 template <Representation_t representation>
111 template <Representation_t representation>
114 assert(ft.
oMja.isPlugged());
115 assert(ft.
jaMfa.isPlugged());
116 assert(ft.
oMjb.isPlugged());
117 assert(ft.
jbMfb.isPlugged());
122 template <Representation_t representation>
125 sotDEBUG(25) <<
"# In {" << std::endl;
130 for (
int i = 0; i < 6; ++i)
133 sotDEBUG(25) <<
"# Out }" << std::endl;
138 v.head<3>() = M.translation();
148 template <Representation_t representation>
160 const Matrix &_jbJjb =
jbJjb(time);
163 (
jbMfb.isPlugged() ?
jbMfb.accessCopy() : Id);
169 Eigen::Matrix<double, 6, 6, Eigen::RowMajor> Jminus;
171 buildFrom(_jbMfb.inverse(Eigen::Affine), X);
173 oMja.access(time).rotation().transpose() *
174 oMjb.access(time).rotation() * _jbMfb.rotation();
175 if (boost::is_same<LieGroup_t, R3xSO3_t>::value)
176 X.topRows<3>().applyOnTheLeft(faRfb);
177 LieGroup_t().template dDifference<pinocchio::ARG1>(
183 for (
unsigned int r = 0; r < 6; ++r)
184 if (fl((
int)r)) J.row(rJ++) = (Jminus * X).row(r) * _jbJjb;
186 if (
jaJja.isPlugged()) {
187 const Matrix &_jaJja =
jaJja(time);
189 (
jaMfa.isPlugged() ?
jaMfa.accessCopy() : Id),
190 _faMfb =
faMfb.accessCopy();
192 buildFrom((_jaMfa * _faMfb).inverse(Eigen::Affine), X);
193 if (boost::is_same<LieGroup_t, R3xSO3_t>::value)
194 X.topRows<3>().applyOnTheLeft(faRfb);
198 for (
unsigned int r = 0; r < 6; ++r)
199 if (fl((
int)r)) J.row(rJ++).noalias() -= (Jminus * X).row(r) * _jaJja;
205 template <Representation_t representation>
210 res = (
oMja(time) *
jaMfa(time)).inverse(Eigen::Affine) *
oMjb(time) *
215 template <Representation_t representation>
216 Vector7 &FeaturePose<representation>::computeQfaMfb(
Vector7 &res,
int time) {
223 template <Representation_t representation>
224 Vector7 &FeaturePose<representation>::computeQfaMfbDes(
Vector7 &res,
int time) {
231 template <Representation_t representation>
238 Eigen::Matrix<double, 6, 1> v;
242 unsigned int cursor = 0;
243 for (
unsigned int i = 0; i < 6; ++i)
244 if (fl((
int)i)) error(cursor++) = v(i);
258 buildFrom(Mdes.inverse(Eigen::Affine), X);
268 nu.tail<3>() = Mdes.rotation().transpose() *
faNufafbDes.tail<3>();
272 template <Representation_t representation>
291 Eigen::Matrix<double, 6, 6, Eigen::RowMajor> Jminus;
293 LieGroup_t().template dDifference<pinocchio::ARG0>(
295 Vector6d nu = convertVelocity<LieGroup_t>(
faMfb(time), _faMfbDes,
297 unsigned int cursor = 0;
298 for (
unsigned int i = 0; i < 6; ++i)
299 if (fl((
int)i)) errordot(cursor++) = Jminus.row(i) * nu;
307 template <Representation_t representation>
313 (
jaMfa.isPlugged() ?
jaMfa.access(time) : Id),
314 _oMjb =
oMjb.access(time),
316 (
jbMfb.isPlugged() ?
jbMfb.access(time) : Id);
317 faMfbDes = (_oMja * _jaMfa).inverse(Eigen::Affine) * _oMjb * _jbMfb;
320 static const char *featureNames[] = {
"X ",
"Y ",
"Z ",
"RX",
"RY",
"RZ"};
321 template <Representation_t representation>
328 for (
int i = 0; i < 6; ++i)
335 os << featureNames[i];
339 os <<
" selectSIN not set.";
Definition: exception-abstract.hh:36
This class gives the abstract definition of a feature.
Definition: feature-abstract.hh:76
unsigned int getDimension(void) const
Shortest method.
Definition: feature-abstract.hh:121
SignalTimeDependent< dynamicgraph::Vector, int > errordotSOUT
Derivative of the error with respect to time: .
Definition: feature-abstract.hh:189
SignalTimeDependent< unsigned int, int > dimensionSOUT
Returns the dimension of the feature as an output signal.
Definition: feature-abstract.hh:196
Feature that controls the relative (or absolute) pose between two frames A (or world) and B.
Definition: feature-pose.hh:62
dynamicgraph::SignalPtr< Matrix, int > jbJjb
Jacobian of the input Joint B, expressed in Joint B
Definition: feature-pose.hh:82
dynamicgraph::SignalPtr< Vector, int > faNufafbDes
Definition: feature-pose.hh:88
SignalTimeDependent< dynamicgraph::Matrix, int > jacobianSOUT
Jacobian of the error wrt the robot state: .
Definition: feature-abstract.hh:193
virtual dynamicgraph::Vector & computeError(dynamicgraph::Vector &res, int time)
Computes .
Definition: feature-pose.hxx:232
FeaturePose(const std::string &name)
Definition: feature-pose.hxx:51
dynamicgraph::SignalPtr< MatrixHomogeneous, int > faMfbDes
The desired pose of Frame B wrt to Frame A.
Definition: feature-pose.hh:85
SignalTimeDependent< Vector7, int > q_faMfbDes
Definition: feature-pose.hh:103
SignalTimeDependent< MatrixHomogeneous, int > faMfb
Pose of Frame B wrt to Frame A.
Definition: feature-pose.hh:95
SignalTimeDependent< dynamicgraph::Vector, int > errorSOUT
This signal returns the error between the desired value and the current value : .
Definition: feature-abstract.hh:185
virtual dynamicgraph::Matrix & computeJacobian(dynamicgraph::Matrix &res, int time)
Definition: feature-pose.hxx:149
virtual void display(std::ostream &os) const
Definition: feature-pose.hxx:322
dynamicgraph::SignalPtr< MatrixHomogeneous, int > oMjb
Input pose of Joint B wrt to world frame.
Definition: feature-pose.hh:76
dynamicgraph::SignalPtr< MatrixHomogeneous, int > jbMfb
Input pose of Frame B wrt to Joint B.
Definition: feature-pose.hh:78
virtual dynamicgraph::Vector & computeErrorDot(dynamicgraph::Vector &res, int time)
Definition: feature-pose.hxx:273
virtual ~FeaturePose(void)
Definition: feature-pose.hxx:105
void servoCurrentPosition(const int &time)
Definition: feature-pose.hxx:308
SignalPtr< Flags, int > selectionSIN
This vector specifies which dimension are used to perform the computation. For instance let us assume...
Definition: feature-abstract.hh:173
static const std::string CLASS_NAME
Definition: feature-pose.hh:64
dynamicgraph::SignalPtr< MatrixHomogeneous, int > oMja
Input pose of Joint A wrt to world frame.
Definition: feature-pose.hh:72
dynamicgraph::SignalPtr< Matrix, int > jaJja
Jacobian of the input Joint A, expressed in Joint A
Definition: feature-pose.hh:80
SignalTimeDependent< Vector7, int > q_faMfb
Definition: feature-pose.hh:99
dynamicgraph::SignalPtr< MatrixHomogeneous, int > jaMfa
Input pose of Frame A wrt to Joint A.
Definition: feature-pose.hh:74
#define sotDEBUG(level)
Definition: debug.hh:165
Eigen::VectorXd::Index Index
Definition: robot-utils.hh:39
@ SE3Representation
Definition: feature-pose.hh:29
Vector6d convertVelocity< R3xSO3_t >(const MatrixHomogeneous &M, const MatrixHomogeneous &Mdes, const Vector &faNufafbDes)
Definition: feature-pose.hxx:262
Eigen::Transform< double, 3, Eigen::Affine > SOT_CORE_EXPORT MatrixHomogeneous
Definition: matrix-geometry.hh:75
Eigen::Matrix< double, 7, 1 > SOT_CORE_EXPORT Vector7
Definition: matrix-geometry.hh:84
void buildFrom(const MatrixHomogeneous &MH, MatrixTwist &MT)
Definition: matrix-geometry.hh:88
pinocchio::SpecialEuclideanOperationTpl< 3, double > SE3_t
Definition: feature-pose.hxx:34
Eigen::Map< Quaternion > SOT_CORE_EXPORT QuaternionMap
Definition: matrix-geometry.hh:86
Vector6d convertVelocity< SE3_t >(const MatrixHomogeneous &M, const MatrixHomogeneous &Mdes, const Vector &faNufafbDes)
Definition: feature-pose.hxx:253
void toVector(const MatrixHomogeneous &M, Vector7 &v)
Definition: feature-pose.hxx:137
Eigen::Matrix< double, 3, 3 > SOT_CORE_EXPORT MatrixRotation
Definition: matrix-geometry.hh:76
Eigen::Matrix< double, 6, 6 > SOT_CORE_EXPORT MatrixTwist
Definition: matrix-geometry.hh:82
pinocchio::CartesianProductOperation< pinocchio::VectorSpaceOperationTpl< 3, double >, pinocchio::SpecialOrthogonalOperationTpl< 3, double > > R3xSO3_t
Definition: feature-pose.hxx:33
Definition: abstract-sot-external-interface.hh:17
Definition: feature-pose.hxx:38
boost::mpl::if_c< representation==SE3Representation, SE3_t, R3xSO3_t >::type type
Definition: feature-pose.hxx:40