Ask Your Question
0

what is equivalent python code for <arg= value=> in launch file?

asked 2020-06-04 04:43:34 -0500

burhan gravatar image

updated 2020-06-04 15:25:46 -0500

jayess gravatar image

Hello,

is there any equivalent python code for <arg = value=> that is used in launch files? Is there a way to know how roslaunch works internally? I tried with sys.argv.append() but this doesn´t work when you load a yaml.file that also need this arguments. Thanks in Advance for help.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2020-06-04 15:31:51 -0500

jayess gravatar image

If I understand you correctly, you're trying set/get a parameter to/from the parameter server using rospy (if this isn't correct then please update your question with more details about what you're doing, what you expect, and what your results are). Luckily, rospy has this built-in so it's straightforward.

To set a parameter use

rospy.set_param(param_name, param_value)

and to get a parameter use

param_value = rospy.get_param(param_name)

You can get more information from the tutorials on the wiki.

edit flag offensive delete link more

Comments

I want to do the same thing that a launch file does in a python script. <arg name="package" value="$(find rospackage)"/> <rosparam command="load" file="$(find rospackage)/example.yaml" subst_value="true"/> <nodename="something" pkg="package" type="package"> And in yaml file this arg will also be used like this packagedetails: packageinput: $(arg package)/config How can i implement this in a python script. If i try this with sys.argv.append() the yaml file will not find the arg but if i launch the launch file it will find the arg that is the problem.

burhan gravatar image burhan  ( 2020-06-05 06:21:58 -0500 )edit

Hi @burhan,

I think the code you are searching is this a xml loader from ros_comm. The roslaunch implementation source code can be found here. However in my humble opinion it would be much better to use the ROS param server as @jayess mentioned rather than trying to reinvent the wheel.

Weasfas gravatar image Weasfas  ( 2020-06-09 03:55:41 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-06-04 04:43:34 -0500

Seen: 82 times

Last updated: Jun 04 '20