Ask Your Question

Obstacle Position

asked 2015-08-17 00:06:17 -0500

ktiwari9 gravatar image

Hi there, Is it possible to obtain the co-ordinates of an obstacle that we manually add in Gazebo ? I want to write a ros node such that the user adds the obstacle initially and then the node obtains that position of obstacle from Gazebo and modifies its x-cordinate. Is this possible ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-08-17 02:09:08 -0500

You can probably achieve what you want by using the Gazebo services that are available when you start gazebo with ROS support. Once Gazebo is started you can do a

rosservice list

and you should multiple services offered by Gazebo that allow retrieving model properties, spawning models, moving them etc (here are the srv definitions).

Most services offered are also described in the Gazebo "Connect to ROS" tutorial.

edit flag offensive delete link more


So in the Connect to ROS tutorial they mention something like rosservice call /gazebo/set_model_state to spawn a coke can at a specific location and orientation, Is it possible to do this via a ROS node ?

ktiwari9 gravatar image ktiwari9  ( 2015-08-17 02:52:45 -0500 )edit

Yes, you can cal ROS service from the command line (by typing "rosservice call ...", but you can of course also call them from code (see Python or C++ tutorials for "Writing a Simple Service and Clieant" here: ).

Stefan Kohlbrecher gravatar image Stefan Kohlbrecher  ( 2015-08-17 04:26:36 -0500 )edit

Hi Stefan, Please see my comments above. I uploaded my code and I have some trouble adding both pedestrian and robot to the scene. Could you help me out ?

ktiwari9 gravatar image ktiwari9  ( 2015-08-18 00:23:30 -0500 )edit

answered 2015-08-17 04:17:25 -0500

updated 2015-08-17 04:18:21 -0500

yes - spawn_model, from the tutorial is an example of that, a node that takes arguments from the command line . The code for that is here

edit flag offensive delete link more


So this is what I have achieved thus far. My source file is hosted here , my main file is hosted here and my launch file is here.Now the problem is I see the husky doing random walk but I do not see human. Why?

ktiwari9 gravatar image ktiwari9  ( 2015-08-18 00:20:47 -0500 )edit

I got the urdf for a human from here. and I wrote the code to add the human in scene and do random respawns but somehow I do not see the human but only the robo doing random walk. No clue why ???

ktiwari9 gravatar image ktiwari9  ( 2015-08-18 00:21:52 -0500 )edit

ROS_INFO shows me human added to position x,y,z and moved to new position but I also get the error SpawnModel: Failure - model name human_model already exist. and I do not see the human in the scene.

ktiwari9 gravatar image ktiwari9  ( 2015-08-18 00:25:07 -0500 )edit

I would try adding the model using spawn_model as is from the command line to check the file works.

Once that is confirmed i would edit spawn_model to add the model programatically and test that, but not integrate it into the husky node, as it's doing a different job.

nickw gravatar image nickw  ( 2015-08-18 03:55:53 -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


Asked: 2015-08-17 00:06:17 -0500

Seen: 683 times

Last updated: Aug 17 '15