Adding arguments via command line during roslaunch
Hi! I want to add command line arguments while calling my launch file in the bash, just like how I add it while running the node via rosrun. For eg. rosrun pkg_name executable_name /home/user/Documents/my_file.yml /home/user/Pictures/
The closest answer I found to solve my problem was this. My launch file looks like this
<launch>
<arg name="my_args"/>
<node pkg="pkg" type="node.py" name="executable" output="screen" args=$(arg my_args)/>
</launch>
and the command looks like this roslaunch launch_file.launch my_args:="/home/user/Documents/my_file.yml"
However, I get the following error: Invalid roslaunch XML syntax: not well-formed (invalid token): line 3, column 90 The traceback for the exception was written to the log file
. I also wanted to know how can I access these command line arguments in my python script. Is it just sys.argv[0]? I also have another c++ node which needs command line arguments. So, in short, I want to launch these two nodes with the respective command line arguments. I would be really thankful if someone could provide an example launch file to solve the above problem. Thanks!
Well, obviously your launchfile is not correct at line 3, column 90. If you share it, we could help instead of only guess....
@mgruhler it is the same as given in the link.. if you see in the answer given by Leonid.
first or second one? just copy'n'paste? Any adaptations? still many open questions. I'd like to help, but I'm not going to dig around if I'm not sure what you are actually using
--> please just edit your question with an unchanged c'n'p of your launch file. Format it with the button 1010101
@mgruhler Just updated
Thanks, this is just way easier to figure out.
@mgruhler I did
args="$(arg my_args)"
and it worked.. however, I am getting a problem in accessing this argument. Is sys.argv[0] the right way?just saw you actually answered your main question yourself :-)