Skip to content

Commit b942ec5

Browse files
committed
Using MotionType from msg definition and MotionHelperType from enum in the controller
1 parent a0744ab commit b942ec5

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

motion_primitives_forward_controller/include/motion_primitives_forward_controller/motion_primitives_forward_controller.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,9 @@ enum class ExecutionState : uint8_t
4646
STOPPED = 4
4747
};
4848

49-
enum class MotionType : uint8_t
49+
using MotionType = industrial_robot_motion_interfaces::msg::MotionPrimitive;
50+
enum class MotionHelperType : uint8_t
5051
{
51-
LINEAR_JOINT = 10,
52-
LINEAR_CARTESIAN = 50,
53-
CIRCULAR_CARTESIAN = 51,
54-
5552
STOP_MOTION = 66,
5653
RESET_STOP = 67,
5754

motion_primitives_forward_controller/src/motion_primitives_forward_controller.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ controller_interface::return_type MotionPrimitivesForwardController::update(
140140
cancel_requested_ = false;
141141
reset_command_interfaces();
142142
// send stop command immediately to the hw-interface
143-
(void)command_interfaces_[0].set_value(static_cast<double>(MotionType::STOP_MOTION));
143+
(void)command_interfaces_[0].set_value(static_cast<double>(MotionHelperType::STOP_MOTION));
144144
// clear the queue (ignore return value)
145145
static_cast<void>(moprim_queue_.get_latest(current_moprim_));
146146
robot_stop_requested_ = true;
@@ -202,7 +202,7 @@ controller_interface::return_type MotionPrimitivesForwardController::update(
202202
// If the robot was stopped by a stop command, reset the command interfaces
203203
// to allow new motion primitives to be sent.
204204
reset_command_interfaces();
205-
(void)command_interfaces_[0].set_value(static_cast<double>(MotionType::RESET_STOP));
205+
(void)command_interfaces_[0].set_value(static_cast<double>(MotionHelperType::RESET_STOP));
206206
robot_stop_requested_ = false;
207207
RCLCPP_INFO(get_node()->get_logger(), "Robot stopped, ready for new motion primitives.");
208208
}
@@ -316,9 +316,7 @@ bool MotionPrimitivesForwardController::set_command_interfaces()
316316
(void)command_interfaces_[13].set_value(goal_pose.orientation.w); // pos_qw
317317

318318
// Process via poses if available (only for circular motion)
319-
if (
320-
current_moprim_.type == static_cast<uint8_t>(MotionType::CIRCULAR_CARTESIAN) &&
321-
current_moprim_.poses.size() == 2)
319+
if (current_moprim_.type == MotionType::CIRCULAR_CARTESIAN && current_moprim_.poses.size() == 2)
322320
{
323321
const auto & via_pose = current_moprim_.poses[1].pose; // via pose
324322
(void)command_interfaces_[14].set_value(via_pose.position.x); // pos_via_x
@@ -400,7 +398,7 @@ rclcpp_action::GoalResponse MotionPrimitivesForwardController::goal_received_cal
400398
{
401399
const auto & primitive = primitives[i];
402400

403-
switch (static_cast<MotionType>(primitive.type))
401+
switch (static_cast<uint8_t>(primitive.type))
404402
{
405403
case MotionType::LINEAR_JOINT:
406404
RCLCPP_INFO(get_node()->get_logger(), "Primitive %zu: LINEAR_JOINT (PTP)", i);
@@ -473,7 +471,7 @@ void MotionPrimitivesForwardController::goal_accepted_callback(
473471
if (primitives.size() > 1)
474472
{
475473
MotionPrimitive start_marker;
476-
start_marker.type = static_cast<uint8_t>(MotionType::MOTION_SEQUENCE_START);
474+
start_marker.type = static_cast<uint8_t>(MotionHelperType::MOTION_SEQUENCE_START);
477475
if (!moprim_queue_.push(start_marker))
478476
{
479477
RCLCPP_WARN(
@@ -483,7 +481,7 @@ void MotionPrimitivesForwardController::goal_accepted_callback(
483481
add_motions(primitives);
484482

485483
MotionPrimitive end_marker;
486-
end_marker.type = static_cast<uint8_t>(MotionType::MOTION_SEQUENCE_END);
484+
end_marker.type = static_cast<uint8_t>(MotionHelperType::MOTION_SEQUENCE_END);
487485
if (!moprim_queue_.push(end_marker))
488486
{
489487
RCLCPP_WARN(get_node()->get_logger(), "Failed to push motion sequence end marker to queue.");

0 commit comments

Comments
 (0)