Skip to content

Commit

Permalink
Merge branch 'tesla_0.7.4_rebase2' into Tesla_0.7.4_rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
SippieCup committed Apr 18, 2020
2 parents bde3c21 + da8dcdd commit 2619554
Show file tree
Hide file tree
Showing 30 changed files with 612 additions and 295 deletions.
4 changes: 2 additions & 2 deletions models/supercombo.dlc
Git LFS file not shown
4 changes: 2 additions & 2 deletions models/supercombo.keras
Git LFS file not shown
4 changes: 2 additions & 2 deletions models/supercombo.model.keras
Git LFS file not shown
4 changes: 2 additions & 2 deletions models/supercombo.weights.keras
Git LFS file not shown
2 changes: 1 addition & 1 deletion panda
Submodule panda updated 65 files
+2 −17 .circleci/config.yml
+1 −1 VERSION
+2 −2 board/build.mk
+0 −27 board/drivers/can.h
+175 −0 board/drivers/lin.h
+1 −1 board/drivers/llcan.h
+224 −0 board/drivers/uja1023.h
+4 −21 board/drivers/usb.h
+0 −2 board/get_sdk_mac.sh
+87 −0 board/inc/core_cmFunc.h
+87 −0 board/inc/core_cmInstr.h
+96 −0 board/inc/core_cmSimd.h
+22 −18 board/main.c
+5 −1 board/pedal/Makefile
+78 −0 board/pedal/enter_canloader.py
+29 −7 board/pedal/main.c
+1 −0 board/pedal_tesla/.gitignore
+85 −0 board/pedal_tesla/Makefile
+28 −0 board/pedal_tesla/README
+361 −0 board/pedal_tesla/main.c
+11 −0 board/pedal_tesla/main_declarations.h
+1 −1 board/power_saving.h
+12 −2 board/safety.h
+1 −3 board/safety/safety_chrysler.h
+2 −7 board/safety/safety_ford.h
+2 −8 board/safety/safety_gm.h
+16 −25 board/safety/safety_honda.h
+1 −3 board/safety/safety_hyundai.h
+42 −50 board/safety/safety_nissan.h
+1 −3 board/safety/safety_subaru.h
+1,937 −95 board/safety/safety_tesla.h
+289 −0 board/safety/safety_teslaradar.h
+12 −19 board/safety/safety_toyota.h
+169 −0 board/safety/safety_toyota_ipas.h
+4 −167 board/safety/safety_volkswagen.h
+0 −18 board/safety_declarations.h
+0 −1 board/spi_flasher.h
+5 −11 python/__init__.py
+185 −0 tests/automated/2_usb_to_can.py
+58 −0 tests/automated/3_wifi.py
+60 −0 tests/automated/4_wifi_functionality.py
+66 −0 tests/automated/5_wifi_udp.py
+195 −0 tests/automated/6_two_panda.py
+0 −42 tests/automated/7_can_loopback.py
+0 −38 tests/bulk_write_test.py
+4 −2 tests/pedal/enter_canloader.py
+0 −6 tests/safety/common.py
+0 −2 tests/safety/libpandasafety_py.py
+2 −0 tests/safety/requirements.txt
+0 −10 tests/safety/test.c
+1 −9 tests/safety/test_chrysler.py
+1 −62 tests/safety/test_gm.py
+1 −93 tests/safety/test_honda.py
+46 −0 tests/safety/test_honda_bosch.py
+1 −9 tests/safety/test_hyundai.py
+29 −40 tests/safety/test_nissan.py
+1 −9 tests/safety/test_subaru.py
+14 −50 tests/safety/test_toyota.py
+247 −0 tests/safety/test_toyota_ipas.py
+1 −9 tests/safety/test_volkswagen_mqb.py
+0 −365 tests/safety/test_volkswagen_pq.py
+9 −20 tests/safety_replay/Dockerfile
+8 −0 tests/safety_replay/requirements.txt
+0 −3 tests/safety_replay/requirements_extra.txt
+1 −2 tests/safety_replay/test_safety_replay.py
16 changes: 16 additions & 0 deletions selfdrive/boardd/boardd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ void *can_send_thread(void *crap) {
while (!do_exit) {
can_send(subscriber);
}

delete subscriber;
delete context;
return NULL;
}

