Stopping Servo Motors via ROS2 Service Call #319
-
I'm working with the GP4 arm and was wondering if there's a ROS2 service call to stop the servo motors, similar to the Below are some relevant code snippets illustrating what I've tried so far: // Command to start the robot
socket_command_function_map_["startRobot"] = [self = shared_from_this()](std::function<void(bool)> result_callback) {
RCLCPP_INFO(self->ros_node_instance_->get_logger(), "Start robot command received. Starting robot.");
auto start_request = std::make_shared<motoros2_interfaces::srv::StartTrajMode::Request>();
self->start_trajectory_mode_client_->async_send_request(start_request,
[self, result_callback](rclcpp::Client<motoros2_interfaces::srv::StartTrajMode>::SharedFuture start_future) {
auto start_result = start_future.get();
//result_callback(start_result->result_code.value == motoros2_interfaces::msg::MotionReadyEnum::MOTION_READY);
// Also, this callback wasn’t working. What should the result code value be?
result_callback(true);
});
}; The above code for starting the robot works as expected. However, stopping the robot is causing issues. Here’s what I’ve tried: // Command to stop the robot (not working)
socket_command_function_map_["stopRobot"] = [self = shared_from_this()](std::function<void(bool)> result_callback) {
RCLCPP_INFO(self->ros_node_instance_->get_logger(), "Stop robot command received. Stopping robot.");
auto stop_request = std::make_shared<std_srvs::srv::Trigger::Request>();
self->stop_trajectory_mode_client_->async_send_request(stop_request,
[self, result_callback](rclcpp::Client<std_srvs::srv::Trigger>::SharedFuture stop_future) {
auto stop_result = stop_future.get();
result_callback(stop_result->success);
});
}; Unfortunately, the above Questions:
Any advice or recommendations would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Are you specifically looking to turn off the servos (ie: power them down), or just want to prevent MotoROS2 from accepting new trajectory goals? The former is not supported right now (although the servos will disengage after the ECO-mode timeout has passed, depending on whether that's enabled). The latter is supported, as that's what As to your questions:
'stop' here is a bit ambiguous, but see my comment above.
I'm not sure what you mean by this exactly. Perhaps you could describe what your trying to achieve, just so we can avoid an xy-problem.
That would be If you receive something else, please provide us with a full debug log. Make sure to start the debug logger before you power on the controller. You can find the debug logger script in the tools sub directory of this repository. Edit:
please try to explain what it is you observe or what happens and how that is different from what you expect. "doesn't [..] work" is not enough for us to be able to help you. |
Beta Was this translation helpful? Give feedback.
no, that's indeed not supported right now.
no, that would not be too difficult in terms of complexity. We would have to find the time though.
If you have a MotoPlus SDK, you could perhaps consider implementing it and submitting a PR so we can merge it here.