Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Librescoot Trip Service

Records every ride from unlock to lock, with adaptive GPS traces and per-profile attribution.

This is a prototype.

Part of the Librescoot open-source platform.

GOTOOLCHAIN=go1.25.7 make build-host
./bin/trip-service --redis localhost:6379 --db /tmp/trips.db

Capabilities

  • Starts a trip when the vehicle enters ready-to-drive, ends it on lock
  • Records GPS points at adaptive intervals (more points in turns, fewer on straight roads)
  • Attributes each trip to the active rider profile
  • Persists everything to SQLite, crash-safe
  • Publishes completion events so the profile service can update per-user stats

Adaptive GPS recording

Recording frequency adjusts to how you're riding:

Speed Interval
< 5 km/h Paused (filters parking noise)
5-20 km/h ~5s
20-45 km/h ~8s
> 45 km/h ~15s

Heading changes > 15 degrees or speed changes > 10 km/h trigger an immediate capture regardless of interval. Points closer than 5m are filtered out (GPS jitter).

A typical 30-minute city ride produces 200-600 points, about 10-25 KB.

Operation and interfaces

Data sources

Reads directly from Redis, same hashes as other services. No dependency on radio-gaga.

Redis Hash Fields Purpose
vehicle state Trip start/end detection
engine-ecu speed, odometer Speed tracking, distance calculation
gps latitude, longitude, altitude, course, speed GPS trace
profile active.id Who's riding

What it publishes

Key Type Content
trip Hash status (recording/idle), id, profile-id, distance-m, duration-s
trip:completed Pub/Sub Fired on trip end with trip ID, profile ID, distance, duration, max speed

Storage

SQLite WAL at /data/trips.db. Two tables:

  • trips - one row per ride (profile, start/end location, odometer, distance, duration, speeds)
  • trip_points - GPS trace points (timestamp, lat/lon, altitude, speed, course, odometer)

Distance comes from odometer delta rather than summing GPS hops — the wheel measurement is more accurate than chasing noisy GPS positions.

Crash recovery

On startup, checks for trips stuck in recording state. If the vehicle is still in ready-to-drive, resumes recording. Otherwise marks the trip as abandoned with whatever data was captured.

Build

GOTOOLCHAIN=go1.25.7 make build        # ARM cross-compile
GOTOOLCHAIN=go1.25.7 make build-host   # native
GOTOOLCHAIN=go1.25.7 make test

Packaging

The Yocto layer in meta-librescoot installs /usr/bin/trip-service and the systemd unit librescoot-trip.service.

License

This project is dual-licensed. The source code is available under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. The maintainers reserve the right to grant separate licenses for commercial distribution; please contact the maintainers to discuss commercial licensing.

CC BY-NC-SA 4.0

Made with ❤️ by the Librescoot community

About

Trip recording with adaptive GPS traces and per-rider attribution for Librescoot (prototype)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages