CS452 - Real-Time Programming - Spring 2011
Lecture 23 - Calibration, Reservations
Pubilic Service Announcement
- Sign up for first milestone demo.
- Acceleration/deceleration pdf.
Stage 3. Calibrating Acceleration and Deceleration
Physics of Acceleration and Deceleration
At the core is a relation, (x, t), which is a space-time point. The
relation says that as time passes a train takes up successive positions
x(t).
Teleportation
The first thing that we rule out is teleportation.
A train having infinite velocity is impossible in practice
- Leave to the physicists whether or not it is possible for a train to
have infinite velocity in theory.
No teleportation means that x(t) must be continuous.
Constant Velocity
Suppose you have a train at (x1, t1) and you have to get it to (x2,
t2).
Two questions:
- Is it possible? If the maximum velocity is vmax, and vmax < (x2 -
x1) / (t2 - t1), then it's impossible.
- How do you do it? If vmax > (x2 - x1) / (t2 - t1) then you might try
- Set v = (x2 - x1) / (t2 - t1) at t1
- Use your velocity calibration for this!
- Set v = 0 at t2.
Doesn't quite work.
- Because of acceleration you arrive at x2 after t2.
- Because of deceleration you don't stop until the stopping distance
beyond x2.
You could
- curse the inadequate train dynamics
- put xmax down very slow
- only accept requests for long in the future
- and be successful because the acceleration and deceleration times
are negligible.
But
- It's against the rules, because
- Your project would only be interesting to trees, and
- You would be unsuccessful because of stalling on curves.
More Fundamental
Infinite acceleration is impossible because the train would be crushed, if
not vaporized!
This is true both in theory and in practice.
Constant Acceleration/Deceleration
Intuitively a good idea to minimize acceleration
- Accelerate at a from t1 to (t2 + t1) / 2
- Decelerate at -a from (t2 + t1) / 2 to t2
- Velocity is a*(t2-t1) / 2 - a*(t - (t2+t1)/2 )
Position is ...
- At t2
- Velocity is 0
- Position is x1 + (1/8)*a*(t2 - t1) ^2, which should be x2.
- Therefore choose a = (8 * (x2 - x1)) / (t2 - t1)^2
But, what happens at t = t1, (t2 + t1) / 2, t2?
- discontinuities in acceleration
- experienced as jerk, in fact, infinite jerk
- And you know from experience that when you jerk things hard enough they
break. E.g.,
Constant Jerk
Third order curve for position, second order for velocity, linear
acceleration. We usually go one better, and try to minimize jerk over the
whole journey.
Minimize Jerk
Acceleration/Deceleration is continuous
The result is a fourth order curve in position, third order in velocity,
which is what you try to achieve when you drive.
This is all more correctly, more coherently and more readably here.
Is it Worth Having an Explicit Function?
Benefits
- You can calculate position explicitly without having to do numerical
integration.
- Euler integration is unstable because of accumulating error.
- You can calculate the parameters of a function with less measurement.
How?
- Start at x = t = 0, which assumes that you get the same function
regrardless of position on the track and time of day.
- Check deceleration inverse of acceleration?
- &c.
The idea is that the person who programmed acceleration/deceleration
into the train was lazy, so there's probably one basic function used over
and over again
Drawbacks
- You need to check that the functional form you have is the right one,
or a right-enough one.
- For practical purposes small look-up tables may be perfectly
adequate.
Reservations
Somebody has been doing something right for the last century. The answer
is reservations.
Two Level Train Control
The two levels are completely independent of one another.
- On heavily used sections of track the lower level is done completely by
hardware with no possibility (almost) of human intervention
Upper Level
- Train asks despatcher for a route
- Despatcher provides a route that he/she thinks to be conflict free
- Train follows the route, reporting back to the despatcher as landmarks
(sensors) are passed.
- The despatcher gets two reports
- One from the hardware
- One from the engineer
- It is up to the despatcher to make certain that they do not
conflict
Lower Level
The lower level is encoded in the coloured lights you see along the
track
- Everything is rigidly enforced by hardware
- The human enters the loop only in that the lights tell the engineer
what he/she is allowed to do
- The engineer loses his licence, FOREVER, if he/she ever goes
through a red light.
- If the system ever gets something it doesn't understand, it enters a
failsafe mode
Here's how it works
- Train asks reservation system for several blocks of track
- Blocks usually end at switches and/or sensors
- If you are ending blocks at switches you must know well enough how
enough where the train is to be confident it is completely clear of
the switch.
- Reservation system grants the blocks if they are available
- Grants include the condition that the train must travel so that it
can come to a complete stop without leaving any reserved block.
- In practice this means:
- If all is clear, the train will travel at the same speed until
it makes a new request before the beginning of the next
block.
- At that point it will make a new request, and if that request
is not granted, then it must be able to stop without passing
beyond already reserved track
- In practice you would grant reservations as follows:
- Train is about to enter block n, and is holding reservations to
block n+x, where
- x is defined so that if the train goes to speed zero now it
will stop before the end of block n+x
- First, suppose that the train will continue travelling at the
same speed, s.
- Then it will be travelling at the same speed when it enters
block n+1
- If it goes to train zero at the beginning of block n+1
where will it stop.
- Say, before the end of block n+y, which you calculate using
your calibration.
- Necessarily, y >= x.
- Try to reserve to n+y: if sucessful keep travelling without
reducing speed, i.e. at speed s..
- If unsuccessful reserve as much as you can: say to the end of
block y'
- Calculate, using your calibration, the speed that allows you to
stop by the end of block n+y' if you set the speed to zero at the
beginning of block n+1.
- Check using your calibration that you can reduce to the
steady-state velocity of speed r by the beginning of block n+1.
- You necessarily can by setting the speed to zero.
- Set your speed to the highest speed that allows you to get to
the velocity of speed r by the end of block n+1.
An Interesting Tit-bit That Doesn't Concern You
Real trains are long and sometimes occupy several blocks at once. How does
the engineer know that the end of a train is clear of a switch?
- When an engineer takes over a train he/she is given printed orders that
include the length of the train.
- There is a resetable counter in the locomotive that count the
revolutions of the locomotives wheels
- When the locomotive passes a switch the engineer resets the
counter.
Something Essential that You Must Do
Design your reservation system before coding it.
Before coding your reservation system work it out on paper and make sure
that it works for all the generic cases you can think of
- One train following another
- Two trains on a collision course
- There are one or more switches in the path
Return to: