|
|
@ -29,7 +29,6 @@ class CarController(): |
|
|
|
|
|
|
|
|
|
|
|
self.torque_r_filtered = 0. |
|
|
|
self.torque_r_filtered = 0. |
|
|
|
self.torque_l_filtered = 0. |
|
|
|
self.torque_l_filtered = 0. |
|
|
|
self.wait_counter = int(5. / DT_CTRL) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def deadband_filter(torque, deadband): |
|
|
|
def deadband_filter(torque, deadband): |
|
|
@ -40,13 +39,13 @@ class CarController(): |
|
|
|
return torque |
|
|
|
return torque |
|
|
|
|
|
|
|
|
|
|
|
def update(self, CC, CS): |
|
|
|
def update(self, CC, CS): |
|
|
|
if self.wait_counter > 0: |
|
|
|
|
|
|
|
self.wait_counter -= 1 |
|
|
|
|
|
|
|
return CC.actuators.copy(), [] |
|
|
|
|
|
|
|
if len(CC.orientationNED) == 0 or len(CC.angularVelocity) == 0: |
|
|
|
|
|
|
|
return CC.actuators.copy(), [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# /////////////////////////////////////// |
|
|
|
torque_l = 0 |
|
|
|
|
|
|
|
torque_r = 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
llk_valid = len(CC.orientationNED) > 0 and len(CC.angularVelocity) > 0 |
|
|
|
|
|
|
|
if CC.enabled and llk_valid: |
|
|
|
|
|
|
|
|
|
|
|
# Steer and accel mixin. Speed should be used as a target? (speed should be in m/s! now it is in RPM) |
|
|
|
# Steer and accel mixin. Speed should be used as a target? (speed should be in m/s! now it is in RPM) |
|
|
|
# Mix steer into torque_diff |
|
|
|
# Mix steer into torque_diff |
|
|
|
# self.steerRatio = 0.5 |
|
|
|
# self.steerRatio = 0.5 |
|
|
@ -100,8 +99,6 @@ class CarController(): |
|
|
|
torque_r = int(np.clip(self.torque_r_filtered, -MAX_TORQUE, MAX_TORQUE)) |
|
|
|
torque_r = int(np.clip(self.torque_r_filtered, -MAX_TORQUE, MAX_TORQUE)) |
|
|
|
torque_l = int(np.clip(self.torque_l_filtered, -MAX_TORQUE, MAX_TORQUE)) |
|
|
|
torque_l = int(np.clip(self.torque_l_filtered, -MAX_TORQUE, MAX_TORQUE)) |
|
|
|
|
|
|
|
|
|
|
|
# /////////////////////////////////////// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
can_sends = [] |
|
|
|
can_sends = [] |
|
|
|
can_sends.append(bodycan.create_control(self.packer, torque_l, torque_r, self.frame // 2)) |
|
|
|
can_sends.append(bodycan.create_control(self.packer, torque_l, torque_r, self.frame // 2)) |
|
|
|
|
|
|
|
|
|
|
|