@@ -182,6 +182,31 @@ bool KinematicsInterfaceKDL::calculate_jacobian(
182
182
return true ;
183
183
}
184
184
185
+ bool KinematicsInterfaceKDL::calculate_jacobian_inverse (
186
+ const Eigen::VectorXd & joint_pos, const std::string & link_name,
187
+ Eigen::Matrix<double , Eigen::Dynamic, 6 > & jacobian_inverse)
188
+ {
189
+ // verify inputs
190
+ if (
191
+ !verify_initialized () || !verify_joint_vector (joint_pos) || !verify_link_name (link_name) ||
192
+ !verify_jacobian_inverse (jacobian_inverse))
193
+ {
194
+ return false ;
195
+ }
196
+
197
+ // get joint array
198
+ q_.data = joint_pos;
199
+
200
+ // calculate Jacobian
201
+ jac_solver_->JntToJac (q_, *jacobian_, link_name_map_[link_name]);
202
+ Eigen::Matrix<double , 6 , Eigen::Dynamic> jacobian = jacobian_->data ;
203
+
204
+ // damped inverse
205
+ jacobian_inverse = (jacobian.transpose () * jacobian + alpha * I).inverse () * jacobian.transpose ();
206
+
207
+ return true ;
208
+ }
209
+
185
210
bool KinematicsInterfaceKDL::calculate_link_transform (
186
211
const Eigen::Matrix<double , Eigen::Dynamic, 1 > & joint_pos, const std::string & link_name,
187
212
Eigen::Isometry3d & transform)
@@ -269,6 +294,20 @@ bool KinematicsInterfaceKDL::verify_jacobian(
269
294
return true ;
270
295
}
271
296
297
+ bool KinematicsInterfaceKDL::verify_jacobian_inverse (
298
+ const Eigen::Matrix<double , Eigen::Dynamic, 6 > & jacobian_inverse)
299
+ {
300
+ if (
301
+ jacobian_inverse.rows () != jacobian_->columns () || jacobian_inverse.cols () != jacobian_->rows ())
302
+ {
303
+ RCLCPP_ERROR (
304
+ LOGGER, " The size of the jacobian (%zu, %zu) does not match the required size of (%u, %u)" ,
305
+ jacobian_inverse.rows (), jacobian_inverse.cols (), jacobian_->columns (), jacobian_->rows ());
306
+ return false ;
307
+ }
308
+ return true ;
309
+ }
310
+
272
311
} // namespace kinematics_interface_kdl
273
312
274
313
#include " pluginlib/class_list_macros.hpp"
0 commit comments