PX4-Autopilot icon indicating copy to clipboard operation
PX4-Autopilot copied to clipboard

µxrce-dds: add parameter services to get and set parameters

Open azerupi opened this issue 1 month ago • 1 comments

Solved Problem

At the moment if you want to get and set parameters from a companion computer the only real interface you have is MAVLink. There is no convenient way to change parameters over µXRCE-DDS from ROS 2.

Solution

This PR adds two new services, one to get and one to set parameters over µXRCE-DDS either by name or by index.

To achieve this, 4 new versioned messages where created that are used in two service definitions. The µXRCE-DDS services follow the implementation of the Vehicle Command service closely but differ because they don't need to provide a response async.

One of the inconvenient parts is that we have to use char[16] for the name and can't use string as far as I know. We would need to add a wrapper around this on the ROS 2 side in e.g. px4-ros2-interface-lib.

If you want to test this, I have a simple ROS 2 python package to test getting a parameter: px4_parameter.zip

Alternatives

Instead of using services we could use topics directly with the messages added here. It is unclear to me if that would have a positive performance impact when getting or setting a lot of parameters at once. With the services from my Laptop with a Python test node, connected to a Pixhawk 6X over ethernet I'm seeing about 15ms round-trip on average while a ping is 1.2 - 1.7ms and I've measured the µXRCE-DDS packet round-trip to be between 5 and 11ms in a wireshark capture.

ros2 run px4_parameter px4_parameter_get
Starting benchmark for parameter 'MPC_XY_VEL_MAX' with 500 iterations...
Progress: 500/500

========================================
Benchmark Results (500 samples)
========================================
Average Time:        15.1521 ms
Standard Deviation:  5.4943 ms
Min Time:            5.3019 ms
Max Time:            36.4480 ms
========================================

Open questions

  • I haven't looked at how to implement this for Zenoh. I don't think Zenoh should block this PR but we should probably have a path to get feature parity in follow-up PRs.

@beniaminopozzan we discussed this feature at the PX4 dev summit, not sure if this is exactly what you had in mind. I'm open to feedback on how to improve this.

azerupi avatar Dec 05 '25 19:12 azerupi

Also at some point we probably should look into how we can consolidate the 3 (or more?) different messages to change parameters. The ones I know of are:

  • The ones used by ModalAI
  • The ones for UAVCAN
  • The ones introduced in this PR

azerupi avatar Dec 06 '25 12:12 azerupi