Gazebo_02_build_a_robot

Gazebo_02_build_a_robot

build a robot

http://gazebosim.org/tutorials?tut=model_structure&cat=build_robot

Model Structure and requirements

ambulance model folder:

image-20200326103839104

models folder contents:

image-20200326104216582

Database (equivalent to the above models folder)

  • database.config : Meta data about the database. This is now populated automatically from CMakeLists.txt

  • model_1 (equivalent to the above ambulance folder)
    A directory for model_1
    • model.config : Meta-data about model_1
    • model.sdf : SDF description of the model
    • model.sdf.erb : Ruby embedded SDF model description
    • meshes : A directory for all COLLADA and STL files
    • materials : A directory which should only contain the textures and scripts subdirectories
      • textures : A directory for image files (jpg, png, etc).
      • scripts : A directory for OGRE material scripts
    • plugins: A directory for plugin source and header files

The database.config file is only required for online repositories. A directory full of models on your local computer does not need a database.config file.

database.config only need to be published to the web, models himself on the local computer does not need this file

Model Config

Each model must have a model.config file in the model's root directory that contains meta information about the model.

The format of this model.config is:

<?xml version="1.0"?>

<model>
  <name>My Model Name</name>
  <version>1.0</version>
  <sdf version='1.5'>model.sdf</sdf>

  <author>
    <name>My name</name>
    <email>[email protected]</email>
  </author>

  <description>
    A description of the model
  </description>
</model>

The name of a SDF or URDF file that describes this model. The version attribute indicates what SDF version the file uses, and is not required for URDFs. Multiple <sdf> elements may be used in order to support multiple SDF versions.

For SDF, <sdf></sdf>, URDF file format version does not require property, sdf SDF file if you want to support multiple versions, multiple sdf tags, such as:

model.sdf

model.sdf

model.sdf

<description>label

  • What the model is (e.g., robot, table, cup)
  • What the plugins do (functionality of the model)

SDF

http://sdformat.org/spec

image-20200324223917103

SDF Models refers to the <model> SDF tag, and is essentially a collection of links, joints, collision objects, visuals, and plugins.

Components of SDF Models

Links: A link contains the physical properties of one body of the model. This can be a wheel, or a link in a joint chain. Each link may contain many collision and visual elements. Try to reduce the number of links in your models in order to improve performance and stability. For example, a table model could consist of 5 links (4 for the legs and 1 for the top) connected via joints. However, this is overly complex, especially since the joints will never move. Instead, create the table with 1 link and 5 collision elements.

Remember: use less link, i.e. the link into a number of other possible link among visual collision and to express these objects and other elements, rather than as a separate link object to express, so that the stability and performance will be better

Collision: A collision element encapsulates(压缩;简述;概括) a geometry that is used for collision checking. This can be a simple shape (which is preferred), or a triangle mesh (which consumes greater resources). A link may contain many collision elements.

Visual: A visual element is used to visualize parts of a link. A link may contain 0 or more visual elements.

Inertial: of The Inertial (inertia; inactive) element describes the dynamic properties of the link, such as mass and rotational inertia matrix ( the moment of inertia matrix).

Sensor: A sensor collects data from the world for use in plugins. A link may contain 0 or more sensors.

Light: A light element describes a light source attached to a link. A link may contain 0 or more lights.

Joints: A joint connects two links. A parent and child relationship is established along with other parameters such as axis of rotation, and joint limits.

Plugins: A plugin is a shared library created by a third party to control a model.

Building a Model

Step 1: Collect your meshes

The acquisition method meshes:

  1. Google's 3D warehouse or other
  2. Use 3D modeler (SUCH AS Blender or Sketchup ) to make your own grids

Gazebo requires that mesh files be formatted as STL, Collada or OBJ, with Collada and OBJ being the preferred formats.

Or preferably formatted into OBJ format Collada

Tip: Use your 3D modeling software to move each mesh so that it is centered on the origin. This will make placement of the model in Gazebo significantly easier.

Tip: Collada and OBJ file formats allow you to attach materials to the meshes. Use this mechanism to improve the visual appearance of your meshes.

Tip: Keep meshes simple. This is especially true if you plan on using the mesh as a collision element. A common practice is to use a low polygon mesh for a collision element, and higher polygon mesh for the visual. An even better practice is to use one of the built-in shapes (box, sphere, cylinder) as the collision element.

Or preferably used Collada OBJ format, while, when collision detection is required, the best choice for built-in graphics or as a simple low collision polygon element.

Make your model SDF file

http://gazebosim.org/tutorials?tut=build_model

gedit box.sdf

