lesson 4 –simulation anders lyhne christensen, d6.05...

20
INTRODUCTION TO AUTONOMOUS MOBILE ROBOTS Lesson 4 – Simulation Anders Lyhne Christensen, D6.05, [email protected]

Upload: others

Post on 27-Jun-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

INTRODUCTION TO AUTONOMOUS

MOBILE ROBOTS

Lesson 4 – Simulation

Anders Lyhne Christensen, D6.05, [email protected]

Page 2: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,
Page 3: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

Overview

� What is simulation?

� Why simulation?

� Examples of existing simulators

� Issues in simulation

� Tutorial: Simbad and the LegoRobotInterface

Page 4: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

What is simulation?

� “Simulation is the imitation of some real thing, state of affairs, or process. The act of simulating something generally entails representing certain key characteristics or behaviours of a selected physical or abstract system.” – Wikipedia, January 2010.

� In robotics, (sensor-based) simulation is usually an application run on one or more computers that simulate the effect of a robots actions on the environment and compute the resulting sensor readings.

Page 5: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

What is simulation?

Typical control loop in a simulator:

repeat

1 compute sensor readings for all robots

2 run robots’ control programs for one cycle

3 robots’ control signals to world physics

4 simulate the world for ∆t

until simulation should end

Page 6: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

Why simulation?

� Speeds up development and debugging

� No robotic hardware necessary

� No damage real (expensive) robots

� Allows for experiments in non-existing environments and with non-existing robots� Also allows for experiments with 100s or 1000s of robots.

� Allows for a high degree of automation

- Because of the above points, simulation is almost always necessary when learning is used – such as evolutionary robotics.

Page 7: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

Examples of existing

simulators� Webots

� http://www.cyberbotics.com/products/webots/index.html

� Gazebo/Player/Stage� http://playerstage.sourceforge.net/

� Microsoft Robotics Developer Studio� http://msdn.microsoft.com/en-us/robotics/default.aspx

� Blender� http://wiki.blender.org/index.php/Robotics:Index

� Simbad 3D Robot Simulator� http://simbad.sourceforge.net/

Page 8: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

Issues in simulation

� Often two different control programs are needed: � one for real hardware

� one for simulation

� Complexity vs. speed� A simple and fast simulation, or

� A complex and more accurate simulation,

� or both?

� Learning: How do we bridge the “reality gap” � How do we ensure that controllers that have been developed or

have been synthesized through learning in simulation work in the real world?

Page 9: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

Main requirements for a

simulator?

Page 10: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

Main requirements for a

simulator?

� Provide a good overview of the action, usually a 2D or 3D rendering

� Faster than real time

� Easily changeable environments

� Extendable: allow for implementation of new sensor and actuators

� Often is also has to allow for the simulation of multiple, possibly different robots at the same time.

Page 11: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

LegoSimBad

� A customization of the Simbad 3D simulator for Lego Mindstorms NXT

� Features:� Written in Java which makes it easy to integrate with

Lejos

� Open Source (GPL)

� Batch simulations

� 3D rendering of simulations

� Works with PicoEvo and PicoNode which are libraries for evolutionary computation and neural networks, respectively.

Page 12: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

Main issues to be aware of

� One Control Program, multiple platforms

� Defining the physical characteristics of the

robot and of the environment

� Implemented and missing features

Page 13: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

One Control Program, multiple platforms

(real hardware, LegoSimbad, …)

LegoRobotInterface

LegoSimbadImplementationRealRobotImplementation

Control Programs

Page 14: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

One control program for both

simulation and real hardware

- incorrect way:

This will not work (why?):

Page 15: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

One control program for both

simulation and real hardware

- incorrect way:

This will not work (why?):

The controller should not define the main

The UltrasonicSensor class is

for the real robot only

Sleep will stop the entire simulator (or if each controller

runs in separate threads, prevent the simulator from

running faster than real-time

Page 16: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

One control program for both

simulation and real hardware

- the correct way:

Page 17: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

One control program for both

simulation and real hardware

- the correct way:

The controller only knows about the LegoRobotInterface

Extends a predefined

Controller class

The robot object gives access

to the particular

implementation of the

LegoRobotInterface

Page 18: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

Defining the physical

characteristics of the robot

and of the environment

See source code

Page 19: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

Implemented and missing

features

Implemented:- Lego robots interface

- UltrasonicSensor

- Compass

- Motors

- Differential drive kinematics

Missing:- Gyroscopic sensor

- Touch sensor

- Microphone

- Gripper

- …

However, they can all be implemented – Look in the source code and in the non-Lego examples in simbad.demos for ideas on how to implement what you need

Page 20: Lesson 4 –Simulation Anders Lyhne Christensen, D6.05 ...home.iscte-iul.pt/~alcen/IARcourse/slides/aula04.pdf · What is simulation? “Simulation is the imitation of some real thing,

Running the simulator

� Download simulator package on the course webpage

� Download and install Java3D 1.5.2� https://java3d.dev.java.net/binary-builds.html, or

� http://www.softpedia.com/get/Programming/Other-Programming-Files/Java-3D.shtml(See the installation instructions online)

� If you have made changes to classes.jar, then make sure that you have Lejos (classes.jar) in the workspace and that the Lejos“classes” project is listed as a dependency in the simulator package.

� Use the commandline to compile a controller for the real robot (see “tips and tricks.txt” in the Eclipse project on how to do that)