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 node using a python launch file passing parameters as a dict, there is a problem parsing the string values 'y' and 'n', as they are interpreted as boolean values.
For instance, the following launch file my_launch.py tries to spawn a node from the pcl_ros package that can receive a string parameter filter_field_name:
If the value of the parameter is any other than 'y' or 'n', the node starts correctly. However, if any of those values is passed, the following error arises: [INFO] [filter_passthrough_node-1]: process started with pid [25858] [filter_passthrough_node-1] terminate called after throwing an instance of 'rclcpp::exceptions::InvalidParameterTypeException' [filter_passthrough_node-1] what(): parameter 'filter_field_name' has invalid type: Wrong parameter type, parameter {filter_field_name} is of type {string}, setting it to {bool} is not allowed. [ERROR] [filter_passthrough_node-1]: process has died [pid 25858, exit code -6, cmd '/home/beltransen/ros2_ws/install/pcl_ros/lib/pcl_ros/filter_passthrough_node --ros-args -r __node:=passthrough_y --params-file /tmp/launch_params_lirux2gp'].
The content of the temporary .yaml file (/tmp/launch_params_lirux2gp) generated from the dictionary of parameters and passed to the node is:
/**:
ros__parameters:
filter_field_name: y
The problem here is that, during the conversion, the 'y' and 'n' strings are inserted into the .yaml file without single quotes, unlike any other string value, which preserves the quotes and, therefore, can be correctly parsed.
If I manually create a .yaml file keeping the single quotes:
/**:
ros__parameters:
filter_field_name: 'y'
And adapt the launch file to read the parameters from the .yaml file instead of passing them as a dictionary:
from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
Node(
package='pcl_ros',
executable='filter_passthrough_node',
name='passthrough_y',
output='screen',
parameters=["/path/to/config.yaml"]
)
])
The node starts correctly.
Expected behavior
The temporary .yaml file created from parameters passed as a dictionary should preserve the quotes of all string parameters.
Actual behavior
The temporary .yaml file created from parameters passed as a dictionary removes the quotes of string parameters when taking 'y' or 'n' values. Afterwards, when the .yaml file is read, those values are interpreted as booleans.
The text was updated successfully, but these errors were encountered:
Bug report
Required Info:
Steps to reproduce issue
When launching a node using a python launch file passing parameters as a dict, there is a problem parsing the string values 'y' and 'n', as they are interpreted as boolean values.
For instance, the following launch file my_launch.py tries to spawn a node from the pcl_ros package that can receive a string parameter filter_field_name:
If the value of the parameter is any other than 'y' or 'n', the node starts correctly. However, if any of those values is passed, the following error arises:
[INFO] [filter_passthrough_node-1]: process started with pid [25858] [filter_passthrough_node-1] terminate called after throwing an instance of 'rclcpp::exceptions::InvalidParameterTypeException' [filter_passthrough_node-1] what(): parameter 'filter_field_name' has invalid type: Wrong parameter type, parameter {filter_field_name} is of type {string}, setting it to {bool} is not allowed. [ERROR] [filter_passthrough_node-1]: process has died [pid 25858, exit code -6, cmd '/home/beltransen/ros2_ws/install/pcl_ros/lib/pcl_ros/filter_passthrough_node --ros-args -r __node:=passthrough_y --params-file /tmp/launch_params_lirux2gp'].
The content of the temporary .yaml file (/tmp/launch_params_lirux2gp) generated from the dictionary of parameters and passed to the node is:
The problem here is that, during the conversion, the 'y' and 'n' strings are inserted into the .yaml file without single quotes, unlike any other string value, which preserves the quotes and, therefore, can be correctly parsed.
If I manually create a .yaml file keeping the single quotes:
And adapt the launch file to read the parameters from the .yaml file instead of passing them as a dictionary:
The node starts correctly.
Expected behavior
The temporary .yaml file created from parameters passed as a dictionary should preserve the quotes of all string parameters.
Actual behavior
The temporary .yaml file created from parameters passed as a dictionary removes the quotes of string parameters when taking 'y' or 'n' values. Afterwards, when the .yaml file is read, those values are interpreted as booleans.
The text was updated successfully, but these errors were encountered: