Gazebo | Ignition | Community
Ask Your Question

Programatically adding object in gazebo

asked 2018-07-18 13:54:23 -0500

Charlie Brown gravatar image


I have a collada file which I want to add at a random location in each run of my robot in the world. What would be the best way to achieve this ?

I have my robot detecting an object and I want to change its location in every iteration.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-07-23 07:17:58 -0500

wentz gravatar image

I created sdf models with my collada files and saved them in the $GAZEBO_MODEL_PATH. In my program i access the sdf files like this:

f = open(self.gazebo_model_path + model_folder_name + '/model.sdf', 'r')
sdff =

Now you can use the gazebo/spawn_sdf_model service:

spawn_model_prox = rospy.ServiceProxy('gazebo/spawn_sdf_model', SpawnModel)
spawn_model_prox(unique_name, sdff, "~/SpawnedObjects", initial_pose, "world")
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-07-18 13:54:23 -0500

Seen: 199 times

Last updated: Jul 23 '18