Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GM refactor #374

Merged
merged 1 commit into from
Sep 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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