3434
3535#include " rclcpp/rclcpp.hpp"
3636#include " rclcpp_action/create_server.hpp"
37+ #include " std_msgs/msg/bool.hpp"
3738#include " std_srvs/srv/trigger.hpp"
3839
3940#include " ur_dashboard_msgs/action/set_mode.hpp"
@@ -60,37 +61,42 @@ class RobotStateHelper
6061
6162 void updateRobotState ();
6263
63- void doTransition ();
64+ bool recoverFromSafety ();
65+ bool doTransition (const urcl::RobotMode target_mode);
66+ bool jumpToRobotMode (const urcl::RobotMode target_mode);
6467
6568 bool safeDashboardTrigger (rclcpp::Client<std_srvs::srv::Trigger>::SharedPtr srv);
6669
70+ bool stopProgram ();
71+
6772 void setModeAcceptCallback (const std::shared_ptr<SetModeGoalHandle> goal_handle);
6873 rclcpp_action::GoalResponse setModeGoalCallback (const rclcpp_action::GoalUUID& uuid,
6974 std::shared_ptr<const ur_dashboard_msgs::action::SetMode::Goal> goal);
7075 rclcpp_action::CancelResponse setModeCancelCallback (const std::shared_ptr<SetModeGoalHandle> goal_handle);
7176
7277 void setModeExecute (const std::shared_ptr<SetModeGoalHandle> goal_handle);
7378
74- void startActionServer ();
75- bool is_started_;
76- bool in_action_;
77-
7879 bool headless_mode_;
7980
8081 std::shared_ptr<ur_dashboard_msgs::action::SetMode::Result> result_;
8182 std::shared_ptr<ur_dashboard_msgs::action::SetMode::Feedback> feedback_;
8283 std::shared_ptr<const ur_dashboard_msgs::action::SetMode::Goal> goal_;
8384 std::shared_ptr<SetModeGoalHandle> current_goal_handle_;
8485
85- urcl::RobotMode robot_mode_;
86- urcl::SafetyMode safety_mode_;
86+ std::atomic<urcl::RobotMode> robot_mode_;
87+ std::atomic<urcl::SafetyMode> safety_mode_;
88+ std::atomic<bool > error_ = false ;
89+ std::atomic<bool > in_action_;
90+ std::atomic<bool > program_running_;
91+ std::mutex goal_mutex_;
8792
8893 rclcpp_action::Server<ur_dashboard_msgs::action::SetMode>::SharedPtr set_mode_as_;
8994
9095 rclcpp::CallbackGroup::SharedPtr robot_mode_sub_cb_;
9196
9297 rclcpp::Subscription<ur_dashboard_msgs::msg::RobotMode>::SharedPtr robot_mode_sub_;
9398 rclcpp::Subscription<ur_dashboard_msgs::msg::SafetyMode>::SharedPtr safety_mode_sub_;
99+ rclcpp::Subscription<std_msgs::msg::Bool>::SharedPtr program_running_sub;
94100
95101 rclcpp::CallbackGroup::SharedPtr service_cb_grp_;
96102
0 commit comments