@@ -437,19 +437,8 @@ DashboardClientROS::DashboardClientROS(const rclcpp::Node::SharedPtr& node, cons
437437
438438 // Service to get robot safety status as a string
439439 get_safety_status_service_ = node->create_service <ur_dashboard_msgs::srv::GetSafetyStatus>(
440- " ~/get_safety_status" , [&](const ur_dashboard_msgs::srv::GetSafetyStatus::Request::SharedPtr /* unused*/ ,
441- ur_dashboard_msgs::srv::GetSafetyStatus::Response::SharedPtr resp) {
442- auto dashboard_response =
443- dashboardCallWithChecks ([this ]() { return client_->commandSafetyStatusWithResponse (); }, resp);
444- if (resp->success ) {
445- handleDashboardResponseData (
446- [dashboard_response, resp]() {
447- resp->safety_status .status = std::get<std::string>(dashboard_response.data .at (" safety_status" ));
448- },
449- resp, dashboard_response);
450- }
451- return true ;
452- });
440+ " ~/get_safety_status" ,
441+ std::bind (&DashboardClientROS::handleSafetyStatusQuery, this , std::placeholders::_1, std::placeholders::_2));
453442
454443 // Service to generate flight report, defaults to system type
455444 generate_flight_report_service_ = node->create_service <ur_dashboard_msgs::srv::GenerateFlightReport>(
@@ -572,6 +561,68 @@ bool DashboardClientROS::handleSafetyModeQuery(const ur_dashboard_msgs::srv::Get
572561 return true ;
573562}
574563
564+ bool DashboardClientROS::handleSafetyStatusQuery (const ur_dashboard_msgs::srv::GetSafetyStatus::Request::SharedPtr req,
565+ ur_dashboard_msgs::srv::GetSafetyStatus::Response::SharedPtr resp)
566+ {
567+ auto dashboard_response =
568+ dashboardCallWithChecks ([this ]() { return client_->commandSafetyStatusWithResponse (); }, resp);
569+ if (resp->success ) {
570+ handleDashboardResponseData (
571+ [dashboard_response, resp]() {
572+ const std::string safety_status_str = std::get<std::string>(dashboard_response.data .at (" safety_status" ));
573+ {
574+ // Note: This list implements all safety status values. The Dashboard server
575+ // documentation doesn't name all of them, so some of them might not be used.
576+ if (safety_status_str == " NORMAL" ) {
577+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::NORMAL;
578+ } else if (safety_status_str == " REDUCED" ) {
579+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::REDUCED;
580+ } else if (safety_status_str == " PROTECTIVE_STOP" ) {
581+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::PROTECTIVE_STOP;
582+ } else if (safety_status_str == " RECOVERY" ) {
583+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::RECOVERY;
584+ } else if (safety_status_str == " SAFEGUARD_STOP" ) {
585+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::SAFEGUARD_STOP;
586+ } else if (safety_status_str == " SYSTEM_EMERGENCY_STOP" ) {
587+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::SYSTEM_EMERGENCY_STOP;
588+ } else if (safety_status_str == " ROBOT_EMERGENCY_STOP" ) {
589+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::ROBOT_EMERGENCY_STOP;
590+ } else if (safety_status_str == " VIOLATION" ) {
591+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::VIOLATION;
592+ } else if (safety_status_str == " FAULT" ) {
593+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::FAULT;
594+ } else if (safety_status_str == " VALIDATE_JOINT" ) {
595+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::VALIDATE_JOINT_ID;
596+ } else if (safety_status_str == " UNDEFINED_SAFETY_MODE" ) {
597+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::UNDEFINED_SAFETY_MODE;
598+ } else if (safety_status_str == " AUTOMATIC_MODE_SAFEGUARD_STOP" ) {
599+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::AUTOMATIC_MODE_SAFEGUARD_STOP;
600+ } else if (safety_status_str == " SYSTEM_THREE_POSITION_ENABLING_STOP" ) {
601+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::SYSTEM_THREE_POSITION_ENABLING_STOP;
602+ } else if (safety_status_str == " TP_THREE_POSITION_ENABLING_STOP" ) {
603+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::TP_THREE_POSITION_ENABLING_STOP;
604+ } else if (safety_status_str == " IMMI_EMERGENCY_STOP" ) {
605+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::IMMI_EMERGENCY_STOP;
606+ } else if (safety_status_str == " IMMI_SAFEGUARD_STOP" ) {
607+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::IMMI_SAFEGUARD_STOP;
608+ } else if (safety_status_str == " PROFISAFE_WAITING_FOR_PARAMETERS" ) {
609+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::PROFISAFE_WAITING_FOR_PARAMETERS;
610+ } else if (safety_status_str == " PROFISAFE_AUTOMATIC_MODE_SAFEGUARD_STOP" ) {
611+ resp->safety_status .status =
612+ ur_dashboard_msgs::msg::SafetyStatus::PROFISAFE_AUTOMATIC_MODE_SAFEGUARD_STOP;
613+ } else if (safety_status_str == " PROFISAFE_SAFEGUARD_STOP" ) {
614+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::PROFISAFE_SAFEGUARD_STOP;
615+ } else if (safety_status_str == " PROFISAFE_EMERGENCY_STOP" ) {
616+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::PROFISAFE_EMERGENCY_STOP;
617+ } else if (safety_status_str == " SAFETY_API_SAFEGUARD_STOP" ) {
618+ resp->safety_status .status = ur_dashboard_msgs::msg::SafetyStatus::SAFETY_API_SAFEGUARD_STOP;
619+ }
620+ }
621+ },
622+ resp, dashboard_response);
623+ }
624+ return true ;
625+ }
575626bool DashboardClientROS::handleRobotModeQuery (const ur_dashboard_msgs::srv::GetRobotMode::Request::SharedPtr req,
576627 ur_dashboard_msgs::srv::GetRobotMode::Response::SharedPtr resp)
577628{
0 commit comments