ros2 access current LaunchConfiguration
I'm in the middle of migrating a ROS1 app of mine to ROS2 and I'm currently trying to convert a .launch
file to a python script.
I want to be able to pass a command line argument to the script and then get its value in the generate_launch_description
call.
This is how I currently pass extra arguments to the LaunchDescription:
run_rqt_arg = DeclareLaunchArgument(name="run_rqt",
default_value="True",
description="Launch RQT?")
run_rviz_arg = DeclareLaunchArgument(name="run_rviz",
default_value="True",
description="Launch RVIZ?")
if run_rqt:
rqt = Node(...)
l.append(rqt)
if run_rviz:
rviz = Node(...)
l.append(rviz)
return LaunchDescription(l, run_rqt, run_rviz)
I'm running the launch script via ros2 launch ...
Is the passing of extra arguments handled correctly? How do I fetch the values of these cli args at runtime?