<?xml version='1.0'?>
<sdf version="1.4">
  <model name="my_model">
    <pose>0 0 0.5 0 0 0</pose>
    <static>true</static>
    <link name="link">
      <inertial>
        <mass>1.0</mass>
        <inertia> <!-- inertias are tricky to compute -->
          <!-- http://gazebosim.org/tutorials?tut=inertia&cat=build_robot -->
          <ixx>0.083</ixx>       <!-- for a box: ixx = 0.083 * mass * (y*y + z*z) -->
          <ixy>0.0</ixy>         <!-- for a box: ixy = 0 -->
          <ixz>0.0</ixz>         <!-- for a box: ixz = 0 -->
          <iyy>0.083</iyy>       <!-- for a box: iyy = 0.083 * mass * (x*x + z*z) -->
          <iyz>0.0</iyz>         <!-- for a box: iyz = 0 -->
          <izz>0.083</izz>       <!-- for a box: izz = 0.083 * mass * (x*x + y*y) -->
        </inertia>
      </inertial>
      <collision name="collision">
        <geometry>
          <box>
            <size>1 1 1</size>
          </box>
        </geometry>
      </collision>
      <visual name="visual">
        <geometry>
          <box>
            <size>1 1 1</size>
          </box>
        </geometry>
      </visual>
    </link>
  </model>
</sdf>

Note that the origin of the Box-geometry is at the geometric center of the box, so in order to have the bottom of the box flush with the ground plane, an origin of 0 0 0.5 0 0 0 is added to raise the box above the ground plane.

x, y, z, a, b, c, provided that the point of this box the position and orientation of the geometric center


Tip: The above example sets the simple box model to be static, which makes the model immovable. This feature is useful during model creation. Once you are done creating your model, set the static tag to false if you want your model to be movable.

To set said static, easy model creation, created after completion, then changed the dynamic, that is, the static tags to false:

<static>false</static>

When setting model.sdf, following the order of what is better:

  1. Add a link.
  2. Set the collision element.
  3. Set the visual element.
  4. Set the inertial properties.
  5. Go to #1 until all links have been added.
  6. Add all joints (if any).
  7. Add all plugins (if any).

That is: LCVIJP

General first model.sdf, model.config first create, then gradually add the components, this can visually see the settings are correct, the following example of a mobile robot is so gazebo inside.

Make a Mobile Robot

http://gazebosim.org/tutorials?tut=build_robot&cat=build_robot

Model Database documentation

SDF reference


model.config

mkdir -p ~/.gazebo/models/my_robot
gedit ~/.gazebo/models/my_robot/model.config
<?xml version="1.0"?>
<model>
    <name>My Robot</name>
    <version>1.0</version>
    <sdf version='1.4'>model.sdf</sdf>

    <author>
        <name>JacobLi</name>
        <email>[email protected]</email>
    </author>
    <description>
        My awesome robot.
    </description>
</model>

model.sdf

gedit ~/.gazebo/models/my_robot/model.sdf

<?xml version='1.0'?>
<sdf version='1.4'>
    <model name="my_robot">
    </model>
</sdf>

As here, we create a model.config and model.sdf file for easy display Gazebo behind the changes made by us, it has gradually adding back changes to model.sdf to improve the model

Build the Model's Structure

<?xml version='1.0'?>
<sdf version='1.4'>
    <model name="my_robot">
        <static>true</static>
        <link name='chassis'>
            <pose>0 0 0.1 0 0 0</pose>
            
            <collision name='collision'>
                <geometry>
                    <box>
                        <size>.4 .2 .1</size>
                    </box>
                </geometry>
            </collision>

            <visual name='visual'>
                <geometry>
                    <box>
                        <size>.4 .2 .1</size>
                    </box>
                </geometry>
            </visual>
        </link>
    </model>
</sdf>


 <static>true</static>

make our model static, which means it will be ignored by the physics engine. As a result the model will stay in one place and allow us to properly align all the components.

To facilitate alignment of the other components of the static

<link name='chassis'>
  <pose>0 0 0.1 0 0 0</pose>

  <collision name='collision'>
    <geometry>
      <box>
        <size>.4 .2 .1</size>
      </box>
    </geometry>
  </collision>

  <visual name='visual'>
    <geometry>
      <box>
        <size>.4 .2 .1</size>
      </box>
    </geometry>
  </visual>
</link>

Here the first link comprises three elements, namely,pose,collision,visual

poseElement indicates that the position and orientation of the geometric center of the box corresponding to x, y, z, a, b, c (three axes and a rotation angle around the three axes),

Element specifies the shape detecting collisions using collision engine. Visual element specifies the rendering engine used shape

created a box with a size of 0.4 x 0.2 x 0.1 meters,

The collision element specifies the shape used by the collision detection engine.

The visual element specifies the shape used by the rendering engine.

For most use cases the collision and visual elements are the same.

The most common use for different collision and visual elements is to have a simplified collision element paired with a visual element that uses a complex mesh. This will help improve performance.

Provided the size and visual impact of the box for the same, in most cases set the same collision and visual

Collision and is usually provided as a collision situation different visual elements simply provided, and visual element with a complex set of grid (i.e., the collision should be simple, set to optimize visualization)

The following direct access to the gazebo inside, use insert, insert model you create yourself (click My Robot)

