how to specify launch argument type in ros2 launch command?
I have a ROS2 node which takes a 'username' string argument. I can normally run the node like this:
ros2 launch my_pkg launch.py username:=XXX
In my case, my username is composed of digits only, like so:
ros2 launch my_pkg launch.py username:=12345
The issue then is that ros2 launch fails because:
rclpy.exceptions.InvalidParameterTypeException: Trying to set parameter 'username' to '12345' of type 'INTEGER', expecting type 'STRING'
surrounding 12345 with quotes like "12345" or '12345' does not help. How can I tell ROS my argument is a String and not an integer?
This can be reproduced with this node: https://github.com/LORD-MicroStrain/n...
$ ros2 launch ntrip_client ntrip_client_launch.py username:=12345
[INFO] [launch]: All log files can be found below /home/vrichard/.ros/log/2022-09-11-13-05-38-795894-vr-desktop-702025
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [ntrip_ros.py-1]: process started with pid [702095]
[ntrip_ros.py-1] Traceback (most recent call last):
[ntrip_ros.py-1] File "/home/vrichard/test/install/ntrip_client/lib/ntrip_client/ntrip_ros.py", line 153, in <module>
[ntrip_ros.py-1] node = NTRIPRos()
[ntrip_ros.py-1] File "/home/vrichard/test/install/ntrip_client/lib/ntrip_client/ntrip_ros.py", line 26, in __init__
[ntrip_ros.py-1] self.declare_parameters(
[ntrip_ros.py-1] File "/opt/ros/galactic/lib/python3.8/site-packages/rclpy/node.py", line 491, in declare_parameters
[ntrip_ros.py-1] self._set_parameters(
[ntrip_ros.py-1] File "/opt/ros/galactic/lib/python3.8/site-packages/rclpy/node.py", line 736, in _set_parameters
[ntrip_ros.py-1] raise InvalidParameterTypeException(
[ntrip_ros.py-1] rclpy.exceptions.InvalidParameterTypeException: Trying to set parameter 'username' to '12345' of type 'INTEGER', expecting type 'STRING'
[ERROR] [ntrip_ros.py-1]: process has died [pid 702095, exit code 1, cmd '/home/vrichard/test/install/ntrip_client/lib/ntrip_client/ntrip_ros.py --ros-args -r __node:=ntrip_client_node -r __ns:=/ntrip_client --params-file /tmp/launch_params_cmiltczq'].
I don't think the launch file is doing any weird thing. The 'username' parameter is just declared with a default string value: https://github.com/LORD-MicroStrain/n...