TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF...

22
TurtleBot2&ROS - Simulations Ing. Zdeněk Materna Department of Computer Graphics and Multimedia Fakulta informačních technologií VUT v Brně TurtleBot2&ROS - Simulations 1 / 22

Transcript of TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF...

Page 1: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

TurtleBot2&ROS - SimulationsIng. Zdeněk Materna

Department of Computer Graphics and MultimediaFakulta informačních technologií

VUT v Brně

TurtleBot2&ROS - Simulations 1 / 22

Page 2: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Presentation outline

Introduction

ROS/Gazebo

URDF

Gazebo / URDF practise

TurtleBot2&ROS - Simulations 2 / 22

Page 3: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Introduction

TurtleBot2&ROS - Simulations 3 / 22

Page 4: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Motivation

"In theory, there is no difference between theory and practice. But,in practice, there is."

Jan L. A. van de Snepscheut

TurtleBot2&ROS - Simulations 4 / 22

Page 5: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Motivation

Advantages of simulation for development and research in mobilerobotics field:

• Testing in simulation can save time and thus money.• More developers can work at the same time, on different

places.• Simulation can provide highly controlled and structured

environment.• Repeatable tests (important for debugging).

TurtleBot2&ROS - Simulations 5 / 22

Page 6: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Motivation

However...• Simulation can only approximate the real world.• There may be high risk and uncertainty during the transfer

from simulation to real world experiment.• Things which works good in simulation may completely fail in

real world.• Real environments are complex, unstructured and

unpredictable.• Simulation is only as good as it’s models.

TurtleBot2&ROS - Simulations 6 / 22

Page 7: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Physics based simulations

• Rigid body dynamics (joints, links), collision detection.• Solves forward dynamics problem (forces, motion of system).• Numerical integration (stability, time-step).• Constraints (revolute, prismatic, spherical).• Material properties (e.g. friction).• Engines: ODE, Bullet, PhysX, Unreal engine (USARSim).

TurtleBot2&ROS - Simulations 7 / 22

Page 8: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

ROS/Gazebo

TurtleBot2&ROS - Simulations 8 / 22

Page 9: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Overview

• Gazebo - general purpose 3D simulator.• Both indoor / outdoor environments, multi-robot.• Uses ODE (physics), OGRE (rendering).• Produces same data as real robot (topics, services).• Same interface of simulated and real robot → no need to

rewrite software.• Special interface to control simulation.• Other simulators - OpenRave, Grasp It!, Webots and many

more.

TurtleBot2&ROS - Simulations 9 / 22

Page 10: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Models

• A lot of available models, robots (list).• PR2, Robonaut, Care-O-Bot

• Robot models are created using XML (URDF).• Common sensors (camera, LIDAR, Kinect, force sensors).

TurtleBot2&ROS - Simulations 10 / 22

Page 11: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

What must be considered• Simulation may not run in real-time.• A lot of parameters to set. . .• Not all physical phenomenas are modelled.• Limited correspondence to real world experiment.• Simulated time means higher load.

0

20000

40000

60000

80000

100000

120000

930 940 950 960 970 980

coun

ts

distance [mm]

Histogram (mean: 950 mm)

TurtleBot2&ROS - Simulations 11 / 22

Page 12: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

TB2 simulation

• Based on simulation of TurtleBot.• Let’s try to run it!

r o s l a un ch btb_gazebo robot_empty_world . l aunch

TurtleBot2&ROS - Simulations 12 / 22

Page 13: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

URDF

TurtleBot2&ROS - Simulations 13 / 22

Page 14: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Overview

• XML robot description format.• Robot kinematics, dynamics, sensors, scenes.• Xacro - macro language.• Usually uploaded to parameter server (i.e. robot_description).• URDF example link.

<?xml v e r s i o n ="1.0"?><robot name="my f i r s t ">

<l i n k name="ba s e_ l i n k "><v i s u a l >

<geometry><c y l i n d e r l e n g t h ="0.6" r a d i u s ="0.2"/>

</geometry></v i s u a l >

</ l i n k ></robot>

TurtleBot2&ROS - Simulations 14 / 22

Page 15: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Structure - links and joints• links

• name, inertial, visual, collision• joints

• name, type (fixed, planar, revolute etc.), parent, child, axis• All values are in SI (meters, kilograms), rotation uses RPY

(apart from TF).• For simulation, we need to specify physical properties for all

links.

TurtleBot2&ROS - Simulations 15 / 22

Page 16: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Tools

• Xacro - kind of preprocessing• Verification - check syntax etc.• Visualisation - create pdf for better understanding.

r o s r un xac ro t e s t_xa c r o . py t u r t l e b o t . u r d f . xac ror o s r un xac ro xac ro . py t u r t l e b o t . u r d f . xac ro \\> t u r t l e b o t . u r d fr o s r un u r d f check_urd f t u r t l e b o t . u r d fr o s r un u r d f_pa r s e r u rd f_to_graph i z t u r t l e b o t . u r d fe v i n c e btb . pdf

TurtleBot2&ROS - Simulations 16 / 22

Page 17: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Relation with TF

• Robot model is used to broadcast TF transforms.• The robot_state_publisher uses URDF model and

joint_states to get 3D poses of robot links.

TurtleBot2&ROS - Simulations 17 / 22

Page 18: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Robot / Joint state publisher

• Go through joint_state_pub.launch• Try to visualise URDF model in RVIZ and manipulate with

joints:

r o s l a un ch tb2_workshop_s imu la t i ons \\j o i n t_ s t a t e_pub . l aunch

TurtleBot2&ROS - Simulations 18 / 22

Page 19: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Gazebo / URDF practise

TurtleBot2&ROS - Simulations 19 / 22

Page 20: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Using URDF with Gazebo

• Physical properties of joints and links must be specified.• Model can be "spawned"from command line:

r o s l a un ch gazebo_wor lds empty_world . l aunchro s cd tb2_workshop_s imu la t i onsr o s r un gazebo spawn_model − f i l e \\. / u r d f / t u r t l e b o t . u r d f −u r d f −z 0 .1 −model btb

• Spawning from launch file - see btb_gazebo package.

TurtleBot2&ROS - Simulations 20 / 22

Page 21: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Gazebo services and topics

r o s s e r v i c e l i s t | g rep gazebor o s t o p i c l i s t

• Services for getting / setting state of simulation.• Getting position of robot:

r o s s e r v i c e c a l l / gazebo / get_mode l_state \\’{model_name : btb } ’

• More examples (link).

TurtleBot2&ROS - Simulations 21 / 22

Page 22: TurtleBot2&ROS - Simulationsspanel/ROSWorkshop2013/1_5 ROS_simulations.pdf · ROS/Gazebo URDF Gazebo / URDF practise TurtleBot2&ROS - Simulations 2/22. Introduction TurtleBot2&ROS

Thanks for your attention

TurtleBot2&ROS - Simulations 22 / 22