@@ -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}
@@ -614,10 +628,19 @@ bool GPIOController::setPayload(const ur_msgs::srv::SetPayload::Request::SharedP
614628 // reset success flag
615629 std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_ASYNC_SUCCESS ].set_value (ASYNC_WAITING );
616630
617- std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_MASS ].set_value (static_cast <double >(req->mass ));
618- std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_COG_X ].set_value (req->center_of_gravity .x );
619- std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_COG_Y ].set_value (req->center_of_gravity .y );
620- std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_COG_Z ].set_value (req->center_of_gravity .z );
631+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_MASS ].set_value (static_cast <double >(req->payload .m ));
632+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_COG_X ].set_value (req->payload .com .x );
633+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_COG_Y ].set_value (req->payload .com .y );
634+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_COG_Z ].set_value (req->payload .com .z );
635+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_INERTIA_IXX ].set_value (req->payload .ixx );
636+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_INERTIA_IYY ].set_value (req->payload .iyy );
637+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_INERTIA_IZZ ].set_value (req->payload .izz );
638+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_INERTIA_IXY ].set_value (req->payload .ixy );
639+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_INERTIA_IXZ ].set_value (req->payload .ixz );
640+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_INERTIA_IYZ ].set_value (req->payload .iyz );
641+ double transition_time_seconds =
642+ static_cast <double >(req->transition_time .sec ) + (static_cast <double >(req->transition_time .nanosec ) * 1e-9 );
643+ std::ignore = command_interfaces_[CommandInterfaces::PAYLOAD_TRANSITION_TIME ].set_value (transition_time_seconds);
621644
622645 if (!waitForAsyncCommand ([&]() {
623646 return command_interfaces_[CommandInterfaces::PAYLOAD_ASYNC_SUCCESS ].get_optional ().value_or (ASYNC_WAITING );
@@ -635,9 +658,11 @@ bool GPIOController::setPayload(const ur_msgs::srv::SetPayload::Request::SharedP
635658 }
636659
637660 if (params_.verify_payload_on_set ) {
638- if (!waitForPayloadRtdeMatch (static_cast <double >(req->mass ), req->center_of_gravity .x , req->center_of_gravity .y ,
639- req->center_of_gravity .z )) {
640- RCLCPP_WARN (get_node ()->get_logger (), " setPayload reported success but RTDE payload / payload_cog do not match "
661+ if (!waitForPayloadRtdeMatch (static_cast <double >(req->payload .m ), req->payload .com .x , req->payload .com .y ,
662+ req->payload .com .z , req->payload .ixx , req->payload .iyy , req->payload .izz ,
663+ req->payload .ixy , req->payload .ixz , req->payload .iyz , transition_time_seconds)) {
664+ RCLCPP_WARN (get_node ()->get_logger (), " setPayload reported success but RTDE payload / payload_cog / "
665+ " payload_inertia do not match "
641666 " the "
642667 " request yet. (This might "
643668 " happen when using the mocked interface.)" );
@@ -706,20 +731,35 @@ bool GPIOController::waitForAsyncCommand(std::function<double(void)> get_value)
706731 return true ;
707732}
708733
709- bool GPIOController::waitForPayloadRtdeMatch (double mass, double cx, double cy, double cz)
734+ bool GPIOController::waitForPayloadRtdeMatch (double mass, double cx, double cy, double cz, double ixx, double iyy,
735+ double izz, double ixy, double ixz, double iyz, double transition_time)
710736{
711737 constexpr double tol_mass = 1e-3 ;
712738 constexpr double tol_cog = 1e-4 ;
739+ constexpr double tol_inertia = 1e-4 ;
713740 const auto maximum_retries = params_.check_io_successfull_retries ;
714741
742+ if (transition_time > 0.0 ) {
743+ std::this_thread::sleep_for (std::chrono::milliseconds (static_cast <int >(transition_time * 1000 )));
744+ }
745+
715746 for (int retries = 0 ; retries <= maximum_retries; ++retries) {
716747 const auto m = state_interfaces_[StateInterfaces::PAYLOAD_STATE_MASS ].get_optional ();
717748 const auto sx = state_interfaces_[StateInterfaces::PAYLOAD_STATE_COG_X ].get_optional ();
718749 const auto sy = state_interfaces_[StateInterfaces::PAYLOAD_STATE_COG_Y ].get_optional ();
719750 const auto sz = state_interfaces_[StateInterfaces::PAYLOAD_STATE_COG_Z ].get_optional ();
720- if (m && sx && sy && sz) {
751+ const auto sixx = state_interfaces_[StateInterfaces::PAYLOAD_STATE_INERTIA_IXX ].get_optional ();
752+ const auto siyy = state_interfaces_[StateInterfaces::PAYLOAD_STATE_INERTIA_IYY ].get_optional ();
753+ const auto sizz = state_interfaces_[StateInterfaces::PAYLOAD_STATE_INERTIA_IZZ ].get_optional ();
754+ const auto sixy = state_interfaces_[StateInterfaces::PAYLOAD_STATE_INERTIA_IXY ].get_optional ();
755+ const auto sixz = state_interfaces_[StateInterfaces::PAYLOAD_STATE_INERTIA_IXZ ].get_optional ();
756+ const auto siyz = state_interfaces_[StateInterfaces::PAYLOAD_STATE_INERTIA_IYZ ].get_optional ();
757+ if (m && sx && sy && sz && sixx && siyy && sizz && sixy && sixz && siyz) {
721758 if (std::abs (*m - mass) <= tol_mass && std::abs (*sx - cx) <= tol_cog && std::abs (*sy - cy) <= tol_cog &&
722- std::abs (*sz - cz) <= tol_cog) {
759+ std::abs (*sz - cz) <= tol_cog && std::abs (*sixx - ixx) <= tol_inertia &&
760+ std::abs (*siyy - iyy) <= tol_inertia && std::abs (*sizz - izz) <= tol_inertia &&
761+ std::abs (*sixy - ixy) <= tol_inertia && std::abs (*sixz - ixz) <= tol_inertia &&
762+ std::abs (*siyz - iyz) <= tol_inertia) {
723763 return true ;
724764 }
725765 }
0 commit comments