A standard unit turns raw sensor readings into comparable physical quantities. In robotics, conversion makes an analog voltage meaningful as distance in meters or brightness in candela. section 3.2.1
The conversion is sensor-specific: an optical distance sensor has a nonlinear voltage-to-distance relationship, so calibration or a lookup table maps discrete voltages to meters. section 3.2.1
Distance and brightness
A distance function can return 0.4 m for a mapped voltage instead of exposing the raw voltage. Similarly, get_brightness() converts voltage to candela before comparing it with an activity threshold. section 3.2.1
Listing 3.3
voltage_to_distance = [0.0] * 32 voltage_to_distance[0] = 0.8 # 0.0 V -> 0.8 m ... voltage_to_distance[4] = 0.7 # 0.4 V -> 0.7 m voltage_to_distance[5] = 0.6 # 0.5 V -> 0.6 m voltage_to_distance[6] = 0.5 # 0.6 V -> 0.5 m voltage_to_distance[7] = 0.4 # 0.7 V -> 0.4 m ... voltage_to_distance[31] = 0.05 # 3.1 V -> 0.05 m def distance(): discrete_voltage = round(input.value() * 10) distance = voltage_to_distance[discrete_voltage] return distance
Inspect a lookup-table implementation that converts sampled analog voltage values into distances measured in meters. section 3.2.1



