Detect lap completions and record lap times from TUM trajectory files. Works with any SLAM algorithm output or MoCap ground truth no ROS2 required.
- Automatic finish line detection (uses start position by default)
- Custom finish line position and zone radius
- Lap time, distance, and average speed per lap
- Best/worst/average lap statistics
- Trajectory map with lap segments coloured by lap number
- Lap time bar chart with best lap marker
- CSV export
- Works with any TUM trajectory file
git clone https://github.com/vader-droid33/f1tenth_lap_timer.git
cd f1tenth_lap_timer
pip install -e .
# Basic lap detection
f1tenth_lap_timer trajectory.tum
# With plot
f1tenth_lap_timer trajectory.tum --plot
# Custom finish line
f1tenth_lap_timer trajectory.tum --finish-line 1.5 0.5 --radius 0.4
# Export lap times
f1tenth_lap_timer trajectory.tum --export laps.csv
# Save plot
f1tenth_lap_timer trajectory.tum --plot --save laps.png --no-show
from f1tenth_lap_timer import load_tum, detect_finish_line, compute_trajectory_stats
timestamps, xyz = load_tum("trajectory.tum")
laps = detect_finish_line(xyz, timestamps, finish_point=[0, 0], radius=0.3)
for lap in laps:
print(f"Lap {lap['lap']}: {lap['duration']:.3f}s")
MIT



