gun belief: bound dead reckoning, reject untrustworthy velocity samples
Cap dead-reckoning lead at MaxDeadReckonTicks (freeze at the last scan past it) and return (0,0) from targetVelocity when the two scans it averages span more than MaxVelGap ticks. computeGun now uses gunAimErrorDeg.
This commit is contained in:
@@ -72,6 +72,12 @@ type ScanHistory* = object
|
||||
|
||||
const ScanWinCap* = 8 ## motion-window length kept for the ELM gun
|
||||
|
||||
const MaxVelGap* = 3 ## ticks. Two scans farther apart than this give a
|
||||
## velocity that averages over too much motion to be
|
||||
## trusted; the corpus velocity is a one-tick delta,
|
||||
## so anything much wider is a different estimator and
|
||||
## worse than not extrapolating at all.
|
||||
|
||||
var
|
||||
scanTick*: int ## incremented once per commandRadar() call
|
||||
lastScan*, prevScan*: ScanHistory
|
||||
@@ -107,10 +113,11 @@ proc scanGap*(): float =
|
||||
|
||||
proc targetVelocity*(): tuple[vx, vy: float] =
|
||||
## px/tick, from the last two scans. (0,0) when there is no gap to measure
|
||||
## over — the corpus uses the same convention.
|
||||
## over or the gap is too wide to be a trustworthy one-tick estimate — the
|
||||
## corpus uses the same (0,0) convention for "velocity unknown".
|
||||
if not (haveLast and havePrev): return (0.0, 0.0)
|
||||
let gap = lastScan.tick - prevScan.tick
|
||||
if gap <= 0: return (0.0, 0.0)
|
||||
if gap <= 0 or gap > MaxVelGap: return (0.0, 0.0)
|
||||
((lastScan.x - prevScan.x) / float(gap), (lastScan.y - prevScan.y) / float(gap))
|
||||
|
||||
proc ownDisp*(selfX, selfY: float): float =
|
||||
|
||||
Reference in New Issue
Block a user