Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6d12e7e
Update carrot_functions.py
ajouatom Sep 21, 2025
e8321c7
fix.. atc..
ajouatom Sep 22, 2025
fb1a846
TR16 model.
ajouatom Sep 22, 2025
fa021b7
fix.. atc
ajouatom Sep 22, 2025
cb24a81
Adjust interpolation value for t_follow calculation
ajouatom Sep 22, 2025
f6882f8
fix safeMode..
ajouatom Sep 23, 2025
3773c31
fix safeMode2
ajouatom Sep 23, 2025
1606bc1
fix.. v_cruise
ajouatom Sep 23, 2025
309ede0
model_turn_speed..
ajouatom Sep 24, 2025
ae2f2a3
fix..
ajouatom Sep 24, 2025
b217cfb
fix..
ajouatom Sep 24, 2025
1e8daba
fix.. cruise.py
ajouatom Sep 24, 2025
37ac22f
fix.. modelTurn..
ajouatom Sep 25, 2025
9c584a1
fix stopped car safe mode.
ajouatom Sep 25, 2025
5f0a756
model turn 120%
ajouatom Sep 25, 2025
564e9dd
remove model turn speed..
ajouatom Sep 25, 2025
47fd727
paramsd...
ajouatom Sep 25, 2025
544ac16
Revert "remove model turn speed.."
ajouatom Sep 25, 2025
e842a7e
model_turn_speed... 120 -> 115%
ajouatom Sep 26, 2025
207adf0
starting achange cost 30 -> 10
ajouatom Sep 26, 2025
4269d54
fix..
ajouatom Sep 26, 2025
a6e4586
aChangeCostStarting
ajouatom Sep 27, 2025
5fe17fc
fix..
ajouatom Sep 27, 2025
0bcd1f5
gwm v7
ajouatom Sep 28, 2025
266783f
Adjust traffic stop distance parameter
ajouatom Sep 28, 2025
c3112e8
Update carrot_functions.py
ajouatom Sep 28, 2025
37d70ef
update gwm 250929
ajouatom Sep 28, 2025
00b97a3
trafficStopDistance adjust
ajouatom Sep 28, 2025
c350ee5
localizer_roll_std
ajouatom Oct 2, 2025
e3e91cf
scc13
ajouatom Oct 2, 2025
2a599e7
fix...
ajouatom Oct 3, 2025
0701a7e
fix.. scc13
ajouatom Oct 3, 2025
1cd87bb
scc14
ajouatom Oct 3, 2025
9102998
bypass scc13
ajouatom Oct 3, 2025
771b974
fix scc13
ajouatom Oct 3, 2025
4223c91
TheCoolPeople's Model
ajouatom Oct 4, 2025
929bc76
North Nevada Model
ajouatom Oct 7, 2025
088cdcb
Revert "model_turn_speed... 120 -> 115%"
ajouatom Oct 7, 2025
2c10aae
Reapply "remove model turn speed.."
ajouatom Oct 7, 2025
846738c
for c3x lite (#218)
crwusiz Oct 8, 2025
5fab818
NNV(North Nevada) v2
ajouatom Oct 9, 2025
85bd38b
fix..
ajouatom Oct 10, 2025
1fa13db
Nuggets In Dijon Model
ajouatom Oct 10, 2025
73201cd
toyota accel pid long
ajouatom Oct 10, 2025
3e813b9
for c3xlite fix (#219)
crwusiz Oct 10, 2025
1377e24
LatSmoothSec
ajouatom Oct 11, 2025
2557c96
Revert "Reapply "remove model turn speed..""
ajouatom Oct 11, 2025
abdfafa
apply livePose
ajouatom Oct 16, 2025
904f48f
releases 251017
ajouatom Oct 17, 2025
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
7 changes: 7 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Carrot2-v9 (2025-10-17)
========================
* Nuggets In Dijon model
* Setting: Adjust traffic stop distance
* liveLocationKalman -> livePose
* C3x lite

Carrot2-v9 (2025-09-21)
========================
* GWM Model
Expand Down
1 change: 1 addition & 0 deletions cereal/log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,7 @@ struct ModelDataV2 {
desire @14 :Desire;
laneChangeProb @15 :Float32;
desireLog @16 : Text;
modelTurnSpeed @17 :Float32;


# deprecated
Expand Down
2 changes: 1 addition & 1 deletion cereal/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, should_log: bool, frequency: float, decimation: Optional[int]
"gnssMeasurements": (True, 10., 10),
"clocks": (True, 0.1, 1),
"ubloxRaw": (True, 20.),
#"livePose": (True, 20., 4),
"livePose": (True, 20., 4),
"liveLocationKalman": (True, 20., 5),
"liveParameters": (True, 20., 5),
"cameraOdometry": (True, 20., 10),
Expand Down
3 changes: 2 additions & 1 deletion common/mock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
import threading
from cereal.messaging import PubMaster
from cereal.services import SERVICE_LIST
from openpilot.common.mock.generators import generate_liveLocationKalman
from openpilot.common.mock.generators import generate_livePose, generate_liveLocationKalman
from openpilot.common.realtime import Ratekeeper


MOCK_GENERATOR = {
"livePose": generate_livePose
"liveLocationKalman": generate_liveLocationKalman
}

Expand Down
13 changes: 13 additions & 0 deletions common/mock/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,16 @@ def generate_liveLocationKalman(location=LOCATION1):
msg.liveLocationKalman.status = 'valid'
msg.liveLocationKalman.gpsOK = True
return msg


def generate_livePose():
msg = messaging.new_message('livePose')
meas = {'x': 0.0, 'y': 0.0, 'z': 0.0, 'xStd': 0.0, 'yStd': 0.0, 'zStd': 0.0, 'valid': True}
msg.livePose.orientationNED = meas
msg.livePose.velocityDevice = meas
msg.livePose.angularVelocityDevice = meas
msg.livePose.accelerationDevice = meas
msg.livePose.inputsOK = True
msg.livePose.posenetOK = True
msg.livePose.sensorsOK = True
return msg
6 changes: 6 additions & 0 deletions common/params_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
{"AutoNaviCountDownMode", PERSISTENT},
{"TurnSpeedControlMode", PERSISTENT},
{"MapTurnSpeedFactor", PERSISTENT},
{"ModelTurnSpeedFactor", PERSISTENT},
{"StoppingAccel", PERSISTENT},
{"AutoSpeedUptoRoadSpeedLimit", PERSISTENT},
{"AutoRoadSpeedAdjust", PERSISTENT},
Expand All @@ -208,6 +209,7 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
{"MyDrivingModeAuto", PERSISTENT},
{"TrafficLightDetectMode", PERSISTENT},
{"SteerActuatorDelay", PERSISTENT},
{"LatSmoothSec", PERSISTENT},
{"CruiseOnDist", PERSISTENT},
{"CruiseMaxVals0", PERSISTENT},
{"CruiseMaxVals1", PERSISTENT},
Expand Down Expand Up @@ -242,6 +244,8 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
{"TFollowGap4", PERSISTENT},
{"DynamicTFollow", PERSISTENT},
{"DynamicTFollowLC", PERSISTENT},
{"AChangeCostStarting", PERSISTENT},
{"TrafficStopDistanceAdjust", PERSISTENT},
{"HapticFeedbackWhenSpeedCamera", PERSISTENT},
{"UseLaneLineSpeed", PERSISTENT},
{"UseLaneLineCurveSpeed", PERSISTENT},
Expand Down Expand Up @@ -289,4 +293,6 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
{"NNFF", PERSISTENT},
{"NNFFLite", PERSISTENT},
{"NNFFModelName", CLEAR_ON_OFFROAD_TRANSITION},

{"HardwareC3xLite", PERSISTENT},
};
11 changes: 10 additions & 1 deletion launch_chffrplus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ function launch {
fi

# events language init
#LANG=$(cat ${PARAMS_ROOT}/d/LanguageSetting)
LANG=$(cat /data/params/d/LanguageSetting)
EVENTSTAT=$(git status)

Expand All @@ -102,6 +101,16 @@ function launch {
cp -f $DIR/scripts/add/events_en.py $DIR/selfdrive/selfdrived/events.py
fi

# c3xl amplifier file change
C3XL=$(cat /data/params/d/HardwareC3xLite)

if [ "${C3XL}" = "1" ] && [[ ! "${EVENTSTAT}" == *"modified: system/hardware/tici/amplifier.py"* ]]; then
cp -f $DIR/system/hardware/tici/amplifier.py $DIR/scripts/add/amplifier_org.py
cp -f $DIR/scripts/add/amplifier_c3xl.py $DIR/system/hardware/tici/amplifier.py
elif [ "${C3XL}" = "0" ] && [[ "${EVENTSTAT}" == *"modified: system/hardware/tici/amplifier.py"* ]]; then
cp -f $DIR/scripts/add/amplifier_org.py $DIR/system/hardware/tici/amplifier.py
fi

# start manager
cd system/manager
if [ ! -f $DIR/prebuilt ]; then
Expand Down
5 changes: 3 additions & 2 deletions opendbc_repo/opendbc/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,9 @@ def update(self, CC, CS, now_nanos):
# 5 Hz ACC options
if self.frame % 20 == 0 and self.CP.openpilotLongitudinalControl:
if camera_scc:
if CS.scc13 is not None:
can_sends.append(hyundaican.create_acc_opt_copy(CS, self.packer))
#if CS.scc13 is not None:
# can_sends.append(hyundaican.create_acc_opt_copy(CS, self.packer))
pass
else:
can_sends.extend(hyundaican.create_acc_opt(self.packer, self.CP))

Expand Down
2 changes: 1 addition & 1 deletion opendbc_repo/opendbc/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def update_canfd(self, can_parsers) -> structs.CarState:
if lane_info is not None:
left_lane_prob = lane_info["LEFT_LANE_PROB"]
right_lane_prob = lane_info["RIGHT_LANE_PROB"]
left_lane_type = lane_info["LEFT_LANE_TYPE"] # 0: dashed, 1: solid, 4: double solid, solid+dashed, 5:dashed + solid
left_lane_type = lane_info["LEFT_LANE_TYPE"] # 0: dashed, 1: solid, 2: undecided, 3: road edge, 4: DLM Inner Solid, 5: DLM InnerDashed, 6:DLM Inner Undecided, 7: Botts Dots, 8: Barrier
right_lane_type = lane_info["RIGHT_LANE_TYPE"]
left_lane_color = lane_info["LEFT_LANE_COLOR"]
right_lane_color = lane_info["RIGHT_LANE_COLOR"]
Expand Down
4 changes: 4 additions & 0 deletions opendbc_repo/opendbc/dbc/hyundai_kia_generic.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,8 @@ BO_ 1290 SCC13: 8 SCC
SG_ SCC_Equip : 3|1@1+ (1,0) [0|1] "" ESC
SG_ AebDrvSetStatus : 4|3@1+ (1,0) [0|7] "" CLU,ESC
SG_ Lead_Veh_Dep_Alert_USM : 13|2@0+ (1,0) [0|3] "" XXX
SG_ NEW_SIGNAL_1 : 23|8@0+ (1,0) [0|255] "" XXX
SG_ NEW_SIGNAL_2 : 31|8@0+ (1,0) [0|255] "" XXX

BO_ 1287 TCS15: 4 ESC
SG_ ABS_W_LAMP : 0|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,CUBIS,IBOX
Expand Down Expand Up @@ -1489,8 +1491,10 @@ BO_ 905 SCC14: 8 SCC
SG_ ComfortBandLower : 6|6@1+ (0.02,0) [0|1.26] "m/s^2" ESC
SG_ JerkUpperLimit : 12|7@1+ (0.1,0) [0|12.7] "m/s^3" ESC
SG_ JerkLowerLimit : 19|7@1+ (0.1,0) [0|12.7] "m/s^3" ESC
SG_ NEW_SIGNAL_1 : 26|6@1+ (1,0) [0|63] "" XXX
SG_ ACCMode : 32|3@1+ (1,0) [0|7] "" CLU,HUD,LDWS_LKAS,ESC
SG_ ObjDistStat : 42|2@1+ (1,0) [0|3] "" XXX
SG_ NEW_SIGNAL_2 : 55|8@0+ (1,0) [0|255] "" XXX
SG_ ObjGap : 56|8@1+ (1,0) [0|255] "" CLU,HUD,ESC

BO_ 1157 LFAHDA_MFC: 8 XXX
Expand Down
16 changes: 12 additions & 4 deletions opendbc_repo/opendbc/safety/safety/safety_hyundai.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ static void hyundai_rx_hook(const CANPacket_t *to_push) {

uint32_t last_ts_lkas11_from_op = 0;
uint32_t last_ts_scc12_from_op = 0;
uint32_t last_ts_scc13_from_op = 0;
uint32_t last_ts_mdps12_from_op = 0;
uint32_t last_ts_fca11_from_op = 0;

Expand Down Expand Up @@ -284,6 +285,8 @@ static bool hyundai_tx_hook(const CANPacket_t *to_send) {
last_ts_mdps12_from_op = (tx == 0 ? 0 : microsecond_timer_get());
else if(addr == 909)
last_ts_fca11_from_op = (tx == 0 ? 0 : microsecond_timer_get());
else if(addr == 1290)
last_ts_scc13_from_op = (tx == 0 ? 0 : microsecond_timer_get());

return tx;
}
Expand All @@ -308,10 +311,11 @@ static int hyundai_fwd_hook(int bus_num, int addr) {
if (bus_num == 2) {
bool is_lkas_msg = addr == 832;
bool is_lfahda_msg = addr == 1157;
bool is_scc_msg = addr == 1056 || addr == 1057 || addr == 1290 || addr == 905;
bool is_scc_msg = addr == 1056 || addr == 1057 || addr == 905;
bool is_scc13_msg = addr == 1290;
bool is_fca_msg = addr == 909 || addr == 1155;

bool block_msg = is_lkas_msg || is_lfahda_msg || is_scc_msg; //|| is_fca_msg;
bool block_msg = is_lkas_msg || is_lfahda_msg || is_scc_msg || is_scc13_msg; //|| is_fca_msg;
if (!block_msg) {
bus_fwd = 0;
}
Expand All @@ -321,8 +325,12 @@ static int hyundai_fwd_hook(int bus_num, int addr) {
bus_fwd = 0;
}
}
else if(is_scc_msg) {
if(now - last_ts_scc12_from_op >= 400000)
else if (is_scc_msg) {
if (now - last_ts_scc12_from_op >= 400000)
bus_fwd = 0;
}
else if (is_scc13_msg) {
if (now - last_ts_scc13_from_op >= 400000)
bus_fwd = 0;
}
else if(is_fca_msg) {
Expand Down
156 changes: 156 additions & 0 deletions scripts/add/amplifier_c3xl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#!/usr/bin/env python3
import time
from smbus2 import SMBus
from collections import namedtuple

# https://datasheets.maximintegrated.com/en/ds/MAX98089.pdf

AmpConfig = namedtuple('AmpConfig', ['name', 'value', 'register', 'offset', 'mask'])
EQParams = namedtuple('EQParams', ['K', 'k1', 'k2', 'c1', 'c2'])

def configs_from_eq_params(base, eq_params):
return [
AmpConfig("K (high)", (eq_params.K >> 8), base, 0, 0xFF),
AmpConfig("K (low)", (eq_params.K & 0xFF), base + 1, 0, 0xFF),
AmpConfig("k1 (high)", (eq_params.k1 >> 8), base + 2, 0, 0xFF),
AmpConfig("k1 (low)", (eq_params.k1 & 0xFF), base + 3, 0, 0xFF),
AmpConfig("k2 (high)", (eq_params.k2 >> 8), base + 4, 0, 0xFF),
AmpConfig("k2 (low)", (eq_params.k2 & 0xFF), base + 5, 0, 0xFF),
AmpConfig("c1 (high)", (eq_params.c1 >> 8), base + 6, 0, 0xFF),
AmpConfig("c1 (low)", (eq_params.c1 & 0xFF), base + 7, 0, 0xFF),
AmpConfig("c2 (high)", (eq_params.c2 >> 8), base + 8, 0, 0xFF),
AmpConfig("c2 (low)", (eq_params.c2 & 0xFF), base + 9, 0, 0xFF),
]

BASE_CONFIG = [
AmpConfig("MCLK prescaler", 0b01, 0x10, 4, 0b00110000),
AmpConfig("PM: enable speakers", 0b11, 0x4D, 4, 0b00110000),
AmpConfig("PM: enable DACs", 0b11, 0x4D, 0, 0b00000011),
AmpConfig("Enable PLL1", 0b1, 0x12, 7, 0b10000000),
AmpConfig("Enable PLL2", 0b1, 0x1A, 7, 0b10000000),
AmpConfig("DAI1: I2S mode", 0b00100, 0x14, 2, 0b01111100),
AmpConfig("DAI2: I2S mode", 0b00100, 0x1C, 2, 0b01111100),
AmpConfig("DAI1 Passband filtering: music mode", 0b1, 0x18, 7, 0b10000000),
AmpConfig("DAI1 voice mode gain (DV1G)", 0b00, 0x2F, 4, 0b00110000),
AmpConfig("DAI1 attenuation (DV1)", 0x0, 0x2F, 0, 0b00001111),
AmpConfig("DAI2 attenuation (DV2)", 0x0, 0x31, 0, 0b00001111),
AmpConfig("DAI2: DC blocking", 0b1, 0x20, 0, 0b00000001),
AmpConfig("DAI2: High sample rate", 0b0, 0x20, 3, 0b00001000),
AmpConfig("ALC enable", 0b1, 0x43, 7, 0b10000000),
AmpConfig("ALC/excursion limiter release time", 0b101, 0x43, 4, 0b01110000),
AmpConfig("ALC multiband enable", 0b1, 0x43, 3, 0b00001000),
AmpConfig("DAI1 EQ enable", 0b0, 0x49, 0, 0b00000001),
AmpConfig("DAI2 EQ clip detection disabled", 0b1, 0x32, 4, 0b00010000),
AmpConfig("DAI2 EQ attenuation", 0x5, 0x32, 0, 0b00001111),
AmpConfig("Excursion limiter upper corner freq", 0b100, 0x41, 4, 0b01110000),
AmpConfig("Excursion limiter lower corner freq", 0b00, 0x41, 0, 0b00000011),
AmpConfig("Excursion limiter threshold", 0b000, 0x42, 0, 0b00001111),
AmpConfig("Distortion limit (THDCLP)", 0x6, 0x46, 4, 0b11110000),
AmpConfig("Distortion limiter release time constant", 0b0, 0x46, 0, 0b00000001),
AmpConfig("Right DAC input mixer: DAI1 left", 0b0, 0x22, 3, 0b00001000),
AmpConfig("Right DAC input mixer: DAI1 right", 0b0, 0x22, 2, 0b00000100),
AmpConfig("Right DAC input mixer: DAI2 left", 0b1, 0x22, 1, 0b00000010),
AmpConfig("Right DAC input mixer: DAI2 right", 0b0, 0x22, 0, 0b00000001),
AmpConfig("DAI1 audio port selector", 0b10, 0x16, 6, 0b11000000),
AmpConfig("DAI2 audio port selector", 0b01, 0x1E, 6, 0b11000000),
AmpConfig("Enable left digital microphone", 0b1, 0x48, 5, 0b00100000),
AmpConfig("Enable right digital microphone", 0b1, 0x48, 4, 0b00010000),
AmpConfig("Enhanced volume smoothing disabled", 0b0, 0x49, 7, 0b10000000),
AmpConfig("Volume adjustment smoothing disabled", 0b0, 0x49, 6, 0b01000000),
AmpConfig("Zero-crossing detection disabled", 0b0, 0x49, 5, 0b00100000),
]

CONFIGS = {
"tici": [
AmpConfig("Right speaker output from right DAC", 0b1, 0x2C, 0, 0b11111111),
AmpConfig("Right Speaker Mixer Gain", 0b00, 0x2D, 2, 0b00001100),
AmpConfig("Right speaker output volume", 0x1c, 0x3E, 0, 0b00011111),
AmpConfig("DAI2 EQ enable", 0b1, 0x49, 1, 0b00000010),

*configs_from_eq_params(0x84, EQParams(0x274F, 0xC0FF, 0x3BF9, 0x0B3C, 0x1656)),
*configs_from_eq_params(0x8E, EQParams(0x1009, 0xC6BF, 0x2952, 0x1C97, 0x30DF)),
*configs_from_eq_params(0x98, EQParams(0x0F75, 0xCBE5, 0x0ED2, 0x2528, 0x3E42)),
*configs_from_eq_params(0xA2, EQParams(0x091F, 0x3D4C, 0xCE11, 0x1266, 0x2807)),
*configs_from_eq_params(0xAC, EQParams(0x0A9E, 0x3F20, 0xE573, 0x0A8B, 0x3A3B)),
],
"tizi": [
AmpConfig("Left speaker output from left DAC", 0b1, 0x2B, 0, 0b11111111),
AmpConfig("Right speaker output from right DAC", 0b1, 0x2C, 0, 0b11111111),
AmpConfig("Left Speaker Mixer Gain", 0b00, 0x2D, 0, 0b00000011),
AmpConfig("Right Speaker Mixer Gain", 0b00, 0x2D, 2, 0b00001100),
AmpConfig("Left speaker output volume", 0x17, 0x3D, 0, 0b00011111),
AmpConfig("Right speaker output volume", 0x17, 0x3E, 0, 0b00011111),

AmpConfig("DAI2 EQ enable", 0b0, 0x49, 1, 0b00000010),
AmpConfig("DAI2: DC blocking", 0b0, 0x20, 0, 0b00000001),
AmpConfig("ALC enable", 0b0, 0x43, 7, 0b10000000),
AmpConfig("DAI2 EQ attenuation", 0x2, 0x32, 0, 0b00001111),
AmpConfig("Excursion limiter upper corner freq", 0b001, 0x41, 4, 0b01110000),
AmpConfig("Excursion limiter threshold", 0b100, 0x42, 0, 0b00001111),
AmpConfig("Distortion limit (THDCLP)", 0x0, 0x46, 4, 0b11110000),
AmpConfig("Distortion limiter release time constant", 0b1, 0x46, 0, 0b00000001),
AmpConfig("Left DAC input mixer: DAI1 left", 0b0, 0x22, 7, 0b10000000),
AmpConfig("Left DAC input mixer: DAI1 right", 0b0, 0x22, 6, 0b01000000),
AmpConfig("Left DAC input mixer: DAI2 left", 0b1, 0x22, 5, 0b00100000),
AmpConfig("Left DAC input mixer: DAI2 right", 0b0, 0x22, 4, 0b00010000),
AmpConfig("Right DAC input mixer: DAI2 left", 0b0, 0x22, 1, 0b00000010),
AmpConfig("Right DAC input mixer: DAI2 right", 0b1, 0x22, 0, 0b00000001),
AmpConfig("Volume adjustment smoothing disabled", 0b1, 0x49, 6, 0b01000000),
],
}

class Amplifier:
AMP_I2C_BUS = 0
AMP_ADDRESS = 0x10

def __init__(self, debug=False):
self.debug = debug

def _get_shutdown_config(self, amp_disabled: bool) -> AmpConfig:
return AmpConfig("Global shutdown", 0b0 if amp_disabled else 0b1, 0x51, 7, 0b10000000)

def _set_configs(self, configs: list[AmpConfig]) -> None:
with SMBus(self.AMP_I2C_BUS) as bus:
for config in configs:
if self.debug:
print(f"Setting \"{config.name}\" to {config.value}:")

old_value = bus.read_byte_data(self.AMP_ADDRESS, config.register, force=True)
new_value = (old_value & (~config.mask)) | ((config.value << config.offset) & config.mask)
bus.write_byte_data(self.AMP_ADDRESS, config.register, new_value, force=True)

if self.debug:
print(f" Changed {hex(config.register)}: {hex(old_value)} -> {hex(new_value)}")

def set_configs(self, configs: list[AmpConfig]) -> bool:
# retry in case panda is using the amp
tries = 1
for i in range(1):
try:
self._set_configs(configs)
return True
except OSError:
print(f"Failed to set amp config, {tries - i - 1} retries left")
time.sleep(0.02)
return False

def set_global_shutdown(self, amp_disabled: bool) -> bool:
return self.set_configs([self._get_shutdown_config(amp_disabled), ])

def initialize_configuration(self, model: str) -> bool:
cfgs = [
self._get_shutdown_config(True),
*BASE_CONFIG,
*CONFIGS[model],
self._get_shutdown_config(False),
]
return self.set_configs(cfgs)


#if __name__ == "__main__":
#with open("/sys/firmware/devicetree/base/model") as f:
# model = f.read().strip('\x00')
#model = model.split('comma ')[-1]

#amp = Amplifier()
#amp.initialize_configuration(model)
6 changes: 3 additions & 3 deletions selfdrive/car/cruise.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def update_v_cruise(self, CS, sm, is_metric):
self.v_cruise_kph = np.clip(v_cruise_kph, 30, self._cruise_speed_max)
self.v_cruise_cluster_kph = self.v_cruise_kph
else:
self.v_cruise_kph = max(20, self.v_ego_kph_set) #V_CRUISE_UNSET
self.v_cruise_kph = np.clip(v_cruise_kph, self._cruise_speed_min, self._cruise_speed_max) #max(20, self.v_ego_kph_set) #V_CRUISE_UNSET
self.v_cruise_cluster_kph = self.v_cruise_kph #V_CRUISE_UNSET
#if self.cruise_state_available_last: # 최초 한번이라도 cruiseState.available이 True였다면
# self._lat_enabled = False
Expand Down Expand Up @@ -495,7 +495,7 @@ def _update_cruise_buttons(self, CS, CC, v_cruise_kph):
if self._soft_hold_active > 0:
self._soft_hold_active = 0
elif self._cruise_ready or not CC.enabled or CS.cruiseState.standstill or self.carrot_cruise_active:
if self._cruise_button_mode in [2, 3]:
if False: #self._cruise_button_mode in [2, 3]:
road_limit_kph = self.nRoadLimitSpeed * self.autoSpeedUptoRoadSpeedLimit
if road_limit_kph > 1.0:
v_cruise_kph = max(v_cruise_kph, road_limit_kph)
Expand Down Expand Up @@ -636,7 +636,7 @@ def _auto_speed_up(self, v_cruise_kph):
v_cruise_kph = self.nRoadLimitSpeed + self.autoRoadSpeedLimitOffset
elif self.nRoadLimitSpeed < self.nRoadLimitSpeed_last and self.autoRoadSpeedAdjust > 0:
new_road_limit_kph = self.nRoadLimitSpeed * self.autoRoadSpeedAdjust + v_cruise_kph * (1 - self.autoRoadSpeedAdjust)
self._add_log(f"AutoSpeed change {v_cruise_kph} -> {new_road_limit_kph}")
self._add_log(f"AutoSpeed change {v_cruise_kph} -> {new_road_limit_kph:.1f}")
v_cruise_kph = min(v_cruise_kph, new_road_limit_kph)
self.road_limit_kph = road_limit_kph
self.nRoadLimitSpeed_last = self.nRoadLimitSpeed
Expand Down
Loading
Loading