Skip to content

Commit 634e2f8

Browse files
krkeeganComma Devicepd0wm
authored and
Casey Francis
committed
Masteryota-Final
Masteryota-Final-2 Masteryota-Final-1 Masteryota Masteryota This reverts commit 916f2de. 1.8 accel max 1.25 follow Copied Sport vals from SA-Eco 3 hours off / saves your 12v battery Testing if the deadzone is causing the delay Or maybe it's the high ki values. Testing old known values from previous versions of OP. No deadzone Toyota logo instead of comma 1.2 follow Fork mods Fork mods lower gain, higher prediction, stiffer wheel, higher steer ratio Fork mods commit 5c673b6399737b3e0b9d9d54e0b830e0cb04b185 Author: cfranhonda <46506059+cfranhonda@users.noreply.github.com> Date: Wed Jul 28 15:47:27 2021 -0700 Fix steer max and make ki a bit higher. commit 039cf40ab0ac72ced1c19de6854b7761a109d4e6 Author: Casey Francis <@cfranhonda> Date: Tue Jul 27 23:19:30 2021 -0700 add LQR for other bosch kids commit 95efde9a50bc4ca38a81e5cfdb86d1307db41f3c Author: Casey Francis <@cfranhonda> Date: Tue Jul 27 22:34:51 2021 -0700 add LQR tune Fork mods commit 9b45eb1 Author: Daehyuk Ahn <daehyuk@live.com> Date: Mon May 24 23:14:34 2021 -0700 Add EnableGasPedal (toggle menu) commit 4e9ac3b Author: Casey Francis <@cfranhonda> Date: Sat Aug 21 17:36:22 2021 -0700 full speed fan commit 152dec1 Author: Casey Francis <@cfranhonda> Date: Sat Aug 21 07:45:17 2021 -0700 add vision/ disable radar toggle commit 5c48f3e Author: Casey Francis <@cfranhonda> Date: Sat Aug 21 07:35:54 2021 -0700 vaggy hack to stop jerk commit 87328dd Author: cfranhonda <46506059+cfranhonda@users.noreply.github.com> Date: Mon Aug 23 07:15:05 2021 -0700 eps mod / gasmax adjust commit baffaee Author: Vehicle Researcher <user@comma.ai> Date: Sun Aug 22 22:13:11 2021 -0700 openpilot v0.8.8 release adding "," fws for modded people Update thermald.py No sound for Saturated steering remove no gps alert Update power_monitoring.py Update interface.py green instead of red path LQR toggle add LQR toggle for select Honda's add LQR toggle for modded Civic's & CRV Revert "Universal LQR tune" This reverts commit c10adf7. add LQR toggle change description Universal LQR tune Universal LQR tune This tune taken from the Toyota Rav4 has shown to be a great alternative to the standard PID tune. It's worked very well on eps mod multipliers of 2, 2.5, 3.5, 4x. It climbs the torque scale much smoother and doesn't "jitter" like PID does sometimes. fix LQR for RDX kf under PID only. add Accord to LQR toggle Conflicts: selfdrive/boardd/boardd.cc selfdrive/controls/lib/events.py selfdrive/ui/qt/offroad/settings.cc LQR toggle lower ff +25% Cruise max add to release notes paramsd cpu usage has been increasing boardd: connect to all pandas if none specified (commaai#23805) Refactor convolutions (commaai#23807) * one conv with defines * add conv * building works on C3 * this is num_outputs too, process replay is so useful cleanup import chaining of T_IDXS (commaai#23806) bump panda ui.py: fix model lead plotting Param to allow upload over cellular (commaai#23811) * param to allow upload over cellular * brackets to be consistent * move outside loop * fix tests longitudinal planner: disable change cost when stopped. not engaged or gas pressed (commaai#23639) * disable change cost completely on standstill and gas press * cleanup * set accel to zero * clean up logic around standstill * update ref onroad_test: increase camerad cpu usage after debayer changes Update raw_logger/framereader to new new ffmpeg api (commaai#23799) * Update raw_logger/framereader to new new ffmpeg api * Can be removed now * Handled by avcodec_free_context * handle EAGAIN and clean up thneed: a few asserts in the optimizer for cases it will fail docs: fix title typo cabana for your terminal Fix tici bigmodel (commaai#23817) * Fix bigmodel on tici: cam intrinsics arent static * Give TICI route own name for import * Make function useable in offline test * typo * change tici ecam focal to trained focal * No shadow variable * Fixed ref * Force update this time * Update model replay ref commit 2022 Hyundai Elantra firmware versions (commaai#23818) Added 2022 Hyundai Elantra fwdCamera, transmission, and engine fingerprints. CARS.md add 2022 elantra hyundai: custom fw version for sonata eps (commaai#23816) * hyundai: custom fw version for sonata eps * another comment HKG: Kia Sorento FPv2 (commaai#23815) * Replace Kia Sorento FPv1 with FPv2 * keep old fingerprint Subaru: add FW for Impreza Limited UDM 2017 (commaai#23802) * FPv2: Add Subaru Impreza Limited USM 2017 * test_fw_query_on_routes.py: add subaru support Fix unmetered upload over cell (fix commaai#23811) (commaai#23820) omx encoder: move writing into thread (commaai#23771) * omx encoder: move writing to separate thread * fix include * pop * log buffers sizes * split copy and write adjust comma two model timing thresholds after bigmodel Toyota: fix flaky EV detection (commaai#23825) script to clear DTCs move lock clearing to uploader (commaai#23826) * move lock clearing to uploader * test case Honda: revert to button enable on Nidec (commaai#23828) * Honda: revert to button enable on Nidec * fix test * bump panda Added (Ecu.eps) fingerprint for Hyundai Ioniq EV 2017 (commaai#23823) fix mac_setup w/ tools+plotjuggler (commaai#23552) * fix pycurl issue: * use newer curl backend for pip install * update lib paths based on brew prefix * fix cert issue when using pycurl using certifi * make output setup nicer * fix linter * typo * dont need that actually * revert * pipenv in brew * forgot this * make brew available on fresh install * undo * more undo * oops * use sytem curl, but homebrew openssl replay: use QCoreApplication (commaai#23831) scons: use correct brew prefix (commaai#23833) replay: use VideoToolbox HW decoder on Mac (commaai#23832) * replay: support VideoToolbox HW decoding * rename flag * remove debug assert Fix watch3 on mac (commaai#23834) this seems to about what my car converges to (commaai#23836) boardd: handle missing pandas Subaru: remove Impreza CAN fingerprints (commaai#23841) * Subaru: remove Impreza CAN fingerprints * fix process replay * update refs Toyota: remove outdated comment (commaai#23844) Remove unused MPC_COST_LONG class (commaai#23843) Faster cruise max Update interface.py :warning: Remove Test Branch Warning; Disable Updates; Remove Prime Ad Disabling of not tested branch warning should only affect users with ssh access to repo (me) and only the main Rav4-TSS2 branch. Disabled in a way that hopefully doesn't harm comma's metrics. Update interface.py faster accel max Use INDI instead of LQR for select Toyota's Add camry to indi bump up gain 10% Prius tss2 INDI instead of LQR for Prius tss2 INDI Update interface.py Lower PID for smoother wheel Update tunes.py Update interface.py Update tunes.py Update interface.py almost stock accel max This reverts commit 9c775d0. Stockify accel Faster accel from start rearrange Steering fault fix Update safety_toyota.h Update carcontroller.py Steering fault fix fault fix 1 fix conflict Rename oops Classic comma spinner '2' boot logo smaller '2' Revert "smaller '2'" This reverts commit 629267e. i think its fixed now Revert "Steering fault fix" This reverts commit 4b33fea. Revert "rearrange" This reverts commit b054950. Revert "Faster accel from start" This reverts commit 03dac75. Remove op long toggle since it's broken fixed traffic TF This reverts commit 6be8366. fixed traffic TF Revert ":warning: Remove Test Branch Warning; Disable Updates; Remove Prime Ad" This reverts commit 11afa4c. tiny bit more boost at take-off Features list Features list Update README.md offset to match dash not just prius speed factor hack for Prius speed factor hack for Prius Update carstate.py offset speed to match dash Dev UI Dev UI Update img_brake_disc.png Update onroad.cc Update onroad.cc add signal for brake disc Update onroad.cc NEOS 20 Turning the speed Red rename Turning the speed Red hotFix add Rav4 to INDI Update interface.py Update longitudinal_planner.py Co-Authored-By: Comma Device <device@comma.ai> Co-Authored-By: Willem Melching <willem.melching@gmail.com>
1 parent 129a6f2 commit 634e2f8

