Gazebo | Ignition | Community
Ask Your Question
0

Programatically adding object in gazebo

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

Charlie Brown gravatar image

Hi,

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.

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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 = f.read()
f.close()

Now you can use the gazebo/spawn_sdf_model service:

rospy.wait_for_service('gazebo/spawn_sdf_model')
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

Question Tools

1 follower

Stats

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

Seen: 313 times

Last updated: Jul 23 '18