简体   繁体   中英

Dynamically setting a ROS2 parameter using launch file?

There are a bunch of resources that describes setting a parameter on node startup using a launch file.( How to launch a node with a parameter in ROS2? )

However this will not trigger the dynamic reconfigure callback: set_on_parameters_set_callback . Is there any way to specify an action in the launch file on a node that triggers this callback ?

Equivalent of running a ros2 param set ... command (which would trigger the callback)

You need to call the ROS 2 service /<node name>/set_parameters to trigger this callback. Eg /talker/set_parameters for the talker node in the demo_nodes_cpp package.

Create a shell script containing:

#!/bin/sh
ros2 service call /<node name>/set_parameters <service type> <your parameters>

...and add it to your launch file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM