Ask Your Question
0

Random number in launch file

asked 2015-08-21 05:06:44 -0500

niall gravatar image

Hi all,

I'm using ROS Indigo with Gazebo to simulate a robot and I would like to spawn my robot at random positions in the world. I use launch files to start the whole simulation. In these launch files the spawning position is initially defined. Therefore I thought it would be best to create a random position in the launch file but since this is all xml, I doubt this is possible. Does anyone have any idea how I can somehow change the spawning position each run? Somehow run an external C++ program that passes a random number to the launch file?

Cheers

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2015-08-21 13:55:44 -0500

NEngelhard gravatar image

updated 2015-08-21 13:56:43 -0500

You could use a script to generate random ros parameters. Just include something like

< param name="robot_position" command="$(find some_package)/scripts/generate_random_position.py"/>

and the generate_random_position.py just returns a random position.

edit flag offensive delete link more

Comments

Great Idea! That way I don't have to alter my normal launch procedure, just put this script before the spawn robot. Thanks FooBar!

niall gravatar imageniall ( 2015-08-24 10:33:43 -0500 )edit
1

answered 2015-08-21 06:25:41 -0500

One straightforward option is to start the launch file once, but use the gazebo_ros_pkgs service API to just move the model around as described in the "Set Model State Example" here. You could write a small Python node that calls this service with some random pose whenever you require it.

edit flag offensive delete link more

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: 2015-08-21 05:06:44 -0500

Seen: 759 times

Last updated: Aug 21 '15