Expand Down Expand Up @@ -665,6 +668,9 @@ void *can_recv_thread(void *crap) {

next_frame_time += dt;
}

delete publisher;
delete c;
return NULL;
}

Expand All @@ -680,6 +686,9 @@ void *can_health_thread(void *crap) {
can_health(publisher);
usleep(500*1000);
}

delete publisher;
delete c;
return NULL;
}

Expand Down Expand Up @@ -914,6 +923,8 @@ void *pigeon_thread(void *crap) {
cnt++;
}

delete publisher;
delete context;
return NULL;
}

Expand Down Expand Up @@ -946,7 +957,12 @@ int main() {
// init libusb
err = libusb_init(&ctx);
assert(err == 0);

#if LIBUSB_API_VERSION >= 0x01000106
libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_INFO);
#else
libusb_set_debug(ctx, 3);
#endif

pthread_t can_health_thread_handle;
err = pthread_create(&can_health_thread_handle, NULL,
Expand Down
5 changes: 0 additions & 5 deletions selfdrive/camerad/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,6 @@ void init_buffers(VisionState *s) {
s->rgb_width = s->frame_width;
s->rgb_height = s->frame_height;
}

for (int i=0; i<UI_BUF_COUNT; i++) {
VisionImg img = visionimg_alloc_rgb24(s->rgb_width, s->rgb_height, &s->rgb_bufs[i]);
s->rgb_bufs_cl[i] = visionbuf_to_cl(&s->rgb_bufs[i], s->device_id, s->context);
Expand Down Expand Up @@ -1013,7 +1012,6 @@ void init_buffers(VisionState *s) {
s->yuv_width = s->rgb_width;
s->yuv_height = s->rgb_height;
s->yuv_buf_size = s->rgb_width * s->rgb_height * 3 / 2;

for (int i=0; i<YUV_COUNT; i++) {
s->yuv_ion[i] = visionbuf_allocate_cl(s->yuv_buf_size, s->device_id, s->context, &s->yuv_cl[i]);
s->yuv_bufs[i].y = (uint8_t*)s->yuv_ion[i].addr;
Expand Down Expand Up @@ -1061,7 +1059,6 @@ void init_buffers(VisionState *s) {
s->krnl_debayer_front = clCreateKernel(s->prg_debayer_front, "debayer10", &err);
assert(err == 0);
}

rgb_to_yuv_init(&s->rgb_to_yuv_state, s->context, s->device_id, s->yuv_width, s->yuv_height, s->rgb_stride);
rgb_to_yuv_init(&s->front_rgb_to_yuv_state, s->context, s->device_id, s->yuv_front_width, s->yuv_front_height, s->rgb_front_stride);
}
Expand Down Expand Up @@ -1177,9 +1174,7 @@ int main(int argc, char *argv[]) {
assert(s->front_frame_sock != NULL);
assert(s->thumbnail_sock != NULL);
#endif

cameras_open(&s->cameras, &s->camera_bufs[0], &s->focus_bufs[0], &s->stats_bufs[0], &s->front_camera_bufs[0]);

party(s);

#if defined(QCOM) || defined(QCOM2)
Expand Down
97 changes: 76 additions & 21 deletions selfdrive/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,102 @@
from cereal import car
from selfdrive.car import apply_std_steer_torque_limits
from selfdrive.car.hyundai.hyundaican import create_lkas11, create_clu11
from selfdrive.car.hyundai.values import Buttons, SteerLimitParams
from selfdrive.car.hyundai.hyundaican import create_lkas11, create_clu11, create_lfa_mfa
from selfdrive.car.hyundai.values import Buttons, SteerLimitParams, CAR
from opendbc.can.packer import CANPacker

VisualAlert = car.CarControl.HUDControl.VisualAlert


def process_hud_alert(enabled, fingerprint, visual_alert, left_lane,
right_lane, left_lane_depart, right_lane_depart):
sys_warning = (visual_alert == VisualAlert.steerRequired)

# initialize to no line visible
sys_state = 1
if left_lane and right_lane or sys_warning: #HUD alert only display when LKAS status is active
if enabled or sys_warning:
sys_state = 3
else:
sys_state = 4
elif left_lane:
sys_state = 5
elif right_lane:
sys_state = 6

# initialize to no warnings
left_lane_warning = 0
right_lane_warning = 0
if left_lane_depart:
left_lane_warning = 1 if fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80] else 2
if right_lane_depart:
right_lane_warning = 1 if fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80] else 2

return sys_warning, sys_state, left_lane_warning, right_lane_warning


class CarController():
def __init__(self, dbc_name, CP, VM):
self.apply_steer_last = 0
self.car_fingerprint = CP.carFingerprint
self.lkas11_cnt = 0
self.cnt = 0
self.last_resume_cnt = 0
self.packer = CANPacker(dbc_name)
self.steer_rate_limited = False
self.resume_cnt = 0
self.last_resume_frame = 0
self.last_lead_distance = 0

def update(self, enabled, CS, actuators, pcm_cancel_cmd, hud_alert):

### Steering Torque
def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert,
left_lane, right_lane, left_lane_depart, right_lane_depart):
# Steering Torque
new_steer = actuators.steer * SteerLimitParams.STEER_MAX
apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, SteerLimitParams)
self.steer_rate_limited = new_steer != apply_steer