28 files changed

+456
-53
lines changed

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
*Based off of Keegans stuff*
2+
*This fork includes the following additions*:
3+
4+
- 3 follow distances, 1.8, 1.45, 1.2 m/s (Toyota only) (Thanks @Keegan)
5+
- Red mph when braking (Thanks @alexandresato)
6+
- Brake disc icon when braking (Thanks @Berno22)
7+
- DevUI with steering angles and lead distance (Thanks @wirelessnet2)
8+
- Rainbow path (changes colors when turning)
9+
- Legacy engage/disgage sounds
10+
- NEOS 20 for bootloop fix (Thanks @Erich)
11+
- INDI steer controllers for Camry/Prius/Rav4 Tss 2.0 (toggle) (Thanks @kumar)
12+
- LQR steer controller for Civic / Accord / CRV (toggle)
13+
- No disengage on brake (toggle)
14+
- Device turns off 3 hours after shutting the car down
15+
- Modded fw detection and tuning for eps mod, Civics / CRV.
16+
17+
- If this fork has helped you, please consider donating to my paypal:
18+
- https://www.paypal.com/donate/?hosted_button_id=ZJQD2YEQEFVHY
19+
- ![myqrcode](https://user-images.githubusercontent.com/46506059/172424461-c195174a-6450-4b84-ac25-e8632d49fceb.png)
20+
21+
22+
123
WARNING
224
------
325

@@ -112,4 +134,4 @@ User shall indemnify and hold harmless Author and its directors, officers, emplo
112134

113135
**THIS IS ALPHA QUALITY SOFTWARE FOR RESEARCH PURPOSES ONLY. THIS IS NOT A PRODUCT.
114136
YOU ARE RESPONSIBLE FOR COMPLYING WITH LOCAL LAWS AND REGULATIONS.
115-
NO WARRANTY EXPRESSED OR IMPLIED.**
137+
NO WARRANTY EXPRESSED OR IMPLIED.**

RELEASES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version 0.8.13.1 (2022-04-27)
2+
========================
3+
* NEOS 20: improved reliability
4+
15
Version 0.8.13 (2022-02-18)
26
========================
37
* Improved driver monitoring

cereal/car.capnp

+4-1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ struct CarState {
188188
# clutch (manual transmission only)
189189
clutchPressed @28 :Bool;
190190

191+
lkMode @39 :Bool;
192+
engineRPM @40 :Float32;
193+
191194
# which packets this state came from
192195
canMonoTimes @12: List(UInt64);
193196

@@ -196,7 +199,7 @@ struct CarState {
196199
rightBlindspot @34 :Bool; # Is there something blocking the right lane change
197200

198201
# KRKeegan toyota distance lines
199-
distanceLines @39 :UInt8;
202+
distanceLines @41 :UInt8;
200203

201204
struct WheelSpeeds {
202205
# optional wheel speeds

launch_env.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export OPENBLAS_NUM_THREADS=1
77
export VECLIB_MAXIMUM_THREADS=1
88

99
if [ -z "$REQUIRED_NEOS_VERSION" ]; then
10-
export REQUIRED_NEOS_VERSION="19.1"
10+
export REQUIRED_NEOS_VERSION="20"
1111
fi
1212

1313
if [ -z "$AGNOS_VERSION" ]; then

selfdrive/assets/img_brake_disc.png

51.3 KB
Loading

selfdrive/assets/img_chffr_wheel.png

-837 Bytes
Loading

selfdrive/assets/sounds/disengage.wav

-27.3 KB
Binary file not shown.

selfdrive/assets/sounds/engage.wav

-21.9 KB
Binary file not shown.

selfdrive/car/honda/carstate.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
def get_can_signals(CP, gearbox_msg, main_on_sig_msg):
1414
signals = [
15+
("ENGINE_RPM", "POWERTRAIN_DATA"),
1516
("XMISSION_SPEED", "ENGINE_DATA"),
1617
("WHEEL_SPEED_FL", "WHEEL_SPEEDS"),
1718
("WHEEL_SPEED_FR", "WHEEL_SPEEDS"),
@@ -167,6 +168,7 @@ def __init__(self, CP):
167168
self.brake_switch_active = False
168169
self.cruise_setting = 0
169170
self.v_cruise_pcm_prev = 0
171+
self.engineRPM = 0
170172

171173
def update(self, cp, cp_cam, cp_body):
172174
ret = car.CarState.new_message()
@@ -229,6 +231,7 @@ def update(self, cp, cp_cam, cp_body):
229231
ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_stalk(
230232
250, cp.vl["SCM_FEEDBACK"]["LEFT_BLINKER"], cp.vl["SCM_FEEDBACK"]["RIGHT_BLINKER"])
231233
ret.brakeHoldActive = cp.vl["VSA_STATUS"]["BRAKE_HOLD_ACTIVE"] == 1
234+
self.engineRPM = cp.vl["POWERTRAIN_DATA"]["ENGINE_RPM"]
232235

233236
if self.CP.carFingerprint in (CAR.CIVIC, CAR.ODYSSEY, CAR.ODYSSEY_CHN, CAR.CRV_5G, CAR.ACCORD, CAR.ACCORDH, CAR.CIVIC_BOSCH,
234237
CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G, CAR.HONDA_E):

selfdrive/car/honda/interface.py

+75-11
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,19 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
9797
# modified filter output values: 0x009F, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0400, 0x0480
9898
# note: max request allowed is 4096, but request is capped at 3840 in firmware, so modifications result in 2x max
9999
ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2560, 8000], [0, 2560, 3840]]
100-
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.1]]
100+
# Use LQR tune if param is set
101+
if Params().get_bool('LqrTune'):
102+
ret.lateralTuning.init('lqr')
103+
ret.lateralTuning.lqr.scale = 1200.0
104+
ret.lateralTuning.lqr.ki = 0.02
105+
ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
106+
ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
107+
ret.lateralTuning.lqr.c = [1., 0.]
108+
ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255]
109+
ret.lateralTuning.lqr.l = [0.3233671, 0.3185757]
110+
ret.lateralTuning.lqr.dcGain = 0.002737852961363602
111+
else:
112+
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.1]]
101113
else:
102114
ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2560], [0, 2560]]
103115
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[1.1], [0.33]]
@@ -109,9 +121,25 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
109121
ret.wheelbase = CivicParams.WHEELBASE
110122
ret.centerToFront = CivicParams.CENTER_TO_FRONT
111123
ret.steerRatio = 15.38 # 10.93 is end-to-end spec
112-
ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end
124+
if eps_modified:
125+
ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2564, 8000], [0, 2564, 3840]]
126+
# Use LQR tune if param is set
127+
if Params().get_bool('LqrTune'):
128+
ret.lateralTuning.init('lqr')
129+
ret.lateralTuning.lqr.scale = 1200.0
130+
ret.lateralTuning.lqr.ki = 0.1
131+
ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
132+
ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
133+
ret.lateralTuning.lqr.c = [1., 0.]
134+
ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255]
135+
ret.lateralTuning.lqr.l = [0.3233671, 0.3185757]
136+
ret.lateralTuning.lqr.dcGain = 0.002237852961363602
137+
else:
138+
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.36], [0.108]] #minus 10% from 0.4, 0.12
139+
else:
140+
ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end
141+
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]]
113142
tire_stiffness_factor = 1.
114-
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]]
115143

