32 FeatureLineDistance::FeatureLineDistance(
const string &pointName)
34 positionSIN(NULL,
"sotFeatureLineDistance(" +
name +
35 ")::input(matrixHomo)::position"),
37 NULL,
"sotFeatureLineDistance(" +
name +
")::input(matrix)::Jq"),
38 positionRefSIN(NULL,
"sotFeatureLineDistance(" +
name +
39 ")::input(vector)::positionRef"),
41 "sotFeatureVector3(" +
name +
")::input(vector3)::vector"),
44 positionSIN << positionRefSIN,
45 "sotFeatureAbstract(" +
name +
")::output(vector)::line") {
110 Skew(0, 1) = -vect(2);
111 Skew(0, 2) = vect(1);
112 Skew(1, 0) = vect(2);
114 Skew(1, 2) = -vect(0);
115 Skew(2, 0) = -vect(1);
116 Skew(2, 1) = vect(0);
122 Jline.resize(6, Jq.cols());
123 for (
unsigned int i = 0;
i < 3; ++
i)
124 for (
int j = 0; j < Jq.cols(); ++j) {
127 for (
unsigned int k = 0; k < 3; ++k) {
128 Jline(
i, j) += R(
i, k) * Jq(k, j);
129 Jline(
i + 3, j) += -RSk(
i, k) * Jq(k + 3, j);
136 const double &
x0 = line(0);
137 const double &y0 = line(1);
138 const double &z0 = line(2);
139 const double &
a0 = line(3);
140 const double &b0 = line(4);
141 const double &c0 = line(5);
144 const double &x1 = posRef(0);
145 const double &y1 = posRef(1);
146 const double &z1 = posRef(2);
147 const double &a1 = posRef(3);
148 const double &b1 = posRef(4);
149 const double &c1 = posRef(5);
152 const double a1_3 = a1 * a1 * a1;
153 const double b1_3 = b1 * b1 * b1;
154 const double c1_3 = c1 * c1 * c1;
156 double K = c0 * c0 * a1 * a1 - 2 * c0 * a1 * a0 * c1 - 2 * c0 * b1 * b0 * c1 +
157 c0 * c0 * b1 * b1 - 2 * b0 * a1 * a0 * b1 + b0 * b0 * a1 * a1 +
158 b0 * b0 * c1 * c1 + a0 * a0 * b1 * b1 + a0 * a0 * c1 * c1;
160 const double diffx0 = -b0 * c1 + c0 * b1;
161 const double diffy0 = a0 * c1 - c0 * a1;
162 const double diffz0 = -a0 * b1 + b0 * a1;
164 const double diffa0 =
165 2 * b0 * c1 * x0 * a0 * b1 * b1 + 2 * c0 * b1 * b1 * x0 * b0 * a1 +
166 2 * c0 * c0 * b1 * x0 * c1 * a1 + 2 * c1 * c1 * y0 * c0 * a1 * a0 -
167 2 * b0 * c1 * c1 * x0 * c0 * a1 - 2 * b0 * b0 * c1 * x0 * b1 * a1 -
168 2 * c1 * c1 * y0 * c0 * b1 * b0 + 2 * b0 * b0 * c1 * x1 * b1 * a1 +
169 2 * b0 * c1 * c1 * x1 * c0 * a1 - 2 * b0 * c1 * x1 * a0 * b1 * b1 -
170 c1 * y0 * c0 * c0 * a1 * a1 + c1 * y0 * c0 * c0 * b1 * b1 +
171 c1 * y0 * b0 * b0 * a1 * a1 - c1 * y0 * a0 * a0 * b1 * b1 +
172 c1 * y1 * c0 * c0 * a1 * a1 - c1 * y1 * c0 * c0 * b1 * b1 -
173 c1 * y1 * b0 * b0 * a1 * a1 + c1 * y1 * a0 * a0 * b1 * b1 -
174 b1 * z0 * c0 * c0 * a1 * a1 + b1 * z0 * b0 * b0 * a1 * a1 -
175 b1 * z0 * b0 * b0 * c1 * c1 + b1 * z0 * a0 * a0 * c1 * c1 +
176 b1 * z1 * c0 * c0 * a1 * a1 - b1 * z1 * b0 * b0 * a1 * a1 +
177 b1 * z1 * b0 * b0 * c1 * c1 - b1 * z1 * a0 * a0 * c1 * c1 +
178 2 * b0 * c1_3 * x0 * a0 - 2 * b0 * c1_3 * x1 * a0 -
179 2 * c0 * b1_3 * x0 * a0 + 2 * c0 * b1_3 * x1 * a0 + c1_3 * y0 * b0 * b0 -
180 c1_3 * y0 * a0 * a0 - c1_3 * y1 * b0 * b0 + c1_3 * y1 * a0 * a0 -
181 b1_3 * z0 * c0 * c0 + b1_3 * z0 * a0 * a0 + b1_3 * z1 * c0 * c0 -
182 b1_3 * z1 * a0 * a0 - 2 * c1 * c1 * y1 * c0 * a1 * a0 +
183 2 * c1 * c1 * y1 * c0 * b1 * b0 + 2 * b1 * b1 * z0 * c0 * b0 * c1 -
184 2 * b1 * b1 * z0 * b0 * a1 * a0 - 2 * b1 * b1 * z1 * c0 * b0 * c1 +
185 2 * b1 * b1 * z1 * b0 * a1 * a0 - 2 * c0 * b1 * x0 * a0 * c1 * c1 -
186 2 * c0 * b1 * b1 * x1 * b0 * a1 - 2 * c0 * c0 * b1 * x1 * c1 * a1 +
187 2 * c0 * b1 * x1 * a0 * c1 * c1 + 2 * c0 * a1 * y0 * a0 * b1 * b1 -
188 2 * c0 * a1 * a1 * y0 * b1 * b0 - 2 * c0 * a1 * y1 * a0 * b1 * b1 +
189 2 * c0 * a1 * a1 * y1 * b1 * b0 + 2 * b0 * a1 * a1 * z0 * c1 * c0 -
190 2 * b0 * a1 * z0 * a0 * c1 * c1 - 2 * b0 * a1 * a1 * z1 * c1 * c0 +
191 2 * b0 * a1 * z1 * a0 * c1 * c1;
192 const double diffb0 =
193 -2 * c1 * c1 * x0 * c0 * b1 * b0 + 2 * c1 * c1 * x0 * c0 * a1 * a0 -
194 c1 * x0 * c0 * c0 * a1 * a1 + c1 * x0 * c0 * c0 * b1 * b1 +
195 c1 * x0 * b0 * b0 * a1 * a1 - c1 * x0 * a0 * a0 * b1 * b1 +
196 c1 * x1 * c0 * c0 * a1 * a1 - c1 * x1 * c0 * c0 * b1 * b1 -
197 c1 * x1 * b0 * b0 * a1 * a1 + c1 * x1 * a0 * a0 * b1 * b1 +
198 a1 * z0 * c0 * c0 * b1 * b1 - a1 * z0 * b0 * b0 * c1 * c1 -
199 a1 * z0 * a0 * a0 * b1 * b1 + a1 * z0 * a0 * a0 * c1 * c1 -
200 a1 * z1 * c0 * c0 * b1 * b1 + a1 * z1 * b0 * b0 * c1 * c1 +
201 a1 * z1 * a0 * a0 * b1 * b1 - a1 * z1 * a0 * a0 * c1 * c1 -
202 2 * a0 * c1_3 * y0 * b0 + 2 * a0 * c1_3 * y1 * b0 + c1_3 * x0 * b0 * b0 -
203 c1_3 * x0 * a0 * a0 - c1_3 * x1 * b0 * b0 + c1_3 * x1 * a0 * a0 +
204 a1_3 * z0 * c0 * c0 - 2 * c1 * c1 * x1 * c0 * a1 * a0 +
205 2 * c1 * c1 * x1 * c0 * b1 * b0 - 2 * a1 * a1 * z0 * c0 * a0 * c1 +
206 2 * a1 * a1 * z0 * b0 * a0 * b1 - a1_3 * z0 * b0 * b0 -
207 a1_3 * z1 * c0 * c0 + a1_3 * z1 * b0 * b0 +
208 2 * a1 * a1 * z1 * c0 * a0 * c1 - 2 * a1 * a1 * z1 * b0 * a0 * b1 +
209 2 * c0 * b1 * b1 * x0 * a1 * a0 - 2 * c0 * b1 * x0 * b0 * a1 * a1 -
210 2 * c0 * b1 * b1 * x1 * a1 * a0 + 2 * c0 * b1 * x1 * b0 * a1 * a1 +
211 2 * a0 * a0 * c1 * y0 * a1 * b1 - 2 * a0 * c1 * y0 * b0 * a1 * a1 +
212 2 * a0 * c1 * c1 * y0 * c0 * b1 - 2 * a0 * a0 * c1 * y1 * a1 * b1 +
213 2 * a0 * c1 * y1 * b0 * a1 * a1 - 2 * a0 * c1 * c1 * y1 * c0 * b1 -
214 2 * c0 * a1 * a1 * y0 * a0 * b1 + 2 * c0 * a1_3 * y0 * b0 -
215 2 * c0 * a1_3 * y1 * b0 + 2 * c0 * a1 * y0 * b0 * c1 * c1 -
216 2 * c0 * c0 * a1 * y0 * c1 * b1 + 2 * c0 * a1 * a1 * y1 * a0 * b1 -
217 2 * c0 * a1 * y1 * b0 * c1 * c1 + 2 * c0 * c0 * a1 * y1 * c1 * b1 +
218 2 * a0 * b1 * z0 * b0 * c1 * c1 - 2 * a0 * b1 * b1 * z0 * c1 * c0 -
219 2 * a0 * b1 * z1 * b0 * c1 * c1 + 2 * a0 * b1 * b1 * z1 * c1 * c0;
222 diffh(0, 0) = diffx0 / K;
223 diffh(0, 1) = diffy0 / K;
224 diffh(0, 2) = diffz0 / K;
226 diffh(0, 3) = diffa0 / K;
227 diffh(0, 4) = diffb0 / K;
231 J.resize(1, J.cols());
247 const double &
x0 = line(0);
248 const double &y0 = line(1);
249 const double &z0 = line(2);
250 const double &
a0 = line(3);
251 const double &b0 = line(4);
252 const double &c0 = line(5);
255 const double &x1 = posRef(0);
256 const double &y1 = posRef(1);
257 const double &z1 = posRef(2);
258 const double &a1 = posRef(3);
259 const double &b1 = posRef(4);
260 const double &c1 = posRef(5);
263 double K = c0 * c0 * a1 * a1 - 2 * c0 * a1 * a0 * c1 - 2 * c0 * b1 * b0 * c1 +
264 c0 * c0 * b1 * b1 - 2 * b0 * a1 * a0 * b1 + b0 * b0 * a1 * a1 +
265 b0 * b0 * c1 * c1 + a0 * a0 * b1 * b1 + a0 * a0 * c1 * c1;
266 error(0) = (-b0 * c1 * x0 + b0 * c1 * x1 + c0 * b1 * x0 - c0 * b1 * x1 +
267 a0 * c1 * y0 - a0 * c1 * y1 - c0 * a1 * y0 + c0 * a1 * y1 -
268 a0 * b1 * z0 + a0 * b1 * z1 + b0 * a1 * z0 - b0 * a1 * z1) /
280 os <<
"LineDistance <" <<
name <<
">";
Eigen::Transform< double, 3, Eigen::Affine > SOT_CORE_EXPORT MatrixHomogeneous
virtual void display(std::ostream &os) const
void signalRegistration(const SignalArray< int > &signals)
#define sotDEBUGOUT(level)
dynamicgraph::SignalTimeDependent< dynamicgraph::Vector, int > lineSOUT
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(FeatureLineDistance, "FeatureLineDistance")
dynamicgraph::SignalPtr< MatrixHomogeneous, int > positionSIN
virtual dynamicgraph::Vector & computeError(dynamicgraph::Vector &res, int time)
#define sotDEBUGIN(level)
SignalTimeDependent< dynamicgraph::Matrix, int > jacobianSOUT
Jacobian of the error wrt the robot state: .
unsigned int getDimension(void) const
Shortest method.
dynamicgraph::Vector & computeLineCoordinates(dynamicgraph::Vector &cood, int time)
Class that defines point-3d control feature.
virtual void addDependency(const SignalBase< Time > &signal)
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > vectorSIN
dynamicgraph::SignalPtr< dynamicgraph::Matrix, int > articularJacobianSIN
This class gives the abstract definition of a feature.
Eigen::Matrix< double, 3, 3 > SOT_CORE_EXPORT MatrixRotation
virtual dynamicgraph::Matrix & computeJacobian(dynamicgraph::Matrix &res, int time)
SignalTimeDependent< dynamicgraph::Vector, int > errorSOUT
This signal returns the error between the desired value and the current value : . ...
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > positionRefSIN