Sensors
Sensors tell your robot about the world. Every sensor is used in the same way:
- Get it by its name with
robot.getDevice(). - Enable it with
enable(timeStep). Until then, it gives no values. - Read it inside the main loop. Values are updated after each
robot.step().
Like real sensors, they have noise: the same reading can change a little from one step to the next. Organizers do not change the noise for the competition, so make your program robust to it, for example by comparing several readings.
The pages below use the sensors of the starter robot.
Distance SensorFind walls next to the robot.
Location SensorKnow where the robot is, with the GPS.
Colour SensorSee the floor: holes, swamps and passages.
RGB CameraSee the walls, and find wall tokens.
LIDARMeasure distances all around the robot.
Gyro and AccelerometerMeasure turns and acceleration.
