I’m currently in the process of setting up a ROS2 environment to communicate with Pixhawk 6x. For the moment, I’m using SITL to test things before going to HW. So far, the AP_DDS works apart from the ROS2 services.
Arm Motors works (arm throttle SUCCESS), but result is ever sent back after the request.
Mode Switch has a very weird behavior. When sending an integer mode, let’s say 4 ROVER_MODE_GUIDED, the message will arrive , but a complete random number and it will fail because that (random) mode does not exist.
I have tested this both with python and cpp ROS2 nodes. Bellow you cna find my cpp node nipet for the request.
void call_mode_switch() {
if (!mode_switch_client_->wait_for_service(std::chrono::seconds(1))) {
RCLCPP_INFO(this->get_logger(), "Service not available, waiting again...");
return;
}
auto request = std::make_shared<ardupilot_msgs::srv::ModeSwitch::Request>();
uint8_t mode = 4;
request->mode = mode;
auto result_future = mode_switch_client_->async_send_request(request);
}