Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
6424e07
limit charge to 67-70%
csouers Jun 17, 2018
2bd5308
syntax fix
csouers Jun 17, 2018
8d3689e
Merge branch 'devel' into my_mods
csouers Jun 19, 2018
7288542
add homeassistant
csouers Jun 25, 2018
43e5996
add homeassistant
csouers Jun 25, 2018
3c31f6e
fix manager
csouers Jun 25, 2018
b269895
fix manager
csouers Jun 25, 2018
b4f6cda
move things around
csouers Jun 25, 2018
9132bc0
move things around
csouers Jun 25, 2018
efcb70c
set back to 60 second delay
csouers Jun 25, 2018
841c4cb
set back to 60 second delay
csouers Jun 25, 2018
30be405
Revert "fix manager"
csouers Jun 25, 2018
34bea7d
Revert "fix manager"
csouers Jun 25, 2018
739db96
Revert "Revert "fix manager""
csouers Jun 25, 2018
76758ab
Revert "Revert "fix manager""
csouers Jun 25, 2018
31bf52f
Revert "move things around"
csouers Jun 25, 2018
b3edb76
Revert "move things around"
csouers Jun 25, 2018
e9e2d31
back to 3 for testing...
csouers Jun 25, 2018
588a82a
back to 3 for testing...
csouers Jun 25, 2018
b911b04
refactor to make it actually wait for a good ping
csouers Jun 25, 2018
e24d411
refactor to make it actually wait for a good ping
csouers Jun 25, 2018
2b32537
timer again
csouers Jun 25, 2018
91fff05
timer again
csouers Jun 25, 2018
8086dcb
fix and remove data
csouers Jun 25, 2018
d59194c
fix and remove data
csouers Jun 25, 2018
61d3aee
private goodness
csouers Jun 25, 2018
583fc06
Merge branch 'my_mods' of https://github.com/csouers/openpilot into m…
csouers Jun 25, 2018
d2f1f26
stuff and timer fix
csouers Jun 25, 2018
b3223a8
ignore secrets
csouers Jun 26, 2018
c3897cd
Merge branch 'devel' into my_mods
csouers Jun 26, 2018
934b810
First try for radarless
csouers Jul 8, 2018
9e4ac98
dbc fix
csouers Jul 8, 2018
60cba74
try 2
csouers Jul 8, 2018
e941e0e
add enableRadar to capnp and change safety mode
csouers Jul 8, 2018
85a8535
fail
csouers Jul 8, 2018
1b69ed8
carstate change
csouers Jul 8, 2018
7f61dfe
carstate
csouers Jul 8, 2018
2a2aa46
carstate
csouers Jul 8, 2018
d9de863
carstate
csouers Jul 8, 2018
8d9dd17
carstate
csouers Jul 8, 2018
1e1ea35
carstate
csouers Jul 8, 2018
c303b91
carstate
csouers Jul 8, 2018
11db122
carstate
csouers Jul 8, 2018
d554924
hondacan
csouers Jul 8, 2018
865d514
hondacan
csouers Jul 8, 2018
5f9188f
interface
csouers Jul 8, 2018
1f5c338
interface
csouers Jul 8, 2018
df097ff
fake the camera too
csouers Jul 8, 2018
e623762
interface
csouers Jul 8, 2018
54d6791
new dbc
csouers Jul 8, 2018
62ab877
dbc fix
csouers Jul 8, 2018
1adf37d
dbc again...
csouers Jul 8, 2018
ba3e0ec
dbc
csouers Jul 8, 2018
ffd48dd
print dbc for debug
csouers Jul 8, 2018
a923740
print
csouers Jul 8, 2018
bfa3ec8
more debugs
csouers Jul 8, 2018
aa1c361
move debug
csouers Jul 8, 2018
542d42f
debug
csouers Jul 8, 2018
8cd1e7b
more debug and beep fix
csouers Jul 8, 2018
4ab907d
hondacan syntax
csouers Jul 8, 2018
21b9961
fix?
csouers Jul 8, 2018
3ebdb41
go back
csouers Jul 8, 2018
143d9cd
hondacan
csouers Jul 8, 2018
84853ad
make radarOffCan good again
csouers Jul 8, 2018
d2612fa
debug print
csouers Jul 8, 2018
da3ea61
less debug
csouers Jul 8, 2018
d076bcb
less debug
csouers Jul 8, 2018
b78d4de
things
csouers Jul 8, 2018
c49bc57
is this it?
csouers Jul 8, 2018
b8d674b
turn off mocked radar
csouers Jul 8, 2018
6b3e18e
no radar dbc for hatch
csouers Jul 8, 2018
6f8629c
Revert "turn off mocked radar"
csouers Jul 8, 2018
35199fa
hondacan
csouers Jul 8, 2018
2918f51
hondacan
csouers Jul 8, 2018
da4c8af
trial
csouers Jul 8, 2018
2ca66fe
hondacan
csouers Jul 8, 2018
eb4a80f
manually set bus
csouers Jul 8, 2018
6a3b721
disable highbeam message
csouers Jul 8, 2018
9a7ee40
fix variablen name
csouers Jul 8, 2018
bf9a185
blank_1fa
csouers Jul 8, 2018
34e3f80
use the huddata's cruise speed for ui
csouers Jul 8, 2018
3415488
fix
csouers Jul 8, 2018
b49f4d0
static test
csouers Jul 8, 2018
a890648
acc hud syntax
csouers Jul 8, 2018
1262760
match dbc
csouers Jul 8, 2018
b8266d8
capitalization
csouers Jul 8, 2018
1f3d9eb
default acc off
csouers Jul 8, 2018
fe43119
disable mini car
csouers Jul 8, 2018
8f16fe0
minimal
csouers Jul 8, 2018
282f0a5
add 0x1ef to OPs creations
csouers Jul 8, 2018
337a082
add it to carcontroller
csouers Jul 8, 2018
f76f2a9
Merge pull request #4 from commaai/devel
csouers Jul 13, 2018
2f8f58e
Merge branch 'devel' of https://github.com/commaai/openpilot into devel
csouers Jul 13, 2018
b753248
Merge branch 'devel' into my_mods
csouers Jul 13, 2018
eae2d28
vision radar
csouers Jul 13, 2018
4f55e51
stop auto update
csouers Jul 13, 2018
b05387f
things
csouers Jul 21, 2018
f322a22
Merge branch 'my_mods' into visiononly
csouers Jul 21, 2018
af27e62
Capitalization lives matter
csouers Jul 22, 2018
7d27ac9
add enabled safety to long control
csouers Jul 22, 2018
ca01d98
import messaging
csouers Jul 22, 2018
9120571
import service list
csouers Jul 22, 2018
a958a53
add to capnp
csouers Jul 22, 2018
dad09bb
fix
csouers Jul 22, 2018
639eb7d
name fix
csouers Jul 22, 2018
e2e957a
change
csouers Jul 22, 2018
bbf97d3
Revert "change"
csouers Jul 22, 2018
9b9d482
null it
csouers Jul 22, 2018
b408b40
change
csouers Jul 22, 2018
b5a1676
try
csouers Jul 22, 2018
362e972
disable this
csouers Jul 22, 2018
98e9ff7
reenable
csouers Jul 22, 2018
364aa01
try. move to eon for working
csouers Jul 22, 2018
169641b
more
csouers Jul 22, 2018
f2d6383
a
csouers Jul 22, 2018
a7023ab
vision radar is now broken. should rebase to 0.5
csouers Jul 24, 2018
f865758
battery limit mods
csouers Jul 28, 2018
5983eca
better, but not accel. apply opendbc corrections for acceleration
csouers Jul 29, 2018
4cb2d7d
some adjustments
csouers Jul 29, 2018
efd6ffe
debug print
csouers Jul 29, 2018
03b6f30
1df isn't being set properly. try decimal. print apply_accel for debug
csouers Jul 31, 2018
14ed72b
value fix attempt.
csouers Jul 31, 2018
8c94d93
disable pedal press and long control stuff
csouers Jul 31, 2018
c15957b
actually allow gas!
csouers Aug 1, 2018
7d5de08
remove accel limit
csouers Aug 1, 2018
76ab08c
remove state print
csouers Aug 1, 2018
e74c2e3
manager controlled controlsd
csouers Aug 1, 2018
ca5e60a
reenable pedal safety and preenable
csouers Aug 1, 2018
66e958e
refactor and add switching value
csouers Aug 1, 2018
f1a8096
syntax
csouers Aug 1, 2018
f62bac5
disable again
csouers Aug 1, 2018
20cbfdb
refactor and adjust prints
csouers Aug 2, 2018
8f40b9d
Merge pull request #5 from commaai/devel
csouers Aug 3, 2018
0df316c
ignore secrets
csouers Jun 26, 2018
0a1c954
Merge branch 'devel' of https://github.com/csouers/openpilot into devel
csouers Aug 3, 2018
8c62284
Merge pull request #6 from commaai/devel
csouers Aug 3, 2018
776b4bc
Merge branch 'devel' of https://github.com/commaai/openpilot into devel
csouers Aug 3, 2018
7202ffb
add lkas button switching and get rid of accel scaling
csouers Aug 3, 2018
11f3bae
fix syntax
geohot Aug 4, 2018
ffbebb3
fix syntax
csouers Aug 4, 2018
2c186ac
Merge branch 'visiononly' of https://github.com/csouers/openpilot int…
csouers Aug 4, 2018
b02517d
refactor. some missing bosch stuff. add accel thresholds. braking, idk
csouers Aug 4, 2018
29451e7
adjustments. add prints
csouers Aug 9, 2018
c759724
fix?
csouers Aug 9, 2018
b5fd703
trying to debug gas command. reduce hysteresis
csouers Aug 9, 2018
63977b1
syntax
csouers Aug 9, 2018
2b37d53
trying to stop prints
csouers Aug 9, 2018
8c06e4b
again
csouers Aug 9, 2018
8c38568
revert thermald comment
csouers Aug 9, 2018
bb4d507
broken?
csouers Aug 9, 2018
5b05fee
fix and refactor
csouers Aug 9, 2018
34edb81
syntax?
csouers Aug 9, 2018
3b89cdd
why don't the variables work???
csouers Aug 11, 2018
64cd35e
Revert "why don't the variables work???"
csouers Aug 11, 2018
513d593
Revert "Revert "why don't the variables work???""
csouers Aug 11, 2018
95ef57a
need to make radar hud
csouers Aug 13, 2018
52196fc
bring back 2 checks
csouers Aug 13, 2018
ac258d2
dont allow gas_command to go negative (is invalid)
csouers Aug 15, 2018
e618de2
set hyst gap and max gas back to prior values
csouers Aug 15, 2018
113f2b3
cant accel when not longenabled
csouers Aug 15, 2018
0da0bb1
add newly found braking flag on 1df
csouers Aug 16, 2018
f5da91c
max to 0.5 until i can fix the trans dropdown jerk
csouers Aug 16, 2018
0035c27
bugs and a tad more hyst
csouers Aug 16, 2018
e9eeca3
new braking flag and put hyst back
csouers Aug 17, 2018
4e6c181
update bosch dbc
csouers Aug 17, 2018
8affc19
pull in dbc edits
csouers Aug 17, 2018
49d7fdb
Merge pull request #7 from commaai/devel
csouers Aug 21, 2018
081d2f3
Merge branch 'devel' into visiononly
csouers Aug 21, 2018
fa84acd
bring back thermal print
csouers Aug 21, 2018
826df69
max accel set back
csouers Aug 22, 2018
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ selfdrive/test/tests/plant/out
/src/

one
selfdrive/passwords.txt
1 change: 1 addition & 0 deletions cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ struct CarParams {
enableCamera @26 :Bool;
enableDsu @27 :Bool; # driving support unit
enableApgs @28 :Bool; # advanced parking guidance system
visionRadar @49 :Bool;

minEnableSpeed @17 :Float32;
safetyModel @18 :Int16;
Expand Down
6 changes: 6 additions & 0 deletions cereal/log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,11 @@ struct Joystick {
buttons @1: List(Bool);
}

struct VisionKeyboard {
gas @0: UInt64;
brake @1: UInt64;
}

struct OrbOdometry {
# timing first
startMonoTime @0 :UInt64;
Expand Down Expand Up @@ -1614,5 +1619,6 @@ struct Event {
orbFeaturesSummary @58 :OrbFeaturesSummary;
driverMonitoring @59 :DriverMonitoring;
boot @60 :Boot;
visionKeyboard @61 :VisionKeyboard;
}
}
8 changes: 5 additions & 3 deletions opendbc/generator/honda/_bosch_2018.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA
BO_ 479 ACC_CONTROL: 8 EON
SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM
SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX
SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX
SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM
SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX
SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
SG_ STATE_FLAG : 7|7@0+ (1,0) [0|69] "" XXX
SG_ GAS_COMMAND : 0|9@0+ (0.001,0) [0|1] "" PCM
SG_ GAS_BRAKE : 31|13@0- (0.001,0) [0|1] "" XXX
SG_ BRAKING_1 : 62|1@0+ (1,0) [0|1] "" XXX
SG_ BRAKING_2 : 34|1@0+ (1,0) [0|1] "" XXX

BO_ 495 ACC_CONTROL_ON: 8 XXX
SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX
Expand Down
4 changes: 4 additions & 0 deletions opendbc/generator/honda/honda_civic_hatchback_ex_2017_can.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ BO_ 432 STANDSTILL: 7 VSA
SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON
SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON

BO_ 506 BLANK_1FA: 8 XXX
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX

BO_ 892 CRUISE_PARAMS: 8 PCM
SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON
Expand Down
6 changes: 3 additions & 3 deletions opendbc/honda_accord_s2t_2018_can_generated.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA
BO_ 479 ACC_CONTROL: 8 EON
SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM
SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX
SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX
SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM
SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX
SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
SG_ GAS_BRAKE : 31|14@0- (.001,0) [0|1] "" XXX
SG_ GAS_COMMAND : 0|9@0+ (.001,0) [0|1] "" PCM
SG_ STATE_FLAG : 7|7@0+ (1,0) [0|69] "" XXX

BO_ 495 ACC_CONTROL_ON: 8 XXX
SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX
Expand Down
12 changes: 9 additions & 3 deletions opendbc/honda_civic_hatchback_ex_2017_can_generated.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,14 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA
BO_ 479 ACC_CONTROL: 8 EON
SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM
SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX
SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX
SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM
SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX
SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
SG_ STATE_FLAG : 7|7@0+ (1,0) [0|69] "" XXX
SG_ GAS_COMMAND : 0|9@0+ (0.001,0) [0|1] "" PCM
SG_ GAS_BRAKE : 31|13@0- (0.001,0) [0|1] "" XXX
SG_ BRAKING_1 : 62|1@0+ (1,0) [0|1] "" XXX
SG_ BRAKING_2 : 34|1@0+ (1,0) [0|1] "" XXX

BO_ 495 ACC_CONTROL_ON: 8 XXX
SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX
Expand Down Expand Up @@ -283,6 +285,10 @@ BO_ 432 STANDSTILL: 7 VSA
SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON
SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON

BO_ 506 BLANK_1FA: 8 XXX
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX

BO_ 892 CRUISE_PARAMS: 8 PCM
SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON
Expand Down
6 changes: 3 additions & 3 deletions opendbc/honda_crv_ex_2017_can_generated.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ BO_ 464 WHEEL_SPEEDS: 8 VSA
BO_ 479 ACC_CONTROL: 8 EON
SG_ SET_TO_1 : 20|5@0+ (1,0) [0|1] "" PCM
SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX
SG_ RELATED_TO_GAS : 7|7@0+ (1,0) [0|69] "" XXX
SG_ GAS_COMMAND : 0|9@0+ (1,0) [0|1] "" PCM
SG_ GAS_BRAKE : 31|14@0- (1,0) [0|1] "" XXX
SG_ ZEROS_BOH : 33|18@0+ (1,0) [100|100] "" XXX
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
SG_ GAS_BRAKE : 31|14@0- (.001,0) [0|1] "" XXX
SG_ GAS_COMMAND : 0|9@0+ (.001,0) [0|1] "" PCM
SG_ STATE_FLAG : 7|7@0+ (1,0) [0|69] "" XXX

BO_ 495 ACC_CONTROL_ON: 8 XXX
SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX
Expand Down
12 changes: 6 additions & 6 deletions panda/board/safety/safety_honda.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
if (buttons == 4 || buttons == 3) {
controls_allowed = 1;
} else if (buttons == 2) {
controls_allowed = 0;
controls_allowed = 1;
}
}

