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}")