Webots User Guide

previous page go up next page

Foreword

Thanks

1.Installing Webots

2.Upgrading from Webots 2

3.Getting Started with Webots

4.Tutorial: Modelling and simulating your robot

5.Robot and Supervisor Controllers

6.Tutorial: Using the KheperaTM robot

7.ALife Contest

     

5.4 Reading Sensor Information

To obtain sensor information, the sensor must be:

  1. identified: this is performed by the robot_get_device function which returns a handler to the sensor from its name. This needs to be done only once in the reset callback function, which is provided as an argument to the robot_live function. The only exception to this rule concerns the root device of a robot (DifferentialWheels or CustomRobot node) which doesn't need to be identified, because it is the default device (it always exists and there is only one of such device in each robot).

  2. enabled: this is performed by the appropriate enable function specific to each sensor (see distance_sensor_enable for example). It can be done once, before the endless loop, or several times inside the endless loop if you decide to disable and enable the sensors from time to time to save computation time.

  3. run: this is performed by the robot_step function inside the endless loop.

  4. read: finally, you can read the sensor value using a sensor specific function call, like distance_sensor_get_value inside the endless loop.

previous page go up next page
^ page top ^

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