Skip to content

Commit 97a1cdf

Browse files
authored
Merge pull request commaai#203 from arne182/release2
Update to latest release2
2 parents 599f26c + 29c4f52 commit 97a1cdf

22 files changed

+363
-118
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ Highlight Features
1212

1313
* **Automatic Lane Change Assist (ALC)**: Check your surroundings, signal in the direction you would like to change lanes, and let openpilot do the rest. You can choose between three ALC profiles, Normal, Wifey, and Mad Max. Each increasing in steering torque.
1414
* **Stock Lane Keeping Assist (LKA)**: Arne has worked on recreating the lake keeping assist system present in your car for openpilot. It works with cruise control not engaged, attempting to steer to keep you inside your lane when it detects you are departing it.
15-
* **[Dynamic Following Distance Profile](https://github.com/ShaneSmiskol/openpilot/blob/dynamic-follow/README.md)**: Three following distance (TR) profiles are available to select; 0.9 seconds, 2.7 seconds, and a custom tuned dynamic follow profile. The first two behave as your stock cruise control system does. Dynamic follow aims to provide a more natural feeling drive, adjusting your distance from the lead car based on your speed, your relative velocity with the lead car, and your acceleration (or deceleration). If the system detects the lead car decelerating, your car should start to brake sooner than a hard-coded TR value. Same with accelerating
15+
* **[Dynamic Following Distance Profile](https://github.com/ShaneSmiskol/openpilot/blob/dynamic-follow/README.md)**: Three following distance (TR) profiles are available to select; 0.9 seconds, 2.7 seconds, and a custom tuned dynamic follow profile. The first two behave as your stock cruise control system does. Dynamic follow aims to provide a more natural feeling drive, adjusting your distance from the lead car based on your speed, your relative velocity with the lead car, and your acceleration (or deceleration). If the system detects the lead car decelerating, your car should start to brake sooner than a hard-coded TR value. Same with accelerating.
1616
* **Slow Mode (SLO)**: For cars with longitudinal control down to 0 mph, you have the option to activate SLO mode which enables you to set your car's cruise control under your car's limit. For example, you could coast along at 15, 10, or even 5 mph.
17-
* **Acceleration Profiles (GAS)**: You can select from two acceleration profiles with the GAS button. If your car accelerates too slowly for your liking, this will solve that.
17+
* **Acceleration Profiles (GAS)**: You can select from three acceleration profiles with the GAS button. If your car accelerates too slowly for your liking, this will solve that. **Recently added**: dynamic acceleration profile for users with comma pedals. This should provide a smoother acceleration experience in stop and go traffic.
1818
* **Select Vision Model (on 0.5.8, `dynamic-follow` branch only)**: You can select whether you would like to use the wiggly model or the normal vision model for path planning. Wiggly has more torque and can better guess the road curvature without lane lines, but it occasionally crashes or mispredicts the path.
1919
* **EON and openpilot Stats**: With the on-screen UI, you can view stats about your EON such as its temperature, your grey panda's GPS accuracy, the lead car's relative velocity, its distance, and more.
2020

21+
---
22+
2123
* [Community](#community)
2224
* [Hardware](#hardware)
2325
* [Supported Cars](#supported-cars)

op-tools.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import time, sys, json
2+
from os import system, name
3+
4+
def main_menu():
5+
print("Please chooce a category:")
6+
while True:
7+
print("1. Dynamic follow\n2. GPS\n3. Other")
8+
c = input("[1-3]: ")
9+
try:
10+
int(c)
11+
except:
12+
return
13+
if int(c) - 1 in range(3):
14+
break
15+
if int(c) == 1:
16+
dynamic_follow()
17+
18+
def dynamic_follow():
19+
clear()
20+
print("\nPress Ctrl + C at any time to quit!")
21+
time.sleep(3)
22+
try:
23+
while True:
24+
clear()
25+
print("\nDynamic follow data:\n")
26+
try:
27+
with open("/data/op-tools-data/dynamic-follow.json", "r") as f:
28+
data = json.loads(f.read())
29+
for i in data:
30+
print(i + ": " + str(data[i]))
31+
except:
32+
print("\nReading error, waiting a second...")
33+
time.sleep(1)
34+
time.sleep(.15)
35+
except KeyboardInterrupt:
36+
print()
37+
main_menu()
38+
39+
def clear():
40+
# for windows
41+
if name == 'nt':
42+
system('cls')
43+
44+
# for mac and linux(here, os.name is 'posix')
45+
else:
46+
system('clear')
47+
48+
49+
main_menu()
50+
51+
52+
'''while True:
53+
sys.stdout.write("\r\r\r" + time.ctime()+"\n"+time.ctime())
54+
sys.stdout.flush()
55+
time.sleep(1)'''

panda/board/safety/safety_toyota.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ const int TOYOTA_MAX_RT_DELTA = 375; // max delta torque allowed for real t
1616
const int TOYOTA_RT_INTERVAL = 250000; // 250ms between real time checks
1717

1818
// longitudinal limits
19-
const int TOYOTA_MAX_ACCEL = 1800; // 1.8 m/s2
20-
const int TOYOTA_MIN_ACCEL = -3600; // 3.6 m/s2
19+
const int TOYOTA_MAX_ACCEL = 3500; // 3.5 m/s2
20+
const int TOYOTA_MIN_ACCEL = -4000; // 4.0 m/s2
2121

2222
// global actuation limit state
2323
int toyota_actuation_limits = 1; // by default steer limits are imposed

selfdrive/car/car_helpers.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,27 @@ def fingerprint(logcan, timeout):
8181
return None, finger
8282

8383
time.sleep(0.01)
84-
85-
cloudlog.warning("fingerprinted %s", candidate_cars[0])
84+
try:
85+
with open("/data/kegman.json", "r") as f:
86+
cloudlog.warning(f.read())
87+
f.close()
88+
except:
89+
pass
90+
try:
91+
with open("/data/params/d/ControlsParams", "r") as f:
92+
cloudlog.warning(f.read())
93+
f.close()
94+
except:
95+
pass
96+
try:
97+
with open("/data/params/d/LiveParameters", "r") as f:
98+
cloudlog.warning(f.read())
99+
f.close()
100+
except:
101+
pass
86102
crash.capture_warning("fingerprinted %s" % candidate_cars[0])
103+
cloudlog.warning("fingerprinted %s", candidate_cars[0])
104+
87105
return (candidate_cars[0], finger)
88106

89107

selfdrive/car/chrysler/carstate.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from selfdrive.car.modules.UIBT_module import UIButtons,UIButton
55
from selfdrive.car.modules.UIEV_module import UIEvents
66
import numpy as np
7+
from selfdrive.kegman_conf import kegman_conf
78

89

910
def parse_gear_shifter(can_gear):
@@ -79,8 +80,9 @@ def get_camera_parser(CP):
7980

8081
class CarState(object):
8182
def __init__(self, CP):
83+
self.kegman = kegman_conf()
8284
self.alcaLabels = ["MadMax","Normal","Wifey","off"]
83-
self.alcaMode = 2 # default to wifey on startup
85+
self.alcaMode = int(self.kegman.conf['lastALCAMode'])
8486
self.prev_distance_button = 0
8587
self.distance_button = 0
8688
self.prev_lka_button = 0
@@ -170,8 +172,12 @@ def update_ui_buttons(self,id,btn_status):
170172
if (id == 1) and (btn_status == 0) and self.cstm_btns.btns[id].btn_name=="alca":
171173
if self.cstm_btns.btns[id].btn_label2 == self.alcaLabels[self.alcaMode]:
172174
self.alcaMode = (self.alcaMode + 1 ) % 4
175+
self.kegman.conf['lastALCAMode'] = str(self.alcaMode) # write last distance bar setting to file
176+
self.kegman.write_config(self.kegman.conf)
173177
else:
174178
self.alcaMode = 0
179+
self.kegman.conf['lastALCAMode'] = str(self.alcaMode) # write last distance bar setting to file
180+
self.kegman.write_config(self.kegman.conf)
175181
self.cstm_btns.btns[id].btn_label2 = self.alcaLabels[self.alcaMode]
176182
self.cstm_btns.hasChanges = True
177183
if self.alcaMode == 3:
@@ -183,6 +189,8 @@ def update_ui_buttons(self,id,btn_status):
183189
self.cstm_btns.btns[id].btn_status = btn_status
184190
if (id == 1) and self.cstm_btns.btns[id].btn_name=="alca":
185191
self.alcaMode = (self.alcaMode + 1 ) % 4
192+
self.kegman.conf['lastALCAMode'] = str(self.alcaMode) # write last distance bar setting to file
193+
self.kegman.write_config(self.kegman.conf)
186194
self.cstm_btns.btns[id].btn_label2 = self.alcaLabels[self.alcaMode]
187195
self.cstm_btns.hasChanges = True
188196

selfdrive/car/honda/carcontroller.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from selfdrive.car.honda.values import AH, CruiseButtons, CAR
99
from selfdrive.can.packer import CANPacker
1010
from selfdrive.car.modules.ALCA_module import ALCAController
11+
from selfdrive.kegman_conf import kegman_conf
12+
13+
kegman = kegman_conf()
1114

1215
def actuator_hystereses(brake, braking, brake_steady, v_ego, car_fingerprint):
1316
# hyst params
@@ -85,6 +88,7 @@ def __init__(self, dbc_name, enable_camera=True):
8588
self.enable_camera = enable_camera
8689
self.packer = CANPacker(dbc_name)
8790
self.new_radar_config = False
91+
self.prev_lead_distance = 0.0
8892
self.ALCA = ALCAController(self,True,False) # Enabled True and SteerByAngle only False
8993

9094
def update(self, sendcan, enabled, CS, frame, actuators, \
@@ -190,7 +194,16 @@ def update(self, sendcan, enabled, CS, frame, actuators, \
190194
if pcm_cancel_cmd:
191195
can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.CANCEL, idx))
192196
elif CS.stopped:
193-
can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx))
197+
if CS.CP.carFingerprint in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH):
198+
if CS.lead_distance > (self.prev_lead_distance + float(kegman.conf['leadDistance'])):
199+
can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx))
200+
elif CS.CP.carFingerprint in (CAR.CIVIC_BOSCH):
201+
if CS.hud_lead == 1:
202+
can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx))
203+
else:
204+
can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx))
205+
else:
206+
self.prev_lead_distance = CS.lead_distance
194207

195208
else:
196209
# Send gas and brake commands.

selfdrive/car/honda/carstate.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ def get_can_signals(CP):
9696
("STANDSTILL", 50)]
9797

9898
if CP.carFingerprint in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.CIVIC_BOSCH):
99-
signals += [("DRIVERS_DOOR_OPEN", "SCM_FEEDBACK", 1)]
99+
signals += [("DRIVERS_DOOR_OPEN", "SCM_FEEDBACK", 1),
100+
("LEAD_DISTANCE", "RADAR_HUD", 0)]
101+
checks += [("RADAR_HUD", 50)]
100102
else:
101103
signals += [("DOOR_OPEN_FL", "DOORS_STATUS", 1),
102104
("DOOR_OPEN_FR", "DOORS_STATUS", 1),
@@ -212,6 +214,8 @@ def __init__(self, CP):
212214
self.user_gas, self.user_gas_pressed = 0., 0
213215
self.brake_switch_prev = 0
214216
self.brake_switch_ts = 0
217+
self.lead_distance = 255
218+
self.hud_lead = 0
215219

216220
self.cruise_buttons = 0
217221
self.cruise_setting = 0
@@ -308,15 +312,21 @@ def update(self, cp, cp_cam):
308312
# update prevs, update must run once per loop
309313
self.prev_cruise_buttons = self.cruise_buttons
310314
self.prev_blinker_on = self.blinker_on
315+
self.prev_lead_distance = self.lead_distance
311316

312317
self.prev_left_blinker_on = self.left_blinker_on
313318
self.prev_right_blinker_on = self.right_blinker_on
314319

315320
# ******************* parse out can *******************
316321

317-
if self.CP.carFingerprint in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.CIVIC_BOSCH): # TODO: find wheels moving bit in dbc
322+
if self.CP.carFingerprint in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH): # TODO: find wheels moving bit in dbc
318323
self.standstill = cp.vl["ENGINE_DATA"]['XMISSION_SPEED'] < 0.1
319324
self.door_all_closed = not cp.vl["SCM_FEEDBACK"]['DRIVERS_DOOR_OPEN']
325+
self.lead_distance = cp.vl["RADAR_HUD"]['LEAD_DISTANCE']
326+
elif self.CP.carFingerprint in (CAR.CIVIC_BOSCH):
327+
self.standstill = cp.vl["ENGINE_DATA"]['XMISSION_SPEED'] < 0.1
328+
self.door_all_closed = not cp.vl["SCM_FEEDBACK"]['DRIVERS_DOOR_OPEN']
329+
self.hud_lead = cp.vl["ACC_HUD"]['HUD_LEAD']
320330
else:
321331
self.standstill = not cp.vl["STANDSTILL"]['WHEELS_MOVING']
322332
self.door_all_closed = not any([cp.vl["DOORS_STATUS"]['DOOR_OPEN_FL'], cp.vl["DOORS_STATUS"]['DOOR_OPEN_FR'],

selfdrive/car/honda/values.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class CAR:
9999
57: 3, 145: 8, 316: 8, 340: 8, 342: 6, 344: 8, 380: 8, 398: 3, 399: 6, 401: 8, 404: 4, 420: 8, 422: 8, 426: 8, 432: 7, 464: 8, 474: 5, 476: 4, 487: 4, 490: 8, 493: 3, 506: 8, 507: 1, 512: 6, 513: 6, 542: 7, 545: 4, 597: 8, 660: 8, 661: 4, 773: 7, 777: 8, 780: 8, 800: 8, 804: 8, 808: 8, 829: 5, 882: 2, 884: 7, 888: 8, 891: 8, 892: 8, 923: 2, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1033: 5, 1036: 8, 1039: 8, 1057: 5, 1064: 7, 1108: 8, 1125: 8, 1296: 8, 1365: 5, 1424: 5, 1600: 5, 1601: 8,
100100
}],
101101
CAR.CRV_5G: [{
102-
57: 3, 148: 8, 199: 4, 228: 5, 231: 5, 232: 7, 304: 8, 330: 8, 340: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 423: 2, 427: 3, 428: 8, 432: 7, 441: 5, 446: 3, 450: 8, 464: 8, 467: 2, 469: 3, 470: 2, 474: 8, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 507: 1, 545: 6, 597: 8, 661: 4, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 814: 4, 815: 8, 817: 4, 825: 4, 829: 5, 862: 8, 881: 8, 882: 4, 884: 8, 888: 8, 891: 8, 927: 8, 918: 7, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1108: 8, 1092: 1, 1115: 4, 1125: 8, 1127: 2, 1296: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1618: 5, 1633: 8, 1670: 5
102+
57: 3, 148: 8, 199: 4, 228: 5, 231: 5, 232: 7, 304: 8, 330: 8, 340: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 423: 2, 427: 3, 428: 8, 432: 7, 441: 5, 446: 3, 450: 8, 464: 8, 467: 2, 469: 3, 470: 2, 474: 8, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 507: 1, 545: 6, 597: 8, 661: 4, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 814: 4, 815: 8, 817: 4, 825: 4, 829: 5, 862: 8, 881: 8, 882: 4, 884: 8, 888: 8, 891: 8, 927: 8, 918: 7, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1108: 8, 1092: 1, 1093: 4, 1115: 4, 1125: 8, 1127: 2, 1296: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1618: 5, 1633: 8, 1670: 5
103103
}],
104104
# 2018 Odyssey w/ Added Comma Pedal Support (512L & 513L)
105105
CAR.ODYSSEY: [{

selfdrive/car/toyota/carstate.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,10 @@ def __init__(self, CP):
154154
self.Angle = [0, 5, 10, 15,20,25,30,35,60,100,180,270,500]
155155
self.Angle_Speed = [255,160,100,80,70,60,55,50,40,33,27,17,12]
156156
#labels for gas mode
157-
self.gasMode = 0
158-
self.gasLabels = ["normal","sport","eco"]
157+
self.gasMode = int(self.kegman.conf['lastGasMode'])
158+
self.sloMode = int(self.kegman.conf['lastSloMode'])
159+
self.sloLabels = ["offset","normal"]
160+
self.gasLabels = ["smooth","sport","eco"]
159161
#labelslabels for ALCA modes
160162
self.alcaLabels = ["MadMax","Normal","Wifey","off"]
161163
self.alcaMode = int(self.kegman.conf['lastALCAMode']) # default to last ALCAmode on startup
@@ -252,7 +254,7 @@ def init_ui_buttons(self):
252254
btns = []
253255
btns.append(UIButton("sound", "SND", 0, "", 0))
254256
btns.append(UIButton("alca", "ALC", 1, self.alcaLabels[self.alcaMode], 1))
255-
btns.append(UIButton("slow", "SLO", 1, "", 2))
257+
btns.append(UIButton("slow", "SLO", 1, self.sloLabels[self.sloMode], 2))
256258
btns.append(UIButton("lka", "LKA", 1, "", 3))
257259
btns.append(UIButton("tr", "TR", 0, "", 4))
258260
btns.append(UIButton("gas", "GAS", 1, self.gasLabels[self.gasMode], 5))
@@ -273,12 +275,17 @@ def update_ui_buttons(self,id,btn_status):
273275
self.cstm_btns.btns[id].btn_label2 = self.alcaLabels[self.alcaMode]
274276
self.cstm_btns.hasChanges = True
275277
if self.alcaMode == 3:
276-
self.cstm_btns.set_button_status("alca", 0)
278+
self.cstm_btns.set_button_status("alca", 0)
277279
elif (id == 5) and (btn_status == 0) and self.cstm_btns.btns[id].btn_name=="gas":
278280
if self.cstm_btns.btns[id].btn_label2 == self.gasLabels[self.gasMode]:
279281
self.gasMode = (self.gasMode + 1 ) % 3
282+
self.kegman.conf['lastGasMode'] = str(self.gasMode) # write last GasMode setting to file
283+
self.kegman.write_config(self.kegman.conf)
280284
else:
281285
self.gasMode = 0
286+
self.kegman.conf['lastGasMode'] = str(self.gasMode) # write last GasMode setting to file
287+
self.kegman.write_config(self.kegman.conf)
288+
282289
self.cstm_btns.btns[id].btn_label2 = self.gasLabels[self.gasMode]
283290
self.cstm_btns.hasChanges = True
284291
else:
@@ -435,8 +442,14 @@ def update(self, cp, cp_cam):
435442
else:
436443
if self.cstm_btns.get_button_status("slow") == 0:
437444
self.acc_slow_on = False
445+
self.sloMode = 0
446+
self.kegman.conf['lastSloMode'] = str(self.sloMode) # write last SloMode setting to file
447+
self.kegman.write_config(self.kegman.conf)
438448
else:
439449
self.acc_slow_on = True
450+
self.sloMode = 1
451+
self.kegman.conf['lastSloMode'] = str(self.sloMode) # write last SloMode setting to file
452+
self.kegman.write_config(self.kegman.conf)
440453

441454
# we could use the override bit from dbc, but it's triggered at too high torque values
442455
self.steer_override = abs(self.steer_torque_driver) > STEER_THRESHOLD

selfdrive/car/toyota/interface.py

+1
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ def update(self, c):
387387
ret.accSlowToggle = self.CS.acc_slow_on
388388
ret.readdistancelines = self.CS.read_distance_lines
389389
ret.gasbuttonstatus = self.CS.cstm_btns.get_button_status("gas")
390+
ret.gasbuttonstatus = self.CS.gasMode
390391
if self.CS.sport_on == 1:
391392
ret.gasbuttonstatus = 1
392393
if self.CS.econ_on == 1:

0 commit comments

Comments
 (0)