Library for Arduino for creating mostly accurate lap-timings using GPS data. Once the driver is within a specified threshold of the line, it begins logging gps lat/lng/alt/speed. Once past the threshold, using the 4 points closest to the line, creates a catmullrom spline to interpolate the exact crossing time.
- literally anything, but fair warning lots of floating point math.
- Seed NRF52840
- Really low power
- 65mA~ with screen, gps, and bluetooth
- 256KB RAM, 1MB Flash
- Has a dedicated high speed FPU for both floats and doubles
- Really low power
- Matek SAM-M8Q
- This GPS is another wonderful addition, Can be configured
- Uses NMEA or UBLOX commands (NMEA for all included examples)
- 128x64 i2c 110X display
- Just for included demo
- Seed NRF52840
- Current lap
- Time
- Distance
- Number
- Last lap
- Time
- Distance
- Best lap
- Time
- Distance
- Number
- Pace difference against current and best lap
- List lap times
- Splits (when I get really bored)
- "Optimal" Lap
Yea let me be real here, I just want the screen to flash when I have a good sector, and check my times in qualifying before the rental races. If you want literally any other feature, use the RaceChrono Android | iPhone App or make it yourself and submit a pull-request.
See the source code, specifically the DovesLapTimer.h file. The code should have clarifying comments wherever there are any unclear bits.
// Initialize with internal debugger, and or crossingThreshold (default 10)
#define DEBUG_SERIAL Serial
// Only change if you know what you're doing
double crossingThresholdMeters = 7.0;
DovesLapTimer lapTimer(crossingThresholdMeters, &DEBUG_SERIAL);
DovesLapTimer lapTimer(crossingThresholdMeters);
DovesLapTimer lapTimer;
Currently only supports one split line, the main start/finish.
// define start/finish line
lapTimer.setStartFinishLine(crossingPointALat, crossingPointALng, crossingPointBLat, crossingPointBLng);
// default interpolation method
lapTimer.forceCatmullRomInterpolation();
// Might be more accurate if your finishline is on a location you expect constant speed
lapTimer.forceLinearInterpolation();
// reset all counters back to zero
lapTimer.reset();
create a simple method with the signature unsigned long getGpsTimeInMilliseconds();
to... as it says, get the current time from the gps in milliseconds.
Now inside of your gps loop, add something like the following
All of the lap timing magic is happening inside of checkStartFinish
consider that our "timing loop".
// try to always keep the time up to date for pace calculations
if (gps->satellites >= 1) {
lapTimer.updateCurrentTime(getGpsTimeInMilliseconds());
}
// update the timer loop only when we have fully fixed data
if (gps->fixquality > 0) {
float altitudeMeters = gps->altitude;
float speedKnots = gps->speed;
lapTimer.loop(gps->latitudeDegrees, gps->longitudeDegrees, altitudeMeters, speedKnots);
}
Here is an example getGpsTimeInMilliseconds()
/**
* @brief Returns the GPS time since midnight in milliseconds
*
* @return unsigned long The time since midnight in milliseconds
*/
unsigned long getGpsTimeInMilliseconds() {
unsigned long timeInMillis = 0;
timeInMillis += gps->hour * 3600000ULL; // Convert hours to milliseconds
timeInMillis += gps->minute * 60000ULL; // Convert minutes to milliseconds
timeInMillis += gps->seconds * 1000ULL; // Convert seconds to milliseconds
timeInMillis += gps->milliseconds; // Add the milliseconds part
return timeInMillis;
}
Now if you want any running information, you have the following...
bool getRaceStarted() const; // True if the race has started, false otherwise (passed the line one time).
bool getCrossing() const; // True if crossing the start/finish line, false otherwise.
unsigned long getCurrentLapStartTime() const; // The current lap start time in milliseconds.
unsigned long getCurrentLapTime() const; // The current lap time in milliseconds.
unsigned long getLastLapTime() const; // The last lap time in milliseconds.
unsigned long getBestLapTime() const; // The best lap time in milliseconds.
float getPaceDifference() const; // Calculates the pace difference (in seconds...) between the current lap and the best lap.
float getCurrentLapOdometerStart() const; // The distance traveled at the start of the current lap in meters.
float getCurrentLapDistance() const; // The distance traveled during the current lap in meters.
float getLastLapDistance() const; // The distance traveled during the last lap in meters.
float getBestLapDistance() const; // The distance traveled during the best lap in meters.
float getTotalDistanceTraveled() const; // The total distance traveled in meters.
int getBestLapNumber() const; // The lap number of the best lap.
int getLaps() const; // The total number of laps completed.
Inside DovesLapTimer.h
// Can ignore now that "real data tests" exist
#define DOVES_UNIT_TEST
- Basic Oled Example
- Shows all basic functionality, along with a simple display literally showing all basic functionality.
- Assumes adafruit compatible authentic ublox GPS
- If not authentic, commands might fail but should probably still work.
- Originally for Seed NRF52840
- Might need to remove/change LED_GREEN blinker
- 128x64 i2c 110X display.
- Display is NOT PRETTY, it is an EXAMPLE / DEBUG SCREEN.
- Too tired to make serial only logger, but you can very easily remove it.
- Borb load screen
- Real Track Data Debug
- Serial Only No GPS Required
- Simple test using data recorded at Orlando Kart Center
- MyLaps : 1:08:807 (magnetic/official)
- DovesTimer: 1:08:748 (LINEAR)
- DovesTimer: 1:08.745 (CATMULLROM)
- RaceChrono: 1:08:630 (GPS Android App)
- Unit Tests
- Code fully covered 34 tests
- I believe, these results should suffice at 10-18hz below 130mph
- Will possibly remove in favor of more "real data tests"
This library is licensed under the MIT Licence.
If you want more features, go and download this dudes app RaceChrono (available on both iPhone and Android), and send the data to your phone, or log it and send it after the race.
RaceChrono is not a sponsor or affiliated, I just really enjoy the app, but don't like keeping my phone in a go-kart. If you are looking for a "proper racing solution", you can log canbus data through the NRF52840, to the RaceChrono app. This will allow you to use a much more affordable GPS module, and have a fully fledged data logger. You can also send this data back to another(or the same) BLE device to create custom digital gauge clusters!
Paid version required for DIY loggers and importing NMEA logs, worth every penny.
RaceChrono Website | RaceChrono iPhone | RaceChrono Android
Source code for: can-bus logger/gps logger/digital gauges
https://github.com/aollin/racechrono-ble-diy-device
Pairs wonderfully with the previously mentioned Seed NRF52840
Might as well plug my youtube here as well :^) bunch of 360 karting videos https://www.youtube.com/shorts/r0rKZCIl5Zw
๐คโจ Crafted with love & a sprinkle of ChatGPT magic! โจ๐ค