if not enabled:
apply_steer = 0
# disable if steer angle reach 90 deg, otherwise mdps fault in some models
lkas_active = enabled and abs(CS.out.steeringAngle) < 90.

# fix for Genesis hard fault at low speed
if CS.out.vEgo < 16.7 and self.car_fingerprint == CAR.HYUNDAI_GENESIS:
lkas_active = 0

steer_req = 1 if enabled else 0
if not lkas_active:
apply_steer = 0

self.apply_steer_last = apply_steer

sys_warning, sys_state, left_lane_warning, right_lane_warning =\
process_hud_alert(enabled, self.car_fingerprint, visual_alert,
left_lane, right_lane, left_lane_depart, right_lane_depart)

can_sends = []
can_sends.append(create_lkas11(self.packer, frame, self.car_fingerprint, apply_steer, lkas_active,
CS.lkas11, sys_warning, sys_state, enabled,
left_lane, right_lane,
left_lane_warning, right_lane_warning))

self.lkas11_cnt = self.cnt % 0x10
self.clu11_cnt = self.cnt % 0x10
if pcm_cancel_cmd:
can_sends.append(create_clu11(self.packer, frame, CS.clu11, Buttons.CANCEL))

can_sends.append(create_lkas11(self.packer, self.car_fingerprint, apply_steer, steer_req, self.lkas11_cnt,
enabled, CS.lkas11, hud_alert, keep_stock=True))
elif CS.out.cruiseState.standstill:
# run only first time when the car stopped
if self.last_lead_distance == 0:
# get the lead distance from the Radar
self.last_lead_distance = CS.lead_distance
self.resume_cnt = 0
# when lead car starts moving, create 6 RES msgs
elif CS.lead_distance != self.last_lead_distance and (frame - self.last_resume_frame) > 5:
can_sends.append(create_clu11(self.packer, frame, CS.clu11, Buttons.RES_ACCEL))
self.resume_cnt += 1
# interval after 6 msgs
if self.resume_cnt > 5:
self.last_resume_frame = frame
self.clu11_cnt = 0
# reset lead distnce after the car starts moving
elif self.last_lead_distance != 0:
self.last_lead_distance = 0

if pcm_cancel_cmd:
can_sends.append(create_clu11(self.packer, CS.clu11, Buttons.CANCEL))
elif CS.out.cruiseState.standstill and (self.cnt - self.last_resume_cnt) > 5:
self.last_resume_cnt = self.cnt
can_sends.append(create_clu11(self.packer, CS.clu11, Buttons.RES_ACCEL))

self.cnt += 1
# 20 Hz LFA MFA message
if frame % 5 == 0 and self.car_fingerprint in [CAR.SONATA, CAR.PALISADE]:
can_sends.append(create_lfa_mfa(self.packer, frame, enabled))

return can_sends
Loading

0 comments on commit 2619554

Please sign in to comment.