handle undershot and ok cases
This commit is contained in:
parent
5d2dafa64c
commit
8fa98e3132
@ -165,10 +165,23 @@ constraints = {
|
|||||||
|
|
||||||
function constraints:constrain(s, want)
|
function constraints:constrain(s, want)
|
||||||
self.color=10
|
self.color=10
|
||||||
|
if (not self.xmin) return want
|
||||||
|
|
||||||
local v1 = calc_velocity(s.dx, want, s.maxspd, s.drag)
|
-- bmx: brake max
|
||||||
local bd, bf = brake_dist(v1, s.thrust + s.drag)
|
local v1, bmx = calc_velocity(s.dx, want, s.maxspd, s.drag), s.thrust + s.drag
|
||||||
|
local bd, bf = brake_dist(v1, bmx)
|
||||||
|
local bx, txm = s.x + bd, self.xmax
|
||||||
|
if bx < self.xmin then
|
||||||
|
self.color = 9
|
||||||
|
want = s.thrust
|
||||||
|
txm = self.xmin
|
||||||
|
v1 = calc_velocity(s.dx, want, s.maxspd, s.drag)
|
||||||
|
bd, bf = brake_dist(v1, bmx)
|
||||||
|
bx = bd + s.x
|
||||||
|
end
|
||||||
|
if (bx < txm) return want
|
||||||
|
self.color = 8
|
||||||
|
-- TODO: implement overshot constraint
|
||||||
return want
|
return want
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user