@@ -170,9 +170,14 @@ std::vector<hardware_interface::StateInterface> URPositionHardwareInterface::exp
170170 &speed_scaling_combined_));
171171
172172 for (auto & sensor : info_.sensors ) {
173- for (uint j = 0 ; j < sensor.state_interfaces .size (); ++j) {
174- state_interfaces.emplace_back (hardware_interface::StateInterface (sensor.name , sensor.state_interfaces [j].name ,
175- &urcl_ft_sensor_measurements_[j]));
173+ if (sensor.name == tf_prefix + " tcp_fts_sensor" ) {
174+ const std::vector<std::string> fts_names = {
175+ " force.x" , " force.y" , " force.z" , " torque.x" , " torque.y" , " torque.z"
176+ };
177+ for (uint j = 0 ; j < 6 ; ++j) {
178+ state_interfaces.emplace_back (
179+ hardware_interface::StateInterface (sensor.name , fts_names[j], &urcl_ft_sensor_measurements_[j]));
180+ }
176181 }
177182 }
178183
@@ -232,6 +237,21 @@ std::vector<hardware_interface::StateInterface> URPositionHardwareInterface::exp
232237 state_interfaces.emplace_back (
233238 hardware_interface::StateInterface (tf_prefix + " gpio" , " program_running" , &robot_program_running_copy_));
234239
240+ state_interfaces.emplace_back (
241+ hardware_interface::StateInterface (tf_prefix + " tcp_pose" , " position.x" , &urcl_tcp_pose_[0 ]));
242+ state_interfaces.emplace_back (
243+ hardware_interface::StateInterface (tf_prefix + " tcp_pose" , " position.y" , &urcl_tcp_pose_[1 ]));
244+ state_interfaces.emplace_back (
245+ hardware_interface::StateInterface (tf_prefix + " tcp_pose" , " position.z" , &urcl_tcp_pose_[2 ]));
246+ state_interfaces.emplace_back (
247+ hardware_interface::StateInterface (tf_prefix + " tcp_pose" , " orientation.x" , &tcp_rotation_buffer.x ));
248+ state_interfaces.emplace_back (
249+ hardware_interface::StateInterface (tf_prefix + " tcp_pose" , " orientation.y" , &tcp_rotation_buffer.y ));
250+ state_interfaces.emplace_back (
251+ hardware_interface::StateInterface (tf_prefix + " tcp_pose" , " orientation.z" , &tcp_rotation_buffer.z ));
252+ state_interfaces.emplace_back (
253+ hardware_interface::StateInterface (tf_prefix + " tcp_pose" , " orientation.w" , &tcp_rotation_buffer.w ));
254+
235255 state_interfaces.emplace_back (hardware_interface::StateInterface (
236256 tf_prefix + " get_robot_software_version" , " get_version_major" , &get_robot_software_version_major_));
237257
@@ -796,10 +816,8 @@ void URPositionHardwareInterface::transformForceTorque()
796816 tcp_torque_.setValue (urcl_ft_sensor_measurements_[3 ], urcl_ft_sensor_measurements_[4 ],
797817 urcl_ft_sensor_measurements_[5 ]);
798818
799- tf2::Quaternion rotation_quat;
800- tf2::fromMsg (tcp_transform_.transform .rotation , rotation_quat);
801- tcp_force_ = tf2::quatRotate (rotation_quat.inverse (), tcp_force_);
802- tcp_torque_ = tf2::quatRotate (rotation_quat.inverse (), tcp_torque_);
819+ tcp_force_ = tf2::quatRotate (tcp_rotation_quat_.inverse (), tcp_force_);
820+ tcp_torque_ = tf2::quatRotate (tcp_rotation_quat_.inverse (), tcp_torque_);
803821
804822 urcl_ft_sensor_measurements_ = { tcp_force_.x (), tcp_force_.y (), tcp_force_.z (),
805823 tcp_torque_.x (), tcp_torque_.y (), tcp_torque_.z () };
@@ -812,17 +830,12 @@ void URPositionHardwareInterface::extractToolPose()
812830 std::sqrt (std::pow (urcl_tcp_pose_[3 ], 2 ) + std::pow (urcl_tcp_pose_[4 ], 2 ) + std::pow (urcl_tcp_pose_[5 ], 2 ));
813831
814832 tf2::Vector3 rotation_vec (urcl_tcp_pose_[3 ], urcl_tcp_pose_[4 ], urcl_tcp_pose_[5 ]);
815- tf2::Quaternion rotation;
816833 if (tcp_angle > 1e-16 ) {
817- rotation .setRotation (rotation_vec.normalized (), tcp_angle);
834+ tcp_rotation_quat_ .setRotation (rotation_vec.normalized (), tcp_angle);
818835 } else {
819- rotation .setValue (0.0 , 0.0 , 0.0 , 1.0 ); // default Quaternion is 0,0,0,0 which is invalid
836+ tcp_rotation_quat_ .setValue (0.0 , 0.0 , 0.0 , 1.0 ); // default Quaternion is 0,0,0,0 which is invalid
820837 }
821- tcp_transform_.transform .translation .x = urcl_tcp_pose_[0 ];
822- tcp_transform_.transform .translation .y = urcl_tcp_pose_[1 ];
823- tcp_transform_.transform .translation .z = urcl_tcp_pose_[2 ];
824-
825- tcp_transform_.transform .rotation = tf2::toMsg (rotation);
838+ tcp_rotation_buffer.set (tcp_rotation_quat_);
826839}
827840
828841hardware_interface::return_type URPositionHardwareInterface::prepare_command_mode_switch (
0 commit comments