Skip to content
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
3 changes: 2 additions & 1 deletion cereal/log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,8 @@ struct ModelDataV2 {
laneChangeProb @15 :Float32;
desireLog @16 : Text;
modelTurnSpeed @17 :Float32;

laneChangeAvailableLeft @18 :Bool;
laneChangeAvailableRight @19 :Bool;

# deprecated
brakeDisengageProbDEPRECATED @2 :Float32;
Expand Down
3 changes: 2 additions & 1 deletion common/params_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"GMapKey", {PERSISTENT, STRING}},
{"SearchInput", {PERSISTENT, INT}},

{"CarSelected3", {PERSISTENT, STRING}},
{"CarSelected3", {PERSISTENT, STRING, "MOCK"}},
{"SupportedCars", {PERSISTENT, STRING}},
{"SupportedCars_gm", {PERSISTENT, STRING}},
{"ShowDebugUI", {PERSISTENT, INT, "0"}},
Expand Down Expand Up @@ -222,6 +222,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {

{"SteerActuatorDelay", {PERSISTENT, INT, "0"}},
{"LatSmoothSec", {PERSISTENT, INT, "13"}},
{"LatSuspendAngleDeg", {PERSISTENT, INT, "300"}},
{"CruiseOnDist", {PERSISTENT, INT, "400"}},

{"CruiseMaxVals0", {PERSISTENT, INT, "160"}},
Expand Down
10 changes: 5 additions & 5 deletions opendbc_repo/opendbc/can/packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self, dbc_name: str):
self.dbc = DBC(dbc_name)
self.counters: dict[int, int] = {}

def pack(self, address: int, values: dict[str, float]) -> bytearray:
def pack(self, address: int, values: dict[str, float], rx_counter: int | None = None) -> bytearray:
msg = self.dbc.addr_to_msg.get(address)
if msg is None:
return bytearray()
Expand All @@ -27,8 +27,8 @@ def pack(self, address: int, values: dict[str, float]) -> bytearray:
counter_set = True
sig_counter = next((s for s in msg.sigs.values() if s.type == SignalType.COUNTER or s.name == "COUNTER"), None)
if sig_counter and not counter_set:
if address not in self.counters:
self.counters[address] = 0
if address not in self.counters:
self.counters[address] = 0 if rx_counter is None else (int(rx_counter) + 1) % (1 << sig_counter.size)
set_value(dat, sig_counter, self.counters[address])
self.counters[address] = (self.counters[address] + 1) % (1 << sig_counter.size)
sig_checksum = next((s for s in msg.sigs.values() if s.type > SignalType.COUNTER), None)
Expand All @@ -37,15 +37,15 @@ def pack(self, address: int, values: dict[str, float]) -> bytearray:
set_value(dat, sig_checksum, checksum)
return dat

def make_can_msg(self, name_or_addr, bus: int, values: dict[str, float]):
def make_can_msg(self, name_or_addr, bus: int, values: dict[str, float], rx_counter: int | None = None):
if isinstance(name_or_addr, int):
addr = name_or_addr
else:
msg = self.dbc.name_to_msg.get(name_or_addr)
if msg is None:
return 0, b'', bus
addr = msg.address
dat = self.pack(addr, values)
dat = self.pack(addr, values, rx_counter = rx_counter)
if len(dat) == 0:
return 0, b'', bus
return addr, bytes(dat), bus
Expand Down
23 changes: 12 additions & 11 deletions opendbc_repo/opendbc/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,12 @@ def update(self, CC, CS, now_nanos):
if self.CP.flags & HyundaiFlags.CANFD:
hda2 = self.CP.flags & HyundaiFlags.CANFD_HDA2
hda2_long = hda2 and self.CP.openpilotLongitudinalControl

# steering control
if camera_scc:
can_sends.extend(hyundaicanfd.create_steering_messages_camera_scc(self.frame, self.packer, self.CP, self.CAN, CC, apply_steer_req, apply_torque, CS, apply_angle, self.lkas_max_torque, angle_control))
else:
can_sends.extend(hyundaicanfd.create_steering_messages(self.packer, self.CP, self.CAN, CC.enabled, apply_steer_req, apply_torque, apply_angle, self.lkas_max_torque, angle_control))

