Use a launchfile substitution as parameter for a node
OS : Ubunutu 22.04, x86, kernel : 5.19.0-50-generic
ROS2 : Humble
I am currently trying to implement a modular launchfile to cover multiple scenarii with some changes of argument. I have one of my node having two parameters, andI would like them to take the value (as a boolean) of my launch argument. Here's how I was able to make it work :
pose_parameters_in = [{"log_slam" : True},
{"log_ekf" : False}]
pose_parameters_out = [{"log_slam" : False},
{"log_ekf" : True}]
pose_logging_in = Node(
condition = IfCondition(PythonExpression([pos_log,' and ',indoor])),
package="pose_logger",
executable="pose_logger_exec",
name="pose_logger",
parameters=pose_parameters_in
)
pose_logging_out = Node(
condition = IfCondition(PythonExpression([pos_log,' and not',indoor])),
package="pose_logger",
executable="pose_logger_exec",
name="pose_logger",
parameters=pose_parameters_out
)
with at the start :
indoor = LaunchConfiguration('indoor')
pos_log = LaunchConfiguration('pos_log')
indoor_launch_arg = DeclareLaunchArgument(
'indoor',
default_value='False',
description="Boolean : describe if it is an indoor or outdoor scenario"
)
pos_log_launch_arg = DeclareLaunchArgument(
'pos_log',
default_value='False'
)
So I need to create the two case manually, when I would have liked to be able to do something that look like that :
pose_parameters = [{"log_slam" : indoor},
{"log_ekf" : not indoor])}]
pose_logging = Node(
condition = IfCondition(pos_log),
package="pose_logger",
executable="pose_logger_exec",
name="pose_logger",
parameters=pose_parameters
)
To sum it up, I would have liked to get the Boolean value of my indoor
argument to pass in the parameters of my node. Is this possible ?
Thanks to anyone that will take the time to help me.
Asked by Timothée on 2023-07-27 10:46:53 UTC
Comments