Commit ef0f83d1 authored by CANNERE Xavier's avatar CANNERE Xavier
Browse files

1.7

parent c066990e
......@@ -10,7 +10,6 @@ Welcome to my ROS2 Tutorial!
:maxdepth: 2
./topic1/t1.rst
./model1.rst
./model2.rst
./model3.rst
.. Modelisation documentation master file, created by
sphinx-quickstart on Tue Apr 12 15:48:41 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Modelization on Gazebo
======================
In this part we will see how we can create a model with Gazebo.
Step 1 : Create and setup your workspace
----------------------------------------
You can download package from isae with typing the following line in a terminal::
Step 1 : Create and setup your workspace
----------------------------------------
Type these lines on a terminal to create your workspace::
mkdir -p ~/Bureau/ws/models/my_robot
gedit ~/.gazebo/gui.ini
And replace what is written there by these lines::
[geometry]
x=0
y=0
[model_paths]
filenames=/home/etdisc/Bureau/ws/models
Step 2 : Create the .sdf file
------------------------------------
SDF files are used to configure your robots.
Create the .sdf file::
cd ~/Bureau/ws/models/my_robot
gedit model.sdf
Then you can paste the following lines in your code::
<?xml version='1.0'?>
<sdf version='1.6'>
<model name="my_robot">
<static>false</static>
<pose>0 0 0.5 0 0 0</pose>
<link name='chassis'>
</link>
</model>
</sdf>
.. csv-table:: Tag memory
:header: "tag", "usage"
:widths: 10, 40
"<?xml>", "declare this is xml language"
"<sdf>", "declare the version of sdf"
"<model>", "declare the name of the model"
"<static>", "declare if the model is immovable (true) or not (false)"
"<link>", "declare a physical link with inertia, collision and viusal properties"
"<pose>", "declare the position (x,y,z) and the rotation(x,y,z) where the model spawn"
Now copy these lines inside the link tag::
<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>
.. csv-table:: Tag memory
:header: "tag", "usage"
:widths: 10, 40
"<collision>", "You will define the collision area into this tag"
"<visual>", "You will define the graphical area into this tag"
"<geometry>", "You will define a shape into this tag"
"<box>", "Declare a box shape"
Your code should look like this::
<?xml version='1.0'?>
<sdf version='1.6'>
<model name="my_robot">
<static>false</static>
<pose> 0 0 0.5 0 0 0</pose>
<link name='chassis'>
<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>
Step 3 : Create the .config file
--------------------------------
The .config file is an other file who'll complete the .sdf file
In a terminal type::
cd ~/Bureau/ws/models/my_robot
gedit model.config
In the config file you'll find the parameters of the models
Paste this lines into your model.config::
<?xml version="1.0"?>
<model>
<name>My_Robot</name>
<version>1.0</version>
<sdf version='1.6'>model.sdf</sdf>
<author>
<name>Your name</name>
<email>youremail@isae-supaero.fr</email>
</author>
<description>
My awesome robot.
</description>
</model>
.. warning::
In the sdf tag there must be the name of .sdf file and the right version of sdf
Step 4 : Test if it works!
--------------------------
In a new terminal type::
gazebo
In gazebo click on **Insert** in the left menu, then click on **Add Path**
Select the folder of your model and import your model on gazebo.
.. figure:: 1.png
:width: 400
:align: center
:alt: image non disponible
*You should see that on gazebo*
Step 5 : Add wheels
-------------------
Open your .sdf file::
gedit model.sdf
Paste this code after ``</link>``::
<link name="left_wheel">
<pose>0.45 0.40 -0.5 1.57 0 0</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</visual>
</link>
That add a left wheel, now we'll add the three other wheel::
<link name="left_back_wheel">
<pose>-0.45 0.40 -0.5 1.57 0 0</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</visual>
</link>
<link name="right_wheel">
<pose>0.45 -0.40 -0.5 1.57 0 0</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</visual>
</link>
<link name="right_back_wheel">
<pose>-0.45 -0.40 -0.5 1.57 0 0</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</visual>
</link>
.. csv-table:: Tag memory
:header: "tag", "usage"
:widths: 10, 40
"<cylinder>", "It's like *box* tag but with a cylinder"
"<radius>", "Define the radius of the cylinder"
"<length>", "Define the length of the cylinder"
Now open gazebo and import your model.
.. figure:: 2.png
:width: 400
:align: center
:alt: image non disponible
*You should see that, something is still missing...*
Step 6 : The joints
-------------------
Joints are used to join two shapes.
Paste this code after your last *link* tag::
<joint type="revolute" name="left_wheel_hinge">
<pose>0 0 0 0 0 0</pose>
<child>left_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint type="revolute" name="left_wheel_hinge2">
<pose>0 0 0 0 0 0</pose>
<child>left_back_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint type="revolute" name="right_wheel_hinge">
<pose>0 0 0 0 0 0</pose>
<child>right_back_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint type="revolute" name="right_wheel_hinge2">
<pose>0 0 0 0 0 0</pose>
<child>right_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
.. csv-table:: Tag memory
:header: "tag", "usage"
:widths: 10, 40
"<joint>", "Declare a joint"
"<child>", "Define the child of the joint"
"<parent>", "Define the parent of the joint"
"<axis>", "You will define into this tag the axis rotation"
"<xyz>", "You will define which axis will rotate"
.. note::
Revolute type of joint is a joint with a single rotation, in this case the rotation will allow the wheel to roll
.. note::
The child will rotate around the parent
Step 7 : Test your model!
-------------------------
First make sure you have the same code::
<?xml version='1.0'?>
<sdf version='1.6'>
<model name="my_robot">
<static>false</static>
<pose> 0 0 0.5 0 0 0</pose>
<link name="chassis">
<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>
<link name="left_wheel">
<pose>0.45 0.40 -0.5 1.57 0 0</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</visual>
</link>
<link name="left_back_wheel">
<pose>-0.45 0.40 -0.5 1.57 0 0</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</visual>
</link>
<link name="right_wheel">
<pose>0.45 -0.40 -0.5 1.57 0 0</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</visual>
</link>
<link name="right_back_wheel">
<pose>-0.45 -0.40 -0.5 1.57 0 0</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.2</radius>
<length>.1</length>
</cylinder>
</geometry>
</visual>
</link>
<joint type="revolute" name="left_wheel_hinge">
<pose>0 0 0 0 0 0</pose>
<child>left_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint type="revolute" name="left_wheel_hinge2">
<pose>0 0 0 0 0 0</pose>
<child>left_back_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint type="revolute" name="right_wheel_hinge">
<pose>0 0 0 0 0 0</pose>
<child>right_back_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint type="revolute" name="right_wheel_hinge2">
<pose>0 0 0 0 0 0</pose>
<child>right_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
</model>
</sdf>
.. figure:: 3.png
:width: 150
:height: 400
:align: center
:alt: image non disponible
*Swipe to the left*
Select your model and change parameters of the velocity and test it!
-----------------------------------
If you want go further you can read the documentation http://sdformat.org/spec?ver=1.9&elem=joint#model_joint
or follow tutorials http://gazebosim.org/tutorials
......@@ -285,3 +285,213 @@ Now open gazebo and import your model.
:alt: image non disponible
*You should see that, something is still missing...*
Step 6 : The joints
-------------------
Joints are used to join two shapes.
Paste this code after your last *link* tag::
<joint type="revolute" name="left_wheel_hinge">
<pose>0 0 0 0 0 0</pose>
<child>left_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint type="revolute" name="left_wheel_hinge2">
<pose>0 0 0 0 0 0</pose>
<child>left_wheel2</child>
<parent>chassis</parent>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint type="revolute" name="right_wheel_hinge">
<pose>0 0 0 0 0 0</pose>
<child>right_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint type="revolute" name="right_wheel_hinge2">
<pose>0 0 0 0 0 0</pose>
<child>right_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 0 1</xyz>
</axis>
</joint>
.. csv-table:: Tag memory
:header: "tag", "usage"
:widths: 10, 40
"<joint>", "Declare a joint"
"<child>", "Define the child of the joint"
"<parent>", "Define the parent of the joint"
"<axis>", "You will define into this tag the axis rotation"
"<xyz>", "You will define which axis will rotate"
.. note::
Revolute type of joint is a joint with a single rotation, in this case the rotation will allow the wheel to roll
.. note::
The child will rotate around the parent
Step 7 : Test your model!
-------------------------
First make sure you have the same code::
<?xml version='1.0'?>
<sdf version='1.6'>
<model name="my_robot">
<static>false</static>
<pose>0 0 0.05 0 0 0</pose>
<link name='chassis'>
<pose>0 0 0.05 0 0 0</pose>
<collision name="collision">
<geometry>
<box>
<size>0.4 0.2 0.1</size>
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>0.4 0.2 0.1</size>
</box>
</geometry>
</visual>
</link>
<link name="left_wheel">
<pose>.09 0.1 0 1.57 0 0</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.06</radius>
<length>.03</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.06</radius>
<length>.03</length>
</cylinder>
</geometry>
</visual>
</link>
<link name="left_wheel2">
<pose>-.09 0.1 0 1.57 0 0</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.06</radius>
<length>.03</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.06</radius>
<length>.03</length>
</cylinder>
</geometry>
</visual>
</link>
<link name="right_wheel">
<pose>.09 -0.1 0 1.57 0 0</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.06</radius>
<length>.03</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.06</radius>
<length>.03</length>
</cylinder>
</geometry>
</visual>
</link>
<link name="right_wheel2">
<pose>-.09 -0.1 0 1.57 0 0</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.06</radius>
<length>.03</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.06</radius>
<length>.03</length>
</cylinder>
</geometry>
</visual>
</link>
<joint type="revolute" name="left_wheel_hinge">
<pose>0 0 0 0 0 0</pose>
<child>left_wheel</child>