Does 'ros2 set param' exist? [closed]
If not, is there a way to declare a global parameter for all nodes?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org |
If not, is there a way to declare a global parameter for all nodes?
Parameters are per node in ROS 2. There is no a global parameter server like ROS 1. It is possible to set a param on a node with ros2 param set
$ ros2 run demo_nodes_cpp parameter_blackboard &
...
$ ros2 param set /parameter_blackboard foo bar
Set parameter successful
$ ros2 param list /parameter_blackboard
foo
use_sim_time
If you'd like to set a parameter on all running nodes, you'll need to enumerate them and set the parameter on each one. If you would like to set a parameter on a lot of nodes that you're launching, the parameter should be passed into each launch_ros.actions.Node
.
import launch
import launch_ros
def generate_launch_description():
use_sim_time = launch.substitutions.LaunchConfiguration('use_sim_time', default=False)
return launch.LaunchDescription(
[
launch_ros.actions.Node(
package='demo_nodes_cpp', node_executable='talker',
node_name='talker',
parameters=[{'use_sim_time': use_sim_time}]),
launch_ros.actions.Node(
package='demo_nodes_cpp', node_executable='listener',
node_name='listener',
parameters=[{'use_sim_time': use_sim_time}]),
])
I used a LaunchConfiguration
in this example. You can give it a value on the command line
$ ros2 launch example_launch.py use_sim_time:=True
...
$ ros2 param get /listener use_sim_time
Boolean value is: True
It doesn't seem to be possible at the moment. But it is listed on the feature list for the next ROS 2 distribution: https://github.com/ros2/ros2/issues/734
passing key-value parameters on CLI
Can I use the same node for another rclcpp::SyncParametersclient
?
I have a node named foo_node
running and do
void Foo::init()
{
auto parameters_client = std::make_shared<rclcpp::SyncParametersClient>(this);
this->declare_parameter("foo");
auto sub = parameters_client->on_parameter_event(
[this](const rcl_interfaces::msg::ParameterEvent::SharedPtr event) -> void
{
for (auto & changed_param : event->changed_parameters)
if (changed_param.name == "foo")
{
RCLCPP_INFO(this->get_logger(), "Foo is set");
}
});
}
and when I run ros2 set param /foo_node foo true
in another process, the callback is not triggered but instead it logs [INFO] [Logger]: Hey
.
Any thoughts?
Asked: 2019-06-20 13:17:19 -0500
Seen: 915 times
Last updated: Jun 20 '19
ROS2 Node sleeps forever after setting parameter
ROS2 Dashing overwrite default param via yaml
Equivalent of checking quaternion is valid in tf2
How to make Gui for control center
ros2 crystal create python pkg
ROS2/rviz2 cannot load pixmaps
error in find_package(), when building with custom message.
ros2_control parser error Couldn't parse params file, Error: Error openingYAML file