Expand All @@ -50,7 +50,7 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
if (IS_USER_BRAKE_MSG(to_push)) {
int brake = USER_BRAKE_VALUE(to_push);
if (brake && (!(brake_prev) || ego_speed)) {
controls_allowed = 0;
controls_allowed = 1;
}
brake_prev = brake;
}
Expand All @@ -62,7 +62,7 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
int gas_interceptor = ((to_push->RDLR & 0xFF) << 8) | ((to_push->RDLR & 0xFF00) >> 8);
if ((gas_interceptor > gas_interceptor_threshold) &&
(gas_interceptor_prev <= gas_interceptor_threshold)) {
controls_allowed = 0;
controls_allowed = 1;
}
gas_interceptor_prev = gas_interceptor;
}
Expand All @@ -72,7 +72,7 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
if ((to_push->RIR>>21) == 0x17C) {
int gas = to_push->RDLR & 0xFF;
if (gas && !(gas_prev)) {
controls_allowed = 0;
controls_allowed = 1;
}
gas_prev = gas;
}
Expand All @@ -86,7 +86,7 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
// block all commands that produce actuation

static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {

return true;
// disallow actuator commands if gas or brake (with vehicle moving) are pressed
// and the the latching controls_allowed flag is True
int pedal_pressed = gas_prev || (gas_interceptor_prev > gas_interceptor_threshold) ||
Expand Down Expand Up @@ -119,7 +119,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
if ((to_send->RDLR & 0xFFFF0000) != to_send->RDLR) return 0;
}
}

