forked from Telos4/RoboRally
reset time when stopping controller
This commit is contained in:
parent
f3babdcf0a
commit
7962199c3a
|
@ -70,9 +70,9 @@ class PIDController(ControllerBase):
|
||||||
angles_unwrapped = np.unwrap([x_pred[2], target_angle]) # unwrap angle to avoid jump in data
|
angles_unwrapped = np.unwrap([x_pred[2], target_angle]) # unwrap angle to avoid jump in data
|
||||||
|
|
||||||
e_angle = angles_unwrapped[0] - angles_unwrapped[1] # angle difference
|
e_angle = angles_unwrapped[0] - angles_unwrapped[1] # angle difference
|
||||||
e_pos = np.linalg.norm(v)
|
e_pos = np.linalg.norm(v[0:2])
|
||||||
|
|
||||||
if e_pos < 0.05:
|
if e_pos < 0.03:
|
||||||
self.mode = 'angle'
|
self.mode = 'angle'
|
||||||
self.e_angle_old = 0
|
self.e_angle_old = 0
|
||||||
self.e_pos_old = 0
|
self.e_pos_old = 0
|
||||||
|
@ -111,6 +111,10 @@ class PIDController(ControllerBase):
|
||||||
u2 = 0.0
|
u2 = 0.0
|
||||||
return u1, u2
|
return u1, u2
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
super(PIDController, self).stop()
|
||||||
|
self.t = None
|
||||||
|
|
||||||
def apply_control(self, control):
|
def apply_control(self, control):
|
||||||
self.t = time.time() # save time when the most recent control was applied
|
self.t = time.time() # save time when the most recent control was applied
|
||||||
super(PIDController, self).apply_control(control)
|
super(PIDController, self).apply_control(control)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user