diff --git a/.gitignore b/.gitignore
index 31cef9422..2b283d3b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,6 +52,7 @@ selfdrive/sensord/_sensord
system/camerad/camerad
system/camerad/test/ae_gray_test
selfdrive/modeld/_modeld
+selfdrive/modeld/_navmodeld
selfdrive/modeld/_dmonitoringmodeld
/src/
diff --git a/Jenkinsfile b/Jenkinsfile
index c34d25358..30c045e41 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -11,6 +11,9 @@ export SOURCE_DIR=${env.SOURCE_DIR}
export GIT_BRANCH=${env.GIT_BRANCH}
export GIT_COMMIT=${env.GIT_COMMIT}
export AZURE_TOKEN='${env.AZURE_TOKEN}'
+export MAPBOX_TOKEN='${env.MAPBOX_TOKEN}'
+
+export GIT_SSH_COMMAND="ssh -i /data/gitkey"
source ~/.bash_profile
if [ -f /TICI ]; then
@@ -47,20 +50,34 @@ pipeline {
TEST_DIR = "/data/openpilot"
SOURCE_DIR = "/data/openpilot_source/"
AZURE_TOKEN = credentials('azure_token')
+ MAPBOX_TOKEN = credentials('mapbox_token')
}
options {
- timeout(time: 4, unit: 'HOURS')
+ timeout(time: 3, unit: 'HOURS')
+ disableConcurrentBuilds(abortPrevious: env.BRANCH_NAME != 'master')
}
stages {
- stage('build release3') {
+ stage('build release3-staging') {
agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
when {
branch 'devel-staging'
}
steps {
phone_steps("tici-needs-can", [
- ["build release3-staging & dashcam3-staging", "PUSH=1 $SOURCE_DIR/release/build_release.sh"],
+ ["build release3-staging & dashcam3-staging", "RELEASE_BRANCH=release3-staging DASHCAM_BRANCH=dashcam3-staging $SOURCE_DIR/release/build_release.sh"],
+ ])
+ }
+ }
+
+ stage('build nightly') {
+ agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
+ when {
+ branch 'master-ci'
+ }
+ steps {
+ phone_steps("tici-needs-can", [
+ ["build nightly", "RELEASE_BRANCH=nightly $SOURCE_DIR/release/build_release.sh"],
])
}
}
@@ -78,6 +95,7 @@ pipeline {
parallel {
+ /*
stage('simulator') {
agent {
dockerfile {
@@ -87,7 +105,8 @@ pipeline {
}
}
steps {
- sh "git config --global --add safe.directory ${WORKSPACE}"
+ sh "git config --global --add safe.directory '*'"
+ sh "git submodule update --init --recursive"
sh "git lfs pull"
lock(resource: "", label: "simulator", inversePrecedence: true, quantity: 1) {
sh "${WORKSPACE}/tools/sim/build_container.sh"
@@ -104,6 +123,7 @@ pipeline {
}
}
}
+ */
stage('build') {
agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
@@ -115,7 +135,6 @@ pipeline {
["build master-ci", "cd $SOURCE_DIR/release && TARGET_DIR=$TEST_DIR EXTRA_FILES='tools/' ./build_devel.sh"],
["build openpilot", "cd selfdrive/manager && ./build.py"],
["check dirty", "release/check-dirty.sh"],
- ["test manager", "python selfdrive/manager/test/test_manager.py"],
["onroad tests", "cd selfdrive/test/ && ./test_onroad.py"],
["test car interfaces", "cd selfdrive/car/tests/ && ./test_car_interfaces.py"],
])
@@ -141,6 +160,7 @@ pipeline {
["test loggerd", "python selfdrive/loggerd/tests/test_loggerd.py"],
["test encoder", "LD_LIBRARY_PATH=/usr/local/lib python selfdrive/loggerd/tests/test_encoder.py"],
["test pigeond", "python selfdrive/sensord/tests/test_pigeond.py"],
+ ["test manager", "python selfdrive/manager/test/test_manager.py"],
])
}
}
@@ -148,7 +168,7 @@ pipeline {
stage('camerad-ar') {
agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
steps {
- phone_steps("tici-ar0321", [
+ phone_steps("tici-ar0231", [
["build", "cd selfdrive/manager && ./build.py"],
["test camerad", "python system/camerad/test/test_camerad.py"],
["test exposure", "python system/camerad/test/test_exposure.py"],
@@ -186,7 +206,7 @@ pipeline {
steps {
phone_steps("tici-common", [
["build", "cd selfdrive/manager && ./build.py"],
- ["model replay", "cd selfdrive/test/process_replay && ./model_replay.py"],
+ ["model replay", "cd selfdrive/test/process_replay && NO_NAV=1 ./model_replay.py"],
])
}
}
diff --git a/README.md b/README.md
index cfeb625bf..4896d9ff7 100755
--- a/README.md
+++ b/README.md
@@ -103,7 +103,6 @@ Directory Structure
├── opendbc # Files showing how to interpret data from cars
├── panda # Code used to communicate on CAN
├── third_party # External libraries
- ├── pyextra # Extra python packages
└── system # Generic services
├── camerad # Driver to capture images from the camera sensors
├── clocksd # Broadcasts current time
@@ -143,7 +142,4 @@ NO WARRANTY EXPRESSED OR IMPLIED.**
[](https://github.com/commaai/openpilot/actions)
-[](https://lgtm.com/projects/g/commaai/openpilot/alerts/)
-[](https://lgtm.com/projects/g/commaai/openpilot/context:python)
-[](https://lgtm.com/projects/g/commaai/openpilot/context:cpp)
[](https://codecov.io/gh/commaai/openpilot)
diff --git a/RELEASES.md b/RELEASES.md
index e15286c5f..f166e7d1c 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -1,3 +1,24 @@
+Version 0.9.1 (2023-02-28)
+========================
+* New driving model
+ * 30% improved height estimation resulting in better driving performance for tall cars
+* Driver monitoring: removed timer resetting on user interaction if distracted
+* UI updates
+ * Adjust alert volume using ambient noise level
+ * Driver monitoring icon shows driver's head pose
+ * German translation thanks to Vrabetz and CzokNorris!
+* Cadillac Escalade 2017 support thanks to rickygilleland!
+* Chevrolet Bolt EV 2022-23 support thanks to JasonJShuler!
+* Genesis GV60 2023 support thanks to sunnyhaibin!
+* Hyundai Tucson 2022-23 support
+* Kia K5 Hybrid 2020 support thanks to sunnyhaibin!
+* Kia Niro Hybrid 2023 support thanks to sunnyhaibin!
+* Kia Sorento 2022-23 support thanks to sunnyhaibin!
+* Kia Sorento Plug-in Hybrid 2022 support thanks to sunnyhaibin!
+* Toyota C-HR 2021 support thanks to eFiniLan!
+* Toyota C-HR Hybrid 2022 support thanks to Korben00!
+* Volkswagen Crafter and MAN TGE 2017-23 support thanks to jyoung8607!
+
Version 0.9.0 (2022-11-21)
========================
* New driving model
diff --git a/SConstruct b/SConstruct
index 74680c059..007931b7f 100644
--- a/SConstruct
+++ b/SConstruct
@@ -71,10 +71,10 @@ if arch == "aarch64" and AGNOS:
lenv = {
"PATH": os.environ['PATH'],
"LD_LIBRARY_PATH": [Dir(f"#third_party/acados/{arch}/lib").abspath],
- "PYTHONPATH": Dir("#").abspath + ":" + Dir("#pyextra/").abspath,
+ "PYTHONPATH": Dir("#").abspath,
"ACADOS_SOURCE_DIR": Dir("#third_party/acados/include/acados").abspath,
- "ACADOS_PYTHON_INTERFACE_PATH": Dir("#pyextra/acados_template").abspath,
+ "ACADOS_PYTHON_INTERFACE_PATH": Dir("#third_party/acados/acados_template").abspath,
"TERA_PATH": Dir("#").abspath + f"/third_party/acados/{arch}/t_renderer"
}
@@ -197,10 +197,6 @@ env = Environment(
"#third_party/libyuv/include",
"#third_party/json11",
"#third_party/curl/include",
- "#third_party/libgralloc/include",
- "#third_party/android_frameworks_native/include",
- "#third_party/android_hardware_libhardware/include",
- "#third_party/android_system_core/include",
"#third_party/linux/include",
"#third_party/snpe/include",
"#third_party/mapbox-gl-native-qt/include",
@@ -282,7 +278,7 @@ Export('envCython')
# Qt build environment
qt_env = env.Clone()
-qt_modules = ["Widgets", "Gui", "Core", "Network", "Concurrent", "Multimedia", "Quick", "Qml", "QuickWidgets", "Location", "Positioning", "DBus"]
+qt_modules = ["Widgets", "Gui", "Core", "Network", "Concurrent", "Multimedia", "Quick", "Qml", "QuickWidgets", "Location", "Positioning", "DBus", "Xml"]
qt_libs = []
if arch == "Darwin":
@@ -298,16 +294,20 @@ if arch == "Darwin":
qt_env["FRAMEWORKS"] += [f"Qt{m}" for m in qt_modules] + ["OpenGL"]
qt_env.AppendENVPath('PATH', os.path.join(qt_env['QTDIR'], "bin"))
else:
- qt_env['QTDIR'] = "/usr"
+ qt_install_prefix = subprocess.check_output(['qmake', '-query', 'QT_INSTALL_PREFIX'], encoding='utf8').strip()
+ qt_install_headers = subprocess.check_output(['qmake', '-query', 'QT_INSTALL_HEADERS'], encoding='utf8').strip()
+
+ qt_env['QTDIR'] = qt_install_prefix
qt_dirs = [
- f"/usr/include/{real_arch}-linux-gnu/qt5",
- f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui/5.12.8/QtGui",
+ f"{qt_install_headers}",
+ f"{qt_install_headers}/QtGui/5.12.8/QtGui",
]
- qt_dirs += [f"/usr/include/{real_arch}-linux-gnu/qt5/Qt{m}" for m in qt_modules]
+ qt_dirs += [f"{qt_install_headers}/Qt{m}" for m in qt_modules]
qt_libs = [f"Qt5{m}" for m in qt_modules]
if arch == "larch64":
qt_libs += ["GLESv2", "wayland-client"]
+ qt_env.PrependENVPath('PATH', Dir("#third_party/qt5/larch64/bin/").abspath)
elif arch != "Darwin":
qt_libs += ["GL"]
@@ -384,10 +384,10 @@ rednose_config = {
if arch != "larch64":
rednose_config['to_build'].update({
'loc_4': ('#selfdrive/locationd/models/loc_kf.py', True, [], rednose_deps),
+ 'lane': ('#selfdrive/locationd/models/lane_kf.py', True, [], rednose_deps),
'pos_computer_4': ('#rednose/helpers/lst_sq_computer.py', False, [], []),
'pos_computer_5': ('#rednose/helpers/lst_sq_computer.py', False, [], []),
'feature_handler_5': ('#rednose/helpers/feature_handler.py', False, [], []),
- 'lane': ('#xx/pipeline/lib/ekf/lane_kf.py', True, [], rednose_deps),
})
Export('rednose_config')
@@ -406,10 +406,10 @@ if arch != "Darwin":
# build submodules
SConscript([
- 'cereal/SConscript',
'body/board/SConscript',
- 'panda/board/SConscript',
+ 'cereal/SConscript',
'opendbc/can/SConscript',
+ 'panda/SConscript',
])
SConscript(['third_party/SConscript'])
@@ -419,7 +419,6 @@ SConscript(['common/transformations/SConscript'])
SConscript(['selfdrive/modeld/SConscript'])
-SConscript(['selfdrive/controls/lib/cluster/SConscript'])
SConscript(['selfdrive/controls/lib/lateral_mpc_lib/SConscript'])
SConscript(['selfdrive/controls/lib/longitudinal_mpc_lib/SConscript'])
@@ -439,9 +438,6 @@ if arch in ['x86_64', 'Darwin'] or GetOption('extras'):
Export('opendbc')
SConscript(['tools/cabana/SConscript'])
-if GetOption('test'):
- SConscript('panda/tests/safety/SConscript')
-
external_sconscript = GetOption('external_sconscript')
if external_sconscript:
SConscript([external_sconscript])
diff --git a/body/board/boards.h b/body/board/boards.h
index 2af4b3eb0..777232540 100644
--- a/body/board/boards.h
+++ b/body/board/boards.h
@@ -40,6 +40,7 @@ void board_detect(void) {
board.led_portB = GPIOC;
board.can_addr_offset = 0x0U;
+ board.uds_offset = 0x0U;
} else if (hw_type == HW_TYPE_KNEE) {
board.hall_left.hall_portA = GPIOC;
@@ -77,6 +78,7 @@ void board_detect(void) {
board.led_portB = GPIOB;
board.can_addr_offset = KNEE_ADDR_OFFSET;
+ board.uds_offset = 0x10U;
#ifndef BOOTSTUB
MX_I2C_Init();
diff --git a/body/board/comms.h b/body/board/comms.h
index b7b3b2986..342163c88 100644
--- a/body/board/comms.h
+++ b/body/board/comms.h
@@ -6,10 +6,10 @@
#define BROADCAST_ADDR 0x7DFU
#define FALLBACK_ADDR 0x7E0U
#define FALLBACK_R_ADDR (FALLBACK_ADDR + OFFSET)
-#define ECU_ADDR 0x720U
-#define ECU_R_ADDR (ECU_ADDR + OFFSET)
-#define DEBUG_ADDR 0x721U
-#define DEBUG_R_ADDR (DEBUG_ADDR + OFFSET)
+#define ENGINE_ADDR 0x720U
+#define ENGINE_R_ADDR (ENGINE_ADDR + OFFSET)
+#define DEBUG_ADDR 0x721U
+#define DEBUG_R_ADDR (DEBUG_ADDR + OFFSET)
#include "drivers/llbxcan.h"
#include "uds.h"
@@ -24,6 +24,8 @@ extern board_t board;
extern uint32_t enter_bootloader_mode;
extern volatile uint32_t torque_cmd_timeout;
+extern volatile uint32_t ignition_off_counter;
+
const uint8_t crc_poly = 0xD5U; // standard crc8
uint32_t current_idx = 0;
@@ -84,8 +86,9 @@ void can_send_msg(uint32_t addr, uint32_t dhr, uint32_t dlr, uint8_t len) {
}
void process_can(void) {
+ __disable_irq();
CAN_FIFOMailBox_TypeDef to_send;
- if (board.CAN->TSR & CAN_TSR_TME0) {
+ if ((board.CAN->TSR & CAN_TSR_TME0) == CAN_TSR_TME0) {
if (can_pop(&can_tx_q, &to_send)) {
board.CAN->sTxMailBox[0].TDLR = to_send.RDLR;
board.CAN->sTxMailBox[0].TDHR = to_send.RDHR;
@@ -93,12 +96,13 @@ void process_can(void) {
board.CAN->sTxMailBox[0].TIR = to_send.RIR;
}
}
+ __enable_irq();
}
void can_rx(void) {
while ((board.CAN->RF0R & CAN_RF0R_FMP0) != 0) {
- int address = board.CAN->sFIFOMailBox[0].RIR >> 21;
- if (address == (int32_t)(0x250U + board.can_addr_offset)) {
+ uint32_t address = board.CAN->sFIFOMailBox[0].RIR >> 21;
+ if (address == (0x250U + board.can_addr_offset)) {
if ((GET_MAILBOX_BYTES_04(&board.CAN->sFIFOMailBox[0]) == 0xdeadface) && (GET_MAILBOX_BYTES_48(&board.CAN->sFIFOMailBox[0]) == 0x0ab00b1e)) {
enter_bootloader_mode = ENTER_SOFTLOADER_MAGIC;
NVIC_SystemReset();
@@ -121,7 +125,7 @@ void can_rx(void) {
current_idx = idx;
}
out_enable(LED_BLUE, true);
- } else if (address == (int32_t)(0x251U + board.can_addr_offset)) {
+ } else if (address == (0x251U + board.can_addr_offset)) {
#define MSG_SPD_LEN 5
uint8_t dat[MSG_TRQ_LEN];
for (int i=0; isFIFOMailBox[0]));
out_enable(LED_BLUE, true);
} else if ((hw_type == HW_TYPE_BASE) && (address == 0x203U + KNEE_ADDR_OFFSET)) { // detect knee by body and set flag for use with UDS message
knee_detected = 1;
+ } else if ((hw_type == HW_TYPE_KNEE) && (address == 0x202U)) { // CAN based ignition for knee
+ ignition_off_counter = 0;
}
// next
board.CAN->RF0R |= CAN_RF0R_RFOM0;
diff --git a/body/board/config.h b/body/board/config.h
index eb1e9231a..a6271ec74 100644
--- a/body/board/config.h
+++ b/body/board/config.h
@@ -5,23 +5,25 @@
#include "stm32f4xx_hal.h"
#define CORE_FREQ 96000000U // MCU frequency in hertz
-#define PWM_FREQ 16000 // PWM frequency in Hz / is also used for buzzer
-#define DEAD_TIME 48 // PWM deadtime
-#define DELAY_IN_MAIN_LOOP 5 // in ms. default 5. it is independent of all the timing critical stuff. do not touch if you do not know what you are doing.
-#define A2BIT_CONV 50 // A to bit for current conversion on ADC. Example: 1 A = 50, 2 A = 100, etc
+#define I2C_CLOCKSPEED 100 // I2C clock in kHz
+#define PWM_FREQ 16000 // PWM frequency in Hz / is also used for buzzer
+#define DEAD_TIME 48 // PWM deadtime
+#define DELAY_IN_MAIN_LOOP 5 // in ms. default 5. it is independent of all the timing critical stuff. do not touch if you do not know what you are doing.
+#define A2BIT_CONV 50 // A to bit for current conversion on ADC. Example: 1 A = 50, 2 A = 100, etc
+
+#define IGNITION_OFF_DELAY 5 // Stop sending CAN messages after 5 seconds
#define ADC_CONV_CLOCK_CYCLES (ADC_SAMPLETIME_15CYCLES)
#define ADC_CLOCK_DIV (4)
#define ADC_TOTAL_CONV_TIME (ADC_CLOCK_DIV * ADC_CONV_CLOCK_CYCLES) // = ((SystemCoreClock / ADC_CLOCK_HZ) * ADC_CONV_CLOCK_CYCLES), where ADC_CLOCK_HZ = SystemCoreClock/ADC_CLOCK_DIV
+#define KNEE_ADDR_OFFSET 0x100U
#define ANGLE_TO_DEGREES 0.021972656 // Convert 14 bit angle sensor output to degrees
#define GEARBOX_RATIO_LEFT 19
#define GEARBOX_RATIO_RIGHT 19
#define TRQ_LIMIT_LEFT 400 // Torque limit for knee gearbox(left)
#define TRQ_LIMIT_RIGHT 200 // Torque limit for hip gearbox(right)
-#define KNEE_ADDR_OFFSET 0x100
-
#define BAT_FILT_COEF 655 // battery voltage filter coefficient in fixed-point. coef_fixedPoint = coef_floatingPoint * 2^16. In this case 655 = 0.01 * 2^16
#define BAT_CALIB_REAL_VOLTAGE 3192 // input voltage measured by multimeter (multiplied by 100). In this case 43.00 V * 100 = 4300
#define BAT_CALIB_ADC 1275 // adc-value measured by mainboard (value nr 5 on UART debug output)
diff --git a/body/board/defines.h b/body/board/defines.h
index cf6745679..bc7459a51 100644
--- a/body/board/defines.h
+++ b/body/board/defines.h
@@ -166,7 +166,8 @@ typedef struct {
GPIO_TypeDef* ignition_port;
uint16_t ignition_pin;
- uint32_t can_addr_offset;
+ uint16_t can_addr_offset;
+ uint8_t uds_offset;
GPIO_TypeDef* led_portR;
uint16_t led_pinR;
@@ -177,4 +178,11 @@ typedef struct {
} board_t;
+typedef struct {
+ uint8_t left_i2c : 1;
+ uint8_t left_angle : 1;
+ uint8_t right_i2c : 1;
+ uint8_t right_angle : 1;
+} fault_status_t;
+
#endif // DEFINES_H
diff --git a/body/board/drivers/angle_sensor.h b/body/board/drivers/angle_sensor.h
index 4bf11ca1d..72f0a857e 100644
--- a/body/board/drivers/angle_sensor.h
+++ b/body/board/drivers/angle_sensor.h
@@ -19,14 +19,29 @@ extern I2C_HandleTypeDef hi2c1;
const uint8_t init_imu_regaddr[] = {0x76, 0x4c, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53};
const uint8_t init_imu_data[] = {0x00, 0x12, 0x2f, 0x26, 0x67, 0x04, 0x00, 0x00};
+fault_status_t fault_status = {0};
void angle_sensor_read(uint16_t *sensor_angle) {
+
+ if (fault_status.left_i2c && fault_status.right_i2c) { // Try to reinitialize halted I2C
+ if (HAL_I2C_Init(&hi2c1) == HAL_OK) {
+ fault_status.left_i2c = 0;
+ fault_status.right_i2c = 0;
+ }
+ }
+
uint8_t buf[2];
if (HAL_I2C_Mem_Read(&hi2c1, (AS5048_ADDRESS_LEFT<<1), AS5048B_ANGLMSB_REG, I2C_MEMADD_SIZE_8BIT, buf, 2, 10) == HAL_OK) {
sensor_angle[0] = (buf[0] << 6) | (buf[1] & 0x3F);
+ fault_status.left_i2c = 0;
+ } else {
+ fault_status.left_i2c = 1;
}
if (HAL_I2C_Mem_Read(&hi2c1, (AS5048_ADDRESS_RIGHT<<1), AS5048B_ANGLMSB_REG, I2C_MEMADD_SIZE_8BIT, buf, 2, 10) == HAL_OK) {
sensor_angle[1] = (buf[0] << 6) | (buf[1] & 0x3F);
+ fault_status.right_i2c = 0;
+ } else {
+ fault_status.right_i2c = 1;
}
}
diff --git a/body/board/drivers/i2c_soft.h b/body/board/drivers/i2c_soft.h
index 1ca60fc05..aa6280bd9 100644
--- a/body/board/drivers/i2c_soft.h
+++ b/body/board/drivers/i2c_soft.h
@@ -1,4 +1,4 @@
-#define SW_I2C_WAIT_TIME 22
+#define SW_I2C_WAIT_TIME 22
#define I2C_READ 0x01
#define READ_CMD 1
@@ -7,14 +7,14 @@
void SW_I2C_init(void)
{
- GPIO_InitTypeDef GPIO_InitStructure;
+ GPIO_InitTypeDef GPIO_InitStructure = { 0 };
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
-
+
GPIO_InitStructure.Pin = SW_I2C1_SCL_PIN;
HAL_GPIO_Init(SW_I2C1_SCL_GPIO, &GPIO_InitStructure);
- GPIO_InitStructure.Pin = SW_I2C1_SDA_PIN;
+ GPIO_InitStructure.Pin = SW_I2C1_SDA_PIN;
HAL_GPIO_Init(SW_I2C1_SDA_GPIO, &GPIO_InitStructure);
}
@@ -24,7 +24,7 @@ uint8_t SW_I2C_ReadVal_SDA(void)
ret = (uint16_t)HAL_GPIO_ReadPin(SW_I2C1_SDA_GPIO, SW_I2C1_SDA_PIN);
return ret;
}
-
+
void sda_high(void)
{
HAL_GPIO_WritePin(SW_I2C1_SDA_GPIO, SW_I2C1_SDA_PIN, GPIO_PIN_SET);
@@ -59,23 +59,23 @@ void sda_out(uint8_t out)
void sda_in_mode(void)
{
- GPIO_InitTypeDef GPIO_InitStructure;
+ GPIO_InitTypeDef GPIO_InitStructure = { 0 };
- GPIO_InitStructure.Speed=GPIO_SPEED_FREQ_HIGH;
- GPIO_InitStructure.Mode=GPIO_MODE_INPUT;
-
- GPIO_InitStructure.Pin = SW_I2C1_SDA_PIN;
+ GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
+
+ GPIO_InitStructure.Pin = SW_I2C1_SDA_PIN;
HAL_GPIO_Init(SW_I2C1_SDA_GPIO, &GPIO_InitStructure);
}
void sda_out_mode(void)
{
- GPIO_InitTypeDef GPIO_InitStructure;
+ GPIO_InitTypeDef GPIO_InitStructure = { 0 };
- GPIO_InitStructure.Speed=GPIO_SPEED_FREQ_HIGH;
- GPIO_InitStructure.Mode=GPIO_MODE_OUTPUT_OD;
-
- GPIO_InitStructure.Pin = SW_I2C1_SDA_PIN;
+ GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_OD;
+
+ GPIO_InitStructure.Pin = SW_I2C1_SDA_PIN;
HAL_GPIO_Init(SW_I2C1_SDA_GPIO, &GPIO_InitStructure);
}
@@ -129,15 +129,15 @@ uint8_t i2c_check_ack(void)
delay(SW_I2C_WAIT_TIME);
for (i = 10; i > 0; i--) {
- temp = !(SW_I2C_ReadVal_SDA());
- if (temp)
+ temp = !(SW_I2C_ReadVal_SDA());
+ if (temp)
{
ack = 1;
break;
}
}
scl_low();
- sda_out_mode();
+ sda_out_mode();
delay(SW_I2C_WAIT_TIME);
return ack;
diff --git a/body/board/drivers/llbxcan.h b/body/board/drivers/llbxcan.h
index 6bdfe968b..15ebb27ed 100644
--- a/body/board/drivers/llbxcan.h
+++ b/body/board/drivers/llbxcan.h
@@ -1,13 +1,11 @@
-// maximum 500kbps! (or needs clock change)
+// SAE 2284-3 : minimum 16 tq, SJW 3, sample point at 81.3%
#define CAN_QUANTA 16U
-#define CAN_SEQ1 13U // roundf(quanta * 0.875f) - 1;
-#define CAN_SEQ2 2U // roundf(quanta * 0.125f);
+#define CAN_SEQ1 12U
+#define CAN_SEQ2 3U
+#define CAN_SJW 3U
#define CAN_PCLK (CORE_FREQ / 2U / 1000U)
-// 333 = 33.3 kbps
-// 5000 = 500 kbps
#define can_speed_to_prescaler(x) (CAN_PCLK / CAN_QUANTA * 10U / (x))
-
#define CAN_INIT_TIMEOUT_MS 500
bool llcan_set_speed(CAN_TypeDef *CAN_obj, uint32_t speed, bool loopback, bool silent) {
@@ -30,7 +28,10 @@ bool llcan_set_speed(CAN_TypeDef *CAN_obj, uint32_t speed, bool loopback, bool s
if(ret){
// set time quanta from defines
- CAN_obj->BTR = ((CAN_BTR_TS1_0 * (CAN_SEQ1-1)) | (CAN_BTR_TS2_0 * (CAN_SEQ2-1)) | (can_speed_to_prescaler(speed) - 1U));
+ CAN_obj->BTR = ((CAN_BTR_TS1_0 * (CAN_SEQ1-1)) |
+ (CAN_BTR_TS2_0 * (CAN_SEQ2-1)) |
+ (CAN_BTR_SJW_0 * (CAN_SJW-1)) |
+ (can_speed_to_prescaler(speed) - 1U));
// silent loopback mode for debugging
if (loopback) {
diff --git a/body/board/main.c b/body/board/main.c
index d493c4a1a..74837b17e 100644
--- a/body/board/main.c
+++ b/body/board/main.c
@@ -58,6 +58,9 @@ extern board_t board;
extern volatile uint32_t buzzerTimer;
volatile uint32_t torque_cmd_timeout = 0U;
volatile uint32_t ignition_off_counter = 0U;
+
+uint16_t cnt_press = 0;
+
int16_t batVoltageCalib; // global variable for calibrated battery voltage
int16_t board_temp_deg_c; // global variable for calibrated temperature in degrees Celsius
volatile int16_t cmdL; // global variable for Left Command
@@ -66,9 +69,7 @@ volatile int16_t cmdR; // global variable for Right Command
uint8_t hw_type; // type of the board detected(0 - base, 3 - knee)
uint8_t ignition = 0; // global variable for ignition on SBU2 line
uint8_t charger_connected = 0; // status of the charger port
-uint8_t fault_status = 0; // fault status of the whole system
uint8_t pkt_idx = 0; // For CAN msg counter
-
//------------------------------------------------------------------------
// Local variables
//------------------------------------------------------------------------
@@ -120,6 +121,7 @@ int main(void) {
} else {
out_enable(POWERSWITCH, false);
ignition = 1;
+ knee_detected = 1;
}
// Reset LEDs on startup
out_enable(LED_RED, false);
@@ -175,8 +177,10 @@ int main(void) {
if (hw_type == HW_TYPE_KNEE) {
// Safety to stop operation if angle sensor reading failed TODO: adjust sensivity and add lowpass to angle sensor?
- if ((ABS((hall_angle_offset[0] + ((motPosL / 15 / GEARBOX_RATIO_LEFT) % 360)) - (sensor_angle[0] * ANGLE_TO_DEGREES)) > 5) ||
- (ABS((hall_angle_offset[1] + ((motPosR / 15 / GEARBOX_RATIO_RIGHT) % 360)) - (sensor_angle[1] * ANGLE_TO_DEGREES)) > 5)) {
+ fault_status.left_angle = (ABS((hall_angle_offset[0] + ((motPosL / 15 / GEARBOX_RATIO_LEFT) % 360)) - (sensor_angle[0] * ANGLE_TO_DEGREES)) > 5);
+ fault_status.right_angle = (ABS((hall_angle_offset[1] + ((motPosR / 15 / GEARBOX_RATIO_RIGHT) % 360)) - (sensor_angle[1] * ANGLE_TO_DEGREES)) > 5);
+
+ if (fault_status.left_angle || fault_status.right_angle) {
cmdL = cmdR = 0;
}
// Safety to stop movement when reaching dead angles, around 20 and 340 degrees
@@ -211,7 +215,7 @@ int main(void) {
}
}
- if (ignition_off_counter <= 10) {
+ if (ignition_off_counter <= IGNITION_OFF_DELAY) {
// MOTORS_DATA: speed_L(2), speed_R(2), counter(1), checksum(1)
uint8_t dat[8];
uint16_t speedL = rtY_Left.n_mot;
@@ -287,19 +291,15 @@ int main(void) {
// runs at 10Hz
if ((HAL_GetTick() - (main_loop_10Hz - main_loop_10Hz_runtime)) >= 100) {
main_loop_10Hz_runtime = HAL_GetTick();
- if (ignition_off_counter <= 10) {
- // VAR_VALUES: fault_status(0:6), enable_motors(0:1), ignition(0:1), left motor error(1), right motor error(1), global fault status(1)
+ if (ignition_off_counter <= IGNITION_OFF_DELAY) {
+ // VAR_VALUES: fault_status(0:4), enable_motors(0:1), ignition(0:1), left motor error(1), right motor error(1)
uint8_t dat[2];
- dat[0] = (((fault_status & 0x3F) << 2U) | (enable_motors << 1U) | ignition);
+ dat[0] = ((fault_status.right_angle << 5U) | (fault_status.right_i2c << 4U) | (fault_status.left_angle << 3U) | (fault_status.left_i2c << 2U) | (enable_motors << 1U) | ignition);
dat[1] = rtY_Left.z_errCode;
dat[2] = rtY_Right.z_errCode;
can_send_msg((0x202U + board.can_addr_offset), 0x0U, ((dat[2] << 16U) | (dat[1] << 8U) | dat[0]), 3U);
}
out_enable(LED_GREEN, ignition);
-
- if (hw_type == HW_TYPE_BASE) {
- poweroffPressCheck();
- }
main_loop_10Hz_runtime = HAL_GetTick() - main_loop_10Hz_runtime;
main_loop_10Hz = HAL_GetTick();
@@ -330,7 +330,7 @@ int main(void) {
out_enable(LED_BLUE, false); // Reset LED after CAN RX
out_enable(LED_GREEN, true); // Always use LED to show that body is on
- if (ignition) {
+ if ((hw_type == HW_TYPE_BASE) && ignition) {
ignition_off_counter = 0;
} else {
ignition_off_counter = (ignition_off_counter < MAX_uint32_T) ? (ignition_off_counter+1) : 0;
@@ -341,6 +341,8 @@ int main(void) {
} else if (rtY_Left.z_errCode || rtY_Right.z_errCode) { // 1 beep (low pitch): Motor error, disable motors
enable_motors = 0;
beepCount(1, 24, 1);
+ } else if (fault_status.left_angle || fault_status.left_i2c || fault_status.right_angle || fault_status.right_i2c) { // 2 beeps (low pitch): Motor error, disable motors
+ beepCount(2, 24, 1);
} else if (TEMP_WARNING_ENABLE && board_temp_deg_c >= TEMP_WARNING) { // 5 beeps (low pitch): Mainboard temperature warning
beepCount(5, 24, 1);
} else if (batVoltage < BAT_LVL1) { // 1 beep fast (medium pitch): Low bat 1
@@ -357,6 +359,20 @@ int main(void) {
main_loop_1Hz = HAL_GetTick();
}
+ if (hw_type == HW_TYPE_BASE) {
+ if (HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) {
+ cnt_press += 1;
+ if (cnt_press == (2 * 1008)) {
+ poweroff();
+ }
+ } else if (cnt_press >= 10) {
+ ignition = !ignition;
+ out_enable(IGNITION, ignition);
+ beepShort(5);
+ cnt_press = 0;
+ }
+ }
+
process_can();
tick_prev = HAL_GetTick();
}
diff --git a/body/board/setup.h b/body/board/setup.h
index 83e548f8e..898b2f393 100644
--- a/body/board/setup.h
+++ b/body/board/setup.h
@@ -8,7 +8,6 @@ TIM_HandleTypeDef htim_right;
TIM_HandleTypeDef htim_left;
ADC_HandleTypeDef hadc;
I2C_HandleTypeDef hi2c1;
-// SPI_HandleTypeDef hspi3;
volatile adc_buf_t adc_buffer;
extern board_t board;
@@ -26,7 +25,7 @@ void MX_GPIO_Clocks_Init(void) {
}
void MX_GPIO_Common_Init(void) {
- GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitTypeDef GPIO_InitStruct = { 0 };
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
@@ -167,7 +166,7 @@ void MX_GPIO_Common_Init(void) {
void MX_I2C_Init(void) {
- GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitTypeDef GPIO_InitStruct = { 0 };
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
@@ -179,7 +178,7 @@ void MX_I2C_Init(void) {
__HAL_RCC_I2C1_CLK_ENABLE();
hi2c1.Instance = I2C1;
- hi2c1.Init.ClockSpeed = 400000;
+ hi2c1.Init.ClockSpeed = (I2C_CLOCKSPEED * 1000);
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
diff --git a/body/board/uds.h b/body/board/uds.h
index 5c3fa855c..f9e151be7 100644
--- a/body/board/uds.h
+++ b/body/board/uds.h
@@ -1,118 +1,125 @@
+extern uint8_t hw_type;
void can_send_msg(uint32_t addr, uint32_t dhr, uint32_t dlr, uint8_t len);
uint8_t uid[10];
-uint32_t uds_request = 0;
+uint32_t uds_engine_request = 0;
+uint32_t uds_debug_request = 0;
uint8_t knee_detected = 0;
+uint8_t sep_time = 0;
void process_uds(uint32_t addr, uint32_t dlr) {
memcpy(uid, (void *)0x1FFF7A10U, 0xAU);
- if ((addr == BROADCAST_ADDR) || (addr == FALLBACK_ADDR)) { // OBD2 broadcast request, redirect to UDS?
+ if ((hw_type == HW_TYPE_BASE) &&
+ ((addr == BROADCAST_ADDR) ||
+ (addr == FALLBACK_ADDR))) { // OBD2 broadcast request, redirect to UDS?
switch(dlr) {
// VIN 09 OBD2
case 0x020902U:
can_send_msg(FALLBACK_R_ADDR, 0x4D4F4301U, 0x02491410U, 8U);
- uds_request = 0xF190U;
+ uds_engine_request = 0xF190U;
break;
// VIN : F190 on broadcast
case 0x90F12203U:
can_send_msg(FALLBACK_R_ADDR, 0x4D4F4390U, 0xF1621410U, 8U);
break;
// VIN continue
- case 0x30U:
- can_send_msg(FALLBACK_R_ADDR, 0x5659444FU, 0x42414D21U, 8U);
- can_send_msg(FALLBACK_R_ADDR, 0x314E4F49U, 0x53524522U, 8U);
+ default:
+ if ((dlr & 0xFF) == 0x30U) {
+ sep_time = (dlr >> 16U) & 0xFF;
+ delay(sep_time);
+ can_send_msg(FALLBACK_R_ADDR, 0x5659444FU, 0x42414D21U, 8U);
+ can_send_msg(FALLBACK_R_ADDR, 0x314E4F49U, 0x53524522U, 8U);
+ }
break;
}
- } else if (addr == ECU_ADDR) { // UDS request to "main" ECU
+ } else if (addr == (ENGINE_ADDR + board.uds_offset)) { // UDS request to "main" ECU
switch(dlr) {
// TESTER PRESENT
case 0x3E02U:
- can_send_msg(ECU_R_ADDR, 0x0U, 0x7E02U, 8U);
+ can_send_msg(ENGINE_R_ADDR + board.uds_offset, 0x0U, 0x7E02U, 8U);
break;
// DIAGNOSTIC SESSION CONTROL: DEFAULT
case 0x011002U:
- can_send_msg(ECU_R_ADDR, 0x0U, 0x015002U, 8U);
+ can_send_msg(ENGINE_R_ADDR + board.uds_offset, 0x0U, 0x015002U, 8U);
break;
// DIAGNOSTIC SESSION CONTROL: EXTENDED
case 0x031002U:
- can_send_msg(ECU_R_ADDR, 0x0U, 0x035002U, 8U);
+ can_send_msg(ENGINE_R_ADDR + board.uds_offset, 0x0U, 0x035002U, 8U);
break;
// APPLICATION SOFTWARE IDENTIFICATION : F181 (used for fingerprinting, firmware version)
case 0x81F12203U:
COMPILE_TIME_ASSERT(sizeof(version) == 6U);
- can_send_msg(ECU_R_ADDR, ((version[2] << 24U) | (version[1] << 16U) | (version[0] << 8U) | 0x81U), 0xF1620910U, 8U);
- uds_request = 0xF181U;
+ can_send_msg(ENGINE_R_ADDR + board.uds_offset, ((version[2] << 24U) | (version[1] << 16U) | (version[0] << 8U) | 0x81U), 0xF1620A10U, 8U);
+ uds_engine_request = 0xF181U;
break;
// ECU SERIAL NUMBER : F18C
case 0x8CF12203U:
- can_send_msg(ECU_R_ADDR, ((uid[2] << 24U) | (uid[1] << 16U) | (uid[0] << 8U) | 0x8CU), 0xF1620D10U, 8U);
- uds_request = 0xF18CU;
+ can_send_msg(ENGINE_R_ADDR + board.uds_offset, ((uid[2] << 24U) | (uid[1] << 16U) | (uid[0] << 8U) | 0x8CU), 0xF1620D10U, 8U);
+ uds_engine_request = 0xF18CU;
break;
// VIN : F190
case 0x90F12203U:
- can_send_msg(ECU_R_ADDR, 0x4D4F4390U, 0xF1621410U, 8U);
- uds_request = 0xF190U;
- break;
- // SYSTEM NAME OR ENGINE TYPE : F197
- case 0x97F12203U:
- can_send_msg(ECU_R_ADDR, 0x454C4597U, 0xF1620C10U, 8U);
- uds_request = 0xF197U;
+ can_send_msg(ENGINE_R_ADDR + board.uds_offset, 0x4D4F4390U, 0xF1621410U, 8U);
+ uds_engine_request = 0xF190U;
break;
// FLOW CONTROL MESSAGE
- case 0x30U:
- switch(uds_request) {
- // APPLICATION SOFTWARE IDENTIFICATION : F181
- case 0xF181U:
- can_send_msg(ECU_R_ADDR, 0x0U, ((version[5] << 24U) | (version[4] << 16U) | (version[3] << 8U) | 0x21U), 8U);
- uds_request = 0;
- break;
- // ECU SERIAL NUMBER : F18C
- case 0xF18CU:
- can_send_msg(ECU_R_ADDR, ((uid[9] << 24U) | (uid[8] << 16U) | (uid[7]<< 8U) | uid[6]), ((uid[5] << 24U) | (uid[4] << 16U) | (uid[3] << 8U) | 0x21U), 8U);
- uds_request = 0;
- break;
- // VIN : F190
- case 0xF190U:
- can_send_msg(ECU_R_ADDR, 0x5659444FU, 0x42414D21U, 8U);
- can_send_msg(ECU_R_ADDR, 0x314E4F49U, 0x53524522U, 8U);
- uds_request = 0;
- break;
- // SYSTEM NAME OR ENGINE TYPE : F197
- case 0xF197U:
- can_send_msg(ECU_R_ADDR, (((knee_detected + 0x30) << 16U) | 0x4349U), 0x52544321U, 8U);
- uds_request = 0;
- break;
+ default:
+ if ((dlr & 0xFF) == 0x30U) {
+ sep_time = (dlr >> 16U) & 0xFF;
+ delay(sep_time);
+ switch(uds_engine_request) {
+ // APPLICATION SOFTWARE IDENTIFICATION : F181
+ case 0xF181U:
+ can_send_msg(ENGINE_R_ADDR + board.uds_offset, (knee_detected + 0x61), ((version[5] << 24U) | (version[4] << 16U) | (version[3] << 8U) | 0x21U), 8U);
+ uds_engine_request = 0;
+ break;
+ // ECU SERIAL NUMBER : F18C
+ case 0xF18CU:
+ can_send_msg(ENGINE_R_ADDR + board.uds_offset, ((uid[9] << 24U) | (uid[8] << 16U) | (uid[7]<< 8U) | uid[6]), ((uid[5] << 24U) | (uid[4] << 16U) | (uid[3] << 8U) | 0x21U), 8U);
+ uds_engine_request = 0;
+ break;
+ // VIN : F190
+ case 0xF190U:
+ can_send_msg(ENGINE_R_ADDR + board.uds_offset, 0x5659444FU, 0x42414D21U, 8U);
+ can_send_msg(ENGINE_R_ADDR + board.uds_offset, 0x314E4F49U, 0x53524522U, 8U);
+ uds_engine_request = 0;
+ break;
+ }
}
break;
}
- } else if (addr == DEBUG_ADDR) { // UDS request to "DEBUG" ECU
+ } else if (addr == (DEBUG_ADDR + board.uds_offset)) { // UDS request to "DEBUG" ECU
switch(dlr) {
// TESTER PRESENT
case 0x3E02U:
- can_send_msg(DEBUG_R_ADDR, 0x0U, 0x7E02U, 8U);
+ can_send_msg(DEBUG_R_ADDR + board.uds_offset, 0x0U, 0x7E02U, 8U);
break;
// DIAGNOSTIC SESSION CONTROL: DEFAULT
case 0x011002U:
- can_send_msg(DEBUG_R_ADDR, 0x0U, 0x015002U, 8U);
+ can_send_msg(DEBUG_R_ADDR + board.uds_offset, 0x0U, 0x015002U, 8U);
break;
// DIAGNOSTIC SESSION CONTROL: EXTENDED
case 0x031002U:
- can_send_msg(DEBUG_R_ADDR, 0x0U, 0x035002U, 8U);
+ can_send_msg(DEBUG_R_ADDR + board.uds_offset, 0x0U, 0x035002U, 8U);
break;
// APPLICATION SOFTWARE IDENTIFICATION : F181 (used for git hash logging)
case 0x81F12203U:
COMPILE_TIME_ASSERT(sizeof(gitversion) == 8U);
- can_send_msg(DEBUG_R_ADDR, ((gitversion[2] << 24U) | (gitversion[1] << 16U) | (gitversion[0] << 8U) | 0x81U), 0xF1620B10U, 8U);
- uds_request = 0xF181U;
+ can_send_msg((DEBUG_R_ADDR + board.uds_offset), ((gitversion[2] << 24U) | (gitversion[1] << 16U) | (gitversion[0] << 8U) | 0x81U), 0xF1620B10U, 8U);
+ uds_debug_request = 0xF181U;
break;
- case 0x30U:
- switch(uds_request) {
- // APPLICATION SOFTWARE IDENTIFICATION : F181
- case 0xF181U:
- can_send_msg(DEBUG_R_ADDR, ((gitversion[7]<< 8U) | gitversion[6]), ((gitversion[5] << 24U) | (gitversion[4] << 16U) | (gitversion[3] << 8U) | 0x21U), 8U);
- uds_request = 0;
- break;
+ default:
+ if ((dlr & 0xFF) == 0x30U) {
+ sep_time = (dlr >> 16U) & 0xFF;
+ delay(sep_time);
+ switch(uds_debug_request) {
+ // APPLICATION SOFTWARE IDENTIFICATION : F181
+ case 0xF181U:
+ can_send_msg((DEBUG_R_ADDR + board.uds_offset), ((gitversion[7]<< 8U) | gitversion[6]), ((gitversion[5] << 24U) | (gitversion[4] << 16U) | (gitversion[3] << 8U) | 0x21U), 8U);
+ uds_debug_request = 0;
+ break;
+ }
}
break;
}
diff --git a/body/board/util.c b/body/board/util.c
index 5b3f0f5f0..c0b19ff19 100644
--- a/body/board/util.c
+++ b/body/board/util.c
@@ -175,22 +175,6 @@ void poweroff(void) {
}
}
-void poweroffPressCheck(void) {
- if(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) {
- uint16_t cnt_press = 0;
- while(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) {
- HAL_Delay(10);
- cnt_press++;
- if (cnt_press == (2 * 100)) { poweroff(); }
- }
- if (cnt_press > 8) {
- ignition = !ignition;
- out_enable(IGNITION, ignition);
- beepShort(5);
- }
- }
-}
-
#define PULL_EFFECTIVE_DELAY 4096
uint8_t detect_with_pull(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, uint32_t mode) {
GPIO_InitTypeDef GPIO_InitStruct;
diff --git a/body/board/util.h b/body/board/util.h
index d2bffff02..0eea10bd0 100644
--- a/body/board/util.h
+++ b/body/board/util.h
@@ -19,7 +19,6 @@ void calcAvgSpeed(void);
// Poweroff Functions
void poweroff(void);
-void poweroffPressCheck(void);
// GPIO functions
uint8_t detect_with_pull(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, uint32_t mode);
diff --git a/body/board/version.h b/body/board/version.h
index 65b6f8869..2cc94a180 100644
--- a/body/board/version.h
+++ b/body/board/version.h
@@ -1 +1 @@
-const uint8_t version[6] = "0.0.02";
+const uint8_t version[6] = "0.3.00";
diff --git a/cereal/.gitignore b/cereal/.gitignore
index 14cd02eff..d6ec0036c 100644
--- a/cereal/.gitignore
+++ b/cereal/.gitignore
@@ -1,6 +1,4 @@
-gen
-node_modules
-package-lock.json
+/gen/
*.tmp
*.pyc
__pycache__
@@ -18,4 +16,3 @@ services.h
.sconsign.dblite
libcereal_shared.*
.mypy_cache/
-catch2/
diff --git a/cereal/car.capnp b/cereal/car.capnp
index 1b68892d1..1af634788 100644
--- a/cereal/car.capnp
+++ b/cereal/car.capnp
@@ -34,7 +34,7 @@ struct CarEvent @0x9b1657f34caf3ad3 {
buttonCancel @11;
buttonEnable @12;
pedalPressed @13; # exits active state
- pedalPressedPreEnable @73; # added during pre-enable state for either pedal
+ preEnableStandstill @73; # added during pre-enable state with brake
gasPressedOverride @108; # added when user is pressing gas with no disengage on gas
steerOverride @114;
cruiseDisabled @14;
@@ -46,7 +46,6 @@ struct CarEvent @0x9b1657f34caf3ad3 {
controlsMismatch @22;
pcmEnable @23;
pcmDisable @24;
- noTarget @25;
radarFault @26;
brakeHold @28;
parkBrake @29;
@@ -138,6 +137,7 @@ struct CarEvent @0x9b1657f34caf3ad3 {
modelLagWarningDEPRECATED @93;
startupOneplusDEPRECATED @82;
startupFuzzyFingerprintDEPRECATED @97;
+ noTargetDEPRECATED @25;
}
}
@@ -205,9 +205,6 @@ struct CarState {
# clutch (manual transmission only)
clutchPressed @28 :Bool;
- # which packets this state came from
- canMonoTimes @12: List(UInt64);
-
# blindspot sensors
leftBlindspot @33 :Bool; # Is there something blocking the left lane change
rightBlindspot @34 :Bool; # Is there something blocking the right lane change
@@ -267,9 +264,11 @@ struct CarState {
}
}
+ # deprecated
errorsDEPRECATED @0 :List(CarEvent.EventName);
brakeLightsDEPRECATED @19 :Bool;
steeringRateLimitedDEPRECATED @29 :Bool;
+ canMonoTimesDEPRECATED @12: List(UInt64);
}
# ******* radar state @ 20hz *******
@@ -278,9 +277,6 @@ struct RadarData @0x888ad6581cf0aacb {
errors @0 :List(Error);
points @1 :List(RadarPoint);
- # which packets this state came from
- canMonoTimes @2 :List(UInt64);
-
enum Error {
canError @0;
fault @1;
@@ -304,6 +300,9 @@ struct RadarData @0x888ad6581cf0aacb {
# some radars flag measurements VS estimates
measured @6 :Bool;
}
+
+ # deprecated
+ canMonoTimesDEPRECATED @2 :List(UInt64);
}
# ******* car controls @ 100hz *******
@@ -317,6 +316,9 @@ struct CarControl {
# Actuator commands as computed by controlsd
actuators @6 :Actuators;
+ leftBlinker @15: Bool;
+ rightBlinker @16: Bool;
+
# Any car specific rate limits or quirks applied by
# the CarController are reflected in actuatorsOutput
# and matches what is sent to the car
@@ -334,8 +336,12 @@ struct CarControl {
brake @1: Float32;
# range from -1.0 - 1.0
steer @2: Float32;
+ # value sent over can to the car
+ steerOutputCan @8: Float32;
steeringAngleDeg @3: Float32;
+ curvature @7: Float32;
+
speed @6: Float32; # m/s
accel @4: Float32; # m/s^2
longControlState @5: LongControlState;
@@ -346,7 +352,6 @@ struct CarControl {
stopping @2;
starting @3;
}
-
}
struct CruiseControl {
@@ -459,7 +464,7 @@ struct CarParams {
vEgoStarting @59 :Float32; # Speed at which the car goes into starting state
stoppingControl @31 :Bool; # Does the car allow full control even at lows speeds when stopping
steerControlType @34 :SteerControlType;
- radarOffCan @35 :Bool; # True when radar objects aren't visible on CAN
+ radarUnavailable @35 :Bool; # True when radar objects aren't visible on CAN or aren't parsed out
stopAccel @60 :Float32; # Required acceleration to keep vehicle stationary
stoppingDecelRate @52 :Float32; # m/s^2/s while trying to stop
startAccel @32 :Float32; # Required acceleration to get car moving
@@ -577,7 +582,7 @@ struct CarParams {
subaruLegacy @22; # pre-Global platform
hyundaiLegacy @23;
hyundaiCommunity @24;
- stellantisDEPRECATED @25; # Consolidated with Chrysler; may be recycled for the next new model
+ volkswagenMlb @25;
hongqi @26;
body @27;
hyundaiCanfd @28;
@@ -586,6 +591,7 @@ struct CarParams {
enum SteerControlType {
torque @0;
angle @1;
+ curvature @2;
}
enum TransmissionType {
@@ -605,6 +611,7 @@ struct CarParams {
request @5 :List(Data);
brand @6 :Text;
bus @7 :UInt8;
+ logging @8 :Bool;
}
enum Ecu {
diff --git a/cereal/log.capnp b/cereal/log.capnp
index 72dcef700..4e657138c 100644
--- a/cereal/log.capnp
+++ b/cereal/log.capnp
@@ -165,7 +165,7 @@ struct FrameData {
sensor @26 :ImageSensor;
enum ImageSensor {
unknown @0;
- ar0321 @1;
+ ar0231 @1;
ox03c10 @2;
}
@@ -543,7 +543,6 @@ struct PeripheralState {
}
struct RadarState @0x9a185389d6fdd05f {
- canMonoTimes @10 :List(UInt64);
mdMonoTime @6 :UInt64;
carStateMonoTime @11 :UInt64;
radarErrors @12 :List(Car.RadarData.Error);
@@ -578,6 +577,7 @@ struct RadarState @0x9a185389d6fdd05f {
calStatusDEPRECATED @2 :Int8;
calCycleDEPRECATED @8 :Int32;
calPercDEPRECATED @9 :Int8;
+ canMonoTimesDEPRECATED @10 :List(UInt64);
}
struct LiveCalibrationData {
@@ -614,7 +614,6 @@ struct LiveTracks {
struct ControlsState @0x97ff69c53601abf1 {
startMonoTime @48 :UInt64;
- canMonoTimes @21 :List(UInt64);
longitudinalPlanMonoTime @28 :UInt64;
lateralPlanMonoTime @50 :UInt64;
@@ -654,10 +653,12 @@ struct ControlsState @0x97ff69c53601abf1 {
lateralControlState :union {
indiState @52 :LateralINDIState;
pidState @53 :LateralPIDState;
- lqrState @55 :LateralLQRState;
angleState @58 :LateralAngleState;
debugState @59 :LateralDebugState;
torqueState @60 :LateralTorqueState;
+ curvatureState @65 :LateralCurvatureState;
+
+ lqrStateDEPRECATED @55 :LateralLQRState;
}
enum OpenpilotState @0xdbe58b96d2d1ac61 {
@@ -742,6 +743,18 @@ struct ControlsState @0x97ff69c53601abf1 {
steeringAngleDesiredDeg @4 :Float32;
}
+ struct LateralCurvatureState {
+ active @0 :Bool;
+ actualCurvature @1 :Float32;
+ desiredCurvature @2 :Float32;
+ error @3 :Float32;
+ p @4 :Float32;
+ i @5 :Float32;
+ f @6 :Float32;
+ output @7 :Float32;
+ saturated @8 :Bool;
+ }
+
struct LateralDebugState {
active @0 :Bool;
steeringAngleDeg @1 :Float32;
@@ -778,6 +791,7 @@ struct ControlsState @0x97ff69c53601abf1 {
jerkFactorDEPRECATED @12 :Float32;
steerOverrideDEPRECATED @20 :Bool;
steeringAngleDesiredDegDEPRECATED @29 :Float32;
+ canMonoTimesDEPRECATED @21 :List(UInt64);
}
struct ModelDataV2 {
@@ -1153,16 +1167,16 @@ struct ProcLog {
}
struct GnssMeasurements {
- ubloxMonoTime @0 :UInt64;
+ measTime @0 :UInt64;
gpsWeek @1 :Int16;
gpsTimeOfWeek @2 :Float64;
correctedMeasurements @3 :List(CorrectedMeasurement);
- positionECEF @4 :LiveLocationKalman.Measurement;
- velocityECEF @5 :LiveLocationKalman.Measurement;
- # Used for debugging:
- positionFixECEF @6 :LiveLocationKalman.Measurement;
+ kalmanPositionECEF @4 :LiveLocationKalman.Measurement;
+ kalmanVelocityECEF @5 :LiveLocationKalman.Measurement;
+ positionECEF @6 :LiveLocationKalman.Measurement;
+ velocityECEF @7 :LiveLocationKalman.Measurement;
# Todo sync this with timing pulse of ublox
struct CorrectedMeasurement {
@@ -1188,14 +1202,14 @@ struct GnssMeasurements {
}
enum ConstellationId {
- # Satellite Constellation using the Ublox gnssid as index
- gps @0;
- sbas @1;
- galileo @2;
- beidou @3;
- imes @4;
- qznss @5;
- glonass @6;
+ # Satellite Constellation using the Ublox gnssid as index
+ gps @0;
+ sbas @1;
+ galileo @2;
+ beidou @3;
+ imes @4;
+ qznss @5;
+ glonass @6;
}
enum EphemerisSourceType {
@@ -1214,6 +1228,7 @@ struct UbloxGnss {
ionoData @2 :IonoData;
hwStatus @3 :HwStatus;
hwStatus2 @4 :HwStatus2;
+ glonassEphemeris @5 :GlonassEphemeris;
}
struct MeasurementReport {
@@ -1324,6 +1339,7 @@ struct UbloxGnss {
ionoAlpha @38 :List(Float64);
ionoBeta @39 :List(Float64);
+ towCount @40 :UInt32;
}
struct IonoData {
@@ -1378,6 +1394,44 @@ struct UbloxGnss {
flash @4;
}
}
+
+ struct GlonassEphemeris {
+ svId @0 :UInt16;
+ year @1 :UInt16;
+ dayInYear @2 :UInt16;
+ hour @3 :UInt16;
+ minute @4 :UInt16;
+ second @5 :Float32;
+
+ x @6 :Float64;
+ xVel @7 :Float64;
+ xAccel @8 :Float64;
+ y @9 :Float64;
+ yVel @10 :Float64;
+ yAccel @11 :Float64;
+ z @12 :Float64;
+ zVel @13 :Float64;
+ zAccel @14 :Float64;
+
+ svType @15 :UInt8;
+ svURA @16 :Float32;
+ age @17 :UInt8;
+
+ svHealth @18 :UInt8;
+ tk @19 :UInt16;
+ tb @20 :UInt16;
+
+ tauN @21 :Float64;
+ deltaTauN @22 :Float64;
+ gammaN @23 :Float64;
+
+ p1 @24 :UInt8;
+ p2 @25 :UInt8;
+ p3 @26 :UInt8;
+ p4 @27 :UInt8;
+
+ freqNum @28 :UInt32;
+ }
}
struct QcomGnss @0xde94674b07ae51c1 {
@@ -1951,6 +2005,30 @@ struct NavRoute {
}
}
+struct MapRenderState {
+ locationMonoTime @0 :UInt64;
+ renderTime @1 :Float32;
+ frameId @2: UInt32;
+}
+
+struct NavModelData {
+ frameId @0 :UInt32;
+ modelExecutionTime @1 :Float32;
+ dspExecutionTime @2 :Float32;
+ features @3 :List(Float32);
+ # predicted future position
+ position @4 :XYData;
+ desirePrediction @5 :List(Float32);
+
+ # All SI units and in device frame
+ struct XYData {
+ x @0 :List(Float32);
+ y @1 :List(Float32);
+ xStd @2 :List(Float32);
+ yStd @3 :List(Float32);
+ }
+}
+
struct EncodeData {
idx @0 :EncodeIndex;
data @1 :Data;
@@ -1961,6 +2039,15 @@ struct EncodeData {
struct UserFlag {
}
+struct Microphone {
+ soundPressure @0 :Float32;
+
+ # uncalibrated, A-weighted
+ soundPressureWeighted @3 :Float32;
+ soundPressureWeightedDb @1 :Float32;
+ filteredSoundPressureWeightedDb @2 :Float32;
+}
+
struct Event {
logMonoTime @0 :UInt64; # nanoseconds
valid @67 :Bool = true;
@@ -2010,6 +2097,7 @@ struct Event {
liveLocationKalman @72 :LiveLocationKalman;
modelV2 @75 :ModelDataV2;
driverStateV2 @92 :DriverStateV2;
+ navModel @104 :NavModelData;
# camera stuff, each camera state has a matching encode idx
roadCameraState @2 :FrameData;
@@ -2020,6 +2108,9 @@ struct Event {
wideRoadEncodeIdx @77 :EncodeIndex;
qRoadEncodeIdx @90 :EncodeIndex;
+ # microphone data
+ microphone @103 :Microphone;
+
# systems stuff
androidLog @20 :AndroidLogEntry;
managerState @78 :ManagerState;
@@ -2034,6 +2125,7 @@ struct Event {
navInstruction @82 :NavInstruction;
navRoute @83 :NavRoute;
navThumbnail @84: Thumbnail;
+ mapRenderState @105: MapRenderState;
# UI services
userFlag @93 :UserFlag;
diff --git a/cereal/messaging/bridge.cc b/cereal/messaging/bridge.cc
index 0b72e067f..2ab751ce2 100644
--- a/cereal/messaging/bridge.cc
+++ b/cereal/messaging/bridge.cc
@@ -7,9 +7,9 @@
typedef void (*sighandler_t)(int sig);
-#include "impl_msgq.h"
-#include "impl_zmq.h"
-#include "services.h"
+#include "cereal/services.h"
+#include "cereal/messaging/impl_msgq.h"
+#include "cereal/messaging/impl_zmq.h"
std::atomic do_exit = false;
static void set_do_exit(int sig) {
@@ -57,7 +57,7 @@ int main(int argc, char** argv) {
}
std::map sub2pub;
- for (auto endpoint: get_services(whitelist_str, zmq_to_msgq)) {
+ for (auto endpoint : get_services(whitelist_str, zmq_to_msgq)) {
PubSocket * pub_sock;
SubSocket * sub_sock;
if (zmq_to_msgq) {
diff --git a/cereal/messaging/impl_msgq.cc b/cereal/messaging/impl_msgq.cc
index 51353b437..18e936449 100644
--- a/cereal/messaging/impl_msgq.cc
+++ b/cereal/messaging/impl_msgq.cc
@@ -5,8 +5,8 @@
#include
#include
-#include "services.h"
-#include "impl_msgq.h"
+#include "cereal/services.h"
+#include "cereal/messaging/impl_msgq.h"
volatile sig_atomic_t msgq_do_exit = 0;
diff --git a/cereal/messaging/impl_msgq.h b/cereal/messaging/impl_msgq.h
index b67aae622..fdad52f9e 100644
--- a/cereal/messaging/impl_msgq.h
+++ b/cereal/messaging/impl_msgq.h
@@ -1,8 +1,10 @@
#pragma once
-#include "messaging.h"
-#include "msgq.h"
-#include
+
#include
+#include
+
+#include "cereal/messaging/messaging.h"
+#include "cereal/messaging/msgq.h"
#define MAX_POLLERS 128
diff --git a/cereal/messaging/impl_zmq.cc b/cereal/messaging/impl_zmq.cc
index aeed176ae..5355c8110 100644
--- a/cereal/messaging/impl_zmq.cc
+++ b/cereal/messaging/impl_zmq.cc
@@ -4,10 +4,8 @@
#include
#include
-#include
-
-#include "services.h"
-#include "impl_zmq.h"
+#include "cereal/services.h"
+#include "cereal/messaging/impl_zmq.h"
static int get_port(std::string endpoint) {
int port = -1;
diff --git a/cereal/messaging/impl_zmq.h b/cereal/messaging/impl_zmq.h
index bb232049e..deeac859c 100644
--- a/cereal/messaging/impl_zmq.h
+++ b/cereal/messaging/impl_zmq.h
@@ -1,7 +1,10 @@
#pragma once
-#include "messaging.h"
+
#include
#include
+#include
+
+#include "cereal/messaging/messaging.h"
#define MAX_POLLERS 128
diff --git a/cereal/messaging/messaging.cc b/cereal/messaging/messaging.cc
index 69c0e80c2..48e405634 100644
--- a/cereal/messaging/messaging.cc
+++ b/cereal/messaging/messaging.cc
@@ -1,9 +1,9 @@
#include
#include
-#include "messaging.h"
-#include "impl_zmq.h"
-#include "impl_msgq.h"
+#include "cereal/messaging/messaging.h"
+#include "cereal/messaging/impl_zmq.h"
+#include "cereal/messaging/impl_msgq.h"
#ifdef __APPLE__
const bool MUST_USE_ZMQ = true;
diff --git a/cereal/messaging/messaging.h b/cereal/messaging/messaging.h
index 51ddb7af2..483b2465c 100644
--- a/cereal/messaging/messaging.h
+++ b/cereal/messaging/messaging.h
@@ -1,10 +1,15 @@
#pragma once
+
#include
#include