Monitoring sensor values

Sensor values can be monitored in two different ways in Robotics API applications:

The first way should be used when the sensor value is needed only once, as this method is expensive to call. In all other cases, a SensorListener should be registered as indicated above. In this case, the listener is called each time the sensor measurement changes (up to a certain frequency).

In case an application needs to register a large amount of listeners for various sensors, the listeners should be collected and registered by one or few calls to RoboticsRuntime#addSensorListeners(..).

When a SensorListener is not needed anymore (ultimately when an application terminates), it should be unregistered by calling Sensor#removeListener(..).


Reading sensor values requires communication with the real-time control core in most cases, which is an expensive operation. Performance can be increased by using SensorListeners and registering them in one operation. As SensorListeners consume resources of the real-time control core, they need to be unregistered when they are not needed anymore!