|
|
Lab 1: Introduction to ROS2 and Turtlebot4
|
|
|
==========================================
|
|
|
|
|
|
Start the simulators
|
|
|
--------------------
|
|
|
The aim of this lab is a basic introduction to ROS2 and its main tools. As part of the lab, you will also be introduced to the simulated platform: Turtlebot4.
|
|
|
|
|
|
* To start the simple simulator (recommended on Thinlinc):
|
|
|
Introduction
|
|
|
------------
|
|
|
|
|
|
_The Robot Operating System (ROS) is a flexible framework for writing robot software. It is a collection of tools, libraries, and conventions that aim to simplify the task of creating complex and robust robot behavior across a wide variety of robotic platforms_. More information can be found on the [official web site](https://www.ros.org/). It is commonly use by many robots in research and industry. ROS can transparently interact with real hardware or with a simulator.
|
|
|
|
|
|
Running
|
|
|
-------
|
|
|
|
|
|
**On Campus**
|
|
|
|
|
|
ROS is already installed on IDA computers, you can find it in the directories ```/opt/ros/galactic```, ```/usr``` and ```/courses/TDDE05/software```.
|
|
|
|
|
|
**thinlinc**
|
|
|
|
|
|
Running on personal computers is currently not supported, however it is possible to use thinlinc to access remotely IDA's computers.
|
|
|
To use thinlinc, follow the installation instruction at http://www.cendio.com/thinlinc/download and connect to the IDA server: ```thinlinc.edu.liu.se```.
|
|
|
|
|
|
ROS
|
|
|
---
|
|
|
|
|
|
![ros_logo](uploads/4ecd29c35a3bc069188ff0a2d9fee0aa/ros_logo.png)
|
|
|
|
|
|
ROS is a framework composed of a communication middleware and a set of modules providing different functionnalities for robots.
|
|
|
|
|
|
**Middleware:** With ROS the various algorithms, interfaces to hardware and simulators all run in different processes. ROS include communication libraries for various programming languages: C++ ([rclcpp](https://index.ros.org/p/rclcpp/)) or Python (rclpy \url{https://index.ros.org/p/rclpy/}).
|
|
|
There are libraries for more programming languages, but they are not as well supported and it is recommended that you stick to C++ and Python for this course.
|
|
|
|
|
|
ROS programs mainly communicate through the use of topics.
|
|
|
ROS topics follow a multi-publishers/multi-subscribers pattern: ROS programs subscribe to individual topics and they will then receive the messages that are published by other programs on the topic.
|
|
|
Topics are associated to a specific type of a ROS message (examples of standard messages can be found at [std_msgs](https://index.ros.org/p/std_msgs/), it is possible to create custom messages to suit your needs).
|
|
|
|
|
|
In addition to topics, ROS programs can offer _service calls_, which is the ROS implementation of Remote Procedure Calls (RPC).
|
|
|
|
|
|
**Packaging system:** ROS also provide a standard method for defining software package, using either the [CMake](cmake.org/) or [setupttools](https://setuptools.pypa.io/en/latest/setuptools.html) build systems. This package system allow to easily install any ROS package.
|
|
|
|
|
|
Turtlebot4
|
|
|
----------
|
|
|
|
|
|
![turtlebot4](uploads/235f84cc0850b252a3b5f92327369fb0/turtlebot4.jpeg)
|
|
|
|
|
|
_TurtleBot 4_ is the next-generation of the world’s most popular open source robotics platform for education and research, offering better computing power, better sensors and a world class user experience at an affordable price point.
|
|
|
|
|
|
For this course, the _Turtlebot 4_ is simulated, using a 2D simulator called \textit{simple simulator}, which can run well in thinlinc or the lab computers. The official project use a 3D simulator, [https://gazebosim.org/](Gazebo), which work poorly on the University computers.
|
|
|
|
|
|
Setup the environment
|
|
|
---------------------
|
|
|
|
|
|
# First you will need to add the following to your ```.bashrc``` file:
|
|
|
|
|
|
```bash
|
|
|
alias start-tdde05=". /courses/TDDE05/software/bin/start-tdde05.sh"
|
|
|
```
|
|
|
|
|
|
To edit your ```.bashrc``` file you can do the following in a terminal:
|
|
|
|
|
|
```bash
|
|
|
kate ~/.bashrc
|
|
|
```
|
|
|
|
|
|
# Every time you open a new terminal, before issuing a ROS command, you will need to run:
|
|
|
|
|
|
```bash
|
|
|
ros2 run air_simple_sim simple_sim platform_type:=turtle
|
|
|
start-tdde05
|
|
|
```
|
|
|
|
|
|
Start the simulator
|
|
|
-------------------
|
|
|
|
|
|
* To start the platform with the simple simulator:
|
|
|
|
|
|
```bash
|
|
|
ros2 launch air_bringup turtle.launch.py
|
|
|
```
|
|
|
|
|
|
If all went well, the following image should appear:
|
|
|
|
|
|
![simple_sim](uploads/303eb34883048aa7deb52ba8d0e7da01/simple_sim.png)
|
|
|
|
|
|
The _red_ dot is the robot. The black square are obstacles and the dots with numbers are semantic objects which are used in an other lab.
|
|
|
|
|
|
Send command to the robot
|
|
|
-------------------------
|
|
|
|
|
|
The robot is ready to take command.
|
|
|
|
|
|
```bash
|
|
|
ros2 action send_goal /navigate_to_position irobot_create_msgs/action/NavigateToPosition "{achieve_goal_heading: true,goal_pose:{pose:{position:{x: 1,y: 4,z: 0.0}, orientation:{x: 0.0,y: 0.0, z: 0.0, w: 1.0}}}}"
|
|
|
```
|
... | ... | |