Skip to content

Commit

Permalink
GM refactor (commaai#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
vntarasov authored and klaus385 committed Dec 25, 2018
1 parent f5533f5 commit 2647b11
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions selfdrive/car/gm/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,11 @@ def update(self, sendcan, enabled, CS, frame, actuators, \
### STEER ###

if (frame % P.STEER_STEP) == 0:
final_steer = actuators.steer if enabled else 0.
apply_steer = final_steer * P.STEER_MAX

apply_steer = apply_std_steer_torque_limits(apply_steer, self.apply_steer_last, CS.steer_torque_driver, P)

lkas_enabled = enabled and not CS.steer_not_allowed and CS.v_ego > 3.

if not lkas_enabled:
if lkas_enabled:
apply_steer = actuators.steer * P.STEER_MAX
apply_steer = apply_std_steer_torque_limits(apply_steer, self.apply_steer_last, CS.steer_torque_driver, P)
else:
apply_steer = 0

self.apply_steer_last = apply_steer
Expand All @@ -115,15 +112,16 @@ def update(self, sendcan, enabled, CS, frame, actuators, \

if self.car_fingerprint == CAR.VOLT:
# no output if not enabled, but keep sending keepalive messages
# threat pedals as one
# treat pedals as one
final_pedal = actuators.gas - actuators.brake

# *** apply pedal hysteresis ***
final_brake, self.brake_steady = actuator_hystereses(
final_pedal, self.pedal_steady)

if not enabled:
apply_gas = P.MAX_ACC_REGEN # TODO: do we really need to send max regen when not enabled?
# Stock ECU sends max regen when not enabled.
apply_gas = P.MAX_ACC_REGEN
apply_brake = 0
else:
apply_gas = int(round(interp(final_pedal, P.GAS_LOOKUP_BP, P.GAS_LOOKUP_V)))
Expand Down

0 comments on commit 2647b11

Please sign in to comment.