116144
elif candidate in (CAR.ACCORD, CAR.ACCORDH):
117145
stop_and_go = True
@@ -120,13 +148,21 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
120148
ret.centerToFront = ret.wheelbase * 0.39
121149
ret.steerRatio = 16.33 # 11.82 is spec end-to-end
122150
ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end
123-
tire_stiffness_factor = 0.8467
124-
125-
if eps_modified:
126-
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.09]]
151+
# Use LQR tune if param is set
152+
if Params().get_bool('LqrTune'):
153+
ret.lateralTuning.init('lqr')
154+
ret.lateralTuning.lqr.scale = 1200.0
155+
ret.lateralTuning.lqr.ki = 0.1
156+
ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
157+
ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
158+
ret.lateralTuning.lqr.c = [1., 0.]
159+
ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255]
160+
ret.lateralTuning.lqr.l = [0.3233671, 0.3185757]
161+
ret.lateralTuning.lqr.dcGain = 0.002237852961363602
127162
else:
128163
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]]
129-
164+
tire_stiffness_factor = 0.8467
165+
130166
elif candidate == CAR.ACURA_ILX:
131167
stop_and_go = False
132168
ret.mass = 3095. * CV.LB_TO_KG + STD_CARGO_KG
@@ -159,7 +195,19 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
159195
# stock request output values: 0x0000, 0x0500, 0x0A15, 0x0E6D, 0x1100, 0x1200, 0x129A, 0x134D, 0x1400
160196
# modified request output values: 0x0000, 0x0500, 0x0A15, 0x0E6D, 0x1100, 0x1200, 0x1ACD, 0x239A, 0x2800
161197
ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2560, 10000], [0, 2560, 3840]]
162-
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.21], [0.07]]
198+
# Use LQR tune if param is set
199+
if Params().get_bool('LqrTune'):
200+
ret.lateralTuning.init('lqr')
201+
ret.lateralTuning.lqr.scale = 1200.0
202+
ret.lateralTuning.lqr.ki = 0.1
203+
ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
204+
ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
205+
ret.lateralTuning.lqr.c = [1., 0.]
206+
ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255]
207+
ret.lateralTuning.lqr.l = [0.3233671, 0.3185757]
208+
ret.lateralTuning.lqr.dcGain = 0.002237852961363602
209+
else:
210+
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.21], [0.07]]
163211
else:
164212
ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 3840], [0, 3840]]
165213
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.64], [0.192]]
@@ -224,11 +272,25 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
224272
ret.mass = 4068. * CV.LB_TO_KG + STD_CARGO_KG
225273
ret.wheelbase = 2.75
226274
ret.centerToFront = ret.wheelbase * 0.41
227-
ret.steerRatio = 11.95 # as spec
275+
ret.steerRatio = 16.0 #11.95 is spec
228276
ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 3840], [0, 3840]]
229-
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.06]]
277+
# Use LQR tune if param is set
278+
if Params().get_bool('LqrTune'):
279+
ret.lateralTuning.init('lqr')
280+
ret.lateralTuning.lqr.scale = 1200.0
281+
ret.lateralTuning.lqr.ki = 0.1
282+
ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
283+
ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
284+
ret.lateralTuning.lqr.c = [1., 0.]
285+
ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255]
286+
ret.lateralTuning.lqr.l = [0.3233671, 0.3185757]
287+
ret.lateralTuning.lqr.dcGain = 0.002237852961363602
288+
else:
289+
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.06]]
290+
ret.lateralTuning.pid.kf = 0.00007818594
230291
tire_stiffness_factor = 0.677
231292

