-
Notifications
You must be signed in to change notification settings - Fork 993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Executing commands on Pixhawk with ArduPilot via MAVROS2 #1863
Comments
Hi, Check id - https://mavlink.io/en/messages/common.html#MAV_RESULT_FAILED why that happened most likely be sent as STATUSTEXT, which printed with |
Hello, I added my check ID to the first post. It seems to be outputting correctly. I actually was able to get the takeoff and land commands to work. However, there is still very limited output on the mavros_node console. Is there a way to make this more verbose, i.e. have it output when the mode changes and when it is performing a command? My prior issues were as follows: I was indoors with no GPS signal. I was attempting to test the Guided_NoGPS mode, and have it take off in that mode. I am unsure of why this was not working, I am guessing there is a different protocol/command to use for this mode. After moving to an area with GPS and retesting in guided mode, takeoff and landing worked as expected.
What mavros command would be for SET_POSITION_TARGET_LOCAL_NED? Would these messages maybe be params that can then be set? Is there something similar to CommandLong but for messages? |
Version 2 mostly have same messages and plugins as v1. So you can list topics and see that you're asking about setpoint* plugins. Actually checkid doesn't looks correct, to few messages coming from 1.1. Should be much more than just a heartbeat. |
Hello @OliverZanone , I'm using the Cube Blue and cannot even change the flight mode. Could you share the parameters you used for serial? |
Issue details
Finding information for MAVROS2 has been pretty frustrating as relevant information seems scarce.
As much as I have struggled to get some of this working, I would be more than happy to write up some tutorials after all of this.
The best source of information I've found came from this post here.
From this, I have been attempting to manually deploy the commands to a Pixhawk FMU via a rpi companion computer using a combination of services and especially commandLong, i.e. for arming:
ros2 service call /mavros/cmd/arming mavros_msgs/srv/CommandBool "{value: True}"
For setting mode to guided:
ros2 service call /mavros/cmd/command mavros_msgs/srv/CommandLong "{command: 176, param1: 1, param2: 4}"
I later realized you must also follow your firmware's documentation as well, and the supported parameters found here for ardupilot, thus the values for param1 and param2.
I can confirm the mode is being set in mission planner flight modes tab.
Since I was able to get those working, I have tried working through other commands found in the mavlink docs and then crossreferencing those with ardupilot documentation.
However, all other commands I've tested have failed.
For example, taking off:
ros2 service call /mavros/cmd/command mavros_msgs/srv/CommandLong "{command: 22, param7: 5}"
With broadcast set to false, nothing happens/no output. Setting broadcast to true shows "Unexpected command 22, result 4" I have all of the prearm safety checks unchecked, other than the hardware button found on my gps unit.
Trying the built in mavros service for taking off:
ros2 service call /mavros/cmd/takeoff mavros_msgs/srv/CommandTOL "{altitude: 5}"
this gives success=false result=4, which according to mavlink docs, 4 means good command but failed to execute, as in the prior method.
My goal is to implement all of the guided commands found here programatically. Some of these fall under the message category, not the command category on mavlink docs, which commandLong I assume is only for the command category.
I assume some of these commands are built into the other mavros services, but as I cannot find any documentation on how to use them, it has really been a game of trial and error on using just the commandLong.
If someone could point me in the right direction on either finding documentation on some of the mavros services or figuring out how to implement some of these commands and messages found in mavlink/ardupilot documentation that would be greatly appreciated.
MAVROS version and platform
Mavros2: 2.4.0-1jammy.20230429.052850
ROS2: Humble
Ubuntu: 22.04.2 LTS (in docker container running on raspberry pi bullseye)
Autopilot type and version
[ x ] ArduPilot
[ ] PX4
Version: V4.0.6
Node logs
Diagnostics
Check ID
The text was updated successfully, but these errors were encountered: