Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrysler #488

Closed
wants to merge 141 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
279e116
panda safety for Chrysler Pacifica
adhintz May 10, 2018
559af6e
initial chrysler pacifica hybrid 2017 OP code. Does not send any stee…
adhintz May 16, 2018
8da085b
fix typo
adhintz May 16, 2018
2295526
add LKAS_INDICATOR_ 2 and 3 to fingerprint
adhintz May 16, 2018
7f7d79a
add lkas 1 to fingerprint
adhintz May 17, 2018
393c7c0
add chrysler SafetyModel to fix this error:
adhintz May 18, 2018
170e005
add one static LKAS message and a check for it.
adhintz May 18, 2018
ce3f7bf
fix DBC message names and comment out checks messages for now
adhintz May 18, 2018
e1c01f1
update message names everywhere
adhintz May 18, 2018
d9d436e
set more values in carstate that are used by interface
adhintz May 18, 2018
6c529a7
use boolean for steer_override
adhintz May 19, 2018
3e63ed5
rewrite radar_interface to match how chrysler works
adhintz May 19, 2018
59939b3
switch PRNDL to big endian because I suspect cabana and OP CanParser do
adhintz May 19, 2018
43d4c7f
switch the signals OP uses to big endian to work around little endian
adhintz May 19, 2018
07f979e
fix brake pressed carstate+interface
adhintz May 19, 2018
e4c9a43
do actual wheel speeds. fix speed factor
adhintz May 19, 2018
ad6169a
fix boolean for cruisestate enabled
adhintz May 20, 2018
d4cad32
emulate lkas, but steer angle hard-coded to 0
adhintz May 20, 2018
a4ba165
remove carstate parameter that we're not using.
adhintz May 20, 2018
8318a48
use correct import name
adhintz May 20, 2018
7cd0705
dbeugging a length issue
adhintz May 20, 2018
83f5a70
fix message address, use string not a list for dat in 292
adhintz May 20, 2018
32089a3
print less
adhintz May 20, 2018
d52ffd3
temporarily use chrysler safety output, but have it behave like allou…
adhintz May 21, 2018
116d9ab
set alt to 0 instead of 1. needed to actually send messages.
adhintz May 21, 2018
c70e970
yes, frame is a 100Hz counter
adhintz May 21, 2018
dfb1112
attempt to steer. convert degrees to car units, log more data.
adhintz May 21, 2018
0553719
float to int
adhintz May 21, 2018
a4dd313
remove chrysler_tx_hook panda safety check in case that's blocking us
adhintz May 22, 2018
3136aca
more logging
adhintz May 22, 2018
2236a48
enforce limits in create292
adhintz May 23, 2018
0433af3
Revert "enforce limits in create292"
adhintz May 23, 2018
fdbde2a
Revert "more logging"
adhintz May 23, 2018
4ba9e56
try the logging and limiting again without syntax errors
adhintz May 23, 2018
d261f0f
log car messages to /tmp/chrylog
adhintz May 23, 2018
48f3f72
try apply_steer and set its maximum delta closer to what the car sends
adhintz May 23, 2018
76f13cd
different status messages based on direction of steering
adhintz May 23, 2018
91a29a4
send more status message bits correctly
adhintz May 26, 2018
ffcec90
add missing self
adhintz May 26, 2018
c9e2b2a
send status message on new steering
adhintz Jul 25, 2018
598df20
Merge in 0.5.0
adhintz Jul 26, 2018
bb21fb5
add missing import
adhintz Jul 26, 2018
cb0ef7d
add new fingerprint value
adhintz Jul 26, 2018
521acf6
add missing break to skip loge
adhintz Jul 26, 2018
3b42d9f
remove some prints to make less noise
adhintz Jul 26, 2018
c1b54d0
give chrysler safety a new value
adhintz Jul 26, 2018
417b347
bump panda version
adhintz Jul 26, 2018
3f0c8ef
change chrylser safety enum to 8 to not conflict with Kia and Hyundai…
adhintz Aug 2, 2018
c178e5a
update chrysler proto enum to 0.5.1 official value
adhintz Aug 2, 2018
2d9e4f8
support for pacifica 2018 non-hybrid
adhintz Aug 9, 2018
f6dd691
fix pacifica 2018 non-hybrid fingerprint
adhintz Aug 10, 2018
5ef75b1
gas value is a float, not a boolean
adhintz Aug 10, 2018
a128ddd
add support for Jeep Grand Cherokee 2018
adhintz Aug 10, 2018
897bdce
add another canbus message to pacifica hybrid 2017 fingerprint
adhintz Aug 16, 2018
17d2474
log all messages from chrysler/carcontroller.py
adhintz Aug 16, 2018
f59f45c
car parameters for chrysler
adhintz Aug 16, 2018
391bc09
do not use radar for non-Giraffe cars
adhintz Aug 17, 2018
e560749
reduce CAR_UNITS_PER_DEGREE in an attempt to reduce over-steering
adhintz Aug 17, 2018
feb3951
merge 0.5.1
adhintz Aug 20, 2018
e197afc
fix merge by adding perception argument
adhintz Aug 20, 2018
d5a3548
merge 0.5.2
adhintz Aug 21, 2018
8e1e89d
increase tire stiffness to reduce ping-pong
adhintz Aug 22, 2018
21c4a7b
comment out jeep radar disable
adhintz Aug 23, 2018
08f8197
do not send 2a6 messages too close to each other in case that's causi…
adhintz Aug 23, 2018
5753077
fix order of operations in frame mod
adhintz Aug 24, 2018
3f7001d
Merge remote-tracking branch 'upstream/devel' into devel
adhintz Aug 25, 2018
41f7ca1
Merge remote-tracking branch 'upstream/devel' into devel
adhintz Aug 25, 2018
a7d4dbb
rework sending status messages
adhintz Aug 27, 2018
4e50a1b
Merge remote-tracking branch 'upstream/devel' into devel
adhintz Aug 27, 2018
6b094f7
always send initial lane-keeping warning in case that helps
adhintz Aug 28, 2018
bd00e8e
always send green lkas when moving. enforce angle step in lower level…
adhintz Aug 30, 2018
c08ee81
fix syntax error
adhintz Aug 30, 2018
11e3c6b
clean out radar disable code
adhintz Sep 5, 2018
7a0e4f1
Merge remote-tracking branch 'upstream/devel' into devel
adhintz Sep 5, 2018
dbdec7b
no longer send initial fake 2a6 warning, it doesn't seem to help
adhintz Sep 5, 2018
b06b108
don't do anything for the first 20 seconds in case that helps
adhintz Sep 6, 2018
c14c70b
sync our frame with 220 in case that matters. remove other attempts a…
adhintz Sep 12, 2018
3422ed3
fix logic to keep frame counter in sync
adhintz Sep 12, 2018
1276841
cast to int for bit logic
adhintz Sep 13, 2018
881f33a
send 2d9 and 2a6 status messages on start
adhintz Sep 13, 2018
89d15db
add sleep at startup to see if that helps
adhintz Sep 17, 2018
97abc0a
better PID constants
adhintz Sep 21, 2018
1041eee
add extra fingerprint for pacifica 2018
adhintz Sep 21, 2018
02a2bb9
Merge remote-tracking branch 'upstream/devel' into devel
adhintz Sep 25, 2018
707813a
Revert "add sleep at startup to see if that helps"
adhintz Sep 26, 2018
ce3455c
add fingerptin for 2018 pacifica hybrid
adhintz Sep 29, 2018
4de842a
steering messages for pacifica 2018 hybrid
adhintz Sep 29, 2018
9ecb714
create fingerprint category for 2018 hybrid pacifica
adhintz Sep 29, 2018
489258f
add to car enum
adhintz Sep 29, 2018
b487b86
another fingerprint for 2018 pac hy
adhintz Sep 29, 2018
e7f4a94
fix hybrid 2018 values.py
adhintz Oct 2, 2018
a7cfdd5
fix constant name for 2018 hybrid
adhintz Oct 3, 2018
797992c
increase steering limit, reduce minimum speed for steering
adhintz Oct 3, 2018
9a5024e
remove logging to /tmp file
adhintz Oct 3, 2018
96e91bc
add logging back in for init and can msg
adhintz Oct 14, 2018
ef82516
drain zmq (both py and cc) sendcan on connection
adhintz Oct 16, 2018
b78e73f
do not send anything if we have not yet read a valid frame
adhintz Oct 16, 2018
be1ae3c
actually drain sendcan in main (non-proxy) boardd_loop
adhintz Oct 16, 2018
77e6a78
also drain sendcan in can/parser.cc after connect
adhintz Oct 16, 2018
56e3bc3
add comments from Willem Melching
adhintz Oct 16, 2018
98bf7b4
remove bad character in comment
adhintz Oct 18, 2018
6e566a4
logging on incoming frame 220
adhintz Oct 18, 2018
d55d9b1
remove sleep
adhintz Oct 18, 2018
942f042
fix frame 220 logging
adhintz Oct 19, 2018
d4a56da
add chrysler carstate checks
adhintz Oct 19, 2018
5e3ca07
save previous frame and do not send if frame repeats.
adhintz Oct 20, 2018
80d88e2
just copy CarInterface frame from CarState 220 instead of doing anyth…
adhintz Oct 20, 2018
dedda8e
frame is an int
adhintz Oct 20, 2018
f82ac8f
increase min speed for steering to avoid disabling actuation
adhintz Oct 25, 2018
c6c4e93
expand pacifica hybrid 2017 fingerprint so it works when already moving.
adhintz Oct 28, 2018
8a74d4c
add comments about what makes each fingerprint unique
adhintz Oct 28, 2018
d91dd0e
Merge remote-tracking branch 'upstream/devel' into limits
adhintz Nov 3, 2018
7d379b6
try out new panda safety code
adhintz Nov 5, 2018
654e388
Merge remote-tracking branch 'upstream/devel' into limits
adhintz Nov 9, 2018
24d06d3
bump panda version
adhintz Nov 9, 2018
5cdd3a7
start cleaning the code
adhintz Nov 9, 2018
dac3561
low_speed_alert and steer_error
adhintz Nov 11, 2018
757103d
include LKAS_IS_GREEN in signal
adhintz Nov 12, 2018
87d5ca2
add minSteerSpeed to warning message
adhintz Nov 13, 2018
a5b494c
delete unused DSU and APGS
adhintz Nov 13, 2018
f556168
remove unused comments
adhintz Nov 13, 2018
ccde2ad
read ESP traction and seatbelt messages for error messages
adhintz Nov 14, 2018
2039198
remove old todo
adhintz Nov 15, 2018
b81e0e4
merge in version 0.5.6
adhintz Nov 18, 2018
31125c3
comment out extra logging in prep for release to devel
adhintz Nov 19, 2018
c716385
ACC cancel button
adhintz Dec 7, 2018
d08d2db
on gas pedal press, send cancel ACC button to cancel OpenPilot
adhintz Dec 9, 2018
ca7c054
try sending +1 counter so our message isn't a duplicate
adhintz Dec 10, 2018
b6c9aac
only do the accel pedal for specific cars
adhintz Dec 10, 2018
fff91b9
do accel pedal for all models
adhintz Dec 10, 2018
bb0d1d4
try always sending 1 for cancel acc frame
adhintz Dec 10, 2018
d661acc
clean up comments and remove unused moving_fast
adhintz Dec 10, 2018
e886808
remove unused make can msg parameters
adhintz Dec 10, 2018
d38fdc6
try incrementing wheel button counter by 2 to see if that works bette…
adhintz Dec 10, 2018
e7472b6
try to simplify message logic
adhintz Dec 11, 2018
0f88bc4
clean up code
adhintz Dec 11, 2018
d73fc45
Merge remote-tracking branch 'upstream/devel' into limits
adhintz Dec 11, 2018
b480d68
move Chrylser into main table in readme
adhintz Dec 11, 2018
a5bff3c
On pedal press, if in steer error state, do not send ACC cancel butto…
adhintz Dec 14, 2018
9442c34
0.5.7 merge (#6)
adhintz Dec 14, 2018
01f94fc
merge conflicts
rbiasini Dec 27, 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
2 changes: 2 additions & 0 deletions opendbc/chrysler_pacifica_2017_hybrid.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ BO_ 571 WHEEL_BUTTONS: 3 XXX
SG_ ACC_SPEED_INC : 2|1@0+ (1,0) [0|255] "" XXX
SG_ ACC_SPEED_DEC : 3|1@1+ (1,0) [0|3] "" XXX
SG_ ACC_FOLLOW_INC : 8|1@1+ (1,0) [0|15] "" XXX
SG_ ACC_CANCEL : 0|1@0+ (1,0) [0|15] "" XXX
SG_ COUNTER : 15|4@0+ (1,0) [0|15] "" XXX

BO_ 669 NEW_MSG_29d: 3 XXX
Expand Down Expand Up @@ -402,6 +403,7 @@ CM_ SG_ 729 LKAS_STATUS_OK "Set to 0x0820 when LKAS system is plugged in.";
CM_ SG_ 288 UNKNOWN_CHECKSUM_120 "not the LKAS checksum";
CM_ SG_ 288 GAS_ENGINE_RPM_MAYBE "lags acceleration, perhaps gas engine";
CM_ SG_ 257 ENERGY_OR_RPM "perhaps energy consumption or RPMs";
CM_ SG_ 571 CHECKSUM_23B "standard checksum";
CM_ SG_ 270 ELECTRIC_MOTOR "0x7fff indicates electric motor not in use";
CM_ SG_ 291 ENERGY_GAIN_LOSS "unsure what this actually is";
CM_ SG_ 291 ENERGY_SMOOTHER_CURVE "unusre what it is, but smoother";
Expand Down
12 changes: 12 additions & 0 deletions selfdrive/boardd/boardd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define SAFETY_CADILLAC 6
#define SAFETY_HYUNDAI 7
#define SAFETY_TESLA 8
#define SAFETY_CHRYSLER 9
#define SAFETY_TOYOTA_IPAS 0x1335
#define SAFETY_TOYOTA_NOLIMITS 0x1336
#define SAFETY_ALLOUTPUT 0x1337
Expand Down Expand Up @@ -120,6 +121,9 @@ void *safety_setter_thread(void *s) {
case (int)cereal::CarParams::SafetyModels::HYUNDAI:
safety_setting = SAFETY_HYUNDAI;
break;
case (int)cereal::CarParams::SafetyModels::CHRYSLER:
safety_setting = SAFETY_CHRYSLER;
break;
default:
LOGE("unknown safety model: %d", safety_model);
}
Expand Down Expand Up @@ -420,6 +424,14 @@ void *can_send_thread(void *crap) {
zmq_setsockopt(subscriber, ZMQ_SUBSCRIBE, "", 0);
zmq_connect(subscriber, "tcp://127.0.0.1:8017");

// drain sendcan to delete any stale messages from previous runs
zmq_msg_t msg;
zmq_msg_init(&msg);
int err = 0;
while(err >= 0) {
err = zmq_msg_recv(&msg, subscriber, ZMQ_DONTWAIT);
}

// run as fast as messages come in
while (!do_exit) {
can_send(subscriber);
Expand Down
10 changes: 10 additions & 0 deletions selfdrive/boardd/boardd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env python

# This file is not used by OpenPilot. Only boardd.cc is used.
# The python version is slower, but has more options for development.

# TODO: merge the extra functionalities of this file (like MOCK) in boardd.c and
# delete this python version of boardd

Expand All @@ -23,6 +26,7 @@
SAFETY_NOOUTPUT = 0
SAFETY_HONDA = 1
SAFETY_TOYOTA = 2
SAFETY_CHRYSLER = 8
SAFETY_TOYOTA_NOLIMITS = 0x1336
SAFETY_ALLOUTPUT = 0x1337

Expand Down Expand Up @@ -163,6 +167,9 @@ def boardd_loop(rate=200):
# *** subscribes to can send
sendcan = messaging.sub_sock(context, service_list['sendcan'].port)

# drain sendcan to delete any stale messages from previous runs
messaging.drain_sock(sendcan)

while 1:
# health packet @ 1hz
if (rk.frame%rate) == 0:
Expand Down Expand Up @@ -205,6 +212,9 @@ def boardd_proxy_loop(rate=200, address="192.168.2.251"):
# *** publishes to can send
sendcan = messaging.pub_sock(context, service_list['sendcan'].port)

# drain sendcan to delete any stale messages from previous runs
messaging.drain_sock(sendcan)

while 1:
# recv @ 100hz
can_msgs = can_recv()
Expand Down
8 changes: 8 additions & 0 deletions selfdrive/can/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ class CANParser {

zmq_connect(subscriber, tcp_addr_char);

// drain sendcan to delete any stale messages from previous runs
zmq_msg_t msgDrain;
zmq_msg_init(&msgDrain);
int err = 0;
while(err >= 0) {
err = zmq_msg_recv(&msgDrain, subscriber, ZMQ_DONTWAIT);
}

dbc = dbc_lookup(dbc_name);
assert(dbc);

Expand Down
Empty file.
79 changes: 79 additions & 0 deletions selfdrive/car/chrysler/carcontroller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import logging
from common.numpy_fast import clip, interp
from selfdrive.boardd.boardd import can_list_to_can_capnp
from selfdrive.car.chrysler.chryslercan import create_2d9, create_2a6, create_292, create_23b
from selfdrive.car.chrysler.values import ECU, STATIC_MSGS
from selfdrive.can.packer import CANPacker

# Steer torque range is 1024+-230. The 1024 is added by our library.
# degrees * 3.0 = car units
CAR_UNITS_PER_DEGREE = 3.0 # originally 5.1
STEER_MAX = 230 / CAR_UNITS_PER_DEGREE # degrees
STEER_DELTA_UP = 2.5 / CAR_UNITS_PER_DEGREE # degrees
STEER_DELTA_DOWN = 2.5 / CAR_UNITS_PER_DEGREE # degrees
MIN_STEER_MS = 3.8 # TODO consolidate with interface.py CP.minSteerSpeed.
# 3.0 works, but increased to 3.8 to make it more reliable.


class CarController(object):
def __init__(self, dbc_name, car_fingerprint, enable_camera):
self.braking = False
# redundant safety check with the board
self.controls_allowed = True
self.last_steer = 0
self.prev_frame = -1 # previous frame from interface from 220 frame
self.ccframe = 0
self.car_fingerprint = car_fingerprint
self.alert_active = False

self.fake_ecus = set()
if enable_camera: self.fake_ecus.add(ECU.CAM)

self.packer = CANPacker(dbc_name)


def update(self, sendcan, enabled, CS, frame, actuators,
pcm_cancel_cmd, hud_alert, audible_alert, send_cancel_acc):

# *** compute control surfaces ***
# steer torque
apply_steer = int(round(actuators.steer * STEER_MAX))
apply_steer = clip(apply_steer, -STEER_MAX, STEER_MAX)

# slow rate if steer torque increases in magnitude
if self.last_steer > 0:
apply_steer = clip(apply_steer, max(self.last_steer - STEER_DELTA_DOWN, - STEER_DELTA_UP), self.last_steer + STEER_DELTA_UP)
else:
apply_steer = clip(apply_steer, self.last_steer - STEER_DELTA_UP, min(self.last_steer + STEER_DELTA_DOWN, STEER_DELTA_UP))

moving_fast = True # for status message
if CS.v_ego < MIN_STEER_MS: # don't steer if going slow to not lock out LKAS
apply_steer = 0
moving_fast = False

self.last_steer = apply_steer

if self.prev_frame == frame:
return # Do not reuse an old frame. This avoids repeating on shut-down.

can_sends = []

#*** control msgs ***

if send_cancel_acc:
new_msg = create_23b(CS.frame_23b + 2)
sendcan.send(can_list_to_can_capnp([new_msg], msgtype='sendcan').to_bytes())

# frame is 100Hz (0.01s period)
if (self.ccframe % 10 == 0): # 0.1s period
new_msg = create_2d9(self.car_fingerprint)
can_sends.append(new_msg)
if (self.ccframe % 25 == 0): # 0.25s period
new_msg = create_2a6(CS.gear_shifter, apply_steer, moving_fast, self.car_fingerprint)
can_sends.append(new_msg)
new_msg = create_292(int(apply_steer * CAR_UNITS_PER_DEGREE), frame)
self.prev_frame = frame # save so we do not reuse frames
can_sends.append(new_msg) # degrees * 5.1 -> car steering units

self.ccframe += 1
sendcan.send(can_list_to_can_capnp(can_sends, msgtype='sendcan').to_bytes())
140 changes: 140 additions & 0 deletions selfdrive/car/chrysler/carstate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import logging
from selfdrive.can.parser import CANParser
from selfdrive.config import Conversions as CV
from selfdrive.car.chrysler.values import CAR, DBC
from common.kalman.simple_kalman import KF1D
import numpy as np


def parse_gear_shifter(can_gear):
if can_gear == 0x1:
return "park"
elif can_gear == 0x2:
return "reverse"
elif can_gear == 0x3:
return "neutral"
elif can_gear == 0x4:
return "drive"
return "unknown"


def get_can_parser(CP):

signals = [
# sig_name, sig_address, default
("PRNDL", "GEAR", 0),
("DOOR_OPEN_FL", "DOORS", 0),
("DOOR_OPEN_FR", "DOORS", 0),
("DOOR_OPEN_RL", "DOORS", 0),
("DOOR_OPEN_RR", "DOORS", 0),
("BRAKE_PRESSED_2", "BRAKE_2", 0),
("ACCEL_PEDAL", "ACCEL_PEDAL_MSG", 0),
("SPEED_LEFT", "SPEED_1", 0),
("SPEED_RIGHT", "SPEED_1", 0),
("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0),
("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0),
("WHEEL_SPEED_RL", "WHEEL_SPEEDS", 0),
("WHEEL_SPEED_FR", "WHEEL_SPEEDS", 0),
("STEER_ANGLE", "STEERING", 0),
("STEERING_RATE", "STEERING", 0),
("TURN_SIGNALS", "STEERING_LEVERS", 0),
("ACC_STATUS_2", "ACC_2", 0),
("HIGH_BEAM_FLASH", "STEERING_LEVERS", 0),
("ACC_SPEED_CONFIG_KPH", "DASHBOARD", 0),
("INCREMENTING_220", "LKAS_INDICATOR_1", -1),
("LKAS_IS_GREEN", "LKAS_INDICATOR_1", 1),
("TRACTION_OFF", "TRACTION_BUTTON", 0),
("SEATBELT_DRIVER_UNLATCHED", "SEATBELT_STATUS", 0),
("COUNTER", "WHEEL_BUTTONS", -1), # incrementing counter for 23b
]

# It's considered invalid if it is not received for 10x the expected period (1/f).
checks = [
# sig_address, frequency
("BRAKE_2", 50),
("LKAS_INDICATOR_1", 100),
("SPEED_1", 100),
("WHEEL_SPEEDS", 50),
("STEERING", 100),
("ACC_2", 50),
]

return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0)


class CarState(object):
def __init__(self, CP):

self.CP = CP
self.left_blinker_on = 0
self.right_blinker_on = 0

# initialize can parser
self.car_fingerprint = CP.carFingerprint

# vEgo kalman filter
dt = 0.01
# Q = np.matrix([[10.0, 0.0], [0.0, 100.0]])
# R = 1e3
self.v_ego_kf = KF1D(x0=np.matrix([[0.0], [0.0]]),
A=np.matrix([[1.0, dt], [0.0, 1.0]]),
C=np.matrix([1.0, 0.0]),
K=np.matrix([[0.12287673], [0.29666309]]))
self.v_ego = 0.0


def update(self, cp):
# copy can_valid
self.can_valid = cp.can_valid

# update prevs, update must run once per loop
self.prev_left_blinker_on = self.left_blinker_on
self.prev_right_blinker_on = self.right_blinker_on

self.frame_220 = int(cp.vl["LKAS_INDICATOR_1"]['INCREMENTING_220'])
self.frame_23b = int(cp.vl["WHEEL_BUTTONS"]['COUNTER'])

self.door_all_closed = not any([cp.vl["DOORS"]['DOOR_OPEN_FL'],
cp.vl["DOORS"]['DOOR_OPEN_FR'],
cp.vl["DOORS"]['DOOR_OPEN_RL'],
cp.vl["DOORS"]['DOOR_OPEN_RR']])
self.seatbelt = (cp.vl["SEATBELT_STATUS"]['SEATBELT_DRIVER_UNLATCHED'] == 0)

self.brake_pressed = cp.vl["BRAKE_2"]['BRAKE_PRESSED_2'] == 5 # human-only
self.pedal_gas = cp.vl["ACCEL_PEDAL_MSG"]['ACCEL_PEDAL']
self.car_gas = self.pedal_gas
self.esp_disabled = (cp.vl["TRACTION_BUTTON"]['TRACTION_OFF'] == 1)

self.v_wheel_fl = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_FL']
self.v_wheel_rr = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_RR']
self.v_wheel_rl = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_RL']
self.v_wheel_fr = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_FR']
self.v_wheel = (cp.vl['SPEED_1']['SPEED_LEFT'] + cp.vl['SPEED_1']['SPEED_RIGHT']) / 2.

# Kalman filter
if abs(self.v_wheel - self.v_ego) > 2.0: # Prevent large accelerations when car starts at non zero speed
self.v_ego_x = np.matrix([[self.v_wheel], [0.0]])

self.v_ego_raw = self.v_wheel
v_ego_x = self.v_ego_kf.update(self.v_wheel)
self.v_ego = float(v_ego_x[0])
self.a_ego = float(v_ego_x[1])
self.standstill = not self.v_wheel > 0.001

self.angle_steers = cp.vl["STEERING"]['STEER_ANGLE']
self.angle_steers_rate = cp.vl["STEERING"]['STEERING_RATE']
self.gear_shifter = parse_gear_shifter(cp.vl['GEAR']['PRNDL'])
self.main_on = cp.vl["ACC_2"]['ACC_STATUS_2'] == 7 # ACC is green.
self.left_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 1
self.right_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 2

self.steer_override = False # TODO
self.steer_error = cp.vl["LKAS_INDICATOR_1"]['LKAS_IS_GREEN'] == 0 # 0 if wheel will not actuate
self.steer_torque_driver = 0 # TODO

self.user_brake = 0
self.brake_lights = self.brake_pressed
self.v_cruise_pcm = cp.vl["DASHBOARD"]['ACC_SPEED_CONFIG_KPH']
self.pcm_acc_status = self.main_on

self.generic_toggle = bool(cp.vl["STEERING_LEVERS"]['HIGH_BEAM_FLASH'])
Loading