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:
1 parent
7fdc0114e6
commit
7204355510
8 files changed
+143
-18
No files matched your search
@@ -53,7 +53,7 @@ module Maptool
|
||||
# from a random place in one of them; with a route (the trip's /api/route
|
||||
# Feature), that route from its start first, random trips after it;
|
||||
# each fix to the block:
|
||||
# { lat:, lon:, speed: m/s, satellites:, hdop:, time: the simulation's epoch s }.
|
||||
# { lat:, lon:, speed: m/s, satellites:, hdop:, mode: 3, time: the simulation's epoch s }.
|
||||
def start(lon = nil, lat = nil, bboxes: nil, route: nil, &on_fix)
|
||||
stop
|
||||
@error = nil
|
||||
@@ -112,7 +112,7 @@ module Maptool
|
||||
i += 1 while i < coords.size - 1 && km[i] < at
|
||||
t = km[i] > km[i - 1] ? ((at - km[i - 1]) / (km[i] - km[i - 1])).clamp(0.0, 1.0) : 1.0
|
||||
lon, lat = coords[i - 1].zip(coords[i]).map { |a, b| a + (b - a) * t }
|
||||
on_fix&.call(lat: lat, lon: lon, speed: kmh / 3.6, satellites: 12, hdop: 0.8, time: @clock.round(1))
|
||||
on_fix&.call(lat: lat, lon: lon, speed: kmh / 3.6, satellites: 12, hdop: 0.8, mode: 3, time: @clock.round(1))
|
||||
break if i == coords.size - 1 && t >= 1
|
||||
|
||||
@sleep.call(TICK_S)
|
||||
|
||||
@@ -97,6 +97,20 @@ module Maptool
|
||||
best
|
||||
end
|
||||
|
||||
# Dead reckoning along the line: from the point nearest `position`,
|
||||
# `meters` further on — [[lon, lat], bearing °], or nil if `position`
|
||||
# is more than ON_ROUTE_M off it (no telling where the car went then).
|
||||
# Stops at the line's end.
|
||||
def self.ahead(coords, position, meters)
|
||||
at, off = locate(coords, position)
|
||||
return nil if off > ON_ROUTE_M
|
||||
|
||||
km = coords.each_cons(2).reduce([0.0]) { |acc, (a, b)| acc << acc.last + GnssSim.meters(a, b) / 1000 }
|
||||
to = [at + meters / 1000.0, km.last].min
|
||||
here = GnssSim.point_at(coords, km, to)
|
||||
[here, GnssSim.bearing(GnssSim.point_at(coords, km, [to - 0.02, 0].max), GnssSim.point_at(coords, km, [to + 0.02, km.last].min)).round(1)]
|
||||
end
|
||||
|
||||
# points: [{ lngLat: [lon, lat], name:, nav:, passed: }]. Routes through
|
||||
# the ones not passed with the block (locations, vehicle id, avoid → the
|
||||
# /api/route Feature, may raise Routing errors) unless only names/nav
|
||||
|
||||
Reference in new issue
Block a user