You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When launching a ROS2 node with ros2 launch ... a parameter containing digits and E or e is always interpreted as a double value. Even when the parameter is defined as a string parameter and even when the whole parameter is passed as string.
Operating System:
Ubuntu 22.04
Installation type:
binaries
Version or commit hash:
humble
Client library (if applicable):
rclpy
Steps to reproduce issue
Create a Python package and have a simple node and launchfile
param_test.py
$ ros2 launch param_test test.launch.py param:="123E5"
[INFO] [launch]: All log files can be found below /root/.ros/log/2023-10-20-14-11-17-221115-708631e4d2d9-2422
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [param_test-1]: process started with pid [2423]
[param_test-1] Traceback (most recent call last):
[param_test-1] File "/ros2_ws/install/param_test/lib/param_test/param_test", line 33, in<module>
[param_test-1] sys.exit(load_entry_point('param-test==0.0.0', 'console_scripts', 'param_test')())
[param_test-1] File "/ros2_ws/install/param_test/lib/python3.10/site-packages/param_test/param_test.py", line 25, in main
[param_test-1] node = ParamTest()
[param_test-1] File "/ros2_ws/install/param_test/lib/python3.10/site-packages/param_test/param_test.py", line 13, in __init__
[param_test-1] self._param = self.declare_parameter('param', 'abc').get_parameter_value().string_value
[param_test-1] File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 367, in declare_parameter
[param_test-1] return self.declare_parameters('', [args], ignore_override)[0]
[param_test-1] File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 494, in declare_parameters
[param_test-1] self._set_parameters(
[param_test-1] File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 739, in _set_parameters
[param_test-1] raise InvalidParameterTypeException(
[param_test-1] rclpy.exceptions.InvalidParameterTypeException: Trying to set parameter 'param' to '12300000.0' of type'DOUBLE', expecting type'STRING'
ros2 launch ... cannot be forced to take this parameter as a string:
$ ros2 launch param_test test.launch.py param:="123E5"
... rclpy.exceptions.InvalidParameterTypeException: Trying to set parameter 'param' to '12300000.0' of type'DOUBLE', expecting type'STRING'
$ ros2 launch param_test test.launch.py param:="'123E5'"
... rclpy.exceptions.InvalidParameterTypeException: Trying to set parameter 'param' to '12300000.0' of type'DOUBLE', expecting type'STRING'
$ ros2 launch param_test test.launch.py param:='"123E5"'
... rclpy.exceptions.InvalidParameterTypeException: Trying to set parameter 'param' to '12300000.0' of type'DOUBLE', expecting type'STRING'
And the most interesting one:
$ ros2 launch param_test test.launch.py param:='!!str 123E5'
... rclpy.exceptions.InvalidParameterTypeException: Trying to set parameter 'param' to '12300000.0' of type'DOUBLE', expecting type'STRING'
Even using all kinds of escapes, ASCII codes and what ever did not work!
The text was updated successfully, but these errors were encountered:
Bug report
When launching a ROS2 node with
ros2 launch ...
a parameter containing digits and E or e is always interpreted as a double value. Even when the parameter is defined as a string parameter and even when the whole parameter is passed as string.Steps to reproduce issue
Create a Python package and have a simple node and launchfile
param_test.py
test.launch.py
Expected behavior
$ ros2 launch param_test test.launch.py param:="123E5" [INFO] [1697811050.937763500] [param_test]: String Param: 123E5
Actual behavior
Additional information
Mirght be related to ros2/ros2cli#677?
ros2 run ...
can be forced to interpret the parameter as a string:$ ros2 run param_test param_test --ros-args -p "param:='123E5'" [INFO] [1697811050.937763500] [param_test]: String Param: 123E5
ros2 launch ...
cannot be forced to take this parameter as a string:The text was updated successfully, but these errors were encountered: