|  | |
5.4 Reading Sensor Information
To obtain sensor information, the sensor must be:
-
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).
-
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.
-
run:
this is performed by the robot_step function inside
the endless loop.
-
read:
finally, you can read the sensor value using a sensor specific function
call, like distance_sensor_get_value inside the
endless loop.

^ page top ^
|