DovesLapTimer 4.3.0
GPS-based lap timing Arduino library — go-karts to race cars
Loading...
Searching...
No Matches
CourseDetector.h
Go to the documentation of this file.
1
13#ifndef _COURSE_DETECTOR_H
14#define _COURSE_DETECTOR_H
15
16#include <Arduino.h>
17#include "DovesLapTimer.h"
18#include "GeoMath.h"
19
20struct CourseInfo {
21 const char* name;
22 float lengthFt;
23};
24
26 int index;
27 float ratio; // distance match quality (0.0 = perfect)
28};
29
31public:
33 void init(CourseInfo* courses, int count);
34 void update(double lat, double lng, float speedKmh, float totalOdometer);
35 void acceptCandidate(int index);
36 // currentOdometer advances the waypoint's lap-window start so the next
37 // ranking pass requires another full lap, rather than immediately
38 // re-ranking while still in proximity.
39 void rejectAllCandidates(float currentOdometer);
40 void reset();
41 void setSpeedThresholdMph(float mph);
42 void setDetectionProximityMeters(float meters);
43
44 // Getters
45 int getState() const;
46 int getDetectedCourseIndex() const;
47 bool isDetected() const;
48 double getWaypointLat() const;
49 double getWaypointLng() const;
50 bool hasWaypoint() const;
51 int getRankedMatchCount() const;
53 // Completed proximity passes (full laps back at the waypoint) that matched
54 // no configured course. CourseManager uses this to reach the Lap Anything
55 // fallback even when the detector never produces candidates to reject.
56 int getNoMatchCount() const;
57
58private:
59 void _checkSpeedThreshold(double lat, double lng, float speedKmh, float totalOdometer);
60 void _checkWaypointProximity(double lat, double lng, float totalOdometer);
61 void _matchCourseRanked(float distanceMeters);
62
63 CourseInfo _courses[MAX_COURSES];
64 int _courseCount;
65 int _state;
66 double _waypointLat;
67 double _waypointLng;
68 float _waypointOdometer;
69 int _detectedCourseIndex;
70 DetectionCandidate _rankedMatches[MAX_COURSES];
71 int _rankedMatchCount;
72 int _noMatchCount;
73 float _speedThresholdMph;
74 float _detectionProximityMeters;
75};
76
77#endif
#define MAX_COURSES
Definition DovesLapTimer.h:67
Definition CourseDetector.h:30
void update(double lat, double lng, float speedKmh, float totalOdometer)
Definition CourseDetector.cpp:34
bool hasWaypoint() const
Definition CourseDetector.cpp:168
void reset()
Definition CourseDetector.cpp:24
int getNoMatchCount() const
Definition CourseDetector.cpp:180
double getWaypointLng() const
Definition CourseDetector.cpp:164
CourseDetector()
Definition CourseDetector.cpp:8
double getWaypointLat() const
Definition CourseDetector.cpp:160
void rejectAllCandidates(float currentOdometer)
Definition CourseDetector.cpp:128
void setSpeedThresholdMph(float mph)
Definition CourseDetector.cpp:138
void setDetectionProximityMeters(float meters)
Definition CourseDetector.cpp:142
void init(CourseInfo *courses, int count)
Definition CourseDetector.cpp:15
int getRankedMatchCount() const
Definition CourseDetector.cpp:172
bool isDetected() const
Definition CourseDetector.cpp:156
int getDetectedCourseIndex() const
Definition CourseDetector.cpp:152
int getState() const
Definition CourseDetector.cpp:148
const DetectionCandidate * getRankedMatches() const
Definition CourseDetector.cpp:176
void acceptCandidate(int index)
Definition CourseDetector.cpp:122
Definition CourseDetector.h:20
const char * name
Definition CourseDetector.h:21
float lengthFt
Definition CourseDetector.h:22
Definition CourseDetector.h:25
int index
Definition CourseDetector.h:26
float ratio
Definition CourseDetector.h:27