# prevent LFA from activating on HDA2 by sending "no lane lines detected" to ADAS ECU
if self.frame % 5 == 0 and hda2 and not camera_scc:
can_sends.extend(hyundaicanfd.create_suppress_lfa(self.packer, self.CAN, CS))
Expand All @@ -352,8 +351,10 @@ def update(self, CC, CS, now_nanos):
can_sends.extend(hyundaicanfd.create_fca_warning_light(self.CP, self.packer, self.CAN, self.frame))
if self.frame % 2 == 0:
if self.CP.flags & HyundaiFlags.CAMERA_SCC.value:
can_sends.append(hyundaicanfd.create_acc_control_scc2(self.packer, self.CAN, CC.enabled, self.accel_last, accel, stopping, CC.cruiseControl.override,
set_speed_in_units, hud_control, self.hyundai_jerk, CS))
msg = hyundaicanfd.create_acc_control_scc2(self.packer, self.CAN, CC.enabled, self.accel_last, accel, stopping, CC.cruiseControl.override,
set_speed_in_units, hud_control, self.hyundai_jerk, CS)
if msg is not None:
can_sends.append(msg)
can_sends.extend(hyundaicanfd.create_tcs_messages(self.packer, self.CAN, CS)) # for sorento SCC radar...
else:
can_sends.append(hyundaicanfd.create_acc_control(self.packer, self.CAN, CC.enabled, self.accel_last, accel, stopping, CC.cruiseControl.override,
Expand All @@ -366,16 +367,16 @@ def update(self, CC, CS, now_nanos):
can_sends.extend(hyundaicanfd.forward_button_message(self.packer, self.CAN, self.frame, CS, send_button, self.MainMode_ACC_trigger, self.LFA_trigger))
else:
can_sends.extend(self.create_button_messages(CC, CS, use_clu11=False))

else:
can_sends.append(hyundaican.create_lkas11(self.packer, self.frame, self.CP, apply_torque, apply_steer_req,
torque_fault, CS.lkas11, sys_warning, sys_state, CC.enabled,
hud_control.leftLaneVisible, hud_control.rightLaneVisible,
left_lane_warning, right_lane_warning, self.is_ldws_car))
if CS.lkas11 is not None:
can_sends.append(hyundaican.create_lkas11(self.packer, self.frame, self.CP, apply_torque, apply_steer_req,
torque_fault, CS.lkas11, sys_warning, sys_state, CC.enabled,
hud_control.leftLaneVisible, hud_control.rightLaneVisible,
left_lane_warning, right_lane_warning, self.is_ldws_car))

if not self.CP.openpilotLongitudinalControl:
can_sends.extend(self.create_button_messages(CC, CS, use_clu11=True))
if self.CP.carFingerprint in CAN_GEARS["send_mdps12"]: # send mdps12 to LKAS to prevent LKAS error
if self.CP.carFingerprint in CAN_GEARS["send_mdps12"] and CS.mdps12 is not None: # send mdps12 to LKAS to prevent LKAS error
can_sends.append(hyundaican.create_mdps12(self.packer, self.frame, CS.mdps12))

casper_opt = self.CP.carFingerprint in (CAR.HYUNDAI_CASPER_EV)
Expand Down Expand Up @@ -464,7 +465,7 @@ def create_button_messages(self, CC: structs.CarControl, CS: CarState, use_clu11
if (self.frame - self.last_button_frame) * DT_CTRL > 0.1:
print("cruiseControl.cancel222222")
if self.CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS:
#can_sends.append(hyundaicanfd.create_acc_cancel(self.packer, self.CP, self.CAN, CS.cruise_info))
#can_sends.append(hyundaicanfd.create_acc_cancel(self.packer, self.CP, self.CAN, CS.scc_control))
if self.cruise_buttons_msg_values is not None:
can_sends.append(hyundaicanfd.alt_cruise_buttons(self.packer, self.CP, self.CAN, Buttons.CANCEL, self.cruise_buttons_msg_values, self.cruise_buttons_msg_cnt))

Expand Down
Loading
Loading