ROS Robot Operating System. Robotica Prof. Davide Brugali Università degli Studi di Bergamo

34  Download (0)

Full text

(1)

Robotica

Prof. Davide Brugali

Università degli Studi di Bergamo

ROS

(2)

Tutorials

2

 [online] http://wiki.ros.org/

 [2014] Jason M. O’Kane

A Gentle Introduction to ROS

https://cse.sc.edu/~jokane/agitr/agitr-letter.pdf

 [2013] Aaron Martinez, Enrique Fernández

Learning ROS for Robotics Programming

http://www.ict.griffith.edu.au/~vlad/teaching/robotics.d/READI NGS/Learning20ROS%20for%20Robotics%20Programming%20% 5BeBook%5D.pdf

(3)

Sviluppo di un sistema composto da tre nodi

ROS Tutorial 3 turtlesim Twist velocity_controller

Fornito con ROS Implementato da noi velocity_keyboard

VelocityCmd

(4)

Workspace di sviluppo per ROS

ROS Tutorial 4 / ROS-Tutorial /mobile_robot/ Workspace CMakeList.txt http://wiki.ros.org/catkin/Tutorials/create_a_workspace mobile_robot / -- WORKSPACE

src / -- SOURCE SPACE (contains the packages) CMakeLists.txt -- The 'toplevel' CMake file

build / -- BUILD SPACE CATKIN_IGNORE

(5)

Creazione del Workspace e compilazione

ROS Tutorial 5

$ mkdir ~ / ROS-Tutorial / mobile_robot / src

$ cd ~ / ROS-Tutorial / mobile_robot / src

$ catkin_init_workspace

$ cd ~ / ROS-Tutorial / mobile_robot

$ catkin_make

(6)

ROS Packages

ROS Tutorial 6

Software in ROS is organized in packages. A package might contain

ROS nodes, a ROS-independent library, a dataset, configuration files, a third-party piece of software, or anything else that logically

constitutes a useful module.

 The goal of these packages it to provide this useful functionality in an

easy-to-consume manner so that software can be easily reused.

 This means that a package is the smallest individual thing you can

build in ROS and it is the way software is bundled for release

(meaning, for example, there is one debian package for each ROS package), respectively.

(7)

Workspace di sviluppo per ROS

ROS Tutorial 7 / ROS-Tutorial /mobile_robot/ Workspace packages turtlesim velocity_keyboard CMakeList.txt package.xml CMakeList.txt velocity_keyboard_node.hpp velocity_keyboard_node.cpp Node http://wiki.ros.org/catkin/Tutorials/create_a_workspace VelocityKeyboard.hpp VelocityKeyboard.cpp Class velocity_controller CMakeList.txt package.xml velocity_controller_node.hpp velocity_controller_node.cpp VelocityController.hpp VelocityController.cpp VelocityCmd.msg Message

(8)

Package velocity_keyboard

ROS Tutorial 8

$ cd ~/ROS-Tutorial/mobile_robot/src

$ catkin_create_pkg velocity_keyboard std_msgs rospy roscpp

$ source ~/ROS-Tutorial/mobile_robot/devel/setup.bash mobile_robot / src / CMakeLists.txt velocity_keyboard/ -- package CMakeLists.txt package.xml

(9)

ROS Nodes

ROS Tutorial 9

A node is a process that performs computation. Nodes are combined

together into a graph and communicate with one another using  streaming topics,

 RPC services,

 and the Parameter Server.

 These nodes are meant to operate at a fine-grained scale; a robot

control system will usually comprise many nodes.

 For example, one node controls a laser range-finder, one Node

controls the robot's wheel motors, one node performs localization, one node performs path planning, one node provide a graphical view of the system, and so on.

(10)

ROS Nodes

ROS Tutorial 10

All running nodes have a graph resource name that uniquely

identifies them to the rest of the system.

 For example, /hokuyo_node could be the name of a Hokuyo driver

broadcasting laser scans.

 Nodes also have a node type, that simplifies the process of referring

to a node executable on the fileystem.

These node types are package resource name with the name of

