|
DovesLapTimer 4.3.0
GPS-based lap timing Arduino library — go-karts to race cars
|
#include <CrossingEngine.h>
Collaboration diagram for CrossingEngine:Public Member Functions | |
| CrossingEngine (double crossingThresholdMeters=7, Stream *debugSerial=NULL) | |
| LineDetectResult | detect (double currentLat, double currentLng, unsigned long currentTimeMs, float currentOdometer, float currentSpeedKmh, const crossingPointBufferEntry *prevFix, double pointALat, double pointALng, double pointBLat, double pointBLng, bool &crossingFlag, int lineLabel, double &outLat, double &outLng, unsigned long &outTime, double &outOdometer) |
| The crossing-zone state machine (formerly DovesLapTimer::_detectLineCrossing). Detects entry, buffers GPS fixes inside the zone, and interpolates the exact crossing point on exit. | |
| bool | getForceLinear () const |
| unsigned int | getRejectedCrossingCount () const |
| Number of crossing-zone exits whose interpolation was rejected. | |
| void | reset () |
| Clears the buffer, the rejected-crossing counter, and any in-flight zone state. Does NOT clear the configured threshold/mode. | |
| void | setDebugSerial (Stream *debugSerial) |
| Attaches / detaches a debug output stream. | |
| void | setForceLinear (bool linear) |
| Selects linear (true, default) or Catmull-Rom (false) position interpolation. Time and odometer are always interpolated linearly. | |
| void | setThreshold (double meters) |
| Sets the crossing zone threshold, in meters. | |
| CrossingEngine::CrossingEngine | ( | double | crossingThresholdMeters = 7, |
| Stream * | debugSerial = NULL |
||
| ) |
| LineDetectResult CrossingEngine::detect | ( | double | currentLat, |
| double | currentLng, | ||
| unsigned long | currentTimeMs, | ||
| float | currentOdometer, | ||
| float | currentSpeedKmh, | ||
| const crossingPointBufferEntry * | prevFix, | ||
| double | pointALat, | ||
| double | pointALng, | ||
| double | pointBLat, | ||
| double | pointBLng, | ||
| bool & | crossingFlag, | ||
| int | lineLabel, | ||
| double & | outLat, | ||
| double & | outLng, | ||
| unsigned long & | outTime, | ||
| double & | outOdometer | ||
| ) |
The crossing-zone state machine (formerly DovesLapTimer::_detectLineCrossing). Detects entry, buffers GPS fixes inside the zone, and interpolates the exact crossing point on exit.
The caller owns the per-line in-zone flag and the vehicle state (current fix + previous-fix snapshot) — the engine owns only the buffer and the math.
| currentLat | / currentLng Current GPS position. | |
| currentTimeMs | Milliseconds since UTC midnight for this fix. | |
| currentOdometer | Total odometer reading at this fix, meters. | |
| currentSpeedKmh | Speed at this fix, km/h. | |
| prevFix | Previous fix snapshot (Catmull-Rom pre-crossing point), or NULL if no previous fix exists yet. | |
| pointALat | / pointALng Line endpoint A. | |
| pointBLat | / pointBLng Line endpoint B. | |
| crossingFlag | Reference to the caller-owned per-line in-zone flag. | |
| lineLabel | Debug label: 0 = start(/finish), 1 = sprint finish, 2 / 3 = sector. | |
| [out] | outLat | / outLng / outTime / outOdometer Interpolated crossing point — only valid when the return is LINE_DETECT_COMPLETED. |
Crossing-line detection: hypotenuse threshold method.
Using the width of the crossing line and "crossingThresholdMeters" to form a right triangle, the calculated hypotenuse is the effective proximity threshold. We measure from the driver to each crossing point; if either distance exceeds the hypotenuse we are not in the zone.
Earlier experiments used acute/obtuse-triangle detection (see DovesLapTimer::isObtuseTriangle), which worked on OKC but felt brittle. Hypotenuse-based threshold has been more reliable across short and long track configurations.
| bool CrossingEngine::getForceLinear | ( | ) | const |
| unsigned int CrossingEngine::getRejectedCrossingCount | ( | ) | const |
Number of crossing-zone exits whose interpolation was rejected.
A rejection means the GPS data inside the zone never produced a usable straddling pair (no side change, pair too far from the line, incoherent timestamps, or crossing landing off the line segment).
| void CrossingEngine::reset | ( | ) |
Clears the buffer, the rejected-crossing counter, and any in-flight zone state. Does NOT clear the configured threshold/mode.
| void CrossingEngine::setDebugSerial | ( | Stream * | debugSerial | ) |
Attaches / detaches a debug output stream.
| void CrossingEngine::setForceLinear | ( | bool | linear | ) |
Selects linear (true, default) or Catmull-Rom (false) position interpolation. Time and odometer are always interpolated linearly.
| void CrossingEngine::setThreshold | ( | double | meters | ) |
Sets the crossing zone threshold, in meters.