Skip to content

Commit 0ef07d5

Browse files
committed
Use scoped enums
1 parent 1822563 commit 0ef07d5

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

ur_robot_driver/include/ur_robot_driver/rtde/rtde_client.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ namespace ur_driver
4848
{
4949
namespace rtde_interface
5050
{
51-
enum UrRtdeRobotStatusBits
51+
enum class UrRtdeRobotStatusBits
5252
{
5353
IS_POWER_ON = 0,
5454
IS_PROGRAM_RUNNING = 1,
5555
IS_TEACH_BUTTON_PRESSED = 2,
5656
IS_POWER_BUTTON_PRESSED = 3
5757
};
5858

59-
enum UrRtdeSafetyStatusBits
59+
enum class UrRtdeSafetyStatusBits
6060
{
6161
IS_NORMAL_MODE = 0,
6262
IS_REDUCED_MODE = 1,

ur_robot_driver/src/ros/hardware_interface.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -652,27 +652,29 @@ void HardwareInterface::extractRobotStatus()
652652
{
653653
using namespace rtde_interface;
654654

655-
robot_status_resource_.mode =
656-
robot_status_bits_[UrRtdeRobotStatusBits::IS_TEACH_BUTTON_PRESSED] ? RobotMode::MANUAL : RobotMode::AUTO;
655+
robot_status_resource_.mode = robot_status_bits_[toUnderlying(UrRtdeRobotStatusBits::IS_TEACH_BUTTON_PRESSED)] ?
656+
RobotMode::MANUAL :
657+
RobotMode::AUTO;
657658

658-
robot_status_resource_.e_stopped =
659-
safety_status_bits_[UrRtdeSafetyStatusBits::IS_EMERGENCY_STOPPED] ? TriState::TRUE : TriState::FALSE;
659+
robot_status_resource_.e_stopped = safety_status_bits_[toUnderlying(UrRtdeSafetyStatusBits::IS_EMERGENCY_STOPPED)] ?
660+
TriState::TRUE :
661+
TriState::FALSE;
660662

661663
// Note that this is true as soon as the drives are powered,
662664
// even if the breakes are still closed
663665
// which is in slight contrast to the comments in the
664666
// message definition
665667
robot_status_resource_.drives_powered =
666-
robot_status_bits_[UrRtdeRobotStatusBits::IS_POWER_ON] ? TriState::TRUE : TriState::FALSE;
668+
robot_status_bits_[toUnderlying(UrRtdeRobotStatusBits::IS_POWER_ON)] ? TriState::TRUE : TriState::FALSE;
667669

668670
robot_status_resource_.motion_possible =
669671
robot_mode_ == ur_dashboard_msgs::RobotMode::RUNNING ? TriState::TRUE : TriState::FALSE;
670672

671673
// I found no way to reliably get information if the robot is moving
672674
robot_status_resource_.in_motion = TriState::UNKNOWN;
673675

674-
if (safety_status_bits_[UrRtdeSafetyStatusBits::IS_PROTECTIVE_STOPPED] ||
675-
safety_status_bits_[UrRtdeSafetyStatusBits::IS_EMERGENCY_STOPPED])
676+
if (safety_status_bits_[toUnderlying(UrRtdeSafetyStatusBits::IS_PROTECTIVE_STOPPED)] ||
677+
safety_status_bits_[toUnderlying(UrRtdeSafetyStatusBits::IS_EMERGENCY_STOPPED)])
676678
{
677679
robot_status_resource_.in_error = TriState::TRUE;
678680
}

0 commit comments

Comments
 (0)