@@ -61,9 +61,14 @@ namespace dynamicgraph {
61
61
{
62
62
return value_->vectorValue ();
63
63
}
64
- EitherType::operator Matrix () const
64
+ EitherType::operator Eigen::MatrixXd () const
65
65
{
66
- return value_->matrixValue ();
66
+ return value_->matrixXdValue ();
67
+ }
68
+
69
+ EitherType::operator Eigen::Matrix4d () const
70
+ {
71
+ return value_->matrix4dValue ();
67
72
}
68
73
69
74
void Value::deleteValue ()
@@ -91,7 +96,10 @@ namespace dynamicgraph {
91
96
delete (const Vector*)value_;
92
97
break ;
93
98
case MATRIX:
94
- delete (const Matrix*)value_;
99
+ delete (const Eigen::MatrixXd*)value_;
100
+ break ;
101
+ case MATRIX4D:
102
+ delete (const Eigen::Matrix4d*)value_;
95
103
break ;
96
104
default :;
97
105
}
@@ -129,8 +137,12 @@ namespace dynamicgraph {
129
137
value_(new Vector(value))
130
138
{
131
139
}
132
- Value::Value (const Matrix& value) : type_(MATRIX),
133
- value_(new Matrix(value))
140
+ Value::Value (const Eigen::MatrixXd& value) : type_(MATRIX),
141
+ value_(new Eigen::MatrixXd(value))
142
+ {
143
+ }
144
+ Value::Value (const Eigen::Matrix4d& value) : type_(MATRIX4D),
145
+ value_(new Eigen::Matrix4d(value))
134
146
{
135
147
}
136
148
@@ -168,7 +180,10 @@ namespace dynamicgraph {
168
180
copy = new Vector (value.vectorValue ());
169
181
break ;
170
182
case Value::MATRIX:
171
- copy = new Matrix (value.matrixValue ());
183
+ copy = new Eigen::MatrixXd (value.matrixXdValue ());
184
+ break ;
185
+ case Value::MATRIX4D:
186
+ copy = new Eigen::Matrix4d (value.matrix4dValue ());
172
187
break ;
173
188
default :
174
189
abort ();
@@ -262,12 +277,20 @@ namespace dynamicgraph {
262
277
" value is not an vector" );
263
278
}
264
279
265
- Matrix Value::matrixValue () const
280
+ Eigen::MatrixXd Value::matrixXdValue () const
266
281
{
267
282
if (type_ == MATRIX)
268
- return *((const Matrix*)value_);
283
+ return *((const Eigen::MatrixXd*)value_);
284
+ throw ExceptionAbstract (ExceptionAbstract::TOOLS,
285
+ " value is not a Eigen matrixXd" );
286
+ }
287
+
288
+ Eigen::Matrix4d Value::matrix4dValue () const
289
+ {
290
+ if (type_ == MATRIX4D)
291
+ return *((const Eigen::Matrix4d*)value_);
269
292
throw ExceptionAbstract (ExceptionAbstract::TOOLS,
270
- " value is not a matrix " );
293
+ " value is not a Eigen matrix4d " );
271
294
}
272
295
273
296
std::string Value::typeName (Type type)
@@ -288,7 +311,9 @@ namespace dynamicgraph {
288
311
case VECTOR:
289
312
return std::string (" vector" );
290
313
case MATRIX:
291
- return std::string (" matrix" );
314
+ return std::string (" matrixXd" );
315
+ case MATRIX4D:
316
+ return std::string (" matrix4d" );
292
317
default :
293
318
return std::string (" unknown" );
294
319
}
@@ -321,7 +346,10 @@ namespace dynamicgraph {
321
346
os << value.vectorValue ();
322
347
break ;
323
348
case Value::MATRIX:
324
- os << value.matrixValue ();
349
+ os << value.matrixXdValue ();
350
+ break ;
351
+ case Value::MATRIX4D:
352
+ os << value.matrix4dValue ();
325
353
break ;
326
354
default :
327
355
return os;
@@ -336,7 +364,8 @@ namespace dynamicgraph {
336
364
template <> const Value::Type ValueHelper<double >::TypeID = Value::DOUBLE;
337
365
template <> const Value::Type ValueHelper<std::string>::TypeID = Value::STRING;
338
366
template <> const Value::Type ValueHelper<Vector>::TypeID = Value::VECTOR;
339
- template <> const Value::Type ValueHelper<Matrix>::TypeID = Value::MATRIX;
367
+ template <> const Value::Type ValueHelper<Eigen::MatrixXd>::TypeID = Value::MATRIX;
368
+ template <> const Value::Type ValueHelper<Eigen::Matrix4d>::TypeID = Value::MATRIX4D;
340
369
341
370
} // namespace command
342
371
} // namespace dynamicgraph
0 commit comments