liveBook · Manning

Unit of measurement

As explained in Robotics for Programmers

A standard unit is an agreed measurement unit that enables comparable quantitative values across instruments and contexts.

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

How Robotics for Programmers covers it

How deep it goes
Explains conversion through sensor physics, nonlinear response, calibration assumptions, and a discrete lookup-table implementation.
Examples
Uses optical distance in meters, brightness in candela, and coffee-supply states derived from thresholded distance.
What it assumes
Assumes familiarity with analog inputs and sensor readings while introducing standard-unit conversion from raw voltage.
What you can do after
Apply sensor-specific conversions so robot code operates on meaningful distance or brightness values instead of raw voltage.
How it connects
Connects standard units with analog inputs, sensor calibration, lookup tables, and threshold classification.

Also explained in

Compare how 4 books explain unit of measurement →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Robotics for Programmers. The section links point to the parts of the book it draws on.