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

Rivian: fix fuzzy test_models failures #1929

Merged
merged 3 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion opendbc/car/rivian/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from opendbc.car.rivian.values import DBC, GEAR_MAP
from opendbc.car.common.conversions import Conversions as CV

GearShifter = structs.CarState.GearShifter


class CarState(CarStateBase):
def __init__(self, CP):
Expand Down Expand Up @@ -62,7 +64,7 @@ def update(self, can_parsers) -> structs.CarState:
cp.vl["VDM_AdasSts"]["VDM_AdasFaultStatus"] in (2, 3)) # 2=Cntr_Fault, 3=Imps_Cmd

# Gear
ret.gearShifter = GEAR_MAP[int(cp.vl["VDM_PropStatus"]["VDM_Prndl_Status"])]
ret.gearShifter = GEAR_MAP.get(int(cp.vl["VDM_PropStatus"]["VDM_Prndl_Status"]), GearShifter.unknown)

# Doors
ret.doorOpen = (cp_adas.vl["IndicatorLights"]["RearDriverDoor"] != 2 or
Expand Down
14 changes: 7 additions & 7 deletions opendbc/car/rivian/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ class CAR(Platforms):
]
)

GEAR_MAP = [
structs.CarState.GearShifter.unknown,
structs.CarState.GearShifter.park,
structs.CarState.GearShifter.reverse,
structs.CarState.GearShifter.neutral,
structs.CarState.GearShifter.drive,
]
GEAR_MAP = {
0: structs.CarState.GearShifter.unknown,
1: structs.CarState.GearShifter.park,
2: structs.CarState.GearShifter.reverse,
3: structs.CarState.GearShifter.neutral,
4: structs.CarState.GearShifter.drive,
}


class CarControllerParams:
Expand Down
3 changes: 2 additions & 1 deletion opendbc/safety/safety/safety_rivian.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ static void rivian_rx_hook(const CANPacket_t *to_push) {
if (bus == 2) {
// Cruise state
if (addr == 0x100) {
pcm_cruise_check(GET_BIT(to_push, 21U));
const int feature_status = GET_BYTE(to_push, 2) >> 5U;
pcm_cruise_check(feature_status == 1);
}
}
}
Expand Down
Loading