the node's package and the name of the node executable file.

 In order to resolve a node type, ROS searches for all executables in

the package with the specified name and chooses the first that it finds.

 As such, you need to be careful and not produce different

(11)

Nodo velocity_keyboard

ROS Tutorial 11 VelocityKeyboard $ roscd velocity_keyboard/ $ gedit include/VelocityKeyboard.hpp $ gedit src/VelocityKeyboard.cpp

N.B. comando per spostarsi direttamente nella cartella

base di un package

velocity_keyboard_node main program

(12)

VelocityKeyboard.hpp

(13)
(14)

velocity_keyboard_node.hpp

(15)

velocity_keyboard_node.cpp

(16)

Messaggio “VelocityCmd”

16 

velocity_keyboard

include

VelocityKeyboard.hpp

velocity_keyboard_node.hpp

msg

VelocityCmd.msg

src

VelocityKeyboard.cpp

velocity_keyboard_node.cpp

CMakeList.txt

package.xml

(17)

Messaggio “VelocityCmd”

17

VelocityCmd.msg

(18)

VelocityController.hpp

(19)

VelocityController.cpp

(20)

velocity_controller_node.hpp

(21)

velocity_controller_node.cpp

(22)

velocity_controller_node.cpp

(23)

CMakeLists.txt

ROS Tutorial 23 ## Declare a cpp executable add_executable(velocity_keyboard_node src/VelocityKeyboard.cpp src/velocity_keyboard_node.cpp)

(24)

Compilare il codice sorgente in ROS

ROS Tutorial 24

 Aprire un terminale selezionando l’icona

 Digitare i seguenti comandi:

$ cd ~/ROS-Tutorial/mobile_robot/src

$ source ~/ROS-Tutorial/mobile_robot/devel/setup.bash $ catkin_make

 Se serve, modificare il codice sorgente

(25)

Creare il progetto Eclipse per un package

ROS Tutorial 25

$ catkin_make --force-cmake -G"Eclipse CDT4 – Unix Makefiles"

$ cd ~/ROS-Tutorial/mobile_robot/build

$ cmake ../src -DCMAKE_BUILD_TYPE=Debug

$ cd ~/ROS-Tutorial/mobile_robot/

$ mkdir eclipse // Eclipse workspace folder

$ source ROS-Tutorial/mobile_robot/devel/setup.bash $ eclipse // avvia Eclipse da terminal

 In Eclipse : File / Import / General /Existing Project  Selezionare la cartella

ROS-Tutorial/mobile_robot/build

(26)

ROS Messages

ROS Tutorial 26  geometry_msgs / Twist.msg nav_msgs / Odometry.msg turtlesim Twist velocity_controller

(27)

POSE

ROS Tutorial 27

(28)

TWIST

ROS Tutorial 28

(29)

Odometry

ROS Tutorial 29

(30)

Esecuzione di programmi ROS

ROS Tutorial 30

 Cambiare workspace di Ubuntu selezionando l’icona

 Selezionare una delle trefinestre libere

(31)

Digitare i seguenti comandi

ROS Tutorial 31

TERMINALE 1 : avviare il core di ROS

$ roscore

TERMINALE 2 : avviare il simulatore del robot Turtle

$ source ~/ROS-Tutorial/mobile_robot/devel/setup.bash $ rosrun turtlesim turtlesim_node

(32)

Digitare i seguenti comandi

ROS Tutorial 32

TERMINALE 3 : avviare l’applicazione velocity_controller

$ source ~/ROS-Tutorial/mobile_robot/devel/setup.bash $ roscd velocity_controller

$ rosrun velocity_controller velocity_controller_node

TERMINALE 4 : avviare l’applicazione velocity_keyboard

$ source ~/ROS-Tutorial/mobile_robot/devel/setup.bash $ roscd velocity_keyboard

(33)

Simulatore TurtleSim

(34)

Sviluppo di un sistema composto da tre nodi

ROS Tutorial 34 turtlesim Twist Odometry position_controller Keyboard Target

Figure

Updating...

References

Related subjects : The Robot Operating System