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

2.4

parent eb2180e9
......@@ -10,6 +10,6 @@ Welcome to my ROS2 Tutorial!
:maxdepth: 2
./topic1/t1.rst
./model2.rst
./topic2/t2.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.
Use component from ROS2 into Gazebo
===================================
Step 1 : Create the sensor
--------------------------
We'll create the sensor, you can type these lines in a new terminal::
mkdir ~/Bureau/ws/models/telemeter
cd ~/Bureau/ws/models/telemeter
gedit model.sdf
Now you can paste the code below into *model.sdf*::
<?xml version='1.0'?>
<sdf version='1.6'>
<model name="telemeter">
<static>false</static>
<pose> 0 0 0.64 0 0 3.14159</pose>
<link name='head'>
<collision name="collision">
<geometry>
<box>
<size>0.3 0.3 0.3</size>
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>0.3 0.3 0.3</size>
</box>
</geometry>
</visual>
</link>
</model>
</sdf>
Then create *model.config*::
cd ~/Bureau/ws/models/telemeter
gedit model.config
and paste that::
<?xml version="1.0"?>
<model>
<name>Telemeter</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 telemeter.
</description>
</model>
.. note::
If you don't understand what does these files you should see again the previous topic.
You can open Gazebo and import the model, you should see a cube smaller than the other model.
Step 2 : Configure the sensor
-----------------------------
We choose a telemeter as sensor for this tutorial. In the .sdf file, into the *<link>* tag and after *</visual>* tag paste this code::
<sensor name="laser" type="ray">
<pose>0 0 0.2 0 0 0</pose>
<ray>
<scan>
<horizontal>
<samples>181</samples>
<resolution>1</resolution>
<min_angle>-1.57080</min_angle>
<max_angle>1.57080</max_angle>
</horizontal>
</scan>
<range>
<min>0.08</min>
<max>10</max>
<resolution>0.05</resolution>
</range>
</ray>
<always_on>1</always_on>
<update_rate>10</update_rate>
<visualize>true</visualize>
<plugin name='laser' filename='libgazebo_ros_ray_sensor.so'>
<ros>
<namespace>/demo</namespace>
<argument>--ros-args --remap ~/out:=scan</argument>
</ros>
<output_type>sensor_msgs/LaserScan</output_type>
</plugin>
</sensor>
Step 3 : Merge the sensor with the robot
----------------------------------------
Type these lines::
mkdir ~/Bureau/ws/models/final_robot
cd ~/Bureau/ws/models/final_robot
gedit model.config
Paste that::
<?xml version="1.0"?>
<model>
<name>Final 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 with his telemeter.
</description>
</model>
Edit new .sdf file::
gedit model.sdf
Merge both file .sdf from *my_robot* and *telemeter*, you can try to do it alone but i'll give you the code below::
<?xml version="1.0" ?>
<sdf version="1.6">
<model name="final">
<include>
<uri>model://testeur</uri>
</include>
<include>
<uri>model://telemeter</uri>
</include>
</model>
</sdf>
.. note::
*<uri>* is used to import an existant model and it must be put in an *<include>* tag.
If you have good following, you know something is missing. If you don't know open the model on Gazebo and try to find it. If you ever don't know look the note after the code below.
Replace the existing code by the following code::
<?xml version="1.0" ?>
<sdf version="1.6">
<model name="final">
<include>
<uri>model://testeur</uri>
</include>
<include>
<uri>model://telemeter</uri>
</include>
<joint type="fixed" name="telemeter_joint">
<pose>0 0 1.350040 0 0 0</pose>
<child>telemeter::head</child>
<parent>testeur::chassis</parent>
</joint>
</model>
</sdf>
.. note::
If you didn't find, the missing section was the joint between the telemeter and the robot.
Step 4 : Test your robot with ROS2
----------------------------------
Let's test the robot, type these command on a new terminal::
sudo apt install ros-galactic-gazebo-ros-pkgs
sudo apt install ros-galactic-ros-core ros-galactic-geometry2
source /opt/ros/galactic/setup.bash
.. warning::
Don't forget to source ROS2 in each terminal you use. **MEMO :** ``source /opt/ros/galactic/setup.bash``
To show all topic the robot can do, type on a terminal::
ros2 topic list
for example, type on your terminal this command, this should make the robot move forward::
ros2 topic echo /demo/laser/out
.. note::
If you want to stop the topic type ``Ctrl+C``
.. note::
You can put shapes in front of the robot to highlight values of sensor
......@@ -6,6 +6,20 @@
Add a sensor on your model
==========================
Prerequires
-----------
We'll install the packages of ROS for Gazebo, type these lines on a terminal::
sudo apt install ros-galactic-gazebo-ros-pkgs
sudo apt install ros-galactic-ros-core ros-galactic-geometry2
Now open your .bashrc and paste that into::
source /opt/ros/galactic/setup.bash
If you had open terminals, restart them.
Step 1 : Create the sensor
--------------------------
......@@ -44,7 +58,7 @@ and paste that::
<sdf version='1.6'>
<model name="sensor">
<static>false</static>
<pose> 0 0 0.185011 0 0 0</pose>
<pose> 0.15 0 0.185011 0 0 0</pose>
<link name='head'>
<collision name="collision">
<geometry>
......@@ -75,7 +89,7 @@ Step 2 : Configure the sensor
We choose a telemeter as sensor for this tutorial. Actually the model is a simple box, we'll add the lines who'll describe this is a telemeter. In the .sdf file, into the *<link>* tag and after *</visual>* tag paste this code::
<sensor name="laser" type="ray">
<pose>0 0 0.2 0 0 0</pose>
<pose>0.15 0 0.2 0 0 0</pose>
<ray>
<scan>
<horizontal>
......@@ -160,17 +174,17 @@ Replace the existing code by the following code::
<?xml version="1.0" ?>
<sdf version="1.6">
<model name="final">
<model name="RoverSensor">
<include>
<uri>model://testeur</uri>
<uri>model://rover</uri>
</include>
<include>
<uri>model://telemeter</uri>
<uri>model://sensor</uri>
</include>
<joint type="fixed" name="telemeter_joint">
<pose>0 0 1.350040 0 0 0</pose>
<child>telemeter::head</child>
<parent>testeur::chassis</parent>
<pose>0 0 0.185010 0 0 0</pose>
<child>sensor::head</child>
<parent>rover::chassis</parent>
</joint>
</model>
</sdf>
......@@ -181,28 +195,23 @@ Replace the existing code by the following code::
Step 4 : Test your robot with ROS2
----------------------------------
Let's test the robot, type these command on a new terminal::
sudo apt install ros-galactic-gazebo-ros-pkgs
sudo apt install ros-galactic-ros-core ros-galactic-geometry2
source /opt/ros/galactic/setup.bash
.. warning::
Don't forget to source ROS2 in each terminal you use. **MEMO :** ``source /opt/ros/galactic/setup.bash``
To show all topic the robot can do, type on a terminal::
To show all topic available for the rover, type on a terminal::
ros2 topic list
for example, type on your terminal this command, this should make the robot move forward::
for example, type on your terminal this command, this should make the rover scan with his telemeter::
ros2 topic echo /demo/laser/out
ros2 topic echo /demo/laser/out
.. note::
If you want to stop the topic type ``Ctrl+C``
.. note::
You can put shapes in front of the robot to highlight values of sensor
You can put shapes in front of the robot to highlight values of sensor
Congratulations you have done your first model!
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment