handle undershot and ok cases
This commit is contained in:
		| @@ -165,10 +165,23 @@ constraints = { | ||||
|  | ||||
| function constraints:constrain(s, want) | ||||
|  self.color=10 | ||||
|  if (not self.xmin) return want | ||||
|  | ||||
|  local v1 = calc_velocity(s.dx, want, s.maxspd, s.drag) | ||||
|  local bd, bf = brake_dist(v1, s.thrust + s.drag) | ||||
|  | ||||
|  -- bmx: brake max | ||||
|  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 | ||||
| end | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user