Measuring your robot

A step response: top speed, time constant and dead band, measured rather than assumed.

U1.6The robot as a systemUniversity30 min

Do this lesson in the simulator

A model of a machine is worth nothing until someone has measured the machine. This lesson is the measurement: a step response, the standard first experiment on anything that moves.

The experiment

Start still. Ask for full power, all at once. Record the speed as often as you can. That is it.

from bugbot import *
connect()

speeds = []
forward(100)                      # the step
for i in range(30):
    v = flow()[1]
    speeds.append(v)
    plot("speed", v)
    wait(0.1)
stop()
print([round(v, 1) for v in speeds])

Run this in the simulator

The chart shows the shape that almost every first order system makes: a fast rise that slows as it approaches a level, never quite arriving.

The two numbers

The final value v_max is where it settles. Average the last several readings rather than taking one, because each reading has noise on it.

The time constant tau is how long it takes to cover 63 percent of the way there. That number is not arbitrary: a first order system follows

v(t) = v_max * (1 - exp(-t / tau))

and at t = tau the bracket is 1 - 1/e, which is 0.632. After 3 tau it is 95 percent of the way, and that is the practical answer to "how long until it has really got there".

For this drive expect something around 20 cm/s and around a quarter of a second, with your own robot's spread on both.

The third number

The dead band is the command below which nothing moves at all. Find it by walking a command up in small steps and watching flow():

from bugbot import *
connect()

for power in range(5, 45, 5):
    forward(power)
    wait(0.8)
    v = flow()[1]
    print(power, round(v, 1))
    stop()
    wait(0.4)

Run this in the simulator

A dead band is not a fault to be corrected in software, it is a property of the actuator to be designed around. A controller whose output spends its life below the dead band does nothing at all, which looks exactly like a bug in the arithmetic.

Doing it honestly

  • Repeat it. One run is an anecdote. Three runs and a spread is a measurement.
  • Wait for the transient. Anything measured in the first 3 tau is measuring the rise, not the level.
  • Say which robot. These numbers belong to this robot, on this mat, at this battery level. Another BugBot has its own.
  • Record the conditions. battery() matters more than anyone expects.

Task: the step response

Run a step to full forward power, plot the speed as speed, and print two lines: v_max: and tau:.

from bugbot import *
connect()

speeds = []
forward(100)

Challenges

  1. Do the same for rotation, using imu()[1] as the measurement. Is tau the same?
  2. Step down as well as up: full speed, then zero. Does it slow with the same time constant?
  3. Step to 50 percent instead of 100. Is tau a property of the machine or of the size of the step?