// FORCE CANCEL: safety check only relevant when spamming the cancel button in Bosch HW
// ensuring that only the cancel button press is sent (VAL 2) when controls are off.
// This avoids unintended engagements while still allowing resume spam
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/car_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ def get_car(logcan, sendcan=None, passive=True):
return None, None

params = interface_cls.get_params(candidate, fingerprints)

return interface_cls(params, sendcan), params
82 changes: 61 additions & 21 deletions selfdrive/car/honda/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
from selfdrive.car.honda import hondacan
from selfdrive.car.honda.values import AH, CruiseButtons, CAR
from selfdrive.can.packer import CANPacker
import zmq
import selfdrive.messaging as messaging
from selfdrive.services import service_list

# Accel limits from toyota
ACCEL_HYST_GAP = 0.02 # was 0.02 # don't change accel command for small oscilalitons within this value
ACCEL_MAX = 1.5 # 1.5 m/s2
ACCEL_MIN = -3.0 # 3 m/s2
ACCEL_SCALE = max(ACCEL_MAX, -ACCEL_MIN)

#honda
def actuator_hystereses(brake, braking, brake_steady, v_ego, car_fingerprint):
# hyst params... TODO: move these to VehicleParams
brake_hyst_on = 0.02 # to activate brakes exceed this value
Expand All @@ -32,6 +42,20 @@ def actuator_hystereses(brake, braking, brake_steady, v_ego, car_fingerprint):

