Robotics StackExchange | Archived questions

Programatically adding object in gazebo

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

Asked by Charlie Brown on 2018-07-18 13:54:23 UTC

Comments

Answers

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")

Asked by wentz on 2018-07-23 07:17:58 UTC

Comments