ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

ros2 launch arg bug with string?

asked 2020-08-07 17:18:20 -0500

Aravind gravatar image

updated 2020-08-07 18:42:14 -0500

In the example launch file below:

<launch>
  <arg name = "foo" default = "a:"/>
  <node pkg = "demo_nodes_py" exec = "listener" output = "screen">
    <param name = "foo"  type = "str" value = "$(var foo)" />
  </node>
</launch>

I get the following error which I don't get if there is not the trailing ":". The error message should also be more informative, maybe provide the arg name and value.

aravind@carrot:ros2_examples$ ros2 launch test.launch.xml
[INFO] [launch]: All log files can be found below /home/aravind/.ros/log/2020-08-07-15-11-27-621475-carrot-25030
[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [launch]: Caught exception in launch (see debug for traceback): Allowed value types are bytes, bool, int, float, str, Sequence[bool], Sequence[int], Sequence[float], Sequence[str]. Got <class 'dict'>.

When I replace it with an integer, I get the following error when I have a C++ node that tries to access the "foo" parameter as a string.

[talker-1] terminate called after throwing an instance of 'rclcpp::ParameterTypeException'
[talker-1]   what():  expected [string] got [integer]

There seems to be implicit conversion here. How can I pass arbitrary strings without conversion?

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-10-31 19:25:05 -0500

lukicdarkoo gravatar image

Adding \0 at the end of the string worked as a workaround for me. For example:

    realsense_node = Node(
        package='realsense2_camera',
        executable='realsense2_camera_node',
        parameters=[
        {
            'serial_no': '123456789\0',
        }],
    )
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-08-07 17:18:20 -0500

Seen: 595 times

Last updated: Oct 31 '22