Hi,
Trying to send commandInt (through ROS-mavros) in Guided mode.
According to this link: Plane Commands in Guided Mode — Dev documentation (ardupilot.org) , we need to send MAV_CMD_NAV_WAYPOINT, encoded with “current = 2”.
When trying this, the respond from the simulation is “Got COMMAND_ACK: NAV_WAYPOINT: UNSUPPORTED”. See the picture below.
Any suggestions on why this is not working?
Are there other ways to control a Plane in guided mode with MAVROS?
We don’t want to use the AUTO mode, because the fixed-wing needs get updated directional commands with a frequency of eg. 5 Hz.
1 Like
tropappar
(Micha Sende)
November 29, 2023, 1:47pm
2
It won’t probably won’t help you anymore now, but I see a couple of problems in your request message:
command
must be 192
(do reposition)
x
and y
must be integers, latitude * 1e7
and longitude * 1e7
z
must be a floating point number
This is how you would do it with Python in ROS 2 using MAVROS:
import rclpy
from mavros_msgs.srv import CommandInt
# create ros node
rclpy.init()
node = rclpy.create_node("guided_waypoint")
# service client for sending integer commands to the vehicle
srv_cmd_int = node.create_client(CommandInt, "mavros/cmd/command_int")
srv_cmd_int.wait_for_service()
# create reposition request
command = CommandInt.Request()
command.frame = 3 # global, relative altitude
command.command = 192 # https://mavlink.io/en/messages/common.html#MAV_CMD_DO_REPOSITION
command.current = 2 # indicate move to message in guided mode
command.x = int(46.6127 * 1e7)
command.y = int(14.2652 * 1e7)
command.z = 50.0 # altitude above ground
# send waypoint to vehicle
future_command = srv_cmd_int.call_async(command)
rclpy.spin_until_future_complete(node, future_command)
if future_command.result().success:
node.get_logger().info("Successfully send move to command to vehicle.")
else:
node.get_logger().warn("Failed to send move to command to vehicle!")