--ros-args argument is always present in launched Node
I am trying to launch a node that requires common command line arguments.
In my launch file, I added a Node() instance in my LaunchDescription which contains the package
, executable
and arguments
attributes. However the launched program complains about not knowing about argument --ros-args
.
I thought it was the ros_arguments
attribute in the Node that added the --ros-args
argument to the launch command so I don't understand why I am getting this error.
I am running Ubuntu 22.04 and ROS2 Humble.
How can we launch a program from a launch file without the launch file adding the --ros-args
argument to the launch command ?
Can you share your launch file and the code that reads command line arguments?
Also, can you clarify what exactly is complaining about the
--ros-args
? Is it your own code, or is ROS 2 itself complaining about it?In short,
--ros-args
is always added to the commandline arguments, but at the end after anyarguments
: https://github.com/ros2/launch_ros/bl.... If you write code to read these commandline arguments, you might need to filter it out.Oh ok, I thought it was more of an either/or logic. Thanks for your help ! Would you like to post an answer so I can accept it ?
sure, done!
Note that I edited my answer to mention
rclcpp::init_and_remove_ros_arguments()
. It just popped into my head.