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

7. Using the KheperaTM robot

8. Using the IPRTM robots

9. Using the LEGO MindstormsTM robots

10. Using the AiboTM robots

11. Robot Soccer Lab

     

9.1 Webots model of the Rover robot

rover

Figure 9.1: The Rover model in Webots

Webots already includes a model for the Rover robot, so you won't have to create it yourself. The world file containing this model is named rover.wbt, shown in figure 9.2. This file is in the projects / robots / mindstorms / worlds directory of Webots.

rover_screenshot

Figure 9.2: The Rover model in Webots

Before opening this file in Webots, Windows and Linux users should check that they have properly installed java on their computer. The java -version command should verify this.

Once you have launched Webots and opened the rover.wbt world, press the stop button to stop the simulation and study the scene carefully. Open the scene tree window by double-clicking on the robot. The scene is very simple; it countains a surrounding wall, a textured floor displaying a track and a Rover robot. Let's open the DifferentialWheels node corresponding to the Rover robot. Looking at its children list will reveal the robot is equipped with one distance sensor (looking down) and a couple of touch sensors, i.e., the bumpers. The two wheels are implemented as Solid nodes with "left wheel" and "right wheel" as names to allow the simulator to make them rotate when necessary. Finally the controller field of this DifferentialWheels node is set to "Rover". The fact that the name of the controller begins with a capital letter means that the robot is programmed using the Java langage. If you press the run button, the Rover robot will start moving, following the track drawn on the floor, as programmed in its controller.

Let's have a look at the Java controller for the Rover robot. This controller can be found in the Rover subdirectory of the controllers directory (in the mindstorms project). It contains a single Java source file named Rover.java and a Makefile, which are used for the compilation. To compile your controller, just type make in the Rover directory and it will produce a Rover.class java binary file that is used by Webots to control the robot.

Now, have a look at the source code. Open Rover.java in a text editor and try to understand what it contains. Useful comments should help you understand the details. If you are familiar with Java you will understand everything very easily, since it is a very simple example. Basically, it gets references to the distance sensor and touch sensor objects, enables these sensors for measurements every 64 milliseconds and enters an endless loop in which it performs a simple line following algorithm using only the distance sensor looking down to read the color of the floor. You may want to modify this program, recompile it and see how your modified version performs.

previous page go up next page
^ page top ^

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