Skip to content

Commit 5621c35

Browse files
author
Felix Exner
committed
Initialize member variables
It can happen that the action gets triggered before the mode callback got triggered While this changes stops the helper from crashing when this happens, it might not be the best idea to do so as the question remains, what we should do if we haven't even received a current status from the robot. With the changes introduced inside this commit, the helper would trigger the respective state changes, which might lead to wrong requests if we aren't entirely sure what to do. One solution would be to reject goals as long as no status was received, but that would break such scenarios where you want to activate the robot automatically during startup. Another idea would be to delay actually starting the action server until we received both, robot mode and safety mode. But I am not entirely sure whether this will scale well.
1 parent b466518 commit 5621c35

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ur_robot_driver/src/ros/robot_state_helper.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@
3030
#include <std_srvs/Trigger.h>
3131
namespace ur_driver
3232
{
33-
RobotStateHelper::RobotStateHelper(const ros::NodeHandle& nh) : nh_(nh), set_mode_as_(nh_, "set_mode", false)
33+
RobotStateHelper::RobotStateHelper(const ros::NodeHandle& nh)
34+
: nh_(nh)
35+
, robot_mode_(RobotMode::POWER_OFF)
36+
, safety_mode_(SafetyMode::UNDEFINED_SAFETY_MODE)
37+
, set_mode_as_(nh_, "set_mode", false)
3438
{
3539
// Topic on which the robot_mode is published by the driver
3640
robot_mode_sub_ = nh_.subscribe("robot_mode", 1, &RobotStateHelper::robotModeCallback, this);

0 commit comments

Comments
 (0)