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

Nissan: Parse distance button from steering wheel #31766

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions selfdrive/car/nissan/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ def __init__(self, CP):
self.steeringTorqueSamples = deque(TORQUE_SAMPLES*[0], TORQUE_SAMPLES)
self.shifter_values = can_define.dv["GEARBOX"]["GEAR_SHIFTER"]

self.prev_distance_button = 0
self.distance_button = 0

def update(self, cp, cp_adas, cp_cam):
ret = car.CarState.new_message()

self.prev_distance_button = self.distance_button
self.distance_button = cp.vl["CRUISE_THROTTLE"]["FOLLOW_DISTANCE_BUTTON"]

if self.CP.carFingerprint in (CAR.ROGUE, CAR.XTRAIL, CAR.ALTIMA):
ret.gas = cp.vl["GAS_PEDAL"]["GAS_PEDAL"]
elif self.CP.carFingerprint in (CAR.LEAF, CAR.LEAF_IC):
Expand Down
6 changes: 5 additions & 1 deletion selfdrive/car/nissan/interface.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from cereal import car
from panda import Panda
from openpilot.selfdrive.car import get_safety_config
from openpilot.selfdrive.car import create_button_events, get_safety_config
from openpilot.selfdrive.car.interfaces import CarInterfaceBase
from openpilot.selfdrive.car.nissan.values import CAR

ButtonType = car.CarState.ButtonEvent.Type


class CarInterface(CarInterfaceBase):

Expand Down Expand Up @@ -35,6 +37,8 @@ def _update(self, c):
be.type = car.CarState.ButtonEvent.Type.accelCruise
buttonEvents.append(be)
sshane marked this conversation as resolved.
Show resolved Hide resolved

ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})

events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.brake])

if self.CS.lkas_enabled:
Expand Down
Loading