mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-21 20:03:46 +08:00
Merge remote-tracking branch 'commaai/openpilot/master' into palisade-2023-port-1
# Conflicts: # panda
This commit is contained in:
@@ -19,5 +19,16 @@
|
||||
"--volume=/tmp/comma_download_cache:/tmp/comma_download_cache",
|
||||
"--volume=/tmp/devcontainer_scons_cache:/tmp/scons_cache",
|
||||
"--shm-size=1G"
|
||||
]
|
||||
],
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"ms-python.python",
|
||||
"ms-vscode.cpptools",
|
||||
"ms-toolsai.jupyter",
|
||||
"guyskk.language-cython",
|
||||
"lharri73.dbc"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
Submodule body updated: 396fa7b923...6ff44357a3
+2
-2
@@ -5,7 +5,7 @@
|
||||
#define GPIO_HUB_RST_N 30
|
||||
#define GPIO_UBLOX_RST_N 32
|
||||
#define GPIO_UBLOX_SAFEBOOT_N 33
|
||||
#define GPIO_UBLOX_PWR_EN 34
|
||||
#define GPIO_GNSS_PWR_EN 34 /* SCHEMATIC LABEL: GPIO_UBLOX_PWR_EN */
|
||||
#define GPIO_STM_RST_N 124
|
||||
#define GPIO_STM_BOOT0 134
|
||||
#define GPIO_BMX_ACCEL_INT 21
|
||||
@@ -17,7 +17,7 @@
|
||||
#define GPIO_HUB_RST_N 0
|
||||
#define GPIO_UBLOX_RST_N 0
|
||||
#define GPIO_UBLOX_SAFEBOOT_N 0
|
||||
#define GPIO_UBLOX_PWR_EN 0
|
||||
#define GPIO_GNSS_PWR_EN 0 /* SCHEMATIC LABEL: GPIO_UBLOX_PWR_EN */
|
||||
#define GPIO_STM_RST_N 0
|
||||
#define GPIO_STM_BOOT0 0
|
||||
#define GPIO_BMX_ACCEL_INT 0
|
||||
|
||||
+7
-1
@@ -31,10 +31,14 @@ I2CBus::I2CBus(uint8_t bus_id) {
|
||||
}
|
||||
|
||||
I2CBus::~I2CBus() {
|
||||
if (i2c_fd >= 0) { close(i2c_fd); }
|
||||
if (i2c_fd >= 0) {
|
||||
close(i2c_fd);
|
||||
}
|
||||
}
|
||||
|
||||
int I2CBus::read_register(uint8_t device_address, uint register_address, uint8_t *buffer, uint8_t len) {
|
||||
std::lock_guard lk(m);
|
||||
|
||||
int ret = 0;
|
||||
|
||||
ret = HANDLE_EINTR(ioctl(i2c_fd, I2C_SLAVE, device_address));
|
||||
@@ -48,6 +52,8 @@ fail:
|
||||
}
|
||||
|
||||
int I2CBus::set_register(uint8_t device_address, uint register_address, uint8_t data) {
|
||||
std::lock_guard lk(m);
|
||||
|
||||
int ret = 0;
|
||||
|
||||
ret = HANDLE_EINTR(ioctl(i2c_fd, I2C_SLAVE, device_address));
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
class I2CBus {
|
||||
private:
|
||||
int i2c_fd;
|
||||
std::mutex m;
|
||||
|
||||
public:
|
||||
I2CBus(uint8_t bus_id);
|
||||
|
||||
@@ -16,7 +16,7 @@ COPY ./body ${OPENPILOT_PATH}/body
|
||||
COPY ./third_party ${OPENPILOT_PATH}/third_party
|
||||
COPY ./site_scons ${OPENPILOT_PATH}/site_scons
|
||||
COPY ./laika_repo ${OPENPILOT_PATH}/laika_repo
|
||||
RUN ln -s ${OPENPILOT_PATH}/laika_repo ${OPENPILOT_PATH}/laika
|
||||
RUN ln -s ${OPENPILOT_PATH}/laika_repo/laika/ ${OPENPILOT_PATH}/laika
|
||||
COPY ./rednose ${OPENPILOT_PATH}/rednose
|
||||
COPY ./rednose_repo ${OPENPILOT_PATH}/rednose_repo
|
||||
COPY ./tools ${OPENPILOT_PATH}/tools
|
||||
|
||||
+1
-1
Submodule laika_repo updated: 6d547801a5...c9baa95ca9
+1
-1
Submodule panda updated: 209c1ae558...ed3e698a6c
+4
-1
@@ -1,8 +1,11 @@
|
||||
[tool.pytest.ini_options]
|
||||
minversion = "6.0"
|
||||
addopts = "--ignore=opendbc/ --ignore=panda/ --ignore=rednose_repo/ --ignore=tinygrad_repo/ --ignore=laika_repo/ -Werror --strict-config --strict-markers"
|
||||
addopts = "--ignore=openpilot/ --ignore=opendbc/ --ignore=panda/ --ignore=rednose_repo/ --ignore=tinygrad_repo/ --ignore=laika_repo/ -Werror --strict-config --strict-markers"
|
||||
python_files = "test_*.py"
|
||||
#timeout = "30" # you get this long by default
|
||||
markers = [
|
||||
"parallel: mark tests as parallelizable (tests with no global state, so can be run in parallel)"
|
||||
]
|
||||
|
||||
[tool.mypy]
|
||||
python_version = "3.11"
|
||||
|
||||
+1
-1
Submodule rednose_repo updated: 22f02dd650...e32658ed91
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -1,7 +1,7 @@
|
||||
from opendbc.can.packer import CANPacker
|
||||
from openpilot.common.realtime import DT_CTRL
|
||||
from openpilot.selfdrive.car import apply_meas_steer_torque_limits
|
||||
from openpilot.selfdrive.car.chrysler.chryslercan import create_lkas_hud, create_lkas_command, create_cruise_buttons
|
||||
from openpilot.selfdrive.car.chrysler import chryslercan
|
||||
from openpilot.selfdrive.car.chrysler.values import RAM_CARS, CarControllerParams, ChryslerFlags
|
||||
|
||||
|
||||
@@ -31,17 +31,18 @@ class CarController:
|
||||
# ACC cancellation
|
||||
if CC.cruiseControl.cancel:
|
||||
self.last_button_frame = self.frame
|
||||
can_sends.append(create_cruise_buttons(self.packer, CS.button_counter + 1, das_bus, cancel=True))
|
||||
can_sends.append(chryslercan.create_cruise_buttons(self.packer, CS.button_counter + 1, das_bus, cancel=True))
|
||||
|
||||
# ACC resume from standstill
|
||||
elif CC.cruiseControl.resume:
|
||||
self.last_button_frame = self.frame
|
||||
can_sends.append(create_cruise_buttons(self.packer, CS.button_counter + 1, das_bus, resume=True))
|
||||
can_sends.append(chryslercan.create_cruise_buttons(self.packer, CS.button_counter + 1, das_bus, resume=True))
|
||||
|
||||
# HUD alerts
|
||||
if self.frame % 25 == 0:
|
||||
if CS.lkas_car_model != -1:
|
||||
can_sends.append(create_lkas_hud(self.packer, self.CP, lkas_active, CC.hudControl.visualAlert, self.hud_count, CS.lkas_car_model, CS.auto_high_beam))
|
||||
can_sends.append(chryslercan.create_lkas_hud(self.packer, self.CP, lkas_active, CC.hudControl.visualAlert,
|
||||
self.hud_count, CS.lkas_car_model, CS.auto_high_beam))
|
||||
self.hud_count += 1
|
||||
|
||||
# steering
|
||||
@@ -72,7 +73,7 @@ class CarController:
|
||||
apply_steer = 0
|
||||
self.apply_steer_last = apply_steer
|
||||
|
||||
can_sends.append(create_lkas_command(self.packer, self.CP, int(apply_steer), lkas_control_bit))
|
||||
can_sends.append(chryslercan.create_lkas_command(self.packer, self.CP, int(apply_steer), lkas_control_bit))
|
||||
|
||||
self.frame += 1
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@ from cereal import car
|
||||
from openpilot.common.numpy_fast import clip
|
||||
from opendbc.can.packer import CANPacker
|
||||
from openpilot.selfdrive.car import apply_std_steer_angle_limits
|
||||
from openpilot.selfdrive.car.ford.fordcan import CanBus, create_acc_msg, create_acc_ui_msg, create_button_msg, \
|
||||
create_lat_ctl_msg, create_lat_ctl2_msg, create_lka_msg, create_lkas_ui_msg
|
||||
from openpilot.selfdrive.car.ford import fordcan
|
||||
from openpilot.selfdrive.car.ford.values import CANFD_CAR, CarControllerParams
|
||||
|
||||
LongCtrlState = car.CarControl.Actuators.LongControlState
|
||||
@@ -27,7 +26,7 @@ class CarController:
|
||||
self.CP = CP
|
||||
self.VM = VM
|
||||
self.packer = CANPacker(dbc_name)
|
||||
self.CAN = CanBus(CP)
|
||||
self.CAN = fordcan.CanBus(CP)
|
||||
self.frame = 0
|
||||
|
||||
self.apply_curvature_last = 0
|
||||
@@ -47,15 +46,15 @@ class CarController:
|
||||
|
||||
### acc buttons ###
|
||||
if CC.cruiseControl.cancel:
|
||||
can_sends.append(create_button_msg(self.packer, self.CAN.camera, CS.buttons_stock_values, cancel=True))
|
||||
can_sends.append(create_button_msg(self.packer, self.CAN.main, CS.buttons_stock_values, cancel=True))
|
||||
can_sends.append(fordcan.create_button_msg(self.packer, self.CAN.camera, CS.buttons_stock_values, cancel=True))
|
||||
can_sends.append(fordcan.create_button_msg(self.packer, self.CAN.main, CS.buttons_stock_values, cancel=True))
|
||||
elif CC.cruiseControl.resume and (self.frame % CarControllerParams.BUTTONS_STEP) == 0:
|
||||
can_sends.append(create_button_msg(self.packer, self.CAN.camera, CS.buttons_stock_values, resume=True))
|
||||
can_sends.append(create_button_msg(self.packer, self.CAN.main, CS.buttons_stock_values, resume=True))
|
||||
can_sends.append(fordcan.create_button_msg(self.packer, self.CAN.camera, CS.buttons_stock_values, resume=True))
|
||||
can_sends.append(fordcan.create_button_msg(self.packer, self.CAN.main, CS.buttons_stock_values, resume=True))
|
||||
# if stock lane centering isn't off, send a button press to toggle it off
|
||||
# the stock system checks for steering pressed, and eventually disengages cruise control
|
||||
elif CS.acc_tja_status_stock_values["Tja_D_Stat"] != 0 and (self.frame % CarControllerParams.ACC_UI_STEP) == 0:
|
||||
can_sends.append(create_button_msg(self.packer, self.CAN.camera, CS.buttons_stock_values, tja_toggle=True))
|
||||
can_sends.append(fordcan.create_button_msg(self.packer, self.CAN.camera, CS.buttons_stock_values, tja_toggle=True))
|
||||
|
||||
### lateral control ###
|
||||
# send steer msg at 20Hz
|
||||
@@ -73,13 +72,13 @@ class CarController:
|
||||
# TODO: extended mode
|
||||
mode = 1 if CC.latActive else 0
|
||||
counter = (self.frame // CarControllerParams.STEER_STEP) % 0xF
|
||||
can_sends.append(create_lat_ctl2_msg(self.packer, self.CAN, mode, 0., 0., -apply_curvature, 0., counter))
|
||||
can_sends.append(fordcan.create_lat_ctl2_msg(self.packer, self.CAN, mode, 0., 0., -apply_curvature, 0., counter))
|
||||
else:
|
||||
can_sends.append(create_lat_ctl_msg(self.packer, self.CAN, CC.latActive, 0., 0., -apply_curvature, 0.))
|
||||
can_sends.append(fordcan.create_lat_ctl_msg(self.packer, self.CAN, CC.latActive, 0., 0., -apply_curvature, 0.))
|
||||
|
||||
# send lka msg at 33Hz
|
||||
if (self.frame % CarControllerParams.LKA_STEP) == 0:
|
||||
can_sends.append(create_lka_msg(self.packer, self.CAN))
|
||||
can_sends.append(fordcan.create_lka_msg(self.packer, self.CAN))
|
||||
|
||||
### longitudinal control ###
|
||||
# send acc msg at 50Hz
|
||||
@@ -91,16 +90,16 @@ class CarController:
|
||||
gas = CarControllerParams.INACTIVE_GAS
|
||||
|
||||
stopping = CC.actuators.longControlState == LongCtrlState.stopping
|
||||
can_sends.append(create_acc_msg(self.packer, self.CAN, CC.longActive, gas, accel, stopping))
|
||||
can_sends.append(fordcan.create_acc_msg(self.packer, self.CAN, CC.longActive, gas, accel, stopping))
|
||||
|
||||
### ui ###
|
||||
send_ui = (self.main_on_last != main_on) or (self.lkas_enabled_last != CC.latActive) or (self.steer_alert_last != steer_alert)
|
||||
# send lkas ui msg at 1Hz or if ui state changes
|
||||
if (self.frame % CarControllerParams.LKAS_UI_STEP) == 0 or send_ui:
|
||||
can_sends.append(create_lkas_ui_msg(self.packer, self.CAN, main_on, CC.latActive, steer_alert, hud_control, CS.lkas_status_stock_values))
|
||||
can_sends.append(fordcan.create_lkas_ui_msg(self.packer, self.CAN, main_on, CC.latActive, steer_alert, hud_control, CS.lkas_status_stock_values))
|
||||
# send acc ui msg at 5Hz or if ui state changes
|
||||
if (self.frame % CarControllerParams.ACC_UI_STEP) == 0 or send_ui:
|
||||
can_sends.append(create_acc_ui_msg(self.packer, self.CAN, self.CP, main_on, CC.latActive,
|
||||
can_sends.append(fordcan.create_acc_ui_msg(self.packer, self.CAN, self.CP, main_on, CC.latActive,
|
||||
fcw_alert, CS.out.cruiseState.standstill, hud_control,
|
||||
CS.acc_tja_status_stock_values))
|
||||
|
||||
|
||||
@@ -320,7 +320,6 @@ class CarState(CarStateBase):
|
||||
def get_can_parser_canfd(self, CP):
|
||||
messages = [
|
||||
(self.gear_msg_canfd, 100),
|
||||
(self.cruise_btns_msg_canfd, 50),
|
||||
(self.accelerator_msg_canfd, 100),
|
||||
("WHEEL_SPEEDS", 100),
|
||||
("STEERING_SENSORS", 100),
|
||||
@@ -331,6 +330,11 @@ class CarState(CarStateBase):
|
||||
("DOORS_SEATBELTS", 4),
|
||||
]
|
||||
|
||||
if not (CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS):
|
||||
messages += [
|
||||
("CRUISE_BUTTONS", 50)
|
||||
]
|
||||
|
||||
if CP.enableBsm:
|
||||
messages += [
|
||||
("BLINDSPOTS_REAR_CORNERS", 20),
|
||||
|
||||
@@ -150,7 +150,6 @@ class CarState(CarStateBase):
|
||||
("CruiseControl", 50),
|
||||
("Wheel_Speeds", 50),
|
||||
("Dash_State2", 1),
|
||||
("Dashlights", 10),
|
||||
]
|
||||
|
||||
return messages
|
||||
|
||||
@@ -261,7 +261,7 @@ def create_preglobal_es_distance(packer, cruise_button, es_distance_msg):
|
||||
"Signal1",
|
||||
"Car_Follow",
|
||||
"Signal2",
|
||||
"Brake_On",
|
||||
"Cruise_Brake_Active",
|
||||
"Distance_Swap",
|
||||
"Standstill",
|
||||
"Signal3",
|
||||
|
||||
@@ -2,9 +2,7 @@ from cereal import car
|
||||
from openpilot.common.numpy_fast import clip, interp
|
||||
from openpilot.selfdrive.car import apply_meas_steer_torque_limits, apply_std_steer_angle_limits, common_fault_avoidance, \
|
||||
create_gas_interceptor_command, make_can_msg
|
||||
from openpilot.selfdrive.car.toyota.toyotacan import create_steer_command, create_ui_command, \
|
||||
create_accel_command, create_acc_cancel_command, \
|
||||
create_fcw_command, create_lta_steer_command
|
||||
from openpilot.selfdrive.car.toyota import toyotacan
|
||||
from openpilot.selfdrive.car.toyota.values import CAR, STATIC_DSU_MSGS, NO_STOP_TIMER_CAR, TSS2_CAR, \
|
||||
MIN_ACC_SPEED, PEDAL_TRANSITION, CarControllerParams, ToyotaFlags, \
|
||||
UNSUPPORTED_DSU_CAR
|
||||
@@ -85,13 +83,13 @@ class CarController:
|
||||
# toyota can trace shows this message at 42Hz, with counter adding alternatively 1 and 2;
|
||||
# sending it at 100Hz seem to allow a higher rate limit, as the rate limit seems imposed
|
||||
# on consecutive messages
|
||||
can_sends.append(create_steer_command(self.packer, apply_steer, apply_steer_req))
|
||||
can_sends.append(toyotacan.create_steer_command(self.packer, apply_steer, apply_steer_req))
|
||||
if self.frame % 2 == 0 and self.CP.carFingerprint in TSS2_CAR:
|
||||
lta_active = lat_active and self.CP.steerControlType == SteerControlType.angle
|
||||
full_torque_condition = (abs(CS.out.steeringTorqueEps) < self.params.STEER_MAX and
|
||||
abs(CS.out.steeringTorque) < MAX_DRIVER_TORQUE_ALLOWANCE)
|
||||
setme_x64 = 100 if lta_active and full_torque_condition else 0
|
||||
can_sends.append(create_lta_steer_command(self.packer, self.last_angle, lta_active, self.frame // 2, setme_x64))
|
||||
can_sends.append(toyotacan.create_lta_steer_command(self.packer, self.last_angle, lta_active, self.frame // 2, setme_x64))
|
||||
|
||||
# *** gas and brake ***
|
||||
if self.CP.enableGasInterceptor and CC.longActive:
|
||||
@@ -135,12 +133,12 @@ class CarController:
|
||||
|
||||
# Lexus IS uses a different cancellation message
|
||||
if pcm_cancel_cmd and self.CP.carFingerprint in UNSUPPORTED_DSU_CAR:
|
||||
can_sends.append(create_acc_cancel_command(self.packer))
|
||||
can_sends.append(toyotacan.create_acc_cancel_command(self.packer))
|
||||
elif self.CP.openpilotLongitudinalControl:
|
||||
can_sends.append(create_accel_command(self.packer, pcm_accel_cmd, pcm_cancel_cmd, self.standstill_req, lead, CS.acc_type, fcw_alert))
|
||||
can_sends.append(toyotacan.create_accel_command(self.packer, pcm_accel_cmd, pcm_cancel_cmd, self.standstill_req, lead, CS.acc_type, fcw_alert))
|
||||
self.accel = pcm_accel_cmd
|
||||
else:
|
||||
can_sends.append(create_accel_command(self.packer, 0, pcm_cancel_cmd, False, lead, CS.acc_type, False))
|
||||
can_sends.append(toyotacan.create_accel_command(self.packer, 0, pcm_cancel_cmd, False, lead, CS.acc_type, False))
|
||||
|
||||
if self.frame % 2 == 0 and self.CP.enableGasInterceptor and self.CP.openpilotLongitudinalControl:
|
||||
# send exactly zero if gas cmd is zero. Interceptor will send the max between read value and gas cmd.
|
||||
@@ -163,12 +161,12 @@ class CarController:
|
||||
send_ui = True
|
||||
|
||||
if self.frame % 20 == 0 or send_ui:
|
||||
can_sends.append(create_ui_command(self.packer, steer_alert, pcm_cancel_cmd, hud_control.leftLaneVisible,
|
||||
hud_control.rightLaneVisible, hud_control.leftLaneDepart,
|
||||
hud_control.rightLaneDepart, CC.enabled, CS.lkas_hud))
|
||||
can_sends.append(toyotacan.create_ui_command(self.packer, steer_alert, pcm_cancel_cmd, hud_control.leftLaneVisible,
|
||||
hud_control.rightLaneVisible, hud_control.leftLaneDepart,
|
||||
hud_control.rightLaneDepart, CC.enabled, CS.lkas_hud))
|
||||
|
||||
if (self.frame % 100 == 0 or send_ui) and (self.CP.enableDsu or self.CP.flags & ToyotaFlags.DISABLE_RADAR.value):
|
||||
can_sends.append(create_fcw_command(self.packer, fcw_alert))
|
||||
can_sends.append(toyotacan.create_fcw_command(self.packer, fcw_alert))
|
||||
|
||||
# *** static msgs ***
|
||||
for addr, cars, bus, fr_step, vl in STATIC_DSU_MSGS:
|
||||
|
||||
@@ -1315,6 +1315,7 @@ FW_VERSIONS = {
|
||||
},
|
||||
CAR.SKODA_SUPERB_MK3: {
|
||||
(Ecu.engine, 0x7e0, None): [
|
||||
b'\xf1\x8704E906027BT\xf1\x899042',
|
||||
b'\xf1\x8704L906026ET\xf1\x891343',
|
||||
b'\xf1\x8704L906026FP\xf1\x891196',
|
||||
b'\xf1\x8704L906026KB\xf1\x894071',
|
||||
@@ -1327,6 +1328,7 @@ FW_VERSIONS = {
|
||||
],
|
||||
(Ecu.transmission, 0x7e1, None): [
|
||||
b'\xf1\x870CW300042H \xf1\x891601',
|
||||
b'\xf1\x870CW300049Q \xf1\x890906',
|
||||
b'\xf1\x870D9300011T \xf1\x894801',
|
||||
b'\xf1\x870D9300012 \xf1\x894940',
|
||||
b'\xf1\x870D9300013A \xf1\x894905',
|
||||
@@ -1350,6 +1352,7 @@ FW_VERSIONS = {
|
||||
],
|
||||
(Ecu.eps, 0x712, None): [
|
||||
b'\xf1\x875Q0909143K \xf1\x892033\xf1\x820514UZ070203',
|
||||
b'\xf1\x875Q0909143M \xf1\x892041\xf1\x820522UZ050303',
|
||||
b'\xf1\x875Q0909143M \xf1\x892041\xf1\x820522UZ070303',
|
||||
b'\xf1\x875Q0909143P \xf1\x892051\xf1\x820526UZ070505',
|
||||
b'\xf1\x875Q0910143B \xf1\x892201\xf1\x82\00563UZ060700',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import numpy as np
|
||||
@@ -7,7 +8,7 @@ from typing import Dict, Optional
|
||||
from setproctitle import setproctitle
|
||||
from cereal.messaging import PubMaster, SubMaster
|
||||
from cereal.visionipc import VisionIpcClient, VisionStreamType, VisionBuf
|
||||
from openpilot.system.hardware import PC
|
||||
from openpilot.system.hardware import PC, TICI
|
||||
from openpilot.system.swaglog import cloudlog
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.filter_simple import FirstOrderFilter
|
||||
@@ -16,8 +17,9 @@ from openpilot.selfdrive.modeld.models.commonmodel_pyx import ModelFrame, CLCont
|
||||
from openpilot.selfdrive.modeld.models.driving_pyx import (
|
||||
PublishState, create_model_msg, create_pose_msg, update_calibration,
|
||||
FEATURE_LEN, HISTORY_BUFFER_LEN, DESIRE_LEN, TRAFFIC_CONVENTION_LEN, NAV_FEATURE_LEN, NAV_INSTRUCTION_LEN,
|
||||
OUTPUT_SIZE, NET_OUTPUT_SIZE, MODEL_FREQ, USE_THNEED)
|
||||
OUTPUT_SIZE, NET_OUTPUT_SIZE, MODEL_FREQ)
|
||||
|
||||
USE_THNEED = int(os.getenv('USE_THNEED', str(int(TICI))))
|
||||
if USE_THNEED:
|
||||
from selfdrive.modeld.runners.thneedmodel_pyx import ThneedModel as ModelRunner
|
||||
else:
|
||||
|
||||
@@ -9,12 +9,6 @@
|
||||
#include "common/util.h"
|
||||
#include "selfdrive/modeld/models/nav.h"
|
||||
|
||||
#ifdef USE_THNEED
|
||||
constexpr bool CPP_USE_THNEED = true;
|
||||
#else
|
||||
constexpr bool CPP_USE_THNEED = false;
|
||||
#endif
|
||||
|
||||
constexpr int FEATURE_LEN = 128;
|
||||
constexpr int HISTORY_BUFFER_LEN = 99;
|
||||
constexpr int DESIRE_LEN = 8;
|
||||
|
||||
@@ -21,7 +21,6 @@ cdef extern from "selfdrive/modeld/models/driving.h":
|
||||
cdef int OUTPUT_SIZE
|
||||
cdef int NET_OUTPUT_SIZE
|
||||
cdef int MODEL_FREQ
|
||||
cdef bool CPP_USE_THNEED
|
||||
cdef struct PublishState: pass
|
||||
|
||||
mat3 update_calibration(float *, bool, bool)
|
||||
|
||||
@@ -11,7 +11,7 @@ from .commonmodel cimport mat3
|
||||
from .driving cimport FEATURE_LEN as CPP_FEATURE_LEN, HISTORY_BUFFER_LEN as CPP_HISTORY_BUFFER_LEN, DESIRE_LEN as CPP_DESIRE_LEN, \
|
||||
TRAFFIC_CONVENTION_LEN as CPP_TRAFFIC_CONVENTION_LEN, DRIVING_STYLE_LEN as CPP_DRIVING_STYLE_LEN, \
|
||||
NAV_FEATURE_LEN as CPP_NAV_FEATURE_LEN, NAV_INSTRUCTION_LEN as CPP_NAV_INSTRUCTION_LEN, \
|
||||
OUTPUT_SIZE as CPP_OUTPUT_SIZE, NET_OUTPUT_SIZE as CPP_NET_OUTPUT_SIZE, MODEL_FREQ as CPP_MODEL_FREQ, CPP_USE_THNEED
|
||||
OUTPUT_SIZE as CPP_OUTPUT_SIZE, NET_OUTPUT_SIZE as CPP_NET_OUTPUT_SIZE, MODEL_FREQ as CPP_MODEL_FREQ
|
||||
from .driving cimport MessageBuilder, PublishState as cppPublishState
|
||||
from .driving cimport fill_model_msg, fill_pose_msg, update_calibration as cpp_update_calibration
|
||||
|
||||
@@ -25,7 +25,6 @@ NAV_INSTRUCTION_LEN = CPP_NAV_INSTRUCTION_LEN
|
||||
OUTPUT_SIZE = CPP_OUTPUT_SIZE
|
||||
NET_OUTPUT_SIZE = CPP_NET_OUTPUT_SIZE
|
||||
MODEL_FREQ = CPP_MODEL_FREQ
|
||||
USE_THNEED = CPP_USE_THNEED
|
||||
|
||||
cdef class PublishState:
|
||||
cdef cppPublishState state
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import os
|
||||
import time
|
||||
import tempfile
|
||||
|
||||
from unittest import mock
|
||||
from functools import wraps
|
||||
|
||||
import cereal.messaging as messaging
|
||||
@@ -67,3 +70,19 @@ def with_processes(processes, init_time=0, ignore_stopped=None):
|
||||
|
||||
return wrap
|
||||
return wrapper
|
||||
|
||||
|
||||
def temporary_mock_dir(mock_path):
|
||||
def wrapper(func):
|
||||
@wraps(func)
|
||||
def wrap(*args, **kwargs):
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
cache_dir_patch = mock.patch(mock_path, temp_dir)
|
||||
cache_dir_patch.start()
|
||||
func(*args, **kwargs, temp_dir=temp_dir)
|
||||
cache_dir_patch.stop()
|
||||
return wrap
|
||||
return wrapper
|
||||
|
||||
temporary_cache_dir = temporary_mock_dir("openpilot.tools.lib.url_file.CACHE_DIR")
|
||||
temporary_swaglog_dir = temporary_mock_dir("openpilot.system.swaglog.SWAGLOG_DIR")
|
||||
@@ -6,7 +6,7 @@ class GPIO:
|
||||
HUB_RST_N = 30
|
||||
UBLOX_RST_N = 32
|
||||
UBLOX_SAFEBOOT_N = 33
|
||||
UBLOX_PWR_EN = 34
|
||||
GNSS_PWR_EN = 34 # SCHEMATIC LABEL: GPIO_UBLOX_PWR_EN
|
||||
STM_RST_N = 124
|
||||
STM_BOOT0 = 134
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ if __name__ == "__main__":
|
||||
t.set_screen_brightness(0)
|
||||
gpio_init(GPIO.STM_RST_N, True)
|
||||
gpio_init(GPIO.HUB_RST_N, True)
|
||||
gpio_init(GPIO.UBLOX_PWR_EN, True)
|
||||
gpio_init(GPIO.GNSS_PWR_EN, True)
|
||||
gpio_init(GPIO.LTE_RST_N, True)
|
||||
gpio_init(GPIO.LTE_PWRKEY, True)
|
||||
gpio_init(GPIO.CAM0_AVDD_EN, True)
|
||||
@@ -65,7 +65,7 @@ if __name__ == "__main__":
|
||||
os.system("sudo su -c 'echo 0 > /sys/kernel/debug/regulator/camera_rear_ldo/enable'") # cam 1v2 off
|
||||
gpio_set(GPIO.CAM0_AVDD_EN, False) # cam 2v8 off
|
||||
gpio_set(GPIO.LTE_RST_N, True) # quectel off
|
||||
gpio_set(GPIO.UBLOX_PWR_EN, False) # gps off
|
||||
gpio_set(GPIO.GNSS_PWR_EN, False) # gps off
|
||||
gpio_set(GPIO.STM_RST_N, True) # panda off
|
||||
gpio_set(GPIO.HUB_RST_N, False) # hub off
|
||||
# cameras in reset
|
||||
@@ -92,7 +92,7 @@ if __name__ == "__main__":
|
||||
gpio_set(GPIO.STM_RST_N, False)
|
||||
time.sleep(5)
|
||||
print("panda: ", read_power_avg())
|
||||
gpio_set(GPIO.UBLOX_PWR_EN, True)
|
||||
gpio_set(GPIO.GNSS_PWR_EN, True)
|
||||
time.sleep(5)
|
||||
print("gps: ", read_power_avg())
|
||||
gpio_set(GPIO.LTE_RST_N, False)
|
||||
|
||||
@@ -27,11 +27,11 @@ UBLOX_ASSIST_ACK = b"\xb5\x62\x13\x60\x08\x00"
|
||||
|
||||
def set_power(enabled: bool) -> None:
|
||||
gpio_init(GPIO.UBLOX_SAFEBOOT_N, True)
|
||||
gpio_init(GPIO.UBLOX_PWR_EN, True)
|
||||
gpio_init(GPIO.GNSS_PWR_EN, True)
|
||||
gpio_init(GPIO.UBLOX_RST_N, True)
|
||||
|
||||
gpio_set(GPIO.UBLOX_SAFEBOOT_N, True)
|
||||
gpio_set(GPIO.UBLOX_PWR_EN, enabled)
|
||||
gpio_set(GPIO.GNSS_PWR_EN, enabled)
|
||||
gpio_set(GPIO.UBLOX_RST_N, enabled)
|
||||
|
||||
def add_ubx_checksum(msg: bytes) -> bytes:
|
||||
|
||||
@@ -271,7 +271,7 @@ def main() -> NoReturn:
|
||||
def cleanup(sig, frame):
|
||||
cloudlog.warning("caught sig disabling quectel gps")
|
||||
|
||||
gpio_set(GPIO.UBLOX_PWR_EN, False)
|
||||
gpio_set(GPIO.GNSS_PWR_EN, False)
|
||||
teardown_quectel(diag)
|
||||
cloudlog.warning("quectel cleanup done")
|
||||
|
||||
@@ -289,8 +289,8 @@ def main() -> NoReturn:
|
||||
want_assistance = not r
|
||||
current_gps_time = utc_to_gpst(GPSTime.from_datetime(datetime.utcnow()))
|
||||
cloudlog.warning("quectel setup done")
|
||||
gpio_init(GPIO.UBLOX_PWR_EN, True)
|
||||
gpio_set(GPIO.UBLOX_PWR_EN, True)
|
||||
gpio_init(GPIO.GNSS_PWR_EN, True)
|
||||
gpio_set(GPIO.GNSS_PWR_EN, True)
|
||||
|
||||
pm = messaging.PubMaster(['qcomGnss', 'gpsLocation'])
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class TestPigeond(unittest.TestCase):
|
||||
managed_processes['pigeond'].stop()
|
||||
|
||||
assert gpio_read(GPIO.UBLOX_RST_N) == 0
|
||||
assert gpio_read(GPIO.UBLOX_PWR_EN) == 0
|
||||
assert gpio_read(GPIO.GNSS_PWR_EN) == 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+6
-1
@@ -77,6 +77,9 @@ class UnixDomainSocketHandler(logging.Handler):
|
||||
self.sock = None
|
||||
|
||||
def __del__(self):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
if self.sock is not None:
|
||||
self.sock.close()
|
||||
if self.zctx is not None:
|
||||
@@ -129,6 +132,8 @@ elif print_level == 'info':
|
||||
elif print_level == 'warning':
|
||||
outhandler.setLevel(logging.WARNING)
|
||||
|
||||
ipchandler = UnixDomainSocketHandler(SwagFormatter(log))
|
||||
|
||||
log.addHandler(outhandler)
|
||||
# logs are sent through IPC before writing to disk to prevent disk I/O blocking
|
||||
log.addHandler(UnixDomainSocketHandler(SwagFormatter(log)))
|
||||
log.addHandler(ipchandler)
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import cereal.messaging as messaging
|
||||
from openpilot.selfdrive.manager.process_config import managed_processes
|
||||
from openpilot.system.swaglog import cloudlog, SWAGLOG_DIR
|
||||
from openpilot.system.swaglog import cloudlog, ipchandler
|
||||
from selfdrive.test.helpers import temporary_swaglog_dir
|
||||
|
||||
|
||||
class TestLogmessaged(unittest.TestCase):
|
||||
def _setup(self, temp_dir):
|
||||
# clear the IPC buffer in case some other tests used cloudlog and filled it
|
||||
ipchandler.close()
|
||||
ipchandler.connect()
|
||||
|
||||
def setUp(self):
|
||||
if os.path.exists(SWAGLOG_DIR):
|
||||
shutil.rmtree(SWAGLOG_DIR)
|
||||
|
||||
self.temp_dir = temp_dir
|
||||
managed_processes['logmessaged'].start()
|
||||
self.sock = messaging.sub_sock("logMessage", timeout=1000, conflate=False)
|
||||
self.error_sock = messaging.sub_sock("logMessage", timeout=1000, conflate=False)
|
||||
@@ -31,9 +32,11 @@ class TestLogmessaged(unittest.TestCase):
|
||||
managed_processes['logmessaged'].stop(block=True)
|
||||
|
||||
def _get_log_files(self):
|
||||
return list(glob.glob(os.path.join(SWAGLOG_DIR, "swaglog.*")))
|
||||
return list(glob.glob(os.path.join(self.temp_dir, "swaglog.*")))
|
||||
|
||||
def test_simple_log(self):
|
||||
@temporary_swaglog_dir
|
||||
def test_simple_log(self, temp_dir):
|
||||
self._setup(temp_dir)
|
||||
msgs = [f"abc {i}" for i in range(10)]
|
||||
for m in msgs:
|
||||
cloudlog.error(m)
|
||||
@@ -42,7 +45,9 @@ class TestLogmessaged(unittest.TestCase):
|
||||
assert len(m) == len(msgs)
|
||||
assert len(self._get_log_files()) >= 1
|
||||
|
||||
def test_big_log(self):
|
||||
@temporary_swaglog_dir
|
||||
def test_big_log(self, temp_dir):
|
||||
self._setup(temp_dir)
|
||||
n = 10
|
||||
msg = "a"*3*1024*1024
|
||||
for _ in range(n):
|
||||
|
||||
@@ -13,20 +13,30 @@ fi
|
||||
if ! command -v "pyenv" > /dev/null 2>&1; then
|
||||
echo "pyenv install ..."
|
||||
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
|
||||
PYENV_PATH_SETUP="export PATH=\$HOME/.pyenv/bin:\$HOME/.pyenv/shims:\$PATH"
|
||||
fi
|
||||
|
||||
if [ -z "$PYENV_SHELL" ] || [ -n "$PYENV_PATH_SETUP" ]; then
|
||||
echo "pyenvrc setup ..."
|
||||
cat <<EOF > "${HOME}/.pyenvrc"
|
||||
if [ -z "\$PYENV_ROOT" ]; then
|
||||
export PATH=\$HOME/.pyenv/bin:\$HOME/.pyenv/shims:\$PATH
|
||||
$PYENV_PATH_SETUP
|
||||
export PYENV_ROOT="\$HOME/.pyenv"
|
||||
eval "\$(pyenv init --path)"
|
||||
eval "\$(pyenv init -)"
|
||||
eval "\$(pyenv virtualenv-init -)"
|
||||
fi
|
||||
EOF
|
||||
echo -e "\nsource ~/.pyenvrc" >> $RC_FILE
|
||||
|
||||
# activate pyenv now
|
||||
source $RC_FILE
|
||||
SOURCE_PYENVRC="source ~/.pyenvrc"
|
||||
if ! grep "^$SOURCE_PYENVRC$" $RC_FILE > /dev/null; then
|
||||
printf "\n$SOURCE_PYENVRC\n" >> $RC_FILE
|
||||
fi
|
||||
|
||||
eval "$SOURCE_PYENVRC"
|
||||
# $(pyenv init -) produces a function which is broken on bash 3.2 which ships on macOS
|
||||
if [ $(uname) == "Darwin" ]; then
|
||||
unset -f pyenv
|
||||
fi
|
||||
fi
|
||||
|
||||
export MAKEFLAGS="-j$(nproc)"
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
os.environ["COMMA_CACHE"] = "/tmp/__test_cache__"
|
||||
from openpilot.tools.lib.url_file import URLFile, CACHE_DIR
|
||||
from openpilot.tools.lib.url_file import URLFile
|
||||
from openpilot.selfdrive.test.helpers import temporary_cache_dir
|
||||
|
||||
|
||||
class TestFileDownload(unittest.TestCase):
|
||||
|
||||
def compare_loads(self, url, start=0, length=None):
|
||||
"""Compares range between cached and non cached version"""
|
||||
shutil.rmtree(CACHE_DIR)
|
||||
|
||||
file_cached = URLFile(url, cache=True)
|
||||
file_downloaded = URLFile(url, cache=False)
|
||||
|
||||
@@ -35,7 +31,8 @@ class TestFileDownload(unittest.TestCase):
|
||||
self.assertEqual(file_cached.get_length(), file_downloaded.get_length())
|
||||
self.assertEqual(response_cached, response_downloaded)
|
||||
|
||||
def test_small_file(self):
|
||||
@temporary_cache_dir
|
||||
def test_small_file(self, temp_dir):
|
||||
# Make sure we don't force cache
|
||||
os.environ["FILEREADER_CACHE"] = "0"
|
||||
small_file_url = "https://raw.githubusercontent.com/commaai/openpilot/master/docs/SAFETY.md"
|
||||
@@ -55,7 +52,8 @@ class TestFileDownload(unittest.TestCase):
|
||||
for i in range(length // 100):
|
||||
self.compare_loads(small_file_url, 100 * i, 100)
|
||||
|
||||
def test_large_file(self):
|
||||
@temporary_cache_dir
|
||||
def test_large_file(self, temp_dir):
|
||||
large_file_url = "https://commadataci.blob.core.windows.net/openpilotci/0375fdf7b1ce594d/2019-06-13--08-32-25/3/qlog.bz2"
|
||||
# Load the end 100 bytes of both files
|
||||
file_large = URLFile(large_file_url)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ COPY ./third_party ${OPENPILOT_PATH}/third_party
|
||||
COPY ./site_scons ${OPENPILOT_PATH}/site_scons
|
||||
COPY ./rednose ${OPENPILOT_PATH}/rednose
|
||||
COPY ./laika_repo ${OPENPILOT_PATH}/laika_repo
|
||||
RUN ln -s ${OPENPILOT_PATH}/laika_repo ${OPENPILOT_PATH}/laika
|
||||
RUN ln -s ${OPENPILOT_PATH}/laika_repo/laika/ ${OPENPILOT_PATH}/laika
|
||||
COPY ./common ${OPENPILOT_PATH}/common
|
||||
COPY ./opendbc ${OPENPILOT_PATH}/opendbc
|
||||
COPY ./cereal ${OPENPILOT_PATH}/cereal
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
Reference in New Issue
Block a user