#################################### ##FILL ME IN #################################### ## links to any required tutorials ## note.0= [[simulator_gazebo/Tutorials/StartingGazebo|Installing and Starting Gazebo]] ## descriptive title for the tutorial ## title = Creating and Spawning Custom URDF Objects in Simulation ## multi-line description to be displayed in search ## description = Creating and Spawning Custom URDF objects in simulation ## the next tutorial description (optional) ## next = ## links to next tutorial (optional) ## next.0.link= [[simulator_gazebo/Tutorials/Gazebo_ROS_API|Manipulating objects in the simulation world using ROS API]] ## next.1.link= ## what level user is this tutorial for ## level= BeginnerCategory ## choose the correct category (this tag will be searched over it must be here) ## domain_answers=answers.gazebosim.org ##################################### <> <> {{{#!wiki red/solid Users are highly discouraged from using the documentation and tutorials for Gazebo on this page. Gazebo is now a stand alone project at [[http://gazebosim.org/tutorials|gazebosim.org]]. See documentation there, thanks! }}} == Spawning Custom Objects in Simulation == '''Description:''' Here we demonstrate how to create a simple box [[urdf]] model using the ''box'' [[urdf/XML/Link|geometric primitive]] and spawn it in a simulated empty world. === Start Simulation of an Empty World === Start an empty world simulation . {{{ roslaunch gazebo_worlds empty_world.launch }}} === Create a Simple Box URDF === Create an URDF for an object and save it as '''object.urdf''': {{{#!xml Gazebo/Blue }}} Here the origins of the inertial center, visual and collision geometry centers are offset in +x by 2m relative to the model origin. The box geometry primitive is used here for visual and collision geometry, and has sizes 1m wide, 1m deep and 2m tall. Note that visual and collision geometries do not always have to be the same, sometimes you want to use a simpler collision geometry to save collision detection time when running a dynamic simulation. The box inertia is defined as 1kg mass and principal moments of inertia i,,xx,,=i,,zz,,=1 kg*m^2^ and i,,yy,,=100 kg*m^2^. === Spawn Model in Simulation === To spawn above URDF object at height '''z''' = 1 meter and assign the name of the model in simulation to be '''my_object''': {{{ rosrun gazebo_ros spawn_model -file `pwd`/object.urdf -urdf -z 1 -model my_object }}} {{attachment:Gazebo_tutorial_1.png|alt Gazebo Screenshot|width="90%"}} <
> Here [[gazebo|spawn_model from gazebo package]] is a convenience command-line tool for accessing gazebo spawning service '''gazebo/spawn_model'''. == Spawn Additional Example Objects in Simulation == Several sample objects are provided in [[https://bitbucket.org/osrf/simulator_gazebo/src/595f9360af4fa9e9fb4262623314ce947495c4db/gazebo_worlds/objects/?at=default|gazebo_worlds/objects]]. For example, you can spawn a desk by typing {{{ roslaunch gazebo_worlds table.launch }}} This should create a table in the simulator GUI (you might have to zoom out and mouse around to find it), then terminate. {{attachment:Gazebo_tutorial_2.png|alt Gazebo Screenshot|width="90%"}} Taking a brief look at [[https://code.ros.org/svn/ros-pkg/stacks/simulator_gazebo/trunk/gazebo_worlds/launch/table.launch|table.launch]]: {{{#!xml block=action }}} The launch file loads `table.urdf.xacro` [[urdf]] XML file onto the ROS parameter server (after first passing it through the [[xacro]] preprocessor). <> Then calls [[gazebo|spawn_model]] node to spawn the model in simulation. <> The spawn_table node gets the XML string from the parameter server and passes it on to Gazebo to spawn the object in the simulated world. . Similarly, to spawn a coffee cup on the table: {{{ roslaunch gazebo_worlds coffee_cup.launch }}} . /!\ Disclaimer: Spawning the coffee cup currently does not work on ROS version more recent than electric. {{attachment:simulator_gazebo/Tutorials/table_and_cups_cturtle.jpg}} ##BeginnerCategory '''Next Tutorial:''' [[simulator_gazebo/Tutorials/Gazebo_ROS_API|Manipulating objects in the simulation world]] ---- ## TutorialCategory ## FILL IN THE STACK TUTORIAL CATEGORY HERE