Missing functionality in ROS2 vs MavLink?

Hey all,

I’m pretty new to PX4 and MavSDK although I’ve done a good amount of ROS2. I’m trying to write some ROS2 C++ based offline control code for a glider and I’m struggling to figure out how to do with the API’s available.

Basically I want ways to do the following things:

  1. get TECSStatus information on a regular basis (this helps me determine if we’ve hit an updraft/thermal)
  2. get other telemetry related to status, position, mode of operation, etc. so I can monitor what’s happening in my code.
  3. fly to a given waypoint GPS waypoint GLIDING there, and ignore altitude - stabilize only in terms of direction/course, and certainly not for altitude. (Even better if I can define an entire route to fly, but I’ll take getting to a single waypoint and manage point to point myself if needed).
  4. fly an orbit at a given radius and direction around a given GPS coordinate (again, unpowered so don’t worry about altitude, in fact I’m hoping to gain altitude by trying to circle inside of a thermal here).
  5. be able to control when the engine turns on/off (I’ll need it to do the initial takeoff and climb to altitude before gliding).

Now, digging through documentation I saw this: https://docs.px4.io/main/en/flight_modes/offboard.html#fixed-wing And in there it shows that there are MavLink messages where you can specify Position Targets and set mode options to tell it to ignore the altitude and trade altitude for forward motion (by adjusting pitch automatically). And also options for telling it to circle a point.

Unfortunately it doesn’t look like either the MavSDK nor the ROS2 message based API expose these options.

Also, really would like to be able to use that mode 292 Glide set point in the Set Position Target Global INT instead of Local NED as I’m trying to make this work for long range glides…

Does anyone know of some other way to either do what I need to do without dropping down to MavLink level (UGH that looks like total hell!) or to get those things added/exposed in the MavSDK or ROS2 message api’s?

I realize what I’m trying to do is probably pretty far off what 99.99% of people are trying to do and thus its a special case ask here…

Any help/advice is greatly appreciated. I’ve been racking my brains for like 3 weeks trying to figure all this out. Started out with a ROS2 Message implementation and then realized the limitations. Thought MavSDK would do what I needed, rewrote and then realized it had similar limitations…

1 Like

Hi @mkopack73 ! You have a very nice application here!
First of all, I’m not an regular user of MAVLINK / MAVSDK / MAVROS therefore I cannot really help you there, but you said you are interested in using ROS 2… Did you take a look at the “direct” PX4 - ROS 2 bridge?

Why am I suggesting it?

  • It let you expose to ROS any uorb topic you are interested in, therefore monitoring the vehicle status is not an issue.
  • you can command the vehicle in offboard mode. Unfortunately this part is more complex than using mavsdk as you have to provide the internal messages to accomplish the task.

Therefore with direct ROS 2 you can accomplish items 1 and 2. Item 3 requires some work: both SET_POSITION_TARGET_LOCAL_NED and SET_POSITION_TARGET_GLOBAL_INT are processed in

where they are decoded and converted in offboard_control_mode and trajectory_setpoint UORB messages. In particular the global position in SET_POSITION_TARGET_GLOBAL_INT is projected into local coordinates and the it is treated as LOCAL_NED. Then, your code would need to take your reference global setpoint, project in local coordinates, assemble a trajectory_setpoint message with the right fields (pos z, vel z, acc z) set to NAN (NAN means ignore).

Item 4 is basically is a specific case of item 3

Item 5… I don’t really know if you can just shut down the motor and keep flying sorry.

BTW, I tried to find where the “non MAVLINK standard type_mask” is defined and used, but I couldn’t find them :man_shrugging:

Benja, thanks for the reply!

Ok, I’m confused then… The page you linked for the ROS2 stuff is where we had started, but as we looked at the various messages found in the px4_msgs package, we saw that there’s the: uint8 type field defined in the PositionSetpoint.msg but when looking at the page: https://docs.px4.io/main/en/flight_modes/offboard.html#fixed-wing it seemed to indicate that those modes to command ignoring the altitude were only available to the MAVLink messages, not the ROS2 messages (which are talked about higher up on that page). Hence we were confused.

If you’re saying you think that we can still use those modes in the ROS2 messages, then cool!

If I’m using that PositionSetpoint message, then can I not just use the lat/lon fields in that message to specify the goal point, (setting altitude to NAN?), use the mode field to tell it to ignore altitude, and maybe set the gliding_enabled boolean to true? OR do I need to go down to those MavLink messages?

(Sorry, just really confused… Having been all over jumping between the MAV ROS2 documentation, MAVSDK, the MAVSDK Python, and then MAVLINK docs it’s all kind of one big jumble in my head at this point.)

I greatly appreciate the help! And yeah, it’s a cool application… IF I can get it working!

It is always possible (and a little bit easy) to add capabilities to mavsdk. I dont know the exact workflow (as my friend does it) but it probably goes somethink like this:

  • edit proto file to add your endpoint
  • generate files (proto/protos/action/action.proto generates src/mavsdk/plugins/action/action.cpp)
  • add imp details to *_impl.cpp files (src/mavsdk/plugins/action/action_impl.cpp for src/mavsdk/plugins/action/action.cpp)
  • if you are using mavsdk-python, copy paste your proto file there and rebuild it. Also make sure that your mavsdk is running, or the path to cpp shows your mavsdk

I see the confusion now.
First of all, in the offboard documentation, controlling the vehicle using ROS 2 refers to the native ROS 2 - PX4 support, no MAVLINK, no MAVSDK, no MAVROS here.
The docs should probably be more clear in this regard.

Therefore, the section about the ROS 2 messages is just for the above mentioned method, while MAVLINK messages is for mavlink. You cannot mix the two.

Moreover, the effort for documenting and testing ROS 2 offboard control for Fixed wings has been limited and you can see that there is no “ROS 2 messages” for the FW section.