@@ -1129,8 +1129,12 @@ namespace robot_dart {
1129
1129
1130
1130
Eigen::Isometry3d Robot::base_pose () const
1131
1131
{
1132
- if (free ())
1133
- return dart::math::expMap (_skeleton->getPositions ().head (6 ));
1132
+ if (free ()) {
1133
+ Eigen::Isometry3d tf (Eigen::Isometry3d::Identity ());
1134
+ tf.linear () = dart::math::expMapRot (_skeleton->getPositions ().head <6 >().head <3 >());
1135
+ tf.translation () = _skeleton->getPositions ().head <6 >().tail <3 >();
1136
+ return tf;
1137
+ }
1134
1138
auto jt = _skeleton->getRootBodyNode ()->getParentJoint ();
1135
1139
ROBOT_DART_ASSERT (jt != nullptr , " Skeleton does not have a proper root BodyNode!" ,
1136
1140
Eigen::Isometry3d::Identity ());
@@ -1144,28 +1148,41 @@ namespace robot_dart {
1144
1148
auto jt = _skeleton->getRootBodyNode ()->getParentJoint ();
1145
1149
ROBOT_DART_ASSERT (jt != nullptr , " Skeleton does not have a proper root BodyNode!" ,
1146
1150
Eigen::Vector6d::Zero ());
1147
- return dart::math::logMap (jt->getTransformFromParentBodyNode ());
1151
+ Eigen::Isometry3d tf = jt->getTransformFromParentBodyNode ();
1152
+ Eigen::Vector6d x;
1153
+ x.head <3 >() = dart::math::logMap (tf.linear ());
1154
+ x.tail <3 >() = tf.translation ();
1155
+ return x;
1148
1156
}
1149
1157
1150
1158
void Robot::set_base_pose (const Eigen::Isometry3d& tf)
1151
1159
{
1152
1160
auto jt = _skeleton->getRootBodyNode ()->getParentJoint ();
1153
1161
if (jt) {
1154
- if (free ())
1155
- jt->setPositions (dart::math::logMap (tf));
1162
+ if (free ()) {
1163
+ Eigen::Vector6d x;
1164
+ x.head <3 >() = dart::math::logMap (tf.linear ());
1165
+ x.tail <3 >() = tf.translation ();
1166
+ jt->setPositions (x);
1167
+ }
1156
1168
else
1157
1169
jt->setTransformFromParentBodyNode (tf);
1158
1170
}
1159
1171
}
1160
1172
1173
+ // / set base pose: pose is a 6D vector (first 3D orientation in angle-axis and last 3D translation)
1161
1174
void Robot::set_base_pose (const Eigen::Vector6d& pose)
1162
1175
{
1163
1176
auto jt = _skeleton->getRootBodyNode ()->getParentJoint ();
1164
1177
if (jt) {
1165
1178
if (free ())
1166
1179
jt->setPositions (pose);
1167
- else
1168
- jt->setTransformFromParentBodyNode (dart::math::expMap (pose));
1180
+ else {
1181
+ Eigen::Isometry3d tf (Eigen::Isometry3d::Identity ());
1182
+ tf.linear () = dart::math::expMapRot (pose.head <3 >());
1183
+ tf.translation () = pose.tail <3 >();
1184
+ jt->setTransformFromParentBodyNode (tf);
1185
+ }
1169
1186
}
1170
1187
}
1171
1188
@@ -1432,16 +1449,25 @@ namespace robot_dart {
1432
1449
auto bd = _skeleton->getBodyNode (body_name);
1433
1450
ROBOT_DART_ASSERT (bd != nullptr , " BodyNode does not exist in skeleton!" , Eigen::Vector6d::Zero ());
1434
1451
1435
- return dart::math::logMap (bd->getWorldTransform ());
1452
+ Eigen::Isometry3d tf = bd->getWorldTransform ();
1453
+ Eigen::Vector6d x;
1454
+ x.head <3 >() = dart::math::logMap (tf.linear ());
1455
+ x.tail <3 >() = tf.translation ();
1456
+
1457
+ return x;
1436
1458
}
1437
1459
1438
1460
Eigen::Vector6d Robot::body_pose_vec (size_t body_index) const
1439
1461
{
1440
1462
ROBOT_DART_ASSERT (body_index < _skeleton->getNumBodyNodes (), " BodyNode index out of bounds" , Eigen::Vector6d::Zero ());
1441
1463
1442
- Eigen::Isometry3d bd_trans = _skeleton->getBodyNode (body_index)->getWorldTransform ();
1464
+ Eigen::Isometry3d tf = _skeleton->getBodyNode (body_index)->getWorldTransform ();
1465
+
1466
+ Eigen::Vector6d x;
1467
+ x.head <3 >() = dart::math::logMap (tf.linear ());
1468
+ x.tail <3 >() = tf.translation ();
1443
1469
1444
- return dart::math::logMap (bd_trans) ;
1470
+ return x ;
1445
1471
}
1446
1472
1447
1473
Eigen::Vector6d Robot::body_velocity (const std::string& body_name) const
@@ -2064,7 +2090,11 @@ namespace robot_dart {
2064
2090
2065
2091
std::shared_ptr<Robot> Robot::create_box (const Eigen::Vector3d& dims, const Eigen::Isometry3d& tf, const std::string& type, double mass, const Eigen::Vector4d& color, const std::string& box_name)
2066
2092
{
2067
- return create_box (dims, dart::math::logMap (tf), type, mass, color, box_name);
2093
+ Eigen::Vector6d x;
2094
+ x.head <3 >() = dart::math::logMap (tf.linear ());
2095
+ x.tail <3 >() = tf.translation ();
2096
+
2097
+ return create_box (dims, x, type, mass, color, box_name);
2068
2098
}
2069
2099
2070
2100
std::shared_ptr<Robot> Robot::create_box (const Eigen::Vector3d& dims, const Eigen::Vector6d& pose, const std::string& type, double mass, const Eigen::Vector4d& color, const std::string& box_name)
@@ -2099,14 +2129,23 @@ namespace robot_dart {
2099
2129
if (type == " free" ) // free floating
2100
2130
robot->set_positions (pose);
2101
2131
else // fixed
2102
- body->getParentJoint ()->setTransformFromParentBodyNode (dart::math::expMap (pose));
2132
+ {
2133
+ Eigen::Isometry3d T;
2134
+ T.linear () = dart::math::expMapRot (pose.head <3 >());
2135
+ T.translation () = pose.tail <3 >();
2136
+ body->getParentJoint ()->setTransformFromParentBodyNode (T);
2137
+ }
2103
2138
2104
2139
return robot;
2105
2140
}
2106
2141
2107
2142
std::shared_ptr<Robot> Robot::create_ellipsoid (const Eigen::Vector3d& dims, const Eigen::Isometry3d& tf, const std::string& type, double mass, const Eigen::Vector4d& color, const std::string& ellipsoid_name)
2108
2143
{
2109
- return create_ellipsoid (dims, dart::math::logMap (tf), type, mass, color, ellipsoid_name);
2144
+ Eigen::Vector6d x;
2145
+ x.head <3 >() = dart::math::logMap (tf.linear ());
2146
+ x.tail <3 >() = tf.translation ();
2147
+
2148
+ return create_ellipsoid (dims, x, type, mass, color, ellipsoid_name);
2110
2149
}
2111
2150
2112
2151
std::shared_ptr<Robot> Robot::create_ellipsoid (const Eigen::Vector3d& dims, const Eigen::Vector6d& pose, const std::string& type, double mass, const Eigen::Vector4d& color, const std::string& ellipsoid_name)
@@ -2143,8 +2182,8 @@ namespace robot_dart {
2143
2182
else // fixed
2144
2183
{
2145
2184
Eigen::Isometry3d T;
2146
- T.linear () = dart::math::eulerXYZToMatrix (pose.head ( 3 ));
2147
- T.translation () = pose.tail ( 3 );
2185
+ T.linear () = dart::math::expMapRot (pose.head < 3 >( ));
2186
+ T.translation () = pose.tail < 3 >( );
2148
2187
body->getParentJoint ()->setTransformFromParentBodyNode (T);
2149
2188
}
2150
2189
0 commit comments