image-20200326205028248

The following is added ball casters

Chassis behind the visual elements are added as follows

<collision name='caster_collision'>
   <pose>-0.15 0 -0.05 0 0 0</pose>
   <geometry>
     <sphere>
       <radius>.05</radius>
     </sphere>
   </geometry>

   <surface>
     <friction>
       <ode>
         <mu>0</mu>
         <mu2>0</mu2>
         <slip1>1.0</slip1>
         <slip2>1.0</slip2>
       </ode>
     </friction>
   </surface>
</collision>

<visual name='caster_visual'>
  <pose>-0.15 0 -0.05 0 0 0</pose>
  <geometry>
    <sphere>
      <radius>.05</radius>
    </sphere>
  </geometry>
</visual>

Caster caster is the collision and visual elements

Writing surface elements of the collision element here in See also:

http://gazebosim.org/tutorials?tut=friction

http://sdformat.org/spec?ver=1.5&elem=collision#surface_friction

The ODE (Open Dynamic Engine) is a free, industrial quality library has a rigid body dynamics, a good open source physics engine, developed under its main programmer Russell Smith and several contributors to the open source community to work together. It is a good simulation of real-world environment of the movable object, it is fast, robust and portable. And it has a built-in collision detection system

image-20200326211352691

image-20200326211313929

When two object collide, such as a ball rolling on a plane, a friction term is generated. In ODE this is composed of two parts, '''mu''' and '''mu2''', where:

  1. '''mu''' is the Coulomb friction coefficient for the first friction direction, and
  2. '''mu2''' is the friction coefficient for the second friction direction (perpendicular to the first friction direction).

ODE comprises two consists of two parts: μ and μ2

'' Mu '' is a Coulomb friction coefficient of the rubbing direction,

"Mu2" is the coefficient of friction of the second friction direction (perpendicular to the first rubbing direction).

ODE will automatically compute the first and second friction directions for us.

The two objects in collision each specify '''mu''' and '''mu2'''. Gazebo will choose the smallest '''mu''' and '''mu2''' from the two colliding objects.

When two objects collide, Gazebo automatically selects two colliding objects selected μ minimum and smallest of μ2

The valid range of values for '''mu''' and '''mu2''' is any non-negative number, where 0 equates to a friction-less contact and a large value approximates a surface with infinite friction.

0 is no friction to minimize friction, the greater the friction coefficient, the greater the friction

Specific reference coefficient of friction: Online References

Directly behind re-insert a direct drag directly load a new set of model (the first model can be deleted directly)

image-20200327203403545

Increase revolver

       <link name="left_wheel">
           <pose>0.1 0.13 0.1 0 1.5707 1.5707</pose>
           <collision name="collision">
               <geometry>
                   <cylinder>
                       <radius>.1</radius>
                       <length>.05</length>
                   </cylinder>
               </geometry>
           </collision>
           <visual name="visual">
               <geometry>
                   <cylinder>
                       <radius>.1</radius>
                       <length>.05</length>
                   </cylinder>
               </geometry>
           </visual>
       </link>

Here the revolver out as a separate link, right wheel Similarly, only the pose variations (three lines as above, red is x, y for the green line, the blue line is z, right-handed helix, corresponding to the left and right wheels just opposite to the y coordinate ).

        <link name="right_wheel">
            <pose>0.1 -0.13 0.1 0 1.5707 1.5707</pose>
            <collision name="collision">
                <geometry>
                    <cylinder>
                        <radius>.1</radius>
                        <length>.05</length>
                    </cylinder>
                </geometry>
            </collision>
            <visual name="visual">
                <geometry>
                    <cylinder>
                        <radius>.1</radius>
                        <length>.05</length>
                    </cylinder>
                </geometry>
            </visual>
        </link>

image-20200326230431020

And dynamically added to left and right wheels rotating joint

Modify <statif>false</static>, add the following code (similar to a link element)

        <joint type="revolute" name="left_wheel_hinge">
            <pose>0 0 -0.03 0 0 0</pose>
            <child>left_wheel</child>
            <parent>chassis</parent>
            <axis>
                <xyz>0 1 0</xyz>
            </axis>
        </joint>

        <joint type="revolute" name="right_wheel_hinge">
            <pose>0 0 0.03 0 0 0</pose>
            <child>right_wheel</child>
            <parent>chassis</parent>
            <axis>
                <xyz>0 1 0</xyz>
            </axis>
        </joint>

Two wheels for rotation around the y axis, are connected in the end disc


end


Official website gives the idea that you can try to achieve their

Idea: A quadruped that consists of torso with four cylindrical legs. Each leg is attached to the torso with a revolute joint.

Trunk of a four-legged animal

Idea: A six wheeled vehicle with a scoop front loading mechanism.

Six-wheeled vehicle with front loading shovel mechanism

Guess you like

Origin www.cnblogs.com/BoltLi/p/12584184.html