[ROS2] Unexpected parameter parsing on Dashing/Eloquent
I made a simple launch file which starts a single turtlesim node. It sets the path to config file, and sets the background parameters to some values (basically to have a blue background):
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch.conditions import IfCondition
from ament_index_python.packages import get_package_share_directory
configurable_parameters = [{'name': 'namespace', 'default': "'turtlesim'", 'description': ''},
{'name': 'background_b', 'default': '255', 'description': ''},
{'name': 'background_g', 'default': '0', 'description': ''},
{'name': 'background_r', 'default': '0', 'description': ''},
{'name': 'config_file', 'default': "'/home/marin/launch/config.yaml'", 'description': ''}
]
def declare_configurable_parameters(parameters):
return [DeclareLaunchArgument(param['name'], default_value=param['default'], description=param['description']) for param in parameters]
def set_configurable_parameters(parameters):
return dict([(param['name'], LaunchConfiguration(param['name'])) for param in parameters])
def generate_launch_description():
return LaunchDescription(declare_configurable_parameters(configurable_parameters) +[
Node(
package='turtlesim',
node_namespace=LaunchConfiguration("namespace"),
node_executable='turtlesim_node',
node_name='sim',
parameters=[set_configurable_parameters(configurable_parameters)
,PythonExpression([LaunchConfiguration('config_file')])
]
)
])
After that, I made another launch file which would start the previous one 2 times, changing the name of the node for each:
import copy
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.substitutions import LaunchConfiguration, ThisLaunchFileDir
from launch.launch_description_sources import PythonLaunchDescriptionSource
import sys
import pathlib
sys.path.append(str(pathlib.Path(__file__).parent.absolute()))
import my_turtlesim_launch
local_parameters = [{'name': 'namespace1', 'default': 'turtlesim1', 'description': 'camera unique name'},
{'name': 'namespace2', 'default': 'turtlesim2', 'description': 'camera unique name'},
]
def set_configurable_parameters(local_params):
return dict([(param['original_name'], LaunchConfiguration(param['name'])) for param in local_params])
def duplicate_params(general_params, posix):
local_params = copy.deepcopy(general_params)
for param in local_params:
param['original_name'] = param['name']
param['name'] += posix
return local_params
def generate_launch_description():
params1 = duplicate_params(my_turtlesim_launch.configurable_parameters, '1')
params2 = duplicate_params(my_turtlesim_launch.configurable_parameters, '2')
return LaunchDescription(
my_turtlesim_launch.declare_configurable_parameters(local_parameters) +
my_turtlesim_launch.declare_configurable_parameters(params1) +
my_turtlesim_launch.declare_configurable_parameters(params2) +
[
IncludeLaunchDescription(
PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/my_turtlesim_launch.py']),
launch_arguments=set_configurable_parameters(params1).items(),
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/my_turtlesim_launch.py']),
launch_arguments=set_configurable_parameters(params2).items(),
),
])
In the config file I have (basically setting the background to green):
turtlesim1:
sim:
ros__parameters:
background_b: 0
background_g: 255
background_r: 0
turtlesim2:
sim:
ros__parameters:
background_b: 0
background_g: 255
background_r: 0
Starting the two nodes, I would expect them to first read the data in configurable_parameters, which would turn the background to blue, but then read config file, which would set the background to green, which I would then see. What happened was that the first node did exactly that, first read from the configurable_parameters and then from config file, and I saw green background for it, but the second one did the opposite, first read from the config file, then read from the configurable_parameters, and I saw blue background:
Nothing weird in terminal either:
[INFO] [launch]: All log files can be found below /home/marin/.ros/log/2021-08-12-07-06-37-393837-marin-Precision-3640-Tower-5754
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [turtlesim_node-1]: process started with pid [5765]
[INFO] [turtlesim_node-2]: process started with pid [5766]
I tested this with few different configurations, and I'm sure that the first camera reads from configurable_parameters and then from the config file, while the second camera does the opposite. So, in both cases it ...
I'm sorry to have to do this for something so seemingly unimportant, but please don't post screenshots of terminal text in question on ROS Answers. It's all text, so there is no need. Just copy-paste the text from the terminal into your question text. Do make sure to format it properly by selecting the text and pressing
ctrl+k
(or clicking the Preformatted Text button (the one with101010
on it)).You don't need to post a new question, just edit your curent one. You can use the
edit
button/link for this.After you replace the screenshot with the error message itself, we can re-open your question.
It's edited, please re-open the question. Thank you.
There are still screenshots showing configuration and
.launch
files. That's also all text.Sorry, I didn't understand you meant all of it. It should be all good now.