return brake, braking, brake_steady

#from toyota
def accel_hysteresis(accel, accel_prev, enabled):

# for small accel oscillations within ACCEL_HYST_GAP, don't change the accel command
if not enabled:
# send 0 when disabled, otherwise acc faults
accel_prev = 0.
elif accel > accel_prev + ACCEL_HYST_GAP:
accel_prev = accel - ACCEL_HYST_GAP
elif accel < accel_prev - ACCEL_HYST_GAP:
accel_prev = accel + ACCEL_HYST_GAP
accel = accel_prev

return accel, accel_prev

def process_hud_alert(hud_alert):
# initialize to no alert
Expand Down Expand Up @@ -60,16 +84,22 @@ def __init__(self, dbc_name, enable_camera=True):
self.braking = False
self.brake_steady = 0.
self.brake_last = 0.
self.accel_prev = 0.
self.enable_camera = enable_camera
self.packer = CANPacker(dbc_name)
self.new_radar_config = False

context = zmq.Context()
poller = zmq.Poller()
keyboard = messaging.sub_sock(context, service_list['visionKeyboard'].port, conflate=True, poller=poller)

def update(self, sendcan, enabled, CS, frame, actuators, \
pcm_speed, pcm_override, pcm_cancel_cmd, pcm_accel, \
radar_error, hud_v_cruise, hud_show_lanes, hud_show_car, \
hud_alert, snd_beep, snd_chime):

""" Controls thread """
CS.setspeed = hud_v_cruise

