CS452 - Real-Time Programming - Winter 2013
Lecture 17 - Calibration II
Pubilc Service Annoucements
- Due date for kernel four.
- Serial I/O questions.
- Measurement is an activity that is not speeded up by being smart.
- Exam: 16.00, 11 April to 18.30 12 April.
Calibration
Where is it?
A question with two different answers
- A location known by the the person who asked the question, a
landmark.
- A route to the item about which the question was asked, taking the
asker into unknown territory. The route contains
- to be discovered landmarks, such as the second traffic light,
and
- abstract geometry, such as seven metres north, which require
measurement.
Where am I?
The usual answer is a combination of a landmark plus a measurement.
- "I'm half a block past the big tree."
To get the second part of the answer you can
- measure explicitly, by eye or with a tape measure, or
- integrate velocity over time.
The second of these is called dead reckoning. To know
where a train is we use a combination of landmarks, sensors, and dead
reckoning, knowing the train's velocity and how long it has been travelling
since the landmark.
Philosophy
You can't do anything until you know where the train is. You accomplish
this by
- Knowing the train's location when it arrives at a landmark, and
- Interpolating between landmarks by knowing the train's velocity all the
time.
Measurement is costly, and you should squeeze every bit of information you
can out of every measurement you make.
- By analogy with human information processing, I recommend that every
time you get a sensor report you make a prediction
- Which sensor do you expect to hit next?
- When do you expect to hit it?
- When you hit the next sensor you automatically have an estimate of how
fast you travelled between the sensors.
- This estimate is your most recent estimate of the train's velocity
on that piece of train, at that speed.
- Using it to improve the calibration tables is what we call
dynamic calibration.
Display the difference between your prediction and your measurement on the
terminal,
- in time,
- in distance,
- in velocity
This gives you an ongoing feeling for how your application is working,
which is very important for setting effective tolerances.
1. Stopping Distance
The simplest objective:
- know where the train stops when you give it a command to stop
- restrict the stop commands to just after the train passes a sensor
- only one train moving
Notice that if you just do the obvious thing you get it right.
2. Calibrating Constant Velocity
At this point there are a few places on the track where you can stop with
a precision of a train length or better. However, suppose you want to reverse
direction at a switch.
- You want to be close to the switch, clear of the switch, and on the
right side of the switch when you stop.
- You want to know when the train has stopped because until then you
cannot give the command to throw the switch.
- You want to know when the switch-throwing is complete because until
then you cannot start the train running in reverse.
Knowing the Current Velocity
An implicit assumption you are making is that the future will closely
resemble the past.
- You measure the time interval between two adjacent sensor reports.
- Knowing the distance between the sensors you calculate the velocity of
the train
- velocity = distance / time interval
- measured in cm / sec.
Note that on average the lag mentioned above -- waiting for sensor
read, time in train controller, time in your system before time stamp --
is unimportant.
- Sensor1 actually hit at .
- You record (S1, t1 + dt) as the first event.
- Sensor2 actually hit at t2
- You record (S2, t2 + dt) as the second event
- You compute the velocity as (S2 - S1) / (t2 + dt - (t1 + dt)) = (S2
- S1) / (t2 - t1)
- But the variation in dt from measurement to measurement adds noise
to the measurement.
- After many measurements you build a table
- Use the table to determine the current velocity
- Use the time since the last sensor report to calculate the distance
beyond the sensor
- distance = velocity * time interval
Using Resources Effectively
The most scarce resources
- Bandwidth to the train controller
- Use of the train itself
The most plentiful resource
Any time you can use a plentiful resource to eliminate use of a scarce one
you have a win. For example
Practical Problems You Have to Solve
- xmlns="http://www.w3.org/1998/Math/MathML"The table is too big.
- You need a ton of
measurements
- The values you measure vary randomly.
- You need to average and estimate error.
The values you measure vary systematically
- For example, each time you measure the velocity estimate is slower,
presumably because the train is moving towards needing oiling.
- xmlns="http://www.w3.org/1998/Math/MathML"You need to make fewer
measurements or use the measurement you make more effectively.
How Long does it Take to Stop?
Try the following exercise.
- Choose a sensor.
- Put the train on a course that will cross the sensor.
- Run the train up to a constant speed.
- Give the speed zero command at a location that stops the train with its
contact on the sensor
- Calculate the time between when you gave the command and when the
sensor triggered.
- Look for regularities.
How Long does it Take the Train to Get up to Speed?
What would a lazy programmer do?