Dashboard overlay (Overlays → Live → Dashboard): one inclinometer (compass ring, roll and pitch), speed, the speed limit with an over-limit warning and, on the route, the next limit change, traffic signal, maneuver and its lanes; /api/route gains speed_limits, signals and lanes, POST /api/road gives the driven road's limit; GNSS simulation (random trips over Valhalla) for trying it without the car; the HMC5883L heading in can.json
CI / check (push) Successful in 24s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-11-30 18:30:21 +01:00
1 parent 5958ffd153
commit 190a8ad334
13 files changed
+713 -27

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
require_relative "test_helper"
require_relative "../lib/maptool/gnss_sim"
class GnssSimTest < Minitest::Test
# A 1 km route north, 36 km/h limit for the first half, untagged after.
class FixedRoute < Maptool::GnssSim
def random_route(_position)
{ geometry: { coordinates: [[17.0, 48.0], [17.0, 48.0 + 1000.0 / 111_320]] },
properties: { speed_limits: [[0.0, 40], [0.5, nil]] } }
end
end
def test_drives_the_route_at_its_limits_and_ends_at_its_end
fixes = []
sim = FixedRoute.new("http://valhalla", sleep: ->(_s) {})
last = sim.drive([17.0, 48.0]) { |fix| fixes << fix }
assert_in_delta 36 / 3.6, fixes.first[:speed], 0.01 # 90 % of 40
assert_in_delta 45 / 3.6, fixes.last[:speed], 0.01 # 90 % of an untagged road's 50
assert_in_delta 48.0 + 1000.0 / 111_320, fixes.last[:lat], 1e-9
assert_equal [17.0, 48.0 + 1000.0 / 111_320], last
assert fixes.each_cons(2).all? { |a, b| b[:lat] >= a[:lat] } # never backwards
assert_in_delta 1000 / (36 / 3.6) / 2 + 500 / (45 / 3.6), fixes.size, 3 # ~1 fix a second
end
end