if not self.enable_camera:
return
Expand Down Expand Up @@ -122,10 +152,16 @@ def update(self, sendcan, enabled, CS, frame, actuators, \
STEER_MAX = 0x3e8 # CR-V only uses 12-bits and requires a lower value (max value from energee)
else:
STEER_MAX = 0x1000
#steer torque is converted back to CAN reference (positive when steering right)
if CS.CP.visionRadar:
# gas and brake. braking is negative
apply_accel = actuators.gas - actuators.brake
apply_accel, self.accel_prev = accel_hysteresis(apply_accel, self.accel_prev, enabled)
apply_accel = clip(apply_accel * ACCEL_SCALE, ACCEL_MIN, ACCEL_MAX)

# steer torque is converted back to CAN reference (positive when steering right)
apply_gas = clip(actuators.gas, 0., 1.)
apply_brake = int(clip(self.brake_last * BRAKE_MAX, 0, BRAKE_MAX - 1))
else:
apply_gas = clip(actuators.gas, 0., 1.)
apply_brake = int(clip(self.brake_last * BRAKE_MAX, 0, BRAKE_MAX))
apply_steer = int(clip(-actuators.steer * STEER_MAX, -STEER_MAX, STEER_MAX))

# any other cp.vl[0x18F]['STEER_STATUS'] is common and can happen during user override. sending 0 torque to avoid EPS sending error 5
Expand All @@ -136,37 +172,41 @@ def update(self, sendcan, enabled, CS, frame, actuators, \

# Send steering command.
idx = frame % 4
can_sends.append(hondacan.create_steering_control(self.packer, apply_steer, lkas_active, CS.CP.carFingerprint, idx))
can_sends.append(hondacan.create_steering_control(self.packer, apply_steer, lkas_active, CS.CP.carFingerprint, CS.CP.visionRadar, CS.CP.radarOffCan, idx))

# Send dashboard UI commands.
if (frame % 10) == 0:
idx = (frame/10) % 4
can_sends.extend(hondacan.create_ui_commands(self.packer, pcm_speed, hud, CS.CP.carFingerprint, idx))
can_sends.extend(hondacan.create_ui_commands(self.packer, pcm_speed, hud, CS.CP.carFingerprint, CS.longenabled, CS.CP.visionRadar, CS.CP.radarOffCan, idx))

if CS.CP.radarOffCan:
if CS.CP.radarOffCan and not CS.CP.visionRadar:
# If using stock ACC, spam cancel command to kill gas when OP disengages.
if pcm_cancel_cmd:
can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.CANCEL, idx))
elif CS.stopped:
can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx))
else:
# Send gas and brake commands.
if (frame % 2) == 0:
idx = (frame / 2) % 4
# Send gas and brake commands.
if (frame % 2) == 0:
idx = (frame / 2) % 4
if CS.CP.visionRadar and CS.CP.carFingerprint == CAR.CIVIC_HATCH:
can_sends.append(hondacan.create_long_command(self.packer, enabled, CS.longenabled, apply_accel, idx))
can_sends.append(hondacan.create_acc_control_on(self.packer, enabled, idx))
can_sends.append(hondacan.create_1fa(self.packer, idx))
else:
can_sends.append(
hondacan.create_brake_command(self.packer, apply_brake, pcm_override,
pcm_cancel_cmd, hud.chime, hud.fcw, idx))
if CS.CP.enableGasInterceptor:
# send exactly zero if apply_gas is zero. Interceptor will send the max between read value and apply_gas.
# This prevents unexpected pedal range rescaling
can_sends.append(hondacan.create_gas_command(self.packer, apply_gas, idx))

# radar at 20Hz, but these msgs need to be sent at 50Hz on ilx (seems like an Acura bug)
if CS.CP.carFingerprint == CAR.ACURA_ILX:
radar_send_step = 2
else:
radar_send_step = 5

if CS.CP.enableGasInterceptor:
# send exactly zero if apply_gas is zero. Interceptor will send the max between read value and apply_gas.
# This prevents unexpected pedal range rescaling
can_sends.append(hondacan.create_gas_command(self.packer, apply_gas, idx))

# radar at 20Hz, but these msgs need to be sent at 50Hz on ilx (seems like an Acura bug)
if CS.CP.carFingerprint == CAR.ACURA_ILX:
radar_send_step = 2
else:
radar_send_step = 5
if not CS.CP.visionRadar:
if (frame % radar_send_step) == 0:
idx = (frame/radar_send_step) % 4
if not self.new_radar_config: # only change state once
Expand Down
Loading