293+
232294
elif candidate == CAR.ODYSSEY:
233295
stop_and_go = False
234296
ret.mass = 4471. * CV.LB_TO_KG + STD_CARGO_KG
@@ -340,6 +402,8 @@ def update(self, c, can_strings):
340402

341403
ret.canValid = self.cp.can_valid and self.cp_cam.can_valid and (self.cp_body is None or self.cp_body.can_valid)
342404

405+
ret.lkMode = self.CS.lkMode
406+
ret.engineRPM = self.CS.engineRPM
343407
buttonEvents = []
344408

345409
if self.CS.cruise_buttons != self.CS.prev_cruise_buttons:

selfdrive/car/honda/values.py

+9
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,15 @@ class CAR:
493493
b'39990-TGG-J510\x00\x00',
494494
b'39990-TGL-E130\x00\x00',
495495
b'39990-TGN-E120\x00\x00',
496+
b'39990-TBA,C020\x00\x00',
497+
b'39990-TBA,C120\x00\x00',
498+
b'39990-TEA,T820\x00\x00',
499+
b'39990-TEZ,T020\x00\x00',
500+
b'39990-TGG,A020\x00\x00',
501+
b'39990-TGG,A120\x00\x00',
502+
b'39990-TGG,J510\x00\x00',
503+
b'39990-TGL,E130\x00\x00',
504+
b'39990-TGN,E120\x00\x00',
496505
],
497506
(Ecu.srs, 0x18da53f1, None): [
498507
b'77959-TBA-A060\x00\x00',

selfdrive/car/toyota/carstate.py

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def update(self, cp, cp_cam):
3838

3939
ret.brakePressed = cp.vl["BRAKE_MODULE"]["BRAKE_PRESSED"] != 0
4040
ret.brakeHoldActive = cp.vl["ESP_CONTROL"]["BRAKE_HOLD_ACTIVE"] == 1
41+
ret.brakeLightsDEPRECATED = bool(cp.vl["ESP_CONTROL"]["BRAKE_LIGHTS_ACC"] or ret.brakePressed or ret.brakeHoldActive)
4142
if self.CP.enableGasInterceptor:
4243
ret.gas = (cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS"] + cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS2"]) / 2.
4344
ret.gasPressed = ret.gas > 15
@@ -161,6 +162,7 @@ def get_can_parser(CP):
161162
("TURN_SIGNALS", "BLINKERS_STATE"),
162163
("LKA_STATE", "EPS_STATUS"),
163164
("AUTO_HIGH_BEAM", "LIGHT_STALK"),
165+
("BRAKE_LIGHTS_ACC", "ESP_CONTROL", 0)
164166
]
165167

