|
19 | 19 |
|
20 | 20 | namespace rcs { |
21 | 21 | namespace hw { |
| 22 | +common::Pose GetFlangeInBaseFrame(const franka::RobotState& robot_state) { |
| 23 | + return common::Pose(robot_state.O_T_EE) * |
| 24 | + common::Pose(robot_state.F_T_EE).inverse(); |
| 25 | +} |
| 26 | + |
22 | 27 | common::Pose GetTCPInBaseFrame(const franka::RobotState& robot_state, |
23 | 28 | const std::optional<common::Pose>& tcp_offset) { |
24 | 29 | if (!tcp_offset.has_value()) { |
25 | 30 | return common::Pose(robot_state.O_T_EE); |
26 | 31 | } |
27 | | - return common::Pose(robot_state.O_T_EE) * |
28 | | - common::Pose(robot_state.F_T_EE).inverse() * tcp_offset.value(); |
| 32 | + return GetFlangeInBaseFrame(robot_state) * tcp_offset.value(); |
29 | 33 | } |
30 | 34 |
|
31 | 35 | Franka::Franka(const FrankaConfig& cfg, |
@@ -120,6 +124,19 @@ common::Pose Franka::get_cartesian_position() { |
120 | 124 | return GetTCPInBaseFrame(robot_state, this->m_cfg.tcp_offset); |
121 | 125 | } |
122 | 126 |
|
| 127 | +common::Pose Franka::get_cartesian_flange_position() { |
| 128 | + this->check_for_background_errors(); |
| 129 | + franka::RobotState robot_state; |
| 130 | + if (this->running_controller.load() == Controller::none) { |
| 131 | + this->curr_state = this->robot.readOnce(); |
| 132 | + robot_state = this->curr_state; |
| 133 | + } else { |
| 134 | + std::lock_guard<std::mutex> lock(this->interpolator_mutex); |
| 135 | + robot_state = this->curr_state; |
| 136 | + } |
| 137 | + return GetFlangeInBaseFrame(robot_state); |
| 138 | +} |
| 139 | + |
123 | 140 | void Franka::set_joint_position(const common::VectorXd& q) { |
124 | 141 | if (this->m_cfg.async_control) { |
125 | 142 | this->controller_set_joint_position(q); |
|
0 commit comments