Home
Webots 2.0 User Guide - EYE Communications AG
Contents
1. Close Name Select Apply Figure 4 4 The robot window for the K213 turret 70 CHAPTER 4 PROGRAMMING WITH THE KHEPERA API Information x Khepera K6300 Turret This vision turret for the Khepera robot provide 2D color vision for local processing It will be commercially available very soon However since this turret is still in development the features of the real turret may differ from those of the virtual one It features a 80 x 60 pixels resolution a horizontal view field of 60 degrees a vertical view field of 60 degrees a 24 bit color depth Note this is a top turret OK Figure 4 5 The real K5300 K6300 turret 4 5 WORKING WITH EXTENSION TURRETS 71 A TETAS File Edit Simulation Options came xem es mine PM von ooo Figure 4 6 The simulated K6300 turret o roboti Khepera Properties IX Khepera robot Simulated Distance Light Motors Controller ecall K bus Khepera K6300 5 Position 0 096 Z 0 08 lt lt 518 5 Close Name K6300 Color Y Image 0 85 0 85 0 85 turret al Select Amy Figure 4 7 The robot window for the K6300 turret 72 CHAPTER 4 PROGRAMMING WITH THE KHEPERA API o EEE Khepera Gripper Turret The gripper turret for the Khepera robot is a commercial product developed by K
2. ke 51 Ba DUPER WDE uox ee dut en a IR RR De RR Re da 52 CONTENTS 7 a ee 53 tub ARA 54 DII chase te ae ack eR ew ve x moe x des vow Bore Roc Bore Ros 55 B D 56 DIS ANCE WD ug wow a 57 59 first Khepera program 59 __ Sourcecodd 59 ontroller directory structure 60 T T ompilngthecontrodle 60 4 1 4 Modifying the controlled 61 LZ _ 62 A Z Khepera controllers 44 4 ex wx mea ee ee e e a ex 62 A AI III 62 etting sensor information 63 4 4 ontrolling Actuators 65 C owe ees 65 a he S RUE Alege ae Se Be ee RS 65 66 66 67 77 AT External Authoring Interfacd dd Roe ome oe 77 5 I Reading information from the world 78 5 diting is dus dus dus sen dle Gk le Boe de we Ele 78 5 1 4 ending messages to the robots 78 8 CONTENTS 81 nclude file and library 81 UT ODIECES 2
3. dt we Bote An nou 54 da AA A 55 B D OW Shi lu oa ea 56 BIZ alce WIM Oe SOG HR 57 63 68 69 69 70 71 71 4 8 e real gripper turret 72 4 9 esimulated gripper turret 73 4 10 e robot window for the gripperturred 73 4 11 The real panoramic turret prototype 74 e simulated panoramic turre 75 e robot window for panoramic turre 75 ge BO Bea aee Aw 80 toe koa ars Da Hoe Sark 80 6 Widgets available in GU 86 List of Tables upported system configurations 13 D Degrees of freedom for navigation 26 D Khepera sensor value 35 5 Alice Messages s OUR Re 719 11 12 LIST OF TABLES Chapter 1 Installing Webots 1 1 Hardware requirements Webots is supported on the UNIX X11 systems described in table I T as well as on Windows 95 Windows 98 and Windows NT Supported Hardware Recommanded Hardware Operating System PC 1386 Pentium II RedHat 6 0 SuSE 6 1 or Debian 2 1 Macintosh PowerPC PowerPC G3 YellowDog Linux 1 1 Linux PPC RS or MkLinux DR3
4. t prevent it from entering obstacles However when the robot moves on its own i e with a controller it cannot penetrate obstacles The Position check box allows one to enable and disable the display of these X Z and a coordinates It might be useful to disable such a display in order to accelerate a little bit the simualtion 2 6 4 Sensor representation The robot properties window contains a lot of information on the robot sensors and motors The Khepera robot has eight infra red sensors all around allowing it to measure distance from obstacles by emitting infra red light and measuring the quantity of reflected light These sensors can also be used as passive sensors to measure the ambient infra red light Each of the infra red sensors is represented as a rectangle for distance measurement and as a triangle for light measurement These rectangles and triangles appear most often blue but their color actually ranges from blue to red according to the measurements performed by the corresponding sensor as explained in table 2 2 Light sources are typically Lamp objects while obstacles can be either Can Box robots or Wall objects Numerical values are also available for both distance measurement and light measurement However only one numerical value can be displayed at a time for each sensor You can choose between the light and the distance numerical value with the corresponding check boxes situated at the left hand side of the window Numeric
5. 7 1 Hacking the world files 7 1 1 Overview The world files end up with the wbt suffix They lie in the worlds directory These files obey Webots file format which is an extension of a subset of the VRML 97 language VRML 97 standing for Virtual Reality Modeling Language is an official standard widely used for 3D on the World Wide Web It features animation and programming capabilities but it is not powerful enough to model virtual robots equipped with realistic sensors To view such 3D scenes and navigate through them you currently need to add a VRML 97 plugin to your favorit web browser Webots file format was implemented as an extension of a subset of VRML 97 Hence 3D scenes and animations produced by Webots could easily be ported to VRML 97 to be published on the World Wide Web You can read and edit the world files with a standard text editor However if the file is corrupted because the syntax is not respected Webots may crash when trying to load the file Please note that not all VRML 97 nodes are implemented Moreover within the implemented nodes not all fields are implemented So don t use nodes or fields that are not implemented this would cause Webots to crash The Reference Manual gives a complete list of nodes and associated fields currently supported in the Webots file format 7 1 2 Robots and Supervisors Webots file format allows storage of robots and supervisors as parts of environments Robots are defined by t
6. For each vertice you can edit its 2D coordinates so that you define a plane shape that is extruded to produce the Wall Please note that the order of the vertices is important like in VRML 97 when progressing in the list of 2 5 EDITING THE ENVIRONMENT 29 Can Properties lt lt o DN Figure 2 4 Can properties window vertices the right hand direction perpendicular to the progression should always point to the inside of the Wa11 object The figure 2 7 explains this rule for ordering vertices The height color positionandorientation ofthe Wall can be changed by editing the corresponding text fields Remember that to display the property window of an object in the scene you will have to double click on this object Robots are special objects The properties window of robots will be discussed later in this manual DCUM 0 1 _ Close Name Unselect Apply Figure 2 5 Lamp properties window 30 CHAPTER 2 WEBOTS BASICS Wall Properties NC Geometry x Z Points 0 5 0 5 E New 0 5 0 5 Delete 0 5 0 5 0 5 Position m 0 0 Orientation deg 0 Height m 0 06 Appearance Color R O S GJ 0 2 Bj 0 3 Close Name Unselect Apply Figure 2 6 Wall properties window 2 5 3 Moving objects A number of buttons are available in the bottom right side of the main window They allow you to selec
7. see figure 2 8 This might be useful especially when using cameras to improve distinction between objects and the background 2 5 6 Changing the Ground The Ground item in the Edit menu will allow you to redefine the ground size and number of plates on which robots evolve It will raise the properties window depicted in figure 2 9 The first and second colors refer to the two colors used to create the ground grid You can change them to fit your needs 32 CHAPTER 2 WEBOTS BASICS A Background A Color 0 4 0 7 BE 1 Ok Apply Cancel Figure 2 8 Background color Ground Properties 6 Geometry Size m X 0 5 2 0 5 Plates X 4 214 Appearance First Color 1 1 0 Second Color 0 8 10 5 0 3 _ Close Name Select Apply Figure 2 9 Ground properties 2 5 7 Going further It is also possible in Webots to use a subset of VRML 97 nodes However these nodes are not available directly from the built in Webots world editor Instead you should use a text editor to edit the world files and add VRML 97 nodes you need More details about this technique are provided in this manual in the Avanced Webots Programming chapter 2 6 Working with the Khepera robots 2 6 1 Khepera overview Khepera is a mini mobile robot 5 cm diameter 70 g which was developed at EPFL LAMI by Andr Guignard Edoardo Franzi and Francesco Mondada see figure 2 10 It
8. Create Cancel Figure 2 3 Creating a new world If any of these fields is set to zero no ground is created The File menu will also allow you to perform the standard file operations Open Save and Save As respectively to load save and save with a new name the current world The following buttons can be used as shortcuts to menu items The default worlds directory contains a lot of examples of worlds files files ending up with the wbt suffix which are described in chapter 3 However on UNIX you won t be able to save your own worlds in this directory unless you are logged on as root We do not recommend that you do so however On Windows there is no protection on this directory and the files it contains but it s better if you do not use this directory for your own worlds files Instead you should create a worlds directory in your home directory and save your own world files there 28 CHAPTER 2 WEBOTS BASICS 2 5 2 Adding objects Several kinds of objects can be added from the world window They are available through the Edit menu or the corresponding buttons o New Ball a ball with which the robots can play o 1 New Can a cylinder that be grasped by the Khepera robots equipped with a gripper turret o KA New Lamp a light bulb emitting light visible by the infra red sensors of the Khepera robot 0 New Robot arobot o New Wall a rectangular parallelepiped wall which 15 ty
9. Other similar useful types are defined in the types h include file They should always be used to avoid platform dependent problems occuring when porting your software to another system Sensor values can be read by using the following generic MODULE_get_SENSOR function see Reference Manual for details Here is the list of all the sensors available with the basic Khepera robot o proximity 8 infra red sensors used to measure the distance from the obstacles o light the same 8 infra red sensors used to measure the level of ambient light o position value of the incremental encoder on each wheel useful for odometry pur poses O speed velocity of each motor wheel o jumper configuration of the jumpers on the upper side of the robot 4 4 Controlling Actuators Unlike sensors actuators don t need to be enabled or disabled They are always available The generic MODULE_set ACTUATOR functions are used to send values to actuators The actuators of the basic Khepera robot include o led the two LEDs which stand on the upper side of the robot o position the internal value of each of the two incremental wheel encoders o speed velocity of each of the motor wheels 4 5 Working with extension turrets Extension turrets can be plugged into the K Bus of the robot as explained in chapter 2 In order to use extension turrets in controllers you will have to include the corresponding in clude file KheperaK213 h KheperaK6
10. actual grey levels Each representation can be disabled through the corresponding check box to achieve faster simulation 68 v M LI CHAPTER 4 PROGRAMMING WITH THE KHEPERA API Information x Khepera K213 Turret This linear vision turret for the Khepera robot is commercialized by K Team S A It allows a simple visual perception of the environment through a 64x1 pixels sensor Applications include landmark recognition with either natural optical pattern or bar code light source identification or visual stimuli classification Wry 3 It features s n a front view of 36 degrees a 64 pixels horizonal resolution a gray scale resolution of 256 levels maximal and minimal pixel intensity Note this is a top turret Ok Figure 4 2 The real K213 turret 4 5 WORKING WITH EXTENSION TURRETS 69 World Editor chase wbt X File Edit Simulation Options 2 e el o 2 8 E ue gt gt 128ms ish Emm Ose Figure 4 3 The simulated K213 turret 4 Predator Khepera Properties m Khepera robot K213 turret 4 2 i J Simulated 6 MEIN Y Raw image Distance 2n P Light v Grey levels graph Motors 0 D an Controller predator E K bus Khepera K213 w Position 0 16 2 0 17 197 1
11. are identified through the use of infra red sensor distance measurements If only one or two sensors in front of the robot are sufficiently excited and no other sensor is excited then the robot deduces it faces a small object which can be grasped by the gripper Then it moves the gripper down grasps the object and moves the gripper up After that the robot continues moving looking for another object to grasp When it finds one it puts down the object it held on its side and grasps the newly found object And this behavior is repeated for ever The source code for these controllers is in the can khepera directory 3 7 ATTACKER WBT 51 3 7 attacker wbt 5 Editor attacker wbt 00x File Edit Simulation Options eje 119 8 mine em SCORE VISITOR HOME Figure 3 6 attacker wbt The Khepera robots are trying to score a goal on a soccer field In order to achieve this the robots use some image processing from the K6300 turret to localize the ball and the goal Then the robots move to the right position to kick the ball in order to get it closer to goal The robots will repeat this behavior 3 or 4 times before a goal is scored A supervisor process is responsi ble for counting and displaying the goals as well as for setting the robots and the ball to their initial position after a goal is scored The source codes for these controllers are in the at tacker_blue khepera and atta
12. can be characterized manipulated and moved lt features 2 DC motors with absolute encoder Ni MI Optical barrier for object detection Resistivity measure of the gripped object 1111 65 x 90 x 10 mm 5 T i About 50 g Note this is an expandahle turret Ok Gripper turret Cancel Figure 2 13 Khepera bus plugin o Khepera Gripper a gripper allowing Khepera to grasp Can objects o Khepera Panoramic 240 degree linear black and white panoramic camera More information on these extension turrets will be detailled later in this manual 2 6 8 Khepera controllers In order to load a controller into the memory of a virtual robot you will need to click on the Controller button Then a file selector window will allow you to look for a directory whose name ends up with the khepera suffix Such a directory is a controller directory for the Khepera robot It contains a number of files which will be explained later in chapter 4 As an example you can try out the braiten khepera controller This controller will make the robot move and avoid any obstacle A controller is actually a simple program written in C or C language It can be compiled either by you or by Webots Then Webots launches the controller as an independent process and communicates with it through inter process communications systems A GUI Graphical User Interface is also available and will allow you to set up windows d
13. can have specific name called DEF name which is given by the designer of the world Such a DEF name can be defined from Webots by clicking on the Name button in the properties window of an object This DEF name can then be used by the supervisor process to get a pointer to that node by issuing the following function call include lt eai h gt eai node pointer to my node pointer to my node eai get MyNode 77 78 CHAPTER 5 PROGRAMMING WITH THE SUPERVISOR API 5 1 2 Reading information from the world The EAI functions eai get xxx where xxx can be replaced by position orientation color etc allow the supervisor process to read informations on the position orientation color etc of a number of nodes in the world The first and sometimes the only argument of the eai get xxx functions is always a pointer specifying the node from which we want to read information See the reference manual for a complete list and description of the different eai get xxx functions 5 1 3 Editing the world 5 1 3 1 eai set xxx The EAI functions eai set xxx where xxx can bereplaced by position orientation color etc allow the supervisor to change the position orientation color etc of a number of nodes in the world It is for example possible to change dynamically the controller of a robot by calling the eai set controller function with the name of the new controller as an argument The first parameter of the eai set xxx funct
14. command Optionally a second byte 80 CHAPTER 5 PROGRAMMING WITH THE SUPERVISOR API contains a parameter The first byte is organized as described in figure EN address command O 7 0 15 Figure 5 1 Command byte for the Alice robot The parameter byte when used contains an integer value coded on the 7 less significant bits LSB of the byte as depicted in figure 5 2 absolute value 0 63 Figure 5 2 Parameter byte for the Alice robot The sign bit has the following meaning O means positive and 1 means negative Hence the parameter value range ranges from 63 to 63 The example of a supervisor controller for Alice described in this manual is available within the Webots package Chapter 6 Using GUI the Graphical User Interface API Robot controllers as well as the supervisor controller can take advantage of using a simple yet powerful graphical user interface the GUI standing for Graphical User Interface This API Application Program Interface allows controllers to open windows to display texts graphics and widgets to handle events coming from the user like mouse movements key pressing etc It is very convenient to improve the interactivity between the user and the simulation This chapter is a tutorial for understanding and using the GUI However it does not provide an exhaustive description of this API See the Reference Manual for an exhaustive description of the GUI 6 1 Basics 6
15. command line compilation You have to add these lines path path where MSVC is installed bin SET MAKE MODE UNIX 3 Other compilers Webots performs the compilation and the link of the controller programs automatically if you set the compiler as described It uses the makefile included in each controller direc tory In particular the file makefile vc6 is used for compiling with Microsoft Visual 20 CHAPTER 1 INSTALLING WEBOTS C 6 0 and the file makefile gcc when you choose Cygwin You can decide at istallation time to avoid this automatic compilation choosing the No compilers This option is useful for two reasons firstly you can view the examples in the distribution all the controllers are provided with the executable without an installed compiler and sec ondly you can develop your own controller program using your preferred compiler In this case you have to create your own makefile and perform the compilation and the link to Webots libraries manually You can use the lib import library files only if your compiler accept the Microsoft Visual C version 6 0 format For instance version 5 0 of the same compiler doesn t work This method was reported to work with Metrowerks Code Warrior for Windows If you successfully develop a controller program using a compiler different from MSVC 6 0 or Cygwin please send us the makefile and the procedures you used for compiling We will be happy to add your compiler to th
16. differ from the real device The k6300_get_red k6300_get_green and k6300 get blue functions are used to get RGB values of the image captured by the camera These functions are implemented as macros or inline functions and hence are very efficient However you might want to use another function to get a pointer to an array containing the same data The k6300_get_image function returns such a pointer which might be more convenient depending on the way you want to read the data In order to allow robots to recognize each other for soccer games for example the color of the K6300 turret can be defined using the RGB text fields in the robot window depicted in figure 7 In order to get faster simulations the display of the image can be disabled by using the image check box 4 5 3 Gripper turret The gripper turret see figures 8 and H IO allows the robot grasp Can objects Such objects can be transported to another location and put down on the floor by the robot The can khepera controller is a good example to start programming with the gripper Two motor commands are available on the gripper The first one controls the position of the arm which can be set down up or in an intermediate position using the gripper set arm function The position of the arm is an integer value which ranges from 0 to 255 but the useful range is 160 255 A value of 255 means that the gripper is down in front of the robot while 4 5 WORKING WITH EXTENSION
17. is commercially available from K Team S A http www k team com This robot is widespread in many Universities all over the world and is used mainly for research and education It has two motor 2 6 WORKING WITH THE KHEPERA ROBOTS 33 wheels and is equiped with 8 infra red sensors allowing it to detect obstacles all around it in a range of about 5 cm These sensors can also provide information about light measurement allowing the robot to look for light sources Khepera supports a number of extension turrets including vision turrets a gripper a radio turret a general I O turret etc However not all of these turrets are implemented in Webots ZN information JS Khepera Mobile Robot This mini mobile robot was developed at LAMI EPFL by Edoardo Franzi Andr Guignard and Francesco Mondada It is now a commercial product distributed by K team S A http Avvew k team com It features 2 independent DC motors with encoders 8 infra red sensors emitter receiver p 11 an onboard 68331 microcontroller an onboard battery 30 min autonomy modular design with extension modules u T y a diameter size of 5cm al eee H motor speeds range from 20 to 20 IR reflection values range from 0 to 1023 IR ambient values range from 0 to 511 Ok Figure 2 10 The Khepera robot 2 6 2 Creating a simulated Khepera To create a robot you can use either the New Ro
18. is the serial number of your own Webots package which is printed on the back side of the CD ROM package under the heading S N After completing this form click on the Submit button Then you will receive within a few hours via e mail to the address you mentioned in the form your personal license file webots key which is needed to install a registered version of Webots on your system as we will see below 1 3 Installation procedure In order to install Webots on your system you will have to follow the instructions corresponding to your computer operating system listed below 16 CHAPTER 1 INSTALLING WEBOTS 1 3 1 PC i386 Linux 1 Log on as root 2 Insert the Webots CD ROM and mount it this might be automatic mount mnt cdromrpm Uvh mnt cdrom libraries Mesa 3 0 1 1386 rpm rpm Uvh mnt cdrom webots webots 2 0 1 i386 rpm 3 You may need to set the environment variable WEBOTS HOME to usr local webots This can be achieved from one of the following commands export WEBOTS HOME usr local webots setenv WEBOTS_HOME usr local webots depending on your shell Note that the rpm installation script will automatically set this variable for you in the etc profile file so that any user of your system could launch Webots 4 Copy your personal webot 5 key file into the usr local webots directory 5 Optionally you may check the convert program is installed on your system This is useful to save a
19. program so that we keep a handler to that label object 6 3 EDITING ADDING AND DELETING GOBS 85 gui label my label my_label gui_new_label window 20 20 I am happy e Then during the execution of the controller the internal state may be changing and we might need to change the text of the label if state SAD gui_label change text my_label I am sad Many write functions allow to change the properties of different objects Their usage and behav ior is explained in the Reference Manual 6 3 2 Adding gobs Adding gobs is as simple as this gui rectangle my rectangle my rectangle gui rectangle new my window 10 40 30 50 GUI RED true According to the Reference Manual this will create a red filled rectangle at location 10 40 with a width of 30 pixels and a height of 50 pixels This rectangle will be immediatly visible See the Reference Manual for creating other kind of objects 6 3 3 Deleting gobs If ever our label gob is not any more needed it is possible to delete it so that it disappears from the window gui label delete my label my labelzNULL It is also possible to delete the window itself if is not any more needed gui window delete my window my_window NULL Note if a window contains some objects gobs or widgets which have not been previously deleted those objects are automatically deleted with the window Further reference to them may
20. programming a robot within Webots As you can see such a program never ends It first performs some initialization and enters an endless loop So it is not possible to exit the program from itself Warning Never invoke the exit C function in a controller this would freeze things up in the simulator 59 60 CHAPTER 4 PROGRAMMING WITH THE KHEPERA API 4 1 2 Controller directory structure The source code listed above is indeed the contents of a C source file named crazy which lies in the crazy khepera directory in the cont rollers directory This name was chosen because the behavior of such a robot is somehow crazy Each controller directory s name ends up with a khepera suffix Other examples of khepera directories are provided in the webots controllers directory Let s observe what is needed in a controller directory by listing the crazy khepera directory On UNIX ls crazy khepera Makefile Crazy c Crazy o Crazy The Makefile is used to define the compilation procedure when the make command is used type man make for more information on make The crazy c file is the C source code for the controller we have just seen above The crazy o file is the object file generated by the compilation of crazy c The crazy file is the executable file that is launched by Webots On Windows dir crazy khepera makefile scp Makefile vc6 Makefile gcc crazy c crazy exe The Makefile vc6 and Makefile gcc are used to d
21. remote controller In order to receive the infra red signals from the remote controller Alice needs an infra red reception turret called Alice IRCom Actually this turret fulfills two functions 1 it receives IR signals from the remote controller and 2 two other infra red sensors can be used for obstacle avoidance using the same principle as with the Khepera robot This infra red remote control is modeled within Webots through the use of the Supervisor API A supervisor controller can control up to 8 Alice robots in a world by sending them messages Hence there is no Alice controller programs but only supervisor controllers sending messages to the Alice robots Such messages indicate a pre wired behavior to be executed by the Alice 42 CHAPTER 2 WEBOTS BASICS robot This technique as well as the complete description of messages is explained later in this manual 2 9 Miscellaneous 2 9 4 Hiding and showing the buttons The Options menu allows you to hide or show the two rows of buttons in the world window The Hide Edit Buttons item will remove the buttons used for editing the world while the Hide Simulation Buttons item will remove the buttons controlling the simulation When the buttons are hidden the same menu will allow you to display the buttons back using the Show Edit ButtonsorShow Simulation Buttons items 2 9 2 Setting up preferences The Preferences item in the Options menu allows you to set up the serial port dev
22. sensor values of the real robot in the robot window updated in real time o For timing reasons the transfer to the real robot needs the speedometer indicates a value close to 1 which means the simulator runs close to real time In order to achieve this you should choose a time basis for the refresh 1 in 8 16 32 64 128 etc which give a ratio as close as possible to 1 The time basis value will depend on the complexity of scene the power of your computer the complexity of your control algorithm etc 2 6 9 2 Cross compiling for the real Khepera Here are the steps to follow in order to cross compile and download the controller to the real robot o Load a controller into the simulated robot o Connect the real robot to one the serial ports of your computer see the manual of your robot to proceed o Set the robot serial mode to 9600 bauds mode 5 on both the simulated robot and the real robot Hence the jumper configuration of the real robot should correspond to the jumper configuration of the simulated robot The jumpers of the simulated robot can be configured from the widget situated just below the left motor in the robot window o Check that the serial ports are properly configured by checking the preferences window Options menu Preferences item The serial ports A and B should point to the corresponding directories Default values should be all right Normally these directories should be readable and writable from
23. the Simulation menu then to zoom on this robot using the control wheels for navigating in the scene The source code for these controllers is in the braiten khepera directory 3 3 PHOTOTAXY WBT 47 3 3 phototaxy wbt Word Editor phototaxy wbt 00 File Edit Simulation Options x ee 1 88 pos Ser Figure 3 2 phototaxy wbt This example makes use of the light measurement capability of the infra red sensors of the Khep era robot A light source is set in the center of the environment and the robot uses light measure ment information to try to find it You will see the robot moving toward the light and avoiding the foot of the light which is an obstacle and going away from the light then coming back and so on The source code for this controller is in the phototaxy khepera directory It can be entertaining to drag the light source with the move cursor to observe the robot running after the light 48 CHAPTER 3 SAMPLE WEBOTS APPLICATIONS 3 4 jumper wbt ESTE SOPLO A Khepera Properties X LLL T1 1 1 04 0 1 1T TT EENEN Figure 3 3 jumper wbt In this example the robot is not moving However interesting things will happen Run the simulation and double click on the robot to have the robot window displayed Then click on the jumpers on the robot window jumpers are just below the left motor of the robot You will be able to observe that setting the left most jump
24. usr local Uncompress the package gunzip webots2 0Solaris tar gz Untar the package tar xvf webots2 0Solaris tar Execute one of the following commands export WEBOTS_HOME usr local webots setenv WEBOTS_HOME usr local webots depending on your shell Create a shortcut so that the webot s executable is in the PATH of any user ln s usr local webots webots usr local bin webots Set the environment variable WEBOTS HOME of the users who want to use Webots to usr local webots as you did in 7 Copy your personnal webot s key file into the usr local webots directory You may need to install libpng on your system if not already installed You will be able to find this package in the Libraries directory of the CD ROM Optionally you may check if the convert program is installed on your system This is useful to save animated GIFs from Webots If not installed you will be able to find it in the ImageMagick package which lies in the libraries directory or the CD ROM 1 3 4 Windows 95 Windows 98 and Windows NT To install Webots on your Windows computer go through the following steps 1 2 3 4 5 Uninstall any previous release of Webots if any Insert the Webots CD ROM and open it the explorer Go to the webot s windows directory on the CD ROM Double click on the WEBOTS SETUP EXE file Follow the installation instructions Here are some explanations about the installation p
25. 1 1 Include file and library In order to use the GUI your controller programs will have to include the gui h file which stands in the webots include directory No additional library is required at link time since the GUI is fully contained into the Controller library So here is the first line of code to get started with the GUI include lt gui h gt 6 1 2 GUI objects Different kinds of objects can be used to create a graphical user interface They are classified into five categories 81 82 CHAPTER 6 USING GUI THE GRAPHICAL USER INTERFACE API windows window o gobs graphical objects arc image label line rectangle o widgets button checkbox popup textfield o invisible objects pixmap timer o utility objects color event screen 6 1 3 Constants In the GUI constants are all uppercase starting with the prefix GUI Constants are defined for the colors the events the keys etc 6 1 4 Functions In the GUI all function names start with the prefix gui This prefix is generally immedi ately followed by the name of an object like window rectangle or button then an underscore _ then an action associated to this object like new delete change_color or get_value For example the function gui_rectangle_change_color is used to change the color of a rectangle 6 1 4 1 Constructor functions Constructor functions are used to create new instances of objects They look like the following protot
26. 300 h KheperaGripper h or Khepera Panoramic h Then you will be able to use a number of functions to read sensor information or write motor commands which are specific to the turret you declared The syntax and usage of each of these functions is detailed in the Reference Manual 66 CHAPTER 4 PROGRAMMING WITH THE KHEPERA API 4 5 1 K213 turret This turret features a 1D black and white linear camera device see figures and 3 It is commercially available from usual Khepera distributors This turret is useful for equipping the Khepera with a simple visual perception system Many applications can take advantage of such a system including but not limited to landmark recog nition natural optical pattern or bar code optical flow light source identification and visual stimuli classification The image produced by this camera is a 64 x pixel image in 256 grey levels corresponding to a front view of 36 degrees see figure 4 4 The pixel intensity is optimized to improve the contrast 4 5 2 K6300 turret This turret helds a 2D color camera digital device see figures and 4 6 Image processing can be performed by the robot itself The real turret corresponding to the K6300 turret in Webots will be available commercially for the Khepera robot soon The black and white version will be called K5300 while the color version will be called K6300 However since the real turret is still a prototype at the time the model included in Webots may
27. 5 ea ee ba ed quinoa oh Oe ESS 81 EN Advanced Webots programming 89 Hacking the world files 89 Robots and Supervisors 89 S roubleshooting 93 8 ommon problems and solutions 93 List of Figures FA D D AAA AA wee 15 Dera 24 25 D reating anew world 27 2 4 an properties window 29 tn ae 29 2 6 Wall properties window 30 D Vertice ordering in Wall nodes 30 2 8 Background colon 32 2 9 round 32 2 10 Khepera robol do ke dod do ok de dea de dodo doa dod 33 A 34 va oe e ae Gone 34 D Khep bus plueim o el eee eoe Say a S ROS 37 39 eee ee ee ee ee 40 le qiie de ae Oh es ho ip Qr o Goh 41 262060 42 2 18 Webots directory structurd 43 2 19 Webots directory structurd 44 AAA 46 3 D DU a ad a do dai nt ed nt ct 47 B D qM 48 10 LIST OF FIGURES 8 4 finderwb 22s 49 ui 50 D attackerwbdl s sear ead 51 SCA 4 ee 52 d 53 AENA A da
28. 6 USING GUI THE GRAPHICAL USER INTERFACE API but rather they are specific to some types of event A complete description of these functions is available in the Reference Manual As an example to check if a button was pressed by the user the callback function has to look like the following void my_callback gui widget if gui_event_get_info GUI_WIDGET_EVENT w gui_event_get_widget if w my button printf my button was else printf Another widget was activated n The callback function can also use widget functions to retrieve information from a widget like the text contained in a textfield just edited by the user Moreover it is useful that the callback function calls other functions to update the state of global variables display some information to the user etc However the callback function should never call the xxx_st ep function directly or indirectly that is by calling a function which calls a function which call a function etc which calls the xxx_step function If this occurs then an undefined behavior will be observed and the controller will probably crash 6 5 Going further The examples provided within the simulator package can be a good starting point to understand the possibilities of the GUI Moreover the Reference Manual covers some issues not discussed here like timers Chapter 7 Advanced Webots programming
29. RS_OFF 5 1 ALICE_SENSORS_ON 6 1 ALICE_STOP 8 1 ALICE FOLLOW RIGHT AND TURN 9 1 ALICE FOLLOW LEFT AND TURN 10 1 ALICE_FOLLOW_RIGHT 11 1 ALICE_FOLLOW_LEFT 12 1 ALICE_STEP_RIGHT parameter 13 2 ALICE STEP LEFT parameter 14 2 Table 5 1 Alice Messages to control by using the eai get node function Then the supervisor controller can send it messages using the eai write_stream functions The same principle can be used to send messages to the Khepera robot However in this case you will have to program your Khepera controller so that it handles the messages sent from the supervisor 5 1 4 2 Messages for the Alice robot The messages sent to the Alice robot must be composed of one or two bytes as described in the table BI Most of these commands are self explanatory However a couple of them need more explana tions The ALICE SENSORS OFF and ALICE SENSORS ON allows the supervisor to turn off and on the obstacle avoidance in the ALICE FORWARD behavior By default this behavior performs obstacle avoidance The ALICE STEP RIGHT and ALICE STEP LEFT commands need an extra byte parameter which indicate the number of steps to be performed This byte needs to follow immediately the first command byte in the message 5 1 4 3 Encoding For compatibility issues with the real robot each message must be encoded in the following way The first byte contains the robot identifier and the associated
30. Sun Microsystems Inc All SPARC trademarks are used under the license and are trademarks or registered trademarks of SPARC International Inc Products bearing SPARC trademarks are based upon an architecture developed by Sun Microsystems Inc SuSE is is a registered trademark of SuSE GmbH UNIX is a registered trademark licensed exclusively by X Open Company Ltd VisualC Windows Windows 95 Windows 98 and Windows NT are registered trademarks of Microsoft Corp Foreword Webots was originally developed as a research tool for investigating various control algorithms in mobile robotics This simulation software has been carefully designed to facilitate the transfer to real robots It is currently specific to the Khepera robot and to the Alice robot However forthcoming versions of Webots will include more robots This user guide will get you started using Webots However the reader is expected to have a minimal knowledge in mobile robotics as well as in C programming It is not necessary to have a real robot to use Webots Cyberbotics is grateful to all the people who contributed to the development of Webots Webots sample applications Webots User Guide Webots Reference Manual and the Webots web site including Yuri Lopez de Meneses Auke Jan Ijspeert Gerald Foliot Allen Johnson Michael Kertesz Aude Billiard and many others Moreover many thanks are due to Prof J D Nicoud LAMI EPFL and Dr F Mondada for their valuable sup
31. Sun Sparc Workstation Sparc 20 Solaris 2 6 Table 1 1 Supported system configurations OpenGL hardware acceleration is supported only on Sun with 3D graphics board and under Windows with an OpenGL acceleration board see below for more information It will be soon available under Linux as well 1 2 Registration procedure 1 2 1 Webots Floating License System Since Webots 2 0 a new license system has been introduced to facilitate the utilization of Webots on several computers This Floating License System FLS relies on a license server located in Southern California USA which is contacted each time Webots is launched Webots send to the server a number of information including the user ID and the hostname on which Webots is running This allows the server to decide whether or not the user could use Webots on that 13 14 CHAPTER 1 INSTALLING WEBOTS machine according to his her license Then the server replies to Webots to acknoledge or refuse the utilization Hence Webots can be installed to an unlimited number of computer regardless of the license However the daily utilization of Webots will depend on your license According to the number of licenses you purchased you could use Webots simulataneously on a corresponding number of computers Note that simultaneously means the same day that is you can change of computer everyday if you need For example if you purchase a single license of Webots you could use it on a co
32. TURRETS 67 a value of about 160 means that the gripper is up The second motor command controls the position of the grip itself that is the two fingers of the device You can close or open this device with the gripper set grip function but no intermediate position is available However when you close the gripper on an object the object will stop the run of the grip at a given position The position is indeed the size of the object and can be measured using the gripper get grip function The gripper turret also features two interesting sensors which are an optical barrier and a re sistivity measurement device The first allows Khepera to detect if an object is inside the grip before or after the grip is closed by using the gripper get presence function The second allows Khepera to measure the electrical resistivity of a gripped object by using the grip per get resistivity function The K Bus button is reserved for future use It is currently not possible to plug in an additional turret over the gripper turret Such a feature will be introduced in further versions The gripper can be controlled from the keyboard like the robot You will have to press the SHIFT key simultaneously with the arrow keys of your keyboard to move the gripper up or down You can also type a new value for the gripper arm position or use the little arrow buttons close to the arm text field The space bar or the Gripper button allows to open or close the gripper H
33. Team 5 4 It allows Khepera to detect the presence of an object to grasp it to measure its electrical resistivity to load unload and ungrasp it Hence objects can be characterized manipulated and moved It features 2 DC motors with absolute encoder Optical barrier for object detection Resistivity measure of the gripped object 65 x 90 x 10 mm About 50 9 Note this is an expandable turret Ok Figure 4 8 The real gripper turret 4 5 WORKING WITH EXTENSION TURRETS 73 Worid Editor can wbt En File Edit Simulation Options dia a 2 o t pd 0 09 cams ich em tei Figure 4 9 The simulated gripper turret Eee Khepera Properties JS Khepera robot Gripper turret i 1 J Simulated 6 7 3 a cue Ss Distance 0n 1 6 v Li 184 see El dH Motors 0 D Gripper 5 i e Controller can lt 2 K bus Gripper K bus arm 184 shift Position 0 036 zl 0 010 341 7 object Yes resistivity 0 Close Name Unselect Apply Figure 4 10 The robot window for the gripper turret 74 CHAPTER 4 PROGRAMMING WITH THE KHEPERA API A Information x Khepera Panoramic Turret This linear vision turret for the Khepera robot was developed at LAMI EPFL by Yuri Lopez de Meneses It is a prototype and not a commercia
34. WEBOTS 2 0 User Guide 1998 1999 Cyberbotics www cyberbotics com September 10 1999 1998 1999 Cyberbotics S a r l All Rights Reserved CYBERBOTICS S A R L CYBERBOTICS MAKES NO WARRANTY OR CONDITION EITHER EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE REGARDING THIS MANUAL AND THE ASSOCIATED SOFTWARE THIS MANUAL IS PROVIDED ON AN AS IS BASIS NEITHER CYBERBOTICS NOR ANY APPLICABLE LICENSOR WILL BE LIABLE FOR ANY INCIDENTAL OR CONSEQUENTIAL DAM AGES This software was initially developped at the Laboratoire de Micro Informatique LAMI of the Swiss Federal Institute of Technology Lausanne Switzerland EPFL The EPFL makes no warranties of any kind on this software In no event shall the EPFL be liable for incidental or consequential damages of any kind in connection with use and exploitation of this software Trademark information CodeWarrior is a registered trademark of Metrowerks Inc IRIX O2 and OpenGL are registered trademark of Silicon Graphics Inc Khepera is a registered trademark of K Team S A Linux is a registered trademark of Linus Torwalds Macintosh is a registered trademark of Apple Computer Inc Pentium is a registered trademark of Intel Corp PowerPC is a registered trademark of IBM Corp Red Hat is a registered trademark of Red Hat Software Inc Solaris and Solaris OpenGL are registered trademarks of
35. al values can be described as follows o Distance values range from 0 no obstacle detected to 1023 obstacle very close o Light values range from 0 light source very close to 512 no light source detected 36 CHAPTER 2 WEBOTS BASICS Since these values are noisy just like with the real sensors they are always oscillating giving a rough approximation of the actual physical value The model of the infra red sensors is based upon a lookup table for light and distance measure ment since the response is non linear with the distance The color of object has some effect on the distance measurements since red or white objects reflect more infra red light than green or black objects A random white noise of 10 is added to each measure light and proximity to make the modeling of the sensor realistic 2 6 5 Motors representation The Khepera robot has two independent motor wheels allowing it to move forward to move backward and to turn Each of the two motors is symbolized by a square on the robot rep resentation This square contains an arrow indicating the velocity of the motor direction and amplitude A numerical value is also displayed which ranges from 20 to 20 Negative speed values can be used to make the robot go backwards Each of these motor speed representations can be enabled or disabled by the Motors check boxes on the left hand side of the robot win dow However motor values can only be assigned by a robot controller s
36. ally using the console 8 2 How to I send a bug report If you find a bug in the Webots software or have a problem which is not covered within the documentation and the examples then you could send a bug report to Cyberbotics In order to do so write an e mail to support cyberbotics com This e mail must contain the following information 1 Your name 2 The version of Webots you use 3 A complete description of your system configuration machine operating system and eventually additional hardware like 3D graphics board 4 A complete description of the bug allowing us to reproduce it step by step 5 Optionally some material allowing us to reproduce the bug 1 e the source code of a controller program a world file etc We really appreacite any bug report They contribute to the improvement of the quality of our software Thank you in advance 8 2 HOW TO I SEND A BUG REPORT 95 96 CHAPTER 8 TROUBLESHOOTING
37. any user crw rw rw If not set the attributes of these files properly using the chmod command as root o n the upper left corner of the robot window change the popup menu from Simulated to Download Serial Download Serial B according to the port on which the robot is connected 40 CHAPTER 2 WEBOTS BASICS o If the controller has cross compiled correctly a popup window should inform you that the binary file is being transferred to the real robot figure 2 15 After that the controller will be automatically executed on the robot If the robot has on board batteries you might want to unplug it from the serial connection Download braiten Transfering Figure 2 15 Downloading a cross compiled controller 2 6 9 3 Software requirements In order to make use of the cross compilation feature of Webots 2 0 you must have properly installed the GNU C based cross compiler for the Khepera robot in your system Please refer to the corresponding software and manuals provided by K Team to set up such an environment 2 7 Working with Supervisors A supervisor is a program similar to a robot controller However such a program is not associated to a robot but to a world It can be used to supervise experiments The supervisor program is able to get information on robots and on some objects in the world like Ba11 objects and to communicate with robots A supervisor can be used to achieve the following o pro
38. are the Microsoft default libraries that are included in the Windows installation CD staring from Windows 95 version B If you have an accelerated 3D graphics card that uses different libraries with the same name like with some 3DFX cards make a backup and remove or rename these files before installing Webots otherwise openg132 d11 and glu32 d11 will not be installed and Webots might not run properly 1 3 4 3 Hardware accelerated graphics cards Webots has been tested on nVidia TNT2 32bits and on 3DFX Voodoo Banshee graphics cards for hardware acceleration 1 nVidia TNT2 32 bits The hardware accleration works fine for both the main window of Webots and the turrets window When the Khepera properties window is displayed the error Pixel Format error sometime occours Webots stops working properly 2 3DFX Voodoo Banshee The new Quake III compatible drivers are available from the web site www These new drivers include an ICD OpenGL are not completly compatible whith standard OpenGL they are only tested to work for Quake Moreover the HW acceleration is working only if you set the screen colors to 16 bits 65536 colors In this mode sometimes the same problem with the TNT2 occours the Pixel Format 1 3 INSTALLATION PROCEDURE 19 error moreover the textures make Webots crash The acceleration does not seems to work for a properties window displayed using some turrets 1 3 4 4 Compiler installatio
39. back void main GUI settings create a window with objects in side gui_event_callback my_callback for supervisor_step 64 It is very important that a controller calls a xxx step function in a loop after setting the callback function since this callback function will be called from the xxx_step function If an event occurs during the execution of the xxx_ step function your callback function is called and it has to retrieve some information about the event to update your program or do whatever you want to do upon reception of events To achieve this a number of functions can be used within the callback function ui_event_get_typ ui event get info ui event get widget ui event get window ui event get mouse x ui event get mouse y ui event get key ui event get modifier ui event get timer In your callback function you may first want to know what kind type of event occured and you will use qui event get type to achieve this To distinguish between widget events and other events you can use qui event get info function Then the other functions will provide you with more detail about this event For example if the qui event get info tells you that a widget event occured the qui event widget will return a pointer to the widget that caused that event Note that all functions are not applicable for any type of event 88 CHAPTER
40. bot menu item or the corresponding button as seen previously A popup menu will let you choose the type of robot you want to create see figure Z T Choose Khepera You will be also prompted to assign a name to the robot You could choose any name you like Let s choose Max as an example The properties window of Max should then appear figure 2 12 However it is possible to obtain the properties window of any robot by double clicking on the desired robot in the world window If Max isn t a good name for you you can change this by clicking on the Name button The Unselect button can be used to unselect the robot in the world window this button will then be changed into a Select button allowing the robot to be selected again This might be very useful when there are several robots in the world and you don t know which one is represented in your robot properties window The Apply button performs the position changes if needed 34 CHAPTER 2 WEBOTS BASICS 3 New Robot X Type Khepera Name Ok Cancel Figure 2 11 Creating a new robot Khepera Properties 1X Khepera robot ERES Simulated il 2 2 Y Y Distance 4 4l 1 _ w Light TR Motors 0 A A Controller braiten 4 3 K bus Y Position X 0 Z 0 0 Close Name Unselect Apply Figure 2 12 Khepera properties window Finally the Close button allows you to close t
41. cker_yellow khepera directories 52 CHAPTER 3 SAMPLE WEBOTS APPLICATIONS 3 8 buffer wbt H World Editor buffer wbt lt O X File Edit Simulation Options Samo 1 99 mH 0 20 ish qi e iX Figure 3 7 buffer wbt This example demonstrates how it is possible to exchange information between a supervisor and a robot The robot is communcating with the supervisor to say when it feels an obstacle in front of it Then the supervisor decides that if the object is close enough to the robot the robot should turn on one LED The supervisor then sends a message to the robot meaning to turn on or off the LED Similar methods can be used to implement some communication between robots via the supervisor The source code for the supervisor is in the buf fer supervisor directory and the source code for the robot controller is in the buffer khepera directory 3 9 TOWN WBT 53 3 9 town wbt Ai World Editor town wbt File Edit Simulation Options ejej mue Ji eo iX Figure 3 8 town wbt This example was developed by G rald Foliot Lyon 2 University France It models a city sized for the Khepera robot with buildings streets rivers parks trees etc in which you can run your own experiments Such an environment is well suited for navigation tasks because a lot of landmarks can be recognized by the robots equipped with vision sensors Note that
42. croll ctrl Tl 7 roll gt zoom t1 Table 2 1 Degrees of freedom for navigation Notice that if an object is selected in the scene the camera will rotate according to the selected axis around this object 2 4 4 Switching between the World View and the Robot View You can choose between two different points of view o World View this view corresponds to a fixed camera standing in the world o Robot View this view corresponds to a mobile camera following a robot You can switch between both modes using the last item of the Simulation menu But before you go into this menu you have to select a robot if you want a RobotView from this robot or unselect any robot if you wantaWorld View the most convenient way to unselect any robot is to click on an object or in the background of the scene Then the last item of the Simulation menu will be set appropriately so that you can select either the Robot View or the World View 2 5 Editing the environment 2 5 1 Creating opening and saving worlds When the simulator is launched a default world is loaded in the world window In order to create your own world you can go to the File menu and select the New item A popup 2 5 EDITING THE ENVIRONMENT 27 window will appear as depicted on figure 2 3 letting you choose the size of the ground grid and the number of plates it is made of Y Create a New X X 100 m Size mm 1 0 2 Plates B 2
43. e list of the supported compilers by Webots 1 3 4 5 The MAKEFILE script In order to perform automatic compilation Webots for Windows uses a script file This is a plain text file called makefile scp and it is present in each controller directory Each line of the makefile scp shows the command line you have to type in the MSDOS console in order to make compile and link the controller program Webots reads this file each time you load a new controller or a new world from the Webots editor If Webots finds a line that is not commented 46 25 i e it doesn t start with the character or it will execute the command Your choose of the compiler during the installation change the makefile scp 1 If you choose MSVC 6 0 the file appears as Makefile for VC 6 0 nmake f Makefile vc6 Makefile for CygWin GCC make f Makefile gcc nocompilation 2 If you choose Cygwin the file appears as Makefile for VC 6 0 nmake f Makefile vc6 Makefile for CygWin GCC make f Makefile gcc nocompilation 3 If you choose the No compiler option the file appears as 1 3 INSTALLATION PROCEDURE 21 Makefile for VC 6 0 nmake f Makefile vc6 Makefile for CygWin GCC make f Makefile gcc nocompilation You are free to edit the makefile scp for example to change the commmand line or to change the compiler you are using or to decide to use no automatic compilation Because there is one makefil
44. e scp in each controller directory if you change the makefile scp this will change the behaviour of Webots only for the controller program in which the makefile scp is present So you can for instance decide to have some controller programs compiled with MSVC 6 0 some with Cygwin and some not automatically compiled Remember these sim ple rules to avoid crashing Webots o no blank lines must appear in the file o the characters for commenting out a line are or and must be at the beginning of the line o the first non commented line is the one used o the command in the non remarked line is used like at the DOS prompt if it is incorrect an error occurs and may stop the compilation or crash Webots You are responsable for ensuring the correctness of the command 1 3 4 6 Cross compilation Cross compilation gives the possibility to compile the controller for the internal chip of a real Khepera download it into the memory of the robot and let it run standalone The cross compi lation is allowed only using the GCC cross compilation You must have the khepack package provided by K Team for more information see www k team com or the manual provided whith khepack For installation of the GCC cross compiler follow the instructions in the khepack manual Then you will have to do the following 1 You have to copy the kepack5 xx directory in the cross compiler directory Thus if you install the GCC cross compiler
45. e using the corresponding MODULE disable SENSOR function The following sample program implements a simple Braitenberg vehicle include lt Khepera h gt include braiten h Interconnection matrix between IR proximity sensors and motors int32 Interconn 16 5 15 18 6 4 4 3 5 4 4 6 18 15 5 5 31 main int32 i left speed right speed khepera live khepera enable proximity IR ALL SENSORS for Khepera never dies left speed 0 right speed 0 for i 0 i lt 8 i Connections sensors motors right_speed khepera get proximity 1 Interconn 11 left speed khepera get proximity i Interconn 8 1 j left speed 400 Global gain right speed 400 left speed FORWARD SPEED Offset right speed FORWARD_SPEED khepera set speed LEFT left_speed Set the motor khepera_set_speed RIGHT right_speed speeds khepera_step 64 Run one step of 64 ms 1 Braitenberg V Vehicles Experiments in Synthetic Psychology MIT Press 1984 4 4 CONTROLLING ACTUATORS 65 This controller introduces infra red sensor proximity readings which are used to drive the robot wheels so that the robot can avoid obstacles on its way It is provided as an example controller in the braiten khepera directory The int 32 type corresponds to a signed integer on 32 bits
46. ed during this call The figure summarizes the structure of a standard controller program An explanation for the MODULE SENSOR and ACTUATOR concepts is given later in this chapter 4 2 WEBOTS EXECUTION SCHEME 63 MODULE enable SENSOR Figure 4 1 Structure of a controller program 4 2 2 Other controllers The webot s program successively calls the robot controllers and the supervisor program if any Here is the sequential order of such operations which are executed once during the Step mode and continuously during the Run and Fast modes o Execute the khepera step or supervisor step function for each controller this includes the simulation of actuators and sensors o Simulate other things within Webots simulation like the Ba11 movement o Update the display of the world if not in Fast mode 64 CHAPTER 4 PROGRAMMING WITH THE KHEPERA API 4 3 Getting sensor information For each sensor you need you will have to declare that you request the computation of the simulated sensor by a function call looking like MODULE enable SENSOR where MODULE can be replaced either by khepera k213 k6300 gripper or panoramic and SENSOR can be replaced either by one of jumper position proximity light speed arm grip presence resistivity raw etc By default no sensor computation is performed So it is important to request explicitly the sensors you need You can also disable some sensors if you don t need them any mor
47. efine the compilation procedure re spectively for the Microsoft Visual C 6 0 and CygWin compilers The Makefile scp is used by Webots to decide which compiler to use for building the controller program You can edit all these files in a text editor like notepad to have more informations or to modify them The crazy file is the C source code for the robot controller The crazy exe file is the executable file that is launched by Webots As a result of the compilation of crazy c you will see some others files appear like crazy o or crazy obj 4 1 MY FIRST KHEPERA PROGRAM 61 4 1 3 Compiling the controller On UNIX the controller can be compiled from the shell by issuing the following command make However you won t be able to compile this controller unless you are logged in as root because you are not allowed to write in the webots directory To compile it you will first have to get a local copy of this controller as explained in the next subsection On Windows the controller can be compiled from the DOS console You have to go in that directory first then you can type the following command nmake f Makefile vc6 if you are using Microsoft Visual C 6 0 compiler or make Makefile gcc if you are using the Cygwin compiler Note that the compilation commands described are written in the makefile scp In this file the lines starting with a or FP character are remarks The first uncommented line must co
48. er will cause the right most LED of the robot to be switched on Unsetting this jumper will cause the same LED to be switched off The middle jumper controls the other LED while the last jumper has no effect The source code for this controller is in the jumper khepera directory 3 5 FINDER WBT 49 3 5 finder wbt DO Figure 3 4 finder wbt This example shows how to use the Panoramic turret to reach a blue target cylinder situated in the center of the environment The robot controller has two behaviors 1 look for a dark object in the linear vision array and turn to set this object in the center of the field of view and 2 go forward and avoid any obstacle As a result you will be able to observe the robot going very efficiently towards the blue cylinder and then turning around the cylinder This can be explained by the fact that the cylinder is also an obstacle and the obstacle avoidance behavior has a strongest priority over the goal seeking behavior The source code for this controller is in the finder khepera directory 50 CHAPTER 3 SAMPLE WEBOTS APPLICATIONS 3 6 can wbt Word Editor can wbt File Edit Simulation Options clans 2 mH e _ d ee EN Figure 3 5 can wbt This example demonstrates two Khepera robots equipped with Gripper turrets and running the same controller program The robots look for small objects which can be grasped by the gripper Such objects
49. ftware pipe interface In order to proceed on the third party software side you have to look in the user manual of that software to find out how pipe files are handled 7 3 2 Using other Inter Process Communication systems Although they are not covered in the manual any other Inter Process Communication IPC system could be used to achieve the same purpose The most interesting though would be a socket based network interface so that you can distribute controller computation over a network of computers This could prove to be very useful for multi agent simulations using computer expensive controllers 92 CHAPTER 7 ADVANCED WEBOTS PROGRAMMING Chapter 8 Troubleshooting This chapter covers a number of known issues that may arise when using Webots Please read it carefully It can help for most common problems with Webots However if the problem remains please send a bug report to Cyberbotics 8 1 Common problems and solutions Problem Webots sometimes leaves some controllers or supervisors alive even after quitting Such controllers or supervisors are independent processes using system resources It might be useful to destroy them in order to release the resources they use Solution On UNIX the useless controllers should appear in the list of processes by issuing a ps or a top command Then you will get their pid process identifier and will be able to destroy them with a ki 11 command On Windows you can remove the u
50. gram inter robot communications o record experimental data like robot trajectories O control experimental parameters O display useful information from robots o define new abstract sensors o control the Alice robots Like with robot controllers a GUI library is available to set up windows with buttons and other widgets Such windows are useful to display and control what s going on in the experiment Supervisor programming is described in chapter 3 of this manual 2 8 WORKING WITH THE ALICE ROBOT 41 2 8 Working with the Alice robot 2 8 1 Alice overview Figure 2 16 The Alice robot The Alice robot is a very small and cheap autonomous mobile robot It was developed by Gilles Caprari from EPFL DMT ISR ASL Its size 23mm x 21 mm x 16 mm makes it suitable to study collective behavior with a large quantity of robots on a table Two watch motors with wheels and tires can drive Alice at a speed of 20 mm per second A PC16C84 microcontroller with 1Kword of EEPROM program memory allows developers to reconfigure its intelligence This robot is powered by two watch batteries providing it with an autonomy of about 8 hours A number of extension turrets can be plugged in on the top of the robot The only extension turret used in Webots is the IRCom turret which is depicted on figure 2 16 2 8 2 Programming the Alice robot In its current configuration the Alice robot needs to be remote controlled using an infra red
51. hat the prey is equipped with a Panoramic turret but it doesn t use it at all It stands here just because of its shape and color to help the predator seeing the prey This experiment is a good example of communication between the supervi sor and the robots The source codes for this experiment are in the chase supervisor predator khepera and prey khepera directories 56 CHAPTER 3 SAMPLE WEBOTS APPLICATIONS 3 12 stick pulling wbt _ World Editor Sticks pulling wbt File Edit Simulation Options x 18 mou e p usnm E NW Li E EN j l E oa E OIX Figure 3 11 stick pulling wbt This experiment of collective robotics was developed by Auke Jan Ijspeert IDSIA LAMI EPFL Switzerland Five robots collaborate to extract wood sticks from the ground These sticks are too long to be extracted by a single robot equipped with a gripper hence the robots find grasp pull the stick and wait for help from another robot The source code for this experiment is in the stick pulling supervisor and stick pulling khepera directories 3 13 ALICE WBT 57 3 13 alice wbt Word Editor alice wbt E X File Edit Simulation Options see mone po mms ic Robot identifier 0 Forward Backward Right Left Stop Emm gv o ism Figure 3 12 alice wbt This example shows how to con
52. heir position configuration and controller code Supervisors are defined only by their controller code A world file should contain no more than a single supervisor 89 90 CHAPTER 7 ADVANCED WEBOTS PROGRAMMING 7 1 3 Textures A subset of the VRML 97 texture nodes 1s supported in Webots 2 0 You might make use of them to set any image as a texture for a specific shape Texture files must be in PNG format and their location must be specified relative to the world directory usually all textures are stored in the textures subdirectory of the world directory A texture image should have a minimal size of 64 x 64 pixels Moreover its width and height should be a power of two otherwise it will be truncated to the first inferior power of two For example if a texture image is sized 150 x 300 pixel it will be truncated to a 128 x 256 image before proceeding the rendering Textures can be applied to Wall Can Cylinder Box and convex IndexedFaceSet nodes Please refer to the reference manual to see in detail which are the supported nodes and corresponding fields 7 2 Using external C C libraries All the sample programs in the Webots distribution are C programs which don t rely on external libraries However it is possible to develop C programs as well and to make use of external libraries In order to do so you will have to modify your Makefile files Webots include files are designed to support C as well 7 3 Interfacing
53. his window To get back to it you will have to double click on the corresponding robot in the world window There is theoretically no limit to the number of robots being simulated However the limit is actually the limit of your computer resources memory speed inter process communications etc and your patience 2 6 3 Moving the Khepera Several ways allow you to move the robot You can either o use the buttons for moving rotating objects o click on the little arrow buttons on the robot representation between both motors 2 6 WORKING WITH THE KHEPERA ROBOTS 35 color distance measurement light measurement blue no obstacle detected no light source detected cyan obstacle away light source away green obstacle nearby light source nearby yellow obstacle close light source close red obstacle very close light source very close Table 2 2 Khepera sensor values o press the arrow keys on your keyboard however you must be careful that the robot window is the current active window o type new coordinates and orientation in the X Z and a text fields X and Z correspond to the position of the robot on the floor expressed in meters m while a corresponds to the orientation of the robot expressed in degrees deg You will have to press the enter or return key after editing each coordinate or orientation field so that your changes are taken into account Moving the robot this way won
54. ice files as seen previously and also to set up a number of default paths and files see figure 2 17 Preferences X Paths and Files Default world default wbt world path hone john webots wor lds CrossComp path home GCC Controller path hone john webots controllers Serial ports dev cual B dev cual Ok Cancel Figure 2 17 Webots preferences The figure 2 17 describes the typical properties on UNIX On Windows you will find COM1 and COM2 instead of dev cua0 and dev cual and the following directories Program Files Webots2 0 worlds C GCC and 2 10 DIRECTORY STRUCTURE 43 Program Files Webots2 0 controllers The Default world is changed each time you quit Webots It is replaced by the current world when Webots quits The World path is the path in which Webots is looking for world files It is changed when successfully loading a world from a new directory The Controller path is the most important since it is the path in which Webots will look for controllers directories when loading a world containing a supervisor and or robots Note that Webots will also look in its own WEBOTS_HOME cont rollers directory Hence if you load a world and neither the controller path nor the WEBOTS_HOME cont rollers directories contain the requested controllers mentioned in this world then Webots will fail running this world So when setting up you
55. in C GCC as suggested in the khepack instructions you must have the khepack in the following directory C GCC khepacks5 2 The khepack directory must be named khepack5 even if you have a different version for example 5 02 Please make a copy of the directory in the cross compiler directory see 1 and rename it to khepack5 22 CHAPTER 1 INSTALLING WEBOTS 1 3 4 7 The preferences file When Webots is first ran the preferences file is created as c windows system webotsre where c windows is the Windows directory You can edit it and make changes using a text editor it is a text file or directly from the Webots menu You can also delete this file if something goes wrong and then re run Webots to create it again 1 3 4 8 Uninstallation Before installing a new version of Webots you will have to uninstall the old one if any and remove the entire directory and files Do not delete your webot s key file Chapter 2 Webots Basics 2 1 Running Webots On UNIX type webots to launch the simulator On Windows click the start button on the system bar go to the Programs Cyberbotics menu and click on Webots 2 0 You should see the world window appear on the screen see figure 2 1 From there a number of possibilities are available through menus and buttons The control wheels and their associated buttons on the left right and bottom side of the window allow you to navigate in the scene You can also click in the scene to se
56. ions is always a pointer specifying the node which is going to be altered The following arguments depend on what kind information needs to be altered For example changing the color of a node will require to pass a pointer to the node as the first argument and the red green and blue levels as the second third and fourth argument See the reference manual for a complete list and description of the different eai set xxx functions 5 1 3 2 eai delete node The EAI function eai delete node is useful to delete nodes from the world The is currently no way to create new nodes from the supervisor 5 1 3 3 eai refresh world If the simulator is not running in Run mode i e not updating regularly the scene then the changes performed with a eai set xxx function will not be visible in the scene until the dis play is updated In order to force to refresh the display of the world the supervisor process can use the eai refresh world function 5 1 4 Sending messages to the robots 5 1 4 1 Overview The only way to control Alice robots in Webots is to send them messages corresponding to behaviors In order to proceed it is necessary to get a pointer to the Alice robot we want 5 1 EAI EXTERNAL AUTHORING INTERFACE 79 Command Identifier Number of bytes ALICE FORWARD 1 1 ALICE_BACKWARD 2 1 ALICE_RIGHT 3 1 ALICE_LEFT 4 1 ALICE_SENSO
57. isplay ing your data and design your own user interfaces fulfilling your specific needs 38 CHAPTER 2 WEBOTS BASICS 2 69 Moving to the real Khepera via the serial connection From the robot properties window it is very easy to switch from a virtual robot to a real robot In order to proceed you will need a real Khepera robot connected via a serial link to your computer From Webots you can choose whether to control the real robot from the simulator or to cross compile and download the controller to the real robot In the first case data 1s being sent continuously from Webots to the Khepera and vice versa 1 e to read sensor data and send motor commands In the second case the robot controller is cross compiled for the real robot processor and downloaded to the real robot which in turn executes the controller on board and no longer interacts with the simulator 2 6 9 1 Remote control of the real Khepera Here are the steps to follow in order to set up a real robot connected to the simulator o Load a controller into the simulated robot braiten khepera is a good example for testing the real robot control o Connect the real robot to one the serial ports of your computer see the manual of your robot to proceed o Set the robot serial mode to 38400 baud mode 3 on both the simulated robot and the real robot Hence the jumper configuration of the real robot should correspond to the jumper configuration of the simulated robot The jum
58. l product The analog artificial retina was developed at CSEM Swiss Center of Electronics and Microtechnics It features a linear black and white analog retina front view of 240 degrees a 150 pixel horizonal resolution a grey scale resolution of 64 levels on chip analog filtering capabilities Note this is a top turret Ok Figure 4 11 The real panoramic turret prototype 4 5 WORKING WITH EXTENSION TURRETS World Editor finder wbt OX xe jas uerbo _ Figure 4 13 The robot window for the panoramic turret 75 76 CHAPTER 4 PROGRAMMING WITH THE KHEPERA API Chapter 5 Programming with the Supervisor API The Supervisor API is very useful to control experiments to record interesting data like sensor information robot trajectory or any statistics to introduce abstract sensors to make the robots communicate with each other etc 5 1 EAI External Authoring Interface The External Authoring Interface API allows the supervisor controller to read and edit the world loaded in the simulator This API is quite similar to the VRML 97 External Authoring Interface allowing Java applets to communicate with VRML 97 scenes within a Web browser In our case the supervisor controller process is able to communicate with the simulator in a similar way 5 1 1 Getting a pointer to a node Each object in the world is called a node like VRML 97 nodes Each node
59. lect an object Alice Ball Can Ground Khepera Lamp or Wa11 or double click on an object to open its properties window The About window is available from the About item in the File menu This window displays the license information To quit Webots you can either close the world window or use the Quit item in the File menu 2 2 Running a simulation In order to run a simulation a number of buttons are available which correspond to menu items in the Simulation menu B Stop interrupt the Run the Fast mode o Step execute one simulation step 23 24 CHAPTER 2 WEBOTS BASICS World Editor default wbt ED dejao ee 108 minis DID Figure 2 1 Default world Step turn on off the recording mode to export the simulation to an animated GIF image Run execute simulation steps until the Stop mode is entered Fast same as Run except that no display is performed The Fast mode corresponds to a very fast simulation mode suited for heavy computation ge netic algorithms vision learning etc However since no display of the world is performed 2 3 EXPORTING AS ANIMATED GIF UNIX ONLY 25 during Fast simulation the scene in the world window becomes black until the Fast mode is stopped A speedometer see figure allows you to observe the speed of simulation on your computer It indicates how fast the simulation runs compa
60. mputer on Monday then another people could use it on an other computer on Tuesday etc This is very useful for example for institutions sharing the utilization of Webots among different groups of people However having a single license will require that you get synchronized with other people so that no more than one computer is used to run Webots the same day If several people need to use Webots the same day and cannot share the same computer like with student classes or teams of researchers using extensively Webots then you will need to purchase a multiple license corresponding to the number of simultaneous users Webots licenses determine the number of computers on which you can run Webots not the number of users using Webots at the same time That is with a single Webots license several users can run Webots on a server computer from their local terminals The main disadvantage of this is that the speed of Webots will decrease as the number of users increases and this may lead to very poor performance when for example a class of students is using Webots from the same server The workaround to this kind of problem is purchasing additional licenses When installing Webots you will get a license file called webots key containing your name address and user ID This encrypted file will enable you to use Webots according to the license you purchased This file is stricly personal you are not allowed provide copies of it to any third pa
61. n Here is some help for installing the compilers 1 Microsoft Visual C 6 0 Follow the normal procedure for installing this compiler You will be prompted to choose whethever to change the autoexec bat on Windows 9x or the PATH environment variable on Windows NT If you choose this way you want have to do anything more Otherwise you have to do it manually In order to set the environment variable for the command line compilation you have to add in the AUTOEXEC BAT file these lines path path where MSVC is installed bin vcvars32 The first line sets the path for the executable of the compiler e g c1 exeandlinker exe the second line calls VCVARS32 BAT file that sets the environment for the compiler Reboot your computer If you receive a message like out of environment space you have to go to the Properties of the MS DOS console and set in the Memory tab the initial en vironment space to a higher value 1024 for instance or better you can add the following line to Config sys shell c command com e 1024 p 2 Cygwin The Cygwin compiler is a GNU compiler so you can get it for free from the web site http sourceware cygnus com cygwin download html or from our ftp server at ftp cyberbotics com cygwin full exe At the time writing the current release is the Beta 20 1 Install the software following the installation instructions then modify the AUTOEXEC BAT in order to set the environment variable for
62. nctions allow you to read the properties of an object They apply to any object These functions look like this gui xxx get yyyorgui xxx is yyy where xxx is the name of an object and yyy is the name of the property to be read The gui xxx is yyy functions always return a boolean value whereas the gui xxx get yyy may return any type The first argument of these functions is a handle to the object Other arguments may be used to retrieve some values or specify more precisely the read request All the read functions are described in detail in the Reference Manual 6 1 4 4 Write functions Write functions allow you to alter the properties of an object Except for utilitiy objects the first argument of a write function is a handle to the object Write functions can have various forms including but not limited to the following gui xxx set yyy o gui xxx show o gui xxx hide o gui xxx enable o gui xxx disable o gui xxx activate o gui xxx desactivate o qui xxx change yyy etc 84 CHAPTER 6 USING GUI THE GRAPHICAL USER INTERFACE API where xxx is the name of the object and yyy if any is the name of the property to be changed Usually the gui_xxx_set_yyy functions will change the property yyy of an object xxx with out redisplaying it whereas the gui_xxx_change_yyy function will change the property y y y of an object xxx and redisplay it For example the gui rectangle change color will change the color of the specified
63. nimated GIFs from Webots If not installed you will be able to find it in the ImageMagick package which lies in the libraries directory of the CD ROM 1 3 2 Macintosh PowerPC YellowDog Linux MkLinux or Linux PPC The installation procedure is the same as for the PC 1386 Linux system except that you must install the RedHat packages Mesa 3 0 1 ppc rpm and webots 2 0 1 ppc rpm cor responding to the Linux PowerPC architecture 1 3 3 Sun Sparc Solaris 1 Logonas root 2 Insert the Webots CD ROM and mount it 3 Check whether the OpenGL library is installed what usr lib libGL so If it is installed you should get a message indicating the release version The most recent version is 1 2 as of December 18 1998 If it is not installed or you would like to get the latest release you can either install it from the CD ROM in the Libraries opengl directory or go to http www sun com solaris opengl and follow the instructions to get it installed 1 3 INSTALLATION PROCEDURE 17 4 10 11 12 13 If you have Sun OpenGL installed copy the file webots2 0Solaris tar gz lo cated in the webot s directory on the CD ROM to your usr local directory This directory is taken as an example and can be changed according to the organization of your file system If you don t want to install Sun OpenGL you can use the package we bots2 0SolarisMesa tar gz instead of webots2 0Solaris tar gz Execute cd
64. ntain the compilation command that Webots will execute for the automatic compilation pro cedure The option nocompilat ion makes Webots skip the automatic compilation 1 you must compile the controller on your own from the DOS console as described earlier Also the absence of the makefile file makes Webots skip the compilation stage 4 1 4 Modifying the controller On UNIX to test the whole editing compilation run process you can copy the whole crazy khepera directory in your home directory cd 7 mkdir webots cd webots mkdir controllers cd controllers cp r usr local webots controllers crazy khepera 62 CHAPTER 4 PROGRAMMING WITH THE KHEPERA API and try to modify the crazy file by changing the value of the right speed to 5 instead of 5 for example Save the modified file and run the make command If no compilation errors occur new object and executable files should be created You can now launch Webots and load your own crazy khepera as a controller for a robot be careful to select your own directory you have just created and not the default one which is usually usr local webots controllers On Windows you can easly copy the whole directory crazy khepera in your own project directory by using the Windows resource manager This way you can modify the con troller without loosing the original file From there you can again modify the crazy c source file You can also add header files or new sou
65. o you won t be able to observe different motor values unless you load a controller which is driving the motors and make it run see later 2 6 6 Jumper configuration The jumpers represented below the left motor can be switched on and off by clicking on them Since the robot can read these jumpers this interface can be used as a communication way between the robot and you However the jumpers configuration should not be changed when using a real robot in remote control or download mode 2 6 7 Extension turrets K Bus Like on the real Khepera robot it is possible with Webots to add extension turrets through the Khepera extension bus called the K Bus In order to plug in an extension turret into your virtual Khepera you just need to click on the K Bus button This will make a window appear in which you will be able to select an extension turret for the robot as depicted in figure 2 13 The central popup menu in the bottom of the window will allow you to plug in a number of extension turrets including o Khepera K213 a black and white linear camera o Khepera K6300 acolor video camera 2 6 WORKING WITH THE KHEPERA ROBOTS 37 Plug in a module K bus XA Khepera Gripper Turret The gripper turret for the Khepera robot is a commercial product developed by K Team 5 4 It allows Khepera to detect the presence of an object to grasp it to measure its electrical resistivity to load unload and ungrasp it Hence objects
66. owever Can objects cannot be grasped this way Grasping of Can objects may occur only when the robot controller is running Run Step or Fast modes 4 5 4 Panoramic turret The real panoramic turret is actually not commercially avaible for the Khepera robot see figures and T3 It is currently a prototype developed at LAMI EPFL by Yuri Lopez de Meneses This turret provides a black and white linear panoramic view around the robot It covers 240 degrees on a linear array of 150 pixels Each pixel has a resolution of 64 grey levels The sensors on this turret correspond to the different types of data you can get from the artificial retina They include raw image data and some filtered image data see the reference manual for more info on these filters The raw data can be obtained from the panoramic_get_raw function The panoramic set parameters function is used to set a number of parameters for filtered images The panoramic set window function allows one to optimize the speed of sensor computa tion by reducing the angle of view of the camera It defines a window within the 150 pixel array that will be computed instead of computing each of the 150 pixels Finally the panoramic set precision function can be used to reduce the resolution of each grey level pixel This precision is expressed in bits and ranges from 1 to 6 bits 1 e from black and white up to 64 grey levels The grey levels can be represented as a graph and or as
67. ows user environment examples Figure 2 19 Webots directory structure WEBOTS BASICS Chapter 3 Sample Webots Applications This chapter provides an overview of the sample applications provided within the Webots pack age All these examples correspond to world files located in the webots worlds directory and can be easily tested while reading this chapter The source code for the examples is located in the webots controllers directory For each example a short description is provided However this description does no attempt to be exhaustive and should be considered as an intro duction More details can be found in the source code 3 1 simple wbt This is the default world It is a very simple square area with a few colorful boxes and a Khep era robot The Khepera has a Braitenberg controller source code in the braiten khepera directory and no extension turret and therefore moves forward while avoiding obstacles 45 46 CHAPTER 3 SAMPLE WEBOTS APPLICATIONS 3 2 five wbt EL LE LR File Edit Simulation Options xem 1 99 Pn cee OT rk B Figure 3 1 five wbt This example is a bit more interesting since five Khepera robots are moving in a maze Each of these robots has a Braitenberg controller loaded Running the simulation will make all the robots move in the maze while avoiding each other as well as obstacles It can be entertaining to select one robot and choose the Robot View item in
68. pers of the simulated robot can be config urated from the widget situated just below the left motor in the robot window However the default configuration of the simulated robot is actually mode 3 which corresponds to 38400 bauds Note that slower serial modes can be used as well 1 mode 1 and mode 2 o Check that the serial ports are properly configured by checking the preferences window Options menu Preferences item On UNIX the serial ports A and B should point to the corresponding directories Default values should be all right Normally these directories should be readable and writable from any user crw rw rw If not set the attributes of these files properly using the chmod command as root On Windows the name of the serial ports are typically COMI and COM2 To verify the correctness of the settings please refer to your main board manual o In the upper left corner of the robot window change the popup menu from Simulated to Remote Serial AorRemote Serial B according to the port on which the robot is connected A popup window should inform you that everything goes right as depicted in figure 2 14 2 6 WORKING WITH THE KHEPERA ROBOTS 39 Message C Connection established at 38400 baud Bios version 5 02 Protocol version 5 01 OK Figure 2 14 Successful serial connection o Click on the Ok button and run the simulation The real robot should move while avoiding obstacles You will be able to see the
69. pically an obstacle for robots For the creation of each of these objects a popup window will appear displaying the properties of the object You will then be able to change the position orientation color etc of the objects Usually the coordinates indicate the center of the object just like in VRML 97 However the y coordinate of the Can is an exception It should always be set to 0 indicating that the can is set on the ground Here are some examples of properties windows depicted on figures 2 4 2 5 and The Resistivity parameter of Can object corresponds to the electrical resistivity of the object as it can be measured by the sensor of the Gripper turret of the Khepera robot This value ranges from 0 to 255 The Intensity parameter of the Lamp object allows one to change the power of the light bulb so that infra red sensors are more or less sensitive to this object A value of 0 means that the lamp is off while a value of 1 means that it is on with the default power However unlike with most 3D rendering software there is no special lighting rendering effects due to the presence of such a Lamp in the scene Such effects would slow down drastically the simulation speed The Wa11 is probably one of the most complex object to edit since it contains a variable number of vertices By default four vertices 11 is created but you can add new vertices You can also remove vertices as long as at least three vertices remain
70. port Contents o W D lt Hardware requirements Registration procedure Webots Floating License 5 uk x 4 0v X R 8 8 ROS e 3 1_ PCi3850 LlinuxX 222A un SPATC SOLAS 44 4 home oes ec 4 Windows 95 Windows 98 and Windows NI 2 Webots Basics D R Webots on os 2 3 Exporting as animated GIF UNIX onlv 2 4 ontrolling the point view 2 5 4 ut and paste operations CONTENTS 2 6 Working with the Khepera robots 32 2 6 4 ensor representation ls 35 2 6 Motors representation 36 2 6 6 umper configuration 36 2 6 8 Khepera controllers 37 2 6 9 Moving to the real Khepera via the serial connection 38 D Working with Supervisor 40 3 4 p Da Se ee eo eee eo ee dd ee oe mb Se tb 48 D tinderwbdt 49 50 D adackerwbll es ea ee Re KR ve ea
71. produce a crash of the controller program Hence we should add the following line for sanity my_rectangle NULL 86 CHAPTER 6 USING GUI THE GRAPHICAL USER INTERFACE API 6 4 Working with widgets Widgets are a bit more complicated than gobs since they provide user feedback to the controller program It is possible to create widgets the same way as for gobs However for handling widget input some additional code has to be implemented Widgets include buttons checkboxes popup menus and textfields as shown in figure 6 1 Close button mE checkbox load Simulated E popup Hello B textfield Figure 6 1 Widgets available in the GUI 6 4 1 Events Events are well known to any programmer dealing with graphical user interfaces The event model in the GUI is very simple to understand and use Different kinds of event in the GUI are listed here All of them except TIME UP are a direct consequence of the user action with the mouse or keyboard o GUI MOUSE DOWN o GUI MOUSE UP UI MOUSE MOVE UI KEY DOWN UI KEY UP UI WINDOW CLOSE UI WINDOW RESIZE UI TIME UP UI WINDOW ENTER QA A A A QAQ UI WINDOW LEAVE 6 4 WORKING WITH WIDGETS 87 6 4 2 Callback function The callback function is a function you will write within your program and declare to the GUI so that it is called whenever an event occurs void my_call
72. r own development environment we recommand that you create your own controllers directories for robots and supervisors in your home directory or sub directories and you set up appropriately the corresponding paths in the Preferences window although Webots should set it automatically when you load a new controller 2 10 Directory structure On UNIX the webots directory typically located in usr local is organized as depicted in figure 2 18 webots LICENSE html license agreement for the preview version biosKhepera cross compilation library for Khepera controllers controller program examples images images used internally by webots include include files necessary to the controllers lib libraries needed by the controllers webots Webots application webotsrc default webotsrc file webots key license file webots xpm Webots logo worlds environment examples Figure 2 18 Webots directory structure On Windows the structure is almost the same see figure 2 19 44 webots LICENSE html biosKhepera controllers images include lib webots exe webotsrc webots key windows html worlds CHAPTER 2 license agreement for the preview version cross compilation library for Khepera controller program examples images used internally by webots include files necessary to the controllers libraries needed by the controllers Webots executable default webotsrc file license file Information for the Wind
73. rce files and modify the Makefile on UNIX the Makefile gcc ormakefile vc6 on Windows according to the source files which need to be compiled It s much easier to build your own system starting from such an example rather than starting from scratch Note that the prefix of the name of a controller directory 1 my_controller khepera must be the same as the name of the executable file 1 my_controller If this is not true Webots will be unable to launch your controller 4 2 Webots execution scheme 4 2 1 Khepera controllers Indeed the controller programs are under the control of the Webots simulator In other words they can be launched and quitted only by the simulator The simulator operates during the khep era_step function During this function call it computes the requested sensor values and updates the position of the robot according to the motor values Then it can either o return to the execution of the controller Run and Fast modes o suspend the execution of the controller Step and Stop modes o exit from and destroy the controller when loading another controller cutting the robot or quitting Webots The khepera step function simulates a number of milliseconds of a real robot running Re quested sensors have to be enabled before calling khepera_step and their values will be avail able after this call Actuator commands have to be requested before calling to knepera_step so that they are actually perform
74. rectangle and redisplay it 6 2 Getting started The very first thing to do when designing a graphical user interface is to create a first window This can be achieved by issuing a gui_window_new function gui_window my_window my window gui_window_new My First Window 10 10 200 100 Note the controller program must always be initialized first that is the xxx live function where xxx may be supervisor or khepera should be called before attempting to use any of the GUI functions Now in order to add some text in this window we will use the following function void gui label new my window 20 20 Hello world This function returns a handle to the new label object it has created but since we don t need it we will just ignore the return value of this function by casting it to void After this stage your window exists and contains some text label but it is not visible on the screen In order to make it appear you will have to use another function gui window show window Now we have a very simple yet complete graphical user interface working within a controller program 6 3 Editing adding and deleting gobs 6 3 1 Editing gobs In order to make this simple graphical user interface more useful it may be interesting to dynam ically change the text of the label we just created according to the internal state of the controller program This can be achieved by changing a little bit the original
75. ring to real time In other words it represents the speed of the virtual time If the value of the speedometer is 2 it means that your computer simulation is running twice as fast as the corresponding real robots would do This information is relevant in Run mode as well as in Fast mode 64 ms Figure 2 2 Speedometer The time step can be choosen from the popup menu situated next to the speedometer It indicates how frequently the display is refreshed It is expressed in virtual time milliseconds The value of this time step also defines the duration of the time step executed during the Step mode In Run mode with a time step of 64 ms and a fairly simple world displayed with the default window size the speedometer will typically indicate approximately 0 5 on a Pentium II 266 without hardware acceleration and 4 on an Ultra Sparc 10 Creator 3D 2 3 Exporting as animated GIF UNIX only The Record mode will allow you to export a simulation as an animated GIF file that can further be used to set up nice web pages or multi media presentations In order to proceed you will need to have the convert utility installed see intallation procedure in this manual Webots will save each image in PNG format in the temporary folder Then it will invoke the convert program to produce the animated GIF file from the PNG images However note that the animated GIF files produced here are not optimized and hence can be huge So reduce the size of the
76. rocedure 18 CHAPTER 1 INSTALLING WEBOTS 1 3 4 1 Choose the compiler In order to create the robot controller programs you need to have a C C compiler installed in your computer The compilers supported by Webots are Microsoft Visual C 6 0 and CygWin 20 1 GCC You can obtain CygWin for free from the web site http sourceware cygnus com cygwin or you can find a copy on our ftp server ftp ftp cyberbotics com During the installation you will be prompted to choose one of these compilers You can install Webots first and install the choosen compiler after or vice versa You can also choose the option No compiler In this case you will be able to view the examples included in the distribution but you will not be able to compile them If you have your own compiler already installed and want to use this you have to choose the No compiler options too In this way you can develop your own controllers using your compiler but you have to manage the compilation routines manually You will be able to change the compiler also after installation of Webots by editing and typing some changes in the text file makefile scp see later for more details 1 3 4 2 OPENGL32 DLL amp GLU32 DLL Webots uses the OpenGL graphic library for rendering the 3D scene The dynamically linked libraries openg132 d11 and g1u32 d11 will be installed in your operating system directory for example C Windows System if not already present These
77. rty in any way including publication of that file on any Internet server web ftp or any other public server Any copy of your license file is under your responsibility If a copy of your license file is used by an unauthorized third party to run Webots then Cyberbotics would disable your license to prevent such an illegal use preventing also you from using Webots until the problem is fixed If you need further information about the Webots Floating License System please send an e mail to license cyberbotics com Please read your license agreement carefully before registering This license is provided within the software package By using the software and documentation you agree to abide by all the provisions of this license 1 2 2 Registering In order to register your computer s to run Webots you will have to fill out a form on the Web and you will receive via e mail the webot s key file corresponding to your license The form is available at the following web address 1 3 INSTALLATION PROCEDURE 15 http www cyberbotics com registration webots html see figure 1 Ea Netscape Cyberbotics Webots Registration B File Edit View Go Communicator Help 19 X 4 3 Thank you for filling this form Title Mr First Name EOF Last Name el E mail FO Address EN State Y Figure 1 1 Webots registration page Please take care to properly fill each field of this form The Serial Number
78. seless controllers by pressing once and only once oth erwise you risk to reboot your system the combination of keys CTRL ALT DEL Using the arrow keys choose the process corresponding to the controller to remove Press Enter or click in the End Task button Problem Webots crashes each time I launch it Solution Remove the webotsrc file from your home directory on UNIX or from your Win dows system directory on Windows and relaunch Webots Problem On UNIX the real robot doesn t work via the serial link Webots says Unable to open serial port Solution Check that the permissions of the serial device files are set appropriately These files must be readable and writable by all the users For example to check dev cua0 you 93 94 CHAPTER 8 TROUBLESHOOTING can do ls 1 dev cua0 crw rw rw 1 root uucp 5 64 Aug 27 16 59 dev cua0 These are the right permissions If they are different you can change them by logging on as root and typing chmod a rw dev cua0 Problem On Windows Webots cannot compile any controller present in the original distribu tion of Webots Solution Check if your compiler is properly installed in the following way delete or rename the file makefile scp in the controllers directory in order to skip the automatic compilation and try again to load the controller Problem On Windows Webots cannot compile my own controller program Solution Compile your controller program manu
79. t and move objects in the world o This turn button allows you to rotate objects click on this button to enter the turn mode then click on an object to select it and then click somewhere else and drag the mouse pointer to rotate the selected object 6 Figure 2 7 Vertice ordering in Wall nodes 2 5 EDITING THE ENVIRONMENT 31 o qT This lift button allows you to translate objets along the vertical axis It is especially suited for Ball and Lamp objects o This move button allows you to translate the object on the ground using familiar drag n drop interface It is probably one of the most useful modes o Li This pointer button allows you to select an object by clicking on it and to open its properties window by double clicking on it 2 5 4 Cut copy and paste operations The standard editing operations are avaible either from the Edit menu or the following buttons A Cut o Copy O Paste In order to perform the Cut or Copy operation you first need to select an object by clicking on it in the scene Pasted objects will appear close to their original clone You will have to turn move or edit the coordinates in their properties windows to move them to the desired location and orientation Note that robots are special objects which can be cut out but not copied nor pasted 2 5 5 Changing the Background The Background item in the Edit menu will allow you to define the color of the back ground in the world
80. this world makes an extensive use of VRML 97 nodes which were not created with Webots but with a text editor 54 CHAPTER 3 SAMPLE WEBOTS APPLICATIONS 3 10 house wbt H World Editor house wbt lt File Edit Simulation Options see es b p Figure 3 9 house wbt This example also developed by G rald Foliot models a simple schematic house sized for the Khepera robot with doors windows corridors and rooms in which you can run your own exper iments Such an environment 1s well suited for indoor navigation tasks for which the problem of recognizing and passing doors is an important issue The robot is equipped with a vision sensor since it seems to be the most suitable type of sensor for such environments Note that this world makes an extensive use of VRML 97 nodes which were not created with Webots but with a text editor 3 11 CHASE WBT 55 3 11 chase wbt 4 World Editor chase wbt X File Edit Simulation Options came mue nl 4 m Figure 3 10 chase wbt This experiment shows a record of the genetic evolution of neural networks for the prey predator experiment developed by Dario Floreano LAMI EPFL Switzerland The robot with the K213 vision turret is the predator and is trying to catch the prey while the prey relies only on infra red sensors to escape from the predator Note t
81. trol several Alice robots from a supervisor by sending messages to the robots A graphical user interface allows the user to select an Alice robot though a popup menu and send it some command The source code for the supervisor controller is in the 1 ice supervisor directory 58 CHAPTER 3 SAMPLE WEBOTS APPLICATIONS Chapter 4 Programming with the Khepera API 4 1 My first Khepera program 4 1 1 Source code Here is one of the simplest C program you can write to control the Khepera robot include lt Khepera h gt We just need Khepera stuff void main khepera_live Initializes the robot for Endless loop khepera set speed LEFT 5 Set the motors to khepera set speed RIGHT 5 the same speed khepera step 64 run one step of 64 ms and repeat this forever This very simple program will make the Khepera robot move forward until it bumps into an obstacle if ever The speed of the Khepera will be of 40 mm s since the speed unit is 8 mm s for the khepera set speed function If you set different speeds to each motor you will observe the robot follows a circular trajectory You may also set negative speed values and observe the robot going backwards Finally if you set opposite values to the left motor and to the right motor you will be able to see the robot spinning on itself like a top This program however illustrates some fundamental aspects of
82. view as much as possible and don t make too long movies Actually each image is stored in the GIF file whereas it would be possible to optimze it by storing only the changes from one image frame to the other In order to proceed such an optimization we recommand you to use the Gimp software GNU Image Manupulation Program which is a very powerful free software tool This software is included on the Webots CD ROM and can be used under the terms of the GNU General Public License On Windows this feature is not working 2 4 Controlling the point of view The view of the scene is produced by a camera which is set according to a given position and orientation You can change this position and orientation to navigate in the scene Moreover you 26 CHAPTER 2 WEBOTS BASICS can set the camera to follow the movements of a given robot or to remain fixed 2 4 1 Navigating in the scene To navigate in the 3D scene you can use the three control wheels situated on the edges of the world window Each wheel is associated with a button allowing to switch between a rotation and a translation Hence you can control six degrees of freedom to move the camera in the scene These degrees of freedom are also available from the keyboard when the world window is active as explained in table D I axis Rotation modifier keys Translation modifier keys X tilt shift horizonal scroll ctrl T4 Y pan shift lt vertical s
83. with third party software C and C are not the only programming languages in the world of computers Hence you may want to use another programming language to drive your robots or supervisors Lisp Java Matlab or whatever language can be used within Webots with only a small development effort Moreover interfaces to scientific data display software like gnuplot are also possible and can be achieved the same way Webots needs to dialog with a C or C based controller program which is linked with the controller library However this controller program can be just an interface to the third party software you want to use 7 3 1 Using a pipe based interface The communication between this interface controller and the third party software can be achieved through the use of pipe files as long as the third party software supports reading from and writting data to a pipe file which is however very common Usually you will want to create two pipe files one for the input data coming from the interface controller and going to your third party 7 3 INTERFACING WITH THIRD PARTY SOFTWARE 91 program and another for the output data coming from your third party software and going to the interface controller The development of such an interface can be divided into two stages 1 Develop the interface controller in C This is the easy part since the example inter face khepera is prodived within your webots package 2 Develop the third party so
84. ype gui xxx new where xxx is the name of an object to be created They apply to all kind of objects except utility objects A constructor function takes a number of arguments used to define the object See the Reference Manul for a complete description of the various constructor functions Note For a gob or a widget the first argument is always the handle of the window in which it is created while the second and third arguments are always its x and y coordinates in the window coordinates system Then the following arguments define more precisely the object and are described in the reference manual 6 1 4 2 Destructor functions Destructor functions look like this gui xxx delete Like constructor functions they apply to all kind of objects except utility objects The first and only argument of these functions is a handle to the object to be destroyed A destructor function frees the memory allocated for the object passed as an argument Moreover it makes the object disappear from the screen 6 1 BASICS 83 or window where it was After calling the destructor of an object no further reference to that object can be done otherwise it might crash your program So it is recommanded to set the corresponding handler to NULL immediately after calling a destructor function unless you are sure that this handler can no longer be used gui pixmap p gui_new_pixmap gui pixmap delete p p NULL 6 1 4 3 Read functions Read fu
Download Pdf Manuals
Related Search
Related Contents
MSI V212-066R ATI Radeon HD5450 1GB graphics card 2112 N95 FastFit Power For The mini-Buck Calibrator GRAND MARCHÉ DE PRODUCTEURS BIO il. hi GE 2-9827 Answering Machine User Manual Instructions Product Manual Wire Inspector Ⅱ 取扱説明書 はじめに Wire Inspector Copyright © All rights reserved.
Failed to retrieve file