Skip to content

Commit

Permalink
Initialize member variables
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fmauch committed May 11, 2020
1 parent b466518 commit 5621c35
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ur_robot_driver/src/ros/robot_state_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
#include <std_srvs/Trigger.h>
namespace ur_driver
{
RobotStateHelper::RobotStateHelper(const ros::NodeHandle& nh) : nh_(nh), set_mode_as_(nh_, "set_mode", false)
RobotStateHelper::RobotStateHelper(const ros::NodeHandle& nh)
: nh_(nh)
, robot_mode_(RobotMode::POWER_OFF)
, safety_mode_(SafetyMode::UNDEFINED_SAFETY_MODE)
, set_mode_as_(nh_, "set_mode", false)
{
// Topic on which the robot_mode is published by the driver
robot_mode_sub_ = nh_.subscribe("robot_mode", 1, &RobotStateHelper::robotModeCallback, this);
Expand Down

0 comments on commit 5621c35

Please sign in to comment.