@@ -135,6 +135,14 @@ controller_interface::InterfaceConfiguration GPIOController::command_interface_c
135135
136136 config.names .emplace_back (tf_prefix + " gpio/analog_output_domain_cmd" );
137137
138+ config.names .emplace_back (tf_prefix + " payload/inertia.ixx" );
139+ config.names .emplace_back (tf_prefix + " payload/inertia.iyy" );
140+ config.names .emplace_back (tf_prefix + " payload/inertia.izz" );
141+ config.names .emplace_back (tf_prefix + " payload/inertia.ixy" );
142+ config.names .emplace_back (tf_prefix + " payload/inertia.ixz" );
143+ config.names .emplace_back (tf_prefix + " payload/inertia.iyz" );
144+ config.names .emplace_back (tf_prefix + " payload/transition_time" );
145+
138146 return config;
139147}
140148
@@ -200,6 +208,12 @@ controller_interface::InterfaceConfiguration ur_controllers::GPIOController::sta
200208 config.names .emplace_back (tf_prefix + " payload/cog.x" );
201209 config.names .emplace_back (tf_prefix + " payload/cog.y" );
202210 config.names .emplace_back (tf_prefix + " payload/cog.z" );
211+ config.names .emplace_back (tf_prefix + " payload/inertia.ixx" );
212+ config.names .emplace_back (tf_prefix + " payload/inertia.iyy" );
213+ config.names .emplace_back (tf_prefix + " payload/inertia.izz" );
214+ config.names .emplace_back (tf_prefix + " payload/inertia.ixy" );
215+ config.names .emplace_back (tf_prefix + " payload/inertia.ixz" );
216+ config.names .emplace_back (tf_prefix + " payload/inertia.iyz" );
203217
204218 return config;
205219}
@@ -593,10 +607,26 @@ bool GPIOController::setPayload(const ur_msgs::srv::SetPayload::Request::SharedP
593607 // reset success flag
594608 command_interfaces_[CommandInterfaces::PAYLOAD_ASYNC_SUCCESS ].set_value (ASYNC_WAITING );
595609
610+ <<<<<<< HEAD
596611 command_interfaces_[CommandInterfaces::PAYLOAD_MASS ].set_value (req->mass );
597612 command_interfaces_[CommandInterfaces::PAYLOAD_COG_X ].set_value (req->center_of_gravity .x );
598613 command_interfaces_[CommandInterfaces::PAYLOAD_COG_Y ].set_value (req->center_of_gravity .y );
599614 command_interfaces_[CommandInterfaces::PAYLOAD_COG_Z ].set_value (req->center_of_gravity .z );
615+ =======
616+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_MASS ].set_value (static_cast <double >(req->mass ));
617+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_COG_X ].set_value (req->center_of_gravity .x );
618+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_COG_Y ].set_value (req->center_of_gravity .y );
619+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_COG_Z ].set_value (req->center_of_gravity .z );
620+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_INERTIA_IXX ].set_value (req->ixx );
621+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_INERTIA_IYY ].set_value (req->iyy );
622+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_INERTIA_IZZ ].set_value (req->izz );
623+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_INERTIA_IXY ].set_value (req->ixy );
624+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_INERTIA_IXZ ].set_value (req->ixz );
625+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_INERTIA_IYZ ].set_value (req->iyz );
626+ double transition_time_seconds =
627+ static_cast <double >(req->transition_time .sec ) + (static_cast <double >(req->transition_time .nanosec ) * 1e-9 );
628+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_TRANSITION_TIME ].set_value (transition_time_seconds);
629+ >>>>>>> 3d18755 (Allow setting payload inertia matrix via set_payload service backwards-compatible (#1811 ))
600630
601631 if (!waitForAsyncCommand (
602632 [&]() { return command_interfaces_[CommandInterfaces::PAYLOAD_ASYNC_SUCCESS ].get_value (); })) {
@@ -613,8 +643,10 @@ bool GPIOController::setPayload(const ur_msgs::srv::SetPayload::Request::SharedP
613643
614644 if (params_.verify_payload_on_set ) {
615645 if (!waitForPayloadRtdeMatch (static_cast <double >(req->mass ), req->center_of_gravity .x , req->center_of_gravity .y ,
616- req->center_of_gravity .z )) {
617- RCLCPP_WARN (get_node ()->get_logger (), " setPayload reported success but RTDE payload / payload_cog do not match "
646+ req->center_of_gravity .z , req->ixx , req->iyy , req->izz , req->ixy , req->ixz , req->iyz ,
647+ transition_time_seconds)) {
648+ RCLCPP_WARN (get_node ()->get_logger (), " setPayload reported success but RTDE payload / payload_cog / "
649+ " payload_inertia do not match "
618650 " the "
619651 " request yet. (This might "
620652 " happen when using the mocked interface.)" );
@@ -680,20 +712,47 @@ bool GPIOController::waitForAsyncCommand(std::function<double(void)> get_value)
680712 return true ;
681713}
682714
683- bool GPIOController::waitForPayloadRtdeMatch (double mass, double cx, double cy, double cz)
715+ bool GPIOController::waitForPayloadRtdeMatch (double mass, double cx, double cy, double cz, double ixx, double iyy,
716+ double izz, double ixy, double ixz, double iyz, double transition_time)
684717{
685718 constexpr double tol_mass = 1e-3 ;
686719 constexpr double tol_cog = 1e-4 ;
720+ constexpr double tol_inertia = 1e-4 ;
687721 const auto maximum_retries = params_.check_io_successfull_retries ;
688722
723+ if (transition_time > 0.0 ) {
724+ std::this_thread::sleep_for (std::chrono::milliseconds (static_cast <int >(transition_time * 1000 )));
725+ }
726+
689727 for (int retries = 0 ; retries <= maximum_retries; ++retries) {
728+ <<<<<<< HEAD
690729 const auto m = state_interfaces_[StateInterfaces::PAYLOAD_STATE_MASS ].get_value ();
691730 const auto sx = state_interfaces_[StateInterfaces::PAYLOAD_STATE_COG_X ].get_value ();
692731 const auto sy = state_interfaces_[StateInterfaces::PAYLOAD_STATE_COG_Y ].get_value ();
693732 const auto sz = state_interfaces_[StateInterfaces::PAYLOAD_STATE_COG_Z ].get_value ();
694733 if (std::abs (m - mass) <= tol_mass && std::abs (sx - cx) <= tol_cog && std::abs (sy - cy) <= tol_cog &&
695734 std::abs (sz - cz) <= tol_cog) {
696735 return true ;
736+ =======
737+ const auto m = state_interfaces_[StateInterfaces::PAYLOAD_STATE_MASS ].get_optional ();
738+ const auto sx = state_interfaces_[StateInterfaces::PAYLOAD_STATE_COG_X ].get_optional ();
739+ const auto sy = state_interfaces_[StateInterfaces::PAYLOAD_STATE_COG_Y ].get_optional ();
740+ const auto sz = state_interfaces_[StateInterfaces::PAYLOAD_STATE_COG_Z ].get_optional ();
741+ const auto sixx = state_interfaces_[StateInterfaces::PAYLOAD_STATE_INERTIA_IXX ].get_optional ();
742+ const auto siyy = state_interfaces_[StateInterfaces::PAYLOAD_STATE_INERTIA_IYY ].get_optional ();
743+ const auto sizz = state_interfaces_[StateInterfaces::PAYLOAD_STATE_INERTIA_IZZ ].get_optional ();
744+ const auto sixy = state_interfaces_[StateInterfaces::PAYLOAD_STATE_INERTIA_IXY ].get_optional ();
745+ const auto sixz = state_interfaces_[StateInterfaces::PAYLOAD_STATE_INERTIA_IXZ ].get_optional ();
746+ const auto siyz = state_interfaces_[StateInterfaces::PAYLOAD_STATE_INERTIA_IYZ ].get_optional ();
747+ if (m && sx && sy && sz && sixx && siyy && sizz && sixy && sixz && siyz) {
748+ if (std::abs (*m - mass) <= tol_mass && std::abs (*sx - cx) <= tol_cog && std::abs (*sy - cy) <= tol_cog &&
749+ std::abs (*sz - cz) <= tol_cog && std::abs (*sixx - ixx) <= tol_inertia &&
750+ std::abs (*siyy - iyy) <= tol_inertia && std::abs (*sizz - izz) <= tol_inertia &&
751+ std::abs (*sixy - ixy) <= tol_inertia && std::abs (*sixz - ixz) <= tol_inertia &&
752+ std::abs (*siyz - iyz) <= tol_inertia) {
753+ return true ;
754+ }
755+ >>>>>>> 3d18755 (Allow setting payload inertia matrix via set_payload service backwards-compatible (#1811 ))
697756 }
698757 std::this_thread::sleep_for (std::chrono::milliseconds (50 ));
699758 }
0 commit comments