166168
checks = [

selfdrive/car/toyota/interface.py

+31-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
from cereal import car
33
from common.numpy_fast import interp
4+
from common.params import Params
45
from selfdrive.config import Conversions as CV
56
from selfdrive.car.toyota.tunes import LatTunes, LongTunes, set_long_tune, set_lat_tune
67
from selfdrive.car.toyota.values import Ecu, CAR, ToyotaFlags, TSS2_CAR, NO_DSU_CAR, MIN_ACC_SPEED, EPS_SCALE, EV_HYBRID_CAR, CarControllerParams
@@ -91,7 +92,13 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
9192
ret.steerRatio = 13.7
9293
tire_stiffness_factor = 0.7933
9394
ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid
94-
set_lat_tune(ret.lateralTuning, LatTunes.PID_C)
95+
if Params().get_bool('LqrTune'):
96+
set_lat_tune(ret.lateralTuning, LatTunes.INDI_PRIUS_TSS2)
97+
ret.steerActuatorDelay = 0.3
98+
ret.steerRateCost = 1.25
99+
ret.steerLimitTimer = 0.5
100+
else:
101+
set_lat_tune(ret.lateralTuning, LatTunes.PID_C)
95102

96103
elif candidate in (CAR.HIGHLANDER_TSS2, CAR.HIGHLANDERH_TSS2):
97104
stop_and_go = True
@@ -122,13 +129,25 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
122129
ret.steerRatio = 14.3
123130
tire_stiffness_factor = 0.7933
124131
ret.mass = 3585. * CV.LB_TO_KG + STD_CARGO_KG # Average between ICE and Hybrid
125-
set_lat_tune(ret.lateralTuning, LatTunes.PID_D)
132+
if Params().get_bool('LqrTune'):
133+
set_lat_tune(ret.lateralTuning, LatTunes.INDI_PRIUS_TSS2)
134+
ret.steerActuatorDelay = 0.3
135+
ret.steerRateCost = 1.25
136+
ret.steerLimitTimer = 0.5
137+
else:
138+
set_lat_tune(ret.lateralTuning, LatTunes.PID_D)
126139

127140
# 2019+ Rav4 TSS2 uses two different steering racks and specific tuning seems to be necessary.
128141
# See https://github.com/commaai/openpilot/pull/21429#issuecomment-873652891
129142
for fw in car_fw:
130143
if fw.ecu == "eps" and (fw.fwVersion.startswith(b'\x02') or fw.fwVersion in [b'8965B42181\x00\x00\x00\x00\x00\x00']):
131-
set_lat_tune(ret.lateralTuning, LatTunes.PID_I)
144+
if Params().get_bool('LqrTune'):
145+
set_lat_tune(ret.lateralTuning, LatTunes.INDI_RAV4_TSS2)
146+
ret.steerActuatorDelay = 0.3
147+
ret.steerRateCost = 1.25
148+
ret.steerLimitTimer = 0.5
149+
else:
150+
set_lat_tune(ret.lateralTuning, LatTunes.PID_I)
132151
break
133152

134153
elif candidate in (CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2):
@@ -181,10 +200,16 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
181200
elif candidate == CAR.PRIUS_TSS2:
182201
stop_and_go = True
183202
ret.wheelbase = 2.70002 # from toyota online sepc.
184-
ret.steerRatio = 13.4 # True steerRatio from older prius
203+
ret.steerRatio = 13.4 # unknown end-to-end spec
185204
tire_stiffness_factor = 0.6371 # hand-tune
186205
ret.mass = 3115. * CV.LB_TO_KG + STD_CARGO_KG
187-
set_lat_tune(ret.lateralTuning, LatTunes.PID_N)
206+
if Params().get_bool('LqrTune'):
207+
set_lat_tune(ret.lateralTuning, LatTunes.INDI_PRIUS_TSS2)
208+
ret.steerActuatorDelay = 0.3
209+
ret.steerRateCost = 1.25
210+
ret.steerLimitTimer = 0.5
211+
else:
212+
set_lat_tune(ret.lateralTuning, LatTunes.PID_N)
188213

189214
elif candidate == CAR.MIRAI:
190215
stop_and_go = True
@@ -240,7 +265,7 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
240265
# Improved longitudinal tune settings from sshane
241266
ret.vEgoStopping = 0.2 # car is near 0.1 to 0.2 when car starts requesting stopping accel
242267
ret.vEgoStarting = 0.2 # needs to be > or == vEgoStopping
243-
ret.stoppingDecelRate = 0.4 # reach stopping target smoothly - seems to take 0.5 seconds to go from 0 to -0.4
268+
ret.stoppingDecelRate = 0.3 # reach stopping target smoothly - seems to take 0.5 seconds to go from 0 to -0.4
244269
ret.longitudinalActuatorDelayLowerBound = 0.3
245270
ret.longitudinalActuatorDelayUpperBound = 0.3
246271
else:

selfdrive/car/toyota/tunes.py

+28
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class LatTunes(Enum):
2424
PID_L = 13
2525
PID_M = 14
2626
PID_N = 15
27+
INDI_PRIUS_TSS2 = 16
28+
INDI_RAV4_TSS2 = 17
29+
2730

2831

2932
###### LONG ######
@@ -61,6 +64,31 @@ def set_lat_tune(tune, name):
6164
tune.indi.actuatorEffectivenessBP = [0.]
6265
tune.indi.actuatorEffectivenessV = [1.0]
6366

67+
elif name == LatTunes.INDI_PRIUS_TSS2:
68+
tune.init('indi')
69+
tune.indi.innerLoopGainBP = [20, 24, 30]
70+
tune.indi.innerLoopGainV = [7.25, 7.5, 9]
71+
tune.indi.outerLoopGainBP = [20, 24, 30]
72+
tune.indi.outerLoopGainV = [6, 7.25, 6]
73+
tune.indi.timeConstantBP = [20, 24]
74+
tune.indi.timeConstantV = [2.0, 2.2]
75+
tune.indi.actuatorEffectivenessBP = [20, 24]
76+
tune.indi.actuatorEffectivenessV = [2, 3]
77+
78+
elif name == LatTunes.INDI_RAV4_TSS2:
79+
tune.init('indi')
80+
tune.indi.innerLoopGainBP = [5.0, 8.3, 11.1, 12.10, 13.9, 16.7, 18, 20, 25, 30]
81+
tune.indi.innerLoopGainV = [3.13, 5.2, 6.66, 7.8, 8.8, 10, 10.8, 12, 15, 15]
82+
tune.indi.outerLoopGainBP = [5.0, 8.3, 11.1, 12.10, 13.9, 16.7, 18, 20, 25, 30]
83+
tune.indi.outerLoopGainV = [2.9, 4.97, 6.51, 7.65, 8.58, 9.78, 10.58, 11.83, 14.9, 14.998]
84+
# inner - outer difference 0.23, 0.23, 0.15, 0.15, 0.22, 0.22 , 0.22, 0.16, 0.1, 0.002
85+
tune.indi.timeConstantBP = [5.0, 8.33, 11.1, 13.9, 16.7, 17.5, 18, 20, 22.5, 23.88, 23.89, 30, 40]
86+
tune.indi.timeConstantV = [0.1461, 0.2427, 0.27871, 0.3, 0,3, 0.3, 0.5, 0.6250, 0.85, 1.1, 2.2, 2.6, 3.2]
87+
#tune.indi.timeConstantV = [0.1461, 0.2427, 0.27871, 0.312, 0,315, 0.32, 0.525, 0.6250, 0.85, 1.1, 1.2, 2.3, 2.6]
88+
tune.indi.actuatorEffectivenessBP = [10, 13, 14, 25, 33]
89+
tune.indi.actuatorEffectivenessV = [15, 13, 13, 15, 15]
90+
91+
6492
elif name == LatTunes.LQR_RAV4:
6593
tune.init('lqr')
6694
tune.lqr.scale = 1500.0

selfdrive/common/params.cc

+1
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ std::unordered_map<std::string, uint32_t> keys = {
177177
{"Offroad_TemperatureTooHigh", CLEAR_ON_MANAGER_START},
178178
{"Offroad_UnofficialHardware", CLEAR_ON_MANAGER_START},
179179
{"Offroad_UpdateFailed", CLEAR_ON_MANAGER_START},
180+
{"LqrTune", PERSISTENT},
180181
};
181182

182183
} // namespace

selfdrive/common/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define COMMA_VERSION "0.8.13"
1+
#define COMMA_VERSION "0.8.13.1"

0 commit comments

Comments
 (0)