Webots User Guide

previous page go up next page

Foreword

Thanks

1. Installing Webots

2. Getting Started with Webots

3. Sample Webots Applications

4. Tutorial: Modeling and simulating your robot

5. Programming Controllers and Plugins

6. Using the e-puck robot

     

3.3 Webots Devices

This section shows examples for using all of the different types of devices provided by Webots. The world files are located in the projects / samples / devices / world directory, and their controllers in the projects / samples / devices / controllers directory. For each, the world file and its corresponding controller have the name of the device they are an example of. For each device, the corresponding controller includes a complete demonstration of its capabilities, and uses all the available functions of the Webots API in nearly all cases.

3.3.1 battery.wbt

Keywords: DifferentialWheels, battery, Charger, MyBot

battery

Figure 3.11: battery.wbt

In this example the robot moves in the world while its battery discharges, and its current level is printed in the Console window. When its battery level reaches zero, Webots stops the robot. In order to continue moving, the robot must pass throught one of the four chargers, which are represented by the semi-transparent cylinders. A charger can reload the robot only if that charger is fully charged; a charger's energy level is represented by its color (red for totally empty and green for totally full). The source code for this controller is in the battery directory.

3.3.2 bumper.wbt

Keywords: DifferentialWheels, bumper, TouchSensor, MyBot

bumper

Figure 3.12: bumper.wbt

In this example the robot moves in its world using its bumper TouchSensor to detect collisions with the obstacles. When a collision is detected, the robot avoids the obstacle by first moving backwards and then turning a bit. The source code for this controller is in the bumper directory.

3.3.3 camera.wbt

Keywords: DifferentialWheels, Camera, image processing, MyBot

camera

Figure 3.13: camera.wbt

In this example the robot uses its color camera to detect objects of different colors. In order to achieve this, the robot analyses the color level of each pixel of the image taken by its camera. The robot turns and stops for a few seconds when it detects something. It also prints a message in the Console window explaining which type of object it has detected. You can move the robot to different places in the world (using the mouse) to see what it is able to detect. The source code for this controller is in the camera directory.

3.3.4 connector.wbt

Keywords: DifferentialWheels, Connector, Servo, IndexedLine, MyBot, USE, DEF

connector

Figure 3.14: connector.wbt

In this example a lighter robot is carried over two heavier robots. In order to achieve this, the robots are equipped with a Connector device placed on the top of a Servo which allows the robot to rotate the Connector. We have added an IndexedLine so that we can easily observe the axes of the Connector device. Using these devices, the lighter robot can move close to the first robot, attach to it and, as both rotate their servo at the same time, be carried over it. The lighter robot will first be carried over the two robots in one direction, then come back to its initial position by hopping in the opposite direction. The robots will repeat this behavior endlessly. All the robots in this world use the same controller; the different behaviors depend on the name of the robot. The source code for this controller is in the connector directory.

3.3.5 distance_sensor.wbt

Keywords: DifferentialWheels, DistanceSensor, Braitenberg, MyBot

distance_sensor

Figure 3.15: distance_sensor.wbt

In this example a robot uses various DistanceSensor devices to avoid the obstacles using a Braitenberg controller. The source code for this controller is in the distance_sensor directory.

3.3.6 emitter_receiver.wbt

Keywords: DifferentialWheels, Emitter, Receiver, infra-red transmission, MyBot, USE, DEF

emitter_receiver

Figure 3.16: emitter_receiver.wbt

In this example, two robots move in the world while one sends data to the other. The emitter's range is represented by the transparent sphere around it. The state of the communication between the two robots is displayed in the Console window. You can observe that as soon as the receiver enters the sphere, the communication works except when there is an obstacle between them, as they are using infra-red communication. The source code for this controller is in the emitter_receiver directory.

3.3.7 encoders.wbt

Keywords: DifferentialWheels, encoder, MyBot

encoders

Figure 3.17: encoders.wbt

In this example a robot moves in the world while reading its wheel position encoders. The controller randomly chooses target positions, and the robot rotates its wheels in the corresponding direction until the encoder values match he randomly chosen values. After that, the encoders are reset and the controller can choose new values. The robot does not pay any attention to obstacles. The source code for this controller is in the encoders directory.

3.3.8 force_sensor.wbt

Keywords: DifferentialWheels, force, TouchSensor, MyBot

force_sensor

Figure 3.18: force_sensor.wbt

This example is nearly the same as bumper.wbt (see subsection 3.3.2). The only difference between these two examples is that in this one, the robot uses a force TouchSensor instead of a bumper. This allows it to measure the force of each collision, which is printed in the Console window. The source code for this controller is in the force_sensor directory.

3.3.9 gps.wbt

Keywords: DifferentialWheels, Supervisor, GPS, supervisor_field_get, keyboard, MyBot

gps

Figure 3.19: gps.wbt

In this example the robot moves in the world while measuring its position and orientation using a GPS (Global Positioning System). In Webots there are two ways to create a GPS: either by using a GPS device or by using a Supervisor which will play the role of the satellite and keep track of the position of the robot. This example implements both of these techniques, and you can switch between them using the keyboard. If you want to see the current position of the robot, you must press a key to tell the robot to print it in the Console window. In order to know which keys will allow you to perform these operations, please read the explanation message printed at the begining of the simulation in the Console window. The source code for this controller is in the gps directory, and the code for the supervisor is in gps_supervisor.

3.3.10 led.wbt

Keywords: DifferentialWheels, LED, MyBot

led

Figure 3.20: led.wbt

In this example a robot equipped with 2 color LEDs moves in the world while randomly changing the color of each LED at random intervals. The color choice is printed in the Console window. Please note that when the number 0 is chosen, this turns the LED off. The source code for this controller is in the led directory.

3.3.11 light_sensor.wbt

Keywords: DifferentialWheels, LightSensor, lamp, object following, MyBot

light_sensor

Figure 3.21: light_sensor.wbt

In this example the robot uses its LightSensor to follow a light. You can move the light with your mouse; the robot will move to follow it. The source code for this controller is in the light_sensor directory.

3.3.12 pen.wbt

Keywords: DifferentialWheels, Pen, keyboard, MyBot

pen

Figure 3.22: pen.wbt

In this example a robot moves in the world while drawing a line on the floor using its Pen device. The controller randomly chooses all the parameters used to define the ink, which slowly fades. You can enable and disable the Pen using the keyboard. In order to know which keys will allow you to perform these operations, please read the explanation message printed at the begining of the simulation in the Console window. The source code for this controller is in the pen directory.

3.3.13 range_finder.wbt

Keywords: DifferentialWheels, range-finder, Camera, MyBot

range_finder

Figure 3.23: range_finder.wbt

In this example a robot moves in the world while avoiding the obstacles using its range-finder Camera device. This device allows the robot to measure the distance to objects within the range of the camera. Using these distances, the controller is able to compute which direction has enough space for the robot to move, and when to stop to avoid hitting an obstacle. The source code for this controller is in the range_finder directory.

previous page go up next page
^ page top ^

  E-mail to webmaster Last updated: Copyright © 2008 Cyberbotics Ltd.