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

2.3

parent ef0f83d1
......@@ -55,8 +55,8 @@ The .config file will define information like the name of robot or the version o
Open a terminal and type::
mkdir ws/gazebo/first_model
cd ws/gazebo/first_model
mkdir ws/gazebo/rover
cd ws/gazebo/rover
gedit model.config
Paste this lines into your model.config::
......
.. 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.
Add a sensor on your model
==========================
Step 1 : Create the sensor
--------------------------
We'll create the sensor, you can type these lines in a new terminal::
mkdir ws/gazebo/sensor
cd ws/gazebo/sensor
gedit model.config
Now you can paste the code below into *model.config*::
<?xml version="1.0"?>
<model>
<name>Sensor</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>
Then create *model.sdf*::
gedit model.sdf
and paste that::
<?xml version='1.0'?>
<sdf version='1.6'>
<model name="sensor">
<static>false</static>
<pose> 0 0 0.185011 0 0 0</pose>
<link name='head'>
<collision name="collision">
<geometry>
<box>
<size>0.05 0.05 0.05</size>
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>0.05 0.05 0.05</size>
</box>
</geometry>
</visual>
</link>
</model>
</sdf>
.. 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. 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>
<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
----------------------------------------
We'll create a new model. This model will merge both previous models (the base what we did in the previous topic and this model).
Type these lines::
mkdir ../RoverSensor
cd ../RoverSensor
gedit model.config
Paste that::
<?xml version="1.0"?>
<model>
<name>RoverSensor</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="RoverSensor">
<include>
<uri>model://rover</uri>
</include>
<include>
<uri>model://sensor</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
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