Dead reckoning in a tunnel: no fix for 3 s (or mode < 2) on the trip's route, the position carried along it (estimated: true, a grey arrow) by the car's CAN speed (vehicle.speed) when there is one, the average speed of the last ~20 s otherwise, up to 10 min (App.gnss_position, TripStore.ahead)

This commit is contained in:
randy committed 2026-12-02 18:24:47 +01:00
1 parent 7fdc0114e6
commit 7204355510
8 files changed
+143 -18

No files matched your search

+31
View File
@@ -679,6 +679,37 @@ class AppTest < Minitest::Test
latest.clear
end
# A tunnel: no fix for a while, the position carried along the trip's
# route — at the average speed it was entered at, by the CAN speed when there is one.
def test_no_fix_on_the_route_is_dead_reckoned_along_it
latest = Maptool::App::GNSS_LATEST
latest.clear
store = Maptool::App::TRIP_STORE
saved = store.instance_variable_get(:@trip)
north = 1000.0 / 111_320 # 1 km north
store.instance_variable_set(:@trip, saved.merge(points: [], route: { geometry: { coordinates: [[17.0, 48.0], [17.0, 48.0 + 5 * north]] } }))
Maptool::App.gnss_update({ lat: 48.0, lon: 17.0, speed: 20.0, mode: 3 }, at: 100.0)
Maptool::App.gnss_update({ lat: 48.0, lon: 17.0, speed: 20.0 }, at: 101.0)
assert_nil Maptool::App.gnss_position(now: 102.0)[:estimated] # not yet: a fix may just be late
position = Maptool::App.gnss_position(now: 111.0) # 10 s × 20 m/s
assert position[:estimated]
assert_in_delta 48.0 + 0.2 * north, position[:lat], 1e-6
assert_in_delta 0.0, position[:track], 0.5
Maptool::App.gnss_update({ lat: 48.0, lon: 17.0, mode: 1 }, at: 105.0) # the receiver repeating its last fix
assert Maptool::App.gnss_position(now: 111.0)[:estimated]
Maptool::App.vehicle_speed_update(10.0, at: 102.0) # the car's own speed: 10 m/s
Maptool::App.vehicle_speed_update(10.0, at: 103.0)
position = Maptool::App.gnss_position(now: 104.0)
assert_in_delta 48.0 + 0.02 * north, position[:lat], 1e-6
assert_equal 10.0, position[:speed]
ensure
latest.clear
store.instance_variable_set(:@trip, saved)
end
private
def upload(filename, content, folder: "", content_type: "application/octet-stream")