@@ -35,20 +35,19 @@ Rotation q_derivative(const Rotation &q, const Vector3 &omega) {
35
35
return Rotation (dxdt, dydt, dzdt, -dwdt); // TODO: why minus????
36
36
}
37
37
38
- void KinematicModel::get_link_pose (size_t link_id,
39
- Transform &out_tf_rlink_to_elink) const {
38
+ void KinematicModel::get_link_pose (
39
+ size_t link_id, Eigen::Affine3d &out_tf_rlink_to_elink) const {
40
40
Eigen::Affine3d const *pose_ptr = transform_cache_.get_cache (link_id);
41
41
if (pose_ptr) {
42
42
// FIXME: remove
43
- // out_tf_rlink_to_elink = *pose_ptr;
44
- out_tf_rlink_to_elink = eigen_affine3d_to_urdf_pose (*pose_ptr);
43
+ out_tf_rlink_to_elink = *pose_ptr;
45
44
return ;
46
45
}
47
46
this ->get_link_pose_inner (link_id, out_tf_rlink_to_elink);
48
47
}
49
48
50
49
void KinematicModel::get_link_pose_inner (
51
- size_t link_id, Transform &out_tf_rlink_to_elink) const {
50
+ size_t link_id, Eigen::Affine3d &out_tf_rlink_to_elink) const {
52
51
urdf::LinkSharedPtr hlink = links_[link_id];
53
52
54
53
Eigen::Affine3d tf_rlink_to_blink = base_pose_;
@@ -85,7 +84,7 @@ void KinematicModel::get_link_pose_inner(
85
84
} else if (pjoint->type == urdf::Joint::REVOLUTE ||
86
85
pjoint->type == urdf::Joint::CONTINUOUS) {
87
86
double angle = joint_angles_[pjoint->id ];
88
- Eigen::AngleAxisd tf_pjoint_to_hlink{
87
+ Eigen::AngleAxisd&& tf_pjoint_to_hlink{
89
88
angle,
90
89
Eigen::Vector3d{pjoint->axis .x , pjoint->axis .y , pjoint->axis .z }};
91
90
tf_plink_to_hlink = tf_plink_to_pjoint * tf_pjoint_to_hlink;
@@ -111,9 +110,7 @@ void KinematicModel::get_link_pose_inner(
111
110
transform_cache_.set_cache (hid, tf_rlink_to_hlink);
112
111
tf_rlink_to_plink = std::move (tf_rlink_to_hlink);
113
112
}
114
- // FIXME
115
- // out_tf_rlink_to_elink = std::move(tf_rlink_to_plink);
116
- out_tf_rlink_to_elink = eigen_affine3d_to_urdf_pose (tf_rlink_to_plink);
113
+ out_tf_rlink_to_elink = std::move (tf_rlink_to_plink);
117
114
}
118
115
119
116
Eigen::MatrixXd
@@ -125,8 +122,10 @@ KinematicModel::get_jacobian(size_t elink_id,
125
122
const int dim_dof = joint_ids.size () + (with_base ? 6 : 0 );
126
123
127
124
// compute values shared through the loop
128
- Transform tf_rlink_to_elink;
129
- this ->get_link_pose (elink_id, tf_rlink_to_elink);
125
+ Eigen::Affine3d tf_rlink_to_elink_tmp; // FIXME
126
+ this ->get_link_pose (elink_id, tf_rlink_to_elink_tmp);
127
+ Transform tf_rlink_to_elink =
128
+ eigen_affine3d_to_urdf_pose (tf_rlink_to_elink_tmp);
130
129
Vector3 &epos = tf_rlink_to_elink.position ;
131
130
Rotation &erot = tf_rlink_to_elink.rotation ;
132
131
@@ -154,8 +153,11 @@ KinematicModel::get_jacobian(size_t elink_id,
154
153
hjoint->getChildLink (); // rotation of clink and hlink is same. so
155
154
// clink is ok.
156
155
157
- Transform tf_rlink_to_clink;
158
- this ->get_link_pose (clink->id , tf_rlink_to_clink);
156
+ // FIXME
157
+ Eigen::Affine3d tf_rlink_to_clink_tmp;
158
+ this ->get_link_pose (clink->id , tf_rlink_to_clink_tmp);
159
+ Transform tf_rlink_to_clink =
160
+ eigen_affine3d_to_urdf_pose (tf_rlink_to_clink_tmp);
159
161
160
162
Rotation &crot = tf_rlink_to_clink.rotation ;
161
163
Vector3 &&world_axis = crot * hjoint->axis ; // axis w.r.t root link
@@ -194,9 +196,11 @@ KinematicModel::get_jacobian(size_t elink_id,
194
196
}
195
197
196
198
Transform tf_rlink_to_blink, tf_blink_to_rlink, tf_blink_to_elink;
199
+ Eigen::Affine3d tf_rlink_to_blink_tmp;
197
200
Vector3 rpy_rlink_to_blink;
198
201
if (with_base) {
199
- this ->get_link_pose (this ->root_link_id_ , tf_rlink_to_blink);
202
+ this ->get_link_pose (this ->root_link_id_ , tf_rlink_to_blink_tmp);
203
+ tf_rlink_to_blink = eigen_affine3d_to_urdf_pose (tf_rlink_to_blink_tmp);
200
204
tf_blink_to_rlink = tf_rlink_to_blink.inverse ();
201
205
rpy_rlink_to_blink = tf_rlink_to_blink.rotation .getRPY ();
202
206
tf_blink_to_elink = pose_transform (tf_blink_to_rlink, tf_rlink_to_elink);
@@ -252,9 +256,11 @@ Vector3 KinematicModel::get_com() {
252
256
Vector3 com_average;
253
257
double mass_total = 0.0 ;
254
258
Transform tf_base_to_com;
259
+ Eigen::Affine3d tf_base_to_com_tmp; // FIXME
255
260
for (const auto &link : com_dummy_links_) {
256
261
mass_total += link->inertial ->mass ;
257
- this ->get_link_pose (link->id , tf_base_to_com);
262
+ this ->get_link_pose (link->id , tf_base_to_com_tmp);
263
+ tf_base_to_com = eigen_affine3d_to_urdf_pose (tf_base_to_com_tmp);
258
264
com_average.x += link->inertial ->mass * tf_base_to_com.position .x ;
259
265
com_average.y += link->inertial ->mass * tf_base_to_com.position .y ;
260
266
com_average.z += link->inertial ->mass * tf_base_to_com.position .z ;
@@ -302,7 +308,9 @@ Eigen::Matrix3d KinematicModel::get_total_inertia_matrix() {
302
308
size_t link_id = link->id ;
303
309
304
310
Transform tf_base_to_link;
305
- this ->get_link_pose (link_id, tf_base_to_link);
311
+ Eigen::Affine3d tf_base_to_link_tmp; // FIXME
312
+ this ->get_link_pose (link_id, tf_base_to_link_tmp);
313
+ tf_base_to_link = eigen_affine3d_to_urdf_pose (tf_base_to_link_tmp);
306
314
const auto &trans = tf_base_to_link.position ;
307
315
Eigen::Vector3d vec;
308
316
vec << trans.x - com.x , trans.y - com.y , trans.z - com.z ;
0 commit comments