How to access PX4 parameters in offboard mode

Hi, I am flying using the PX4-Autopilot software in offboard mode. In some cases, I need to adjust the PX4 parameters, but I have to connect to the PX4 with a cable to do so. This is quite cumbersome because the PX4 is in a hard-to-reach location. The Companion Computer (Jetson Xavier) I am using is connected to the network. My question is: Can we access PX4 data directly through Jetson? If so, how should we do this? (I am using ROS2 on the Jetson to control PX4.)

Actually the best option is to purchase a telemetry radios pair, with wich you can connect with px4 board via QGroundControl wireless. Take a look at Telemetry Radios/Modems | PX4 Guide (main) for details. Holybro actually sells its own kit, but if your are interested in a more compact solution, at the link i shared are described lots of compact alternative that you may actually integrate in your drone hardware setup.

Otherwise you can try to connect the debug port of the board to the jetson using a usb-c cable. Then by launching QGC from the jetson, you can modify the parameters in the shell. This can actually be difficult since in this way you can not see the QGC API and modify the parameters easily.

Another solution that comes to my mind is actually to create a parameters file, in which you can modify the parameters you want, and then load it in the px4 board using QGC.

Be aware that the parameters should not be changed during flight, even if you actually can by means of such connection-less methods, because this may lead to very unstable and unexpected behaviours.

There is a ParameterSetValueRequest message among the offboard messages. Can’t the parameters be set with this message?

Over mavros I was able to change params realtime, being able to do that was really useful.
It seems over ros2 you cannot do it for now (check the discussion below), unless there is a new update:

you can use following script and change the params over mavlink, I have tested it is working just change the param name, and also be careful about your device directory

from pymavlink import mavutil

connection = mavutil.mavlink_connection(‘/dev/ttyACM0’, baud=115200)

connection.wait_heartbeat()
print(“Connected to system %u component %u” % (connection.target_system, connection.target_component))

param_name = “MPC_XY_VEL_MAX”

connection.mav.param_request_read_send(
connection.target_system,
connection.target_component,
param_name.encode(‘utf-8’),
-1
)

message = connection.recv_match(type=‘PARAM_VALUE’, blocking=True)
print(f"Current value of {param_name}: {message.param_value}")

new_value = 5.0
connection.mav.param_set_send(
connection.target_system,
connection.target_component,
param_name.encode(‘utf-8’),
new_value,
mavutil.mavlink.MAV_PARAM_TYPE_REAL32
)

message = connection.recv_match(type=‘PARAM_VALUE’, blocking=True)
print(f"Updated value of {param_name}: {message.param_value}")

1 Like

As already suggestd by @Halil and as far as I know, you cannot set parameters via ROS2 topics, at least for now. I’ve never used MAVLINK directly, but if the method described is what you were looking for, give it a try.

Personally i prefere to have the QGC API when parameters need to be changed, since there you can find parameters description and possible values. But clearly if you need to sistematically modify a certain parameter whose possible values ​​you know, the suggested method could be the best solution.

As stated here, generally you shouldn’t be changing parameters via your companion computer - they should be considered internal and only changed if you really know what you are doing. You can change some of them “on the fly”, but testing is needed.

So my first question would be what are you trying to achieve?

If I had to do this I would use MAVSDK on a separate channel from my companion.

If you need to do something in ROS 2 and you’re not sure how, you can look at what uorb topic MAVLink writes/reads to in PX4 source, and in ROS 2 you can directly read/write those topics. Upshot, if you have done your research and this is really needed, you’re probably looking at ParameterSetValueRequest as suggested by @serkan above

1 Like

I have never used MAVROS. I am more familiar with the ROS2 part. My goal is to change parameters in some cases. Since PX4 is in a hard to reach place in the vehicle, I wanted to set the parameters directly from Jetson.