diff --git a/README.md b/README.md index 564287562b4bfa..edcbbeeaa7f988 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![](https://i.imgur.com/UetIFyH.jpg)](#) -Welcome to openpilot +Welcome to openpilot SPECIFICALLY FOR THE CHEVY BOLT (NO PASSTHROUGH) ====== [openpilot](http://github.com/commaai/openpilot) is an open source driver assistance system. Currently, it performs the functions of Adaptive Cruise Control (ACC) and Automated Lane Centering (ALC) for selected Honda, Toyota, Acura, Lexus, Chevrolet, Hyundai, Kia, Subaru, Volkswagen. It's about on par with Tesla Autopilot and GM Super Cruise, and better than [all other manufacturers](http://www.thedrive.com/tech/5707/the-war-for-autonomous-driving-part-iii-us-vs-germany-vs-japan). @@ -63,6 +63,7 @@ Supported Cars | Buick3 | Regal 20186 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | | Chevrolet3 | Malibu 20176 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | | Chevrolet3 | Volt 2017-186 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | +| Chevrolet3 | Bolt 2019 | Driver Confidence II | Yes | No | 0mph | 7mph | | Cadillac3 | ATS 2018 | Adaptive Cruise | Yes | Yes | 0mph | 7mph | | Chrysler | Pacifica 2017-187 | Adaptive Cruise | Yes | Stock | 0mph | 9mph | | Chrysler | Pacifica Hybrid 2017-187| Adaptive Cruise | Yes | Stock | 0mph | 9mph | diff --git a/models/driving_model.dlc b/models/driving_model.dlc index e04f9f93a1a0fa..8526838a473549 100644 Binary files a/models/driving_model.dlc and b/models/driving_model.dlc differ diff --git a/opendbc/gm_global_a_powertrain.dbc b/opendbc/gm_global_a_powertrain.dbc index 2e3bd7c85dd435..25dbe40bc5acfc 100644 --- a/opendbc/gm_global_a_powertrain.dbc +++ b/opendbc/gm_global_a_powertrain.dbc @@ -209,6 +209,12 @@ BO_ 1912 PSCM_778: 8 K43_PSCM BO_ 1930 ASCM_78A: 7 K124_ASCM +BO_ 800 FCABrakingCmd: 6 XXX + SG_ RollingCounter : 5|2@0+ (1,0) [0|3] "" XXX + SG_ Checksum : 27|20@0+ (1,0) [0|2047] "" XXX + SG_ BrakeCmdActive : 3|1@1+ (1,0) [0|1] "" XXX + SG_ BrakingForce : 2|7@0+ (1,0) [0|7] "" XXX + BO_TX_BU_ 384 : K124_ASCM,NEO; BO_TX_BU_ 880 : NEO,K124_ASCM; BO_TX_BU_ 1033 : K124_ASCM,NEO; diff --git a/panda/VERSION b/panda/VERSION index 4279ff22f4fa77..25120d3de063a4 100644 --- a/panda/VERSION +++ b/panda/VERSION @@ -1 +1 @@ -v1.5.9 \ No newline at end of file +v1.5.33 \ No newline at end of file diff --git a/panda/board/boards/common.h b/panda/board/boards/common.h index e33b2a2f0426c4..98ac89e2ed371f 100644 --- a/panda/board/boards/common.h +++ b/panda/board/boards/common.h @@ -62,7 +62,9 @@ void peripherals_init(void){ RCC->APB1ENR |= RCC_APB1ENR_TIM4EN; // gmlan_alt and IR PWM //RCC->APB1ENR |= RCC_APB1ENR_TIM5EN; //RCC->APB1ENR |= RCC_APB1ENR_TIM6EN; + RCC->APB1ENR |= RCC_APB1ENR_TIM7EN; RCC->APB1ENR |= RCC_APB1ENR_PWREN; // for RTC config + //RCC->APB1ENR |= RCC_APB1ENR_TIM12EN; RCC->APB2ENR |= RCC_APB2ENR_USART1EN; RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; //RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; diff --git a/panda/board/drivers/can.h b/panda/board/drivers/can.h index c9bf2d25436b35..209a62c1502ce0 100644 --- a/panda/board/drivers/can.h +++ b/panda/board/drivers/can.h @@ -363,6 +363,8 @@ void ignition_can_hook(CAN_FIFOMailBox_TypeDef *to_push) { ignition_can = (GET_BYTE(to_push, 2) & 0x2) != 0; } } + //TODO: remove this - for testing only + //ignition_can = true; } // CAN receive handlers @@ -420,6 +422,26 @@ void CAN3_TX_IRQHandler(void) { process_can(2); } void CAN3_RX0_IRQHandler(void) { can_rx(2); } void CAN3_SCE_IRQHandler(void) { can_sce(CAN3); } + +void pump_send(pump_hook hook) { + uint8_t bus_number = 0U; + if (hook == NULL) return; + CAN_FIFOMailBox_TypeDef *to_push = hook(); + if (to_push != NULL) { + if (bus_number < BUS_MAX) { + // add CAN packet to send queuesend + // bus number isn't passed through + to_push->RDTR &= 0xF; + if ((bus_number == 3U) && (can_num_lookup[3] == 0xFFU)) { + gmlan_send_errs += bitbang_gmlan(to_push) ? 0U : 1U; + } else { + can_fwd_errs += can_push(can_queues[bus_number], to_push) ? 0U : 1U; + process_can(CAN_NUM_FROM_BUS_NUM(bus_number)); + } + } + } +} + void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number) { if (safety_tx_hook(to_push) != 0) { if (bus_number < BUS_MAX) { diff --git a/panda/board/main.c b/panda/board/main.c index 3bcae876e203d0..97c8333b460955 100644 --- a/panda/board/main.c +++ b/panda/board/main.c @@ -630,6 +630,28 @@ int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out) { // ***************************** main code ***************************** +// *pump_hook message_pump_hook; + +// void enable_message_pump(uint32_t divider, *pump_hook hook) { +// //Timer for LKAS pump +// message_pump_hook = hook; +// timer_init(TIM7, divider); +// NVIC_EnableIRQ(TIM7_IRQn); +// } + +// void update_message_pump_rate(uint32_t divider) { +// //TODO: test if this works +// TIM7->PSC = divider-1; +// } + +// void disable_message_pump() { +// NVIC_DisableIRQ(TIM7_IRQn); +// pump_hook = null; +// } + + + + // cppcheck-suppress unusedFunction ; used in headers not included in cppcheck void __initialize_hardware_early(void) { early(); @@ -646,6 +668,20 @@ uint64_t tcnt = 0; #define EON_HEARTBEAT_IGNITION_CNT_ON 5U #define EON_HEARTBEAT_IGNITION_CNT_OFF 2U + + + +void TIM7_IRQHandler(void) { + //TODO: This needs to check for ignition and stop itself? + if (TIM7->SR != 0) { + if (message_pump_hook != NULL) { + pump_send(message_pump_hook); + } + } + TIM7->SR = 0; +} + + // called once per second // cppcheck-suppress unusedFunction ; used in headers not included in cppcheck void TIM1_BRK_TIM9_IRQHandler(void) { @@ -760,6 +796,7 @@ int main(void) { TIM2->EGR = TIM_EGR_UG; // use TIM2->CNT to read + // default to silent mode to prevent issues with Ford // hardcode a specific safety mode if you want to force the panda to be in a specific mode int err = safety_set_mode(SAFETY_NOOUTPUT, 0); @@ -790,6 +827,10 @@ int main(void) { timer_init(TIM9, 1464); NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn); + // //Timer for LKAS pump + // timer_init(TIM7, 15); + // NVIC_EnableIRQ(TIM7_IRQn); + #ifdef DEBUG puts("DEBUG ENABLED\n"); #endif diff --git a/panda/board/main_declarations.h b/panda/board/main_declarations.h index 8929e9ac0e0cd9..a06067a470d2d3 100644 --- a/panda/board/main_declarations.h +++ b/panda/board/main_declarations.h @@ -6,6 +6,10 @@ typedef struct board board; typedef struct harness_configuration harness_configuration; void can_flip_buses(uint8_t bus1, uint8_t bus2); void can_set_obd(uint8_t harness_orientation, bool obd); +// void enable_message_pump(uint32_t divider, *pump_hook hook); +// void update_message_pump_rate(uint32_t divider); +// void disable_message_pump(void); + // ********************* Globals ********************** uint8_t hw_type = 0; diff --git a/panda/board/obj/panda.bin.signed b/panda/board/obj/panda.bin.signed deleted file mode 100644 index 7fa3f83e559081..00000000000000 Binary files a/panda/board/obj/panda.bin.signed and /dev/null differ diff --git a/panda/board/safety.h b/panda/board/safety.h index c68eda2c4a4864..857af5b666432e 100644 --- a/panda/board/safety.h +++ b/panda/board/safety.h @@ -55,6 +55,29 @@ int safety_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { return current_hooks->fwd(bus_num, to_fwd); } +pump_hook message_pump_hook; + +void enable_message_pump(uint32_t divider, pump_hook hook) { + //Timer for LKAS pump + //todo: some kind of locking? + message_pump_active = true; + message_pump_hook = hook; + timer_init(TIM7, divider); + NVIC_EnableIRQ(TIM7_IRQn); +} + +void update_message_pump_rate(uint32_t divider) { + //TODO: test if this works + TIM7->PSC = divider-1; +} + +void disable_message_pump() { + NVIC_DisableIRQ(TIM7_IRQn); + message_pump_hook = NULL; + message_pump_active = false; +} + + typedef struct { uint16_t id; const safety_hooks *hooks; @@ -94,6 +117,10 @@ int safety_set_mode(uint16_t mode, int16_t param) { if ((set_status == 0) && (current_hooks->init != NULL)) { current_hooks->init(param); } + if (mode == SAFETY_NOOUTPUT) { + puts("Disabling message pump due to SAFETY_NOOUTPUT"); + disable_message_pump(); + } return set_status; } diff --git a/panda/board/safety/safety_gm.h b/panda/board/safety/safety_gm.h index 452f70953df640..545ceb49a253b2 100644 --- a/panda/board/safety/safety_gm.h +++ b/panda/board/safety/safety_gm.h @@ -8,7 +8,17 @@ // brake rising edge // brake > 0mph -const int GM_MAX_STEER = 300; +typedef struct { + uint32_t current_ts; + CAN_FIFOMailBox_TypeDef current_frame; + uint32_t stock_ts; + CAN_FIFOMailBox_TypeDef stock_frame; + uint32_t op_ts; + CAN_FIFOMailBox_TypeDef op_frame; + uint32_t rolling_counter; +} gm_dual_buffer; + +const int GM_MAX_STEER = 550; const int GM_MAX_RT_DELTA = 128; // max delta torque allowed for real time checks const uint32_t GM_RT_INTERVAL = 250000; // 250ms between real time checks const int GM_MAX_RATE_UP = 7; @@ -29,6 +39,54 @@ int gm_desired_torque_last = 0; uint32_t gm_ts_last = 0; struct sample_t gm_torque_driver; // last few driver torques measured +static void gm_init_lkas_pump(void); + + +volatile gm_dual_buffer gm_lkas_buffer; + +// CAN_FIFOMailBox_TypeDef gm_current_lkas; +// volatile uint32_t gm_current_lkas_ts = 0; +// volatile CAN_FIFOMailBox_TypeDef gm_stock_lkas; +// volatile bool gm_have_stock_lkas = false; +// volatile uint32_t gm_stock_lkas_ts = 0; +// volatile CAN_FIFOMailBox_TypeDef gm_op_lkas; +// volatile bool gm_have_op_lkas = false; +// volatile uint32_t gm_op_lkas_ts = 0; +// volatile int gm_lkas_rolling_counter = 0; +volatile bool gm_ffc_detected = false; + +static void gm_apply_buffer(volatile gm_dual_buffer *buffer, bool stock) { + if (stock) { + buffer->current_frame.RIR = buffer->stock_frame.RIR | 1; + buffer->current_frame.RDTR = buffer->stock_frame.RDTR; + buffer->current_frame.RDLR = buffer->stock_frame.RDLR; + buffer->current_frame.RDHR = buffer->stock_frame.RDHR; + buffer->current_ts = buffer->stock_ts; + } else { + buffer->current_frame.RIR = buffer->op_frame.RIR; + buffer->current_frame.RDTR = buffer->op_frame.RDTR; + buffer->current_frame.RDLR = buffer->op_frame.RDLR; + buffer->current_frame.RDHR = buffer->op_frame.RDHR; + buffer->current_ts = buffer->op_ts; + } +} + +static void gm_set_stock_lkas(CAN_FIFOMailBox_TypeDef *to_send) { + gm_lkas_buffer.stock_frame.RIR = to_send->RIR; + gm_lkas_buffer.stock_frame.RDTR = to_send->RDTR; + gm_lkas_buffer.stock_frame.RDLR = to_send->RDLR; + gm_lkas_buffer.stock_frame.RDHR = to_send->RDHR; + gm_lkas_buffer.stock_ts = TIM2->CNT; +} + +static void gm_set_op_lkas(CAN_FIFOMailBox_TypeDef *to_send) { + gm_lkas_buffer.op_frame.RIR = to_send->RIR; + gm_lkas_buffer.op_frame.RDTR = to_send->RDTR; + gm_lkas_buffer.op_frame.RDLR = to_send->RDLR; + gm_lkas_buffer.op_frame.RDHR = to_send->RDHR; + gm_lkas_buffer.op_ts = TIM2->CNT; +} + static void gm_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { int bus_number = GET_BUS(to_push); int addr = GET_ADDR(to_push); @@ -142,6 +200,13 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { // LKA STEER: safety check if (addr == 384) { + uint32_t vals[4]; + vals[0] = 0x00000000U; + vals[1] = 0x10000fffU; + vals[2] = 0x20000ffeU; + vals[3] = 0x30000ffdU; + int rolling_counter = GET_BYTE(to_send, 0) >> 4; + int desired_torque = ((GET_BYTE(to_send, 0) & 0x7U) << 8) + GET_BYTE(to_send, 1); uint32_t ts = TIM2->CNT; bool violation = 0; @@ -149,6 +214,7 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { if (current_controls_allowed) { + // *** global torque limit check *** violation |= max_limit_check(desired_torque, GM_MAX_STEER, -GM_MAX_STEER); @@ -184,8 +250,13 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { } if (violation) { - tx = 0; + //Replace payload with appropriate zero value for expected rolling counter + to_send->RDLR = vals[rolling_counter]; + //tx = 0; } + tx = 0; + gm_set_op_lkas(to_send); + gm_init_lkas_pump(); } // PARK ASSIST STEER: unlimited torque, no thanks @@ -213,16 +284,119 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { return tx; } + + + static void gm_init(int16_t param) { UNUSED(param); controls_allowed = 0; + gm_lkas_buffer.current_ts = 0; + gm_lkas_buffer.op_ts = 0; + gm_lkas_buffer.stock_ts = 0; +} + + +static int gm_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { + return -1; + int bus_fwd = -1; + if (bus_num == 0) { + bus_fwd = 1; // Camera is on CAN2 + } + if (bus_num == 1) { + int addr = GET_ADDR(to_fwd); + if (addr != 384) return 0; + gm_set_stock_lkas(to_fwd); + gm_ffc_detected = true; + gm_init_lkas_pump(); + } + + // fallback to do not forward + return bus_fwd; } +static CAN_FIFOMailBox_TypeDef * gm_pump_hook(void) { + volatile int pedal_pressed = (volatile int)gm_gas_prev || ((volatile int)gm_brake_prev && (volatile int)gm_moving); + volatile bool current_controls_allowed = (volatile bool)controls_allowed && !(volatile int)pedal_pressed; + + if (!gm_ffc_detected) { + //If we haven't seen lkas messages from CAN2, there is no passthrough, just use OP + if (gm_lkas_buffer.op_ts == 0) return NULL; + //puts("using OP lkas\n"); + gm_apply_buffer(&gm_lkas_buffer, false); + //In OP only mode we need to send zero if controls are not allowed + if (!current_controls_allowed) { + gm_lkas_buffer.current_frame.RDLR = 0U; + gm_lkas_buffer.current_frame.RDHR = 0U; + } + } + else + { + if (!current_controls_allowed) { + if (gm_lkas_buffer.stock_ts == 0) return NULL; + //puts("using stock lkas\n"); + gm_apply_buffer(&gm_lkas_buffer, true); + } else { + if (gm_lkas_buffer.op_ts == 0) return NULL; + //puts("using OP lkas\n"); + gm_apply_buffer(&gm_lkas_buffer, false); + } + } + + // If the timestamp of the last message is more than 40ms old, fallback to zero + // If it is more than 1 second, disable message pump + uint32_t ts = TIM2->CNT; + uint32_t ts_elapsed = get_ts_elapsed(ts, gm_lkas_buffer.current_ts); + + + + if (ts_elapsed > 1000000u) { + puts("Disabling message pump due to stale buffer\n"); + disable_message_pump(); + } else if (ts_elapsed > 40000u) { + puts("Zeroing frame due to stale buffer: "); + puth(ts_elapsed); + puts("\n"); + gm_lkas_buffer.current_frame.RDLR = 0U; + gm_lkas_buffer.current_frame.RDHR = 0U; + } + + gm_lkas_buffer.rolling_counter = (gm_lkas_buffer.rolling_counter + 1) % 4; + + //update the rolling counter + gm_lkas_buffer.current_frame.RDLR = (0xFFFFFFCF & gm_lkas_buffer.current_frame.RDLR) | (gm_lkas_buffer.rolling_counter << 4); + + // Recalculate checksum - Thanks Andrew C + + // Replacement rolling counter + uint32_t newidx = gm_lkas_buffer.rolling_counter; + + // Pull out LKA Steering CMD data and swap endianness (not including rolling counter) + uint32_t dataswap = ((gm_lkas_buffer.current_frame.RDLR << 8) & 0x0F00U) | ((gm_lkas_buffer.current_frame.RDLR >> 8) &0xFFU); + + // Compute Checksum + uint32_t checksum = (0x1000 - dataswap - newidx) & 0x0fff; + + //Swap endianness of checksum back to what GM expects + uint32_t checksumswap = (checksum >> 8) | ((checksum << 8) & 0xFF00U); + + // Merge the rewritten checksum back into the BxCAN frame RDLR + gm_lkas_buffer.current_frame.RDLR &= 0x0000FFFF; + gm_lkas_buffer.current_frame.RDLR |= (checksumswap << 16); + + return (CAN_FIFOMailBox_TypeDef*)&gm_lkas_buffer.current_frame; +} + +static void gm_init_lkas_pump() { + if (message_pump_active) return; + puts("Starting message pump\n"); + enable_message_pump(15, gm_pump_hook); +} + const safety_hooks gm_hooks = { .init = gm_init, .rx = gm_rx_hook, .tx = gm_tx_hook, .tx_lin = nooutput_tx_lin_hook, - .fwd = default_fwd_hook, + .fwd = gm_fwd_hook, }; diff --git a/panda/board/safety_declarations.h b/panda/board/safety_declarations.h index efa6a4e2b8744c..35489bd6eb8593 100644 --- a/panda/board/safety_declarations.h +++ b/panda/board/safety_declarations.h @@ -31,6 +31,12 @@ typedef void (*rx_hook)(CAN_FIFOMailBox_TypeDef *to_push); typedef int (*tx_hook)(CAN_FIFOMailBox_TypeDef *to_send); typedef int (*tx_lin_hook)(int lin_num, uint8_t *data, int len); typedef int (*fwd_hook)(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd); +typedef CAN_FIFOMailBox_TypeDef * (*pump_hook)(void); + +void enable_message_pump(uint32_t divider, pump_hook hook); +void update_message_pump_rate(uint32_t divider); +void disable_message_pump(void); + typedef struct { safety_hook_init init; @@ -48,5 +54,7 @@ int gas_interceptor_prev = 0; // This is set by USB command 0xdf bool long_controls_allowed = 1; +bool message_pump_active = false; + // avg between 2 tracks #define GET_INTERCEPTOR(msg) (((GET_BYTE((msg), 0) << 8) + GET_BYTE((msg), 1) + ((GET_BYTE((msg), 2) << 8) + GET_BYTE((msg), 3)) / 2 ) / 2) diff --git a/selfdrive/can/common.h b/selfdrive/can/common.h index 2ec25075859ef5..a496c3918b91ad 100644 --- a/selfdrive/can/common.h +++ b/selfdrive/can/common.h @@ -1,17 +1,13 @@ -#ifndef SELFDRIVE_CAN_COMMON_H -#define SELFDRIVE_CAN_COMMON_H +#pragma once -#include -#include -#include -#include #include +#include +#include "common_dbc.h" #include #include "cereal/gen/cpp/log.capnp.h" #define MAX_BAD_COUNTER 5 -#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) // Helper functions unsigned int honda_checksum(unsigned int address, uint64_t d, int l); @@ -22,74 +18,6 @@ unsigned int pedal_checksum(uint64_t d, int l); uint64_t read_u64_be(const uint8_t* v); uint64_t read_u64_le(const uint8_t* v); -struct SignalPackValue { - const char* name; - double value; -}; - -struct SignalParseOptions { - uint32_t address; - const char* name; - double default_value; -}; - -struct MessageParseOptions { - uint32_t address; - int check_frequency; -}; - -struct SignalValue { - uint32_t address; - uint16_t ts; - const char* name; - double value; -}; - - -enum SignalType { - DEFAULT, - HONDA_CHECKSUM, - HONDA_COUNTER, - TOYOTA_CHECKSUM, - PEDAL_CHECKSUM, - PEDAL_COUNTER, - VOLKSWAGEN_CHECKSUM, - VOLKSWAGEN_COUNTER, -}; - -struct Signal { - const char* name; - int b1, b2, bo; - bool is_signed; - double factor, offset; - bool is_little_endian; - SignalType type; -}; - -struct Msg { - const char* name; - uint32_t address; - unsigned int size; - size_t num_sigs; - const Signal *sigs; -}; - -struct Val { - const char* name; - uint32_t address; - const char* def_val; - const Signal *sigs; -}; - -struct DBC { - const char* name; - size_t num_msgs; - const Msg *msgs; - const Val *vals; - size_t num_vals; -}; - - class MessageState { public: uint32_t address; @@ -129,17 +57,3 @@ class CANParser { std::vector query_latest(); }; - - - - -const DBC* dbc_lookup(const std::string& dbc_name); - -void dbc_register(const DBC* dbc); - -#define dbc_init(dbc) \ -static void __attribute__((constructor)) do_dbc_init_ ## dbc(void) { \ - dbc_register(&dbc); \ -} - -#endif diff --git a/selfdrive/can/common.pxd b/selfdrive/can/common.pxd index 54c6e444fdfcd8..d26f8da46f6057 100644 --- a/selfdrive/can/common.pxd +++ b/selfdrive/can/common.pxd @@ -17,7 +17,9 @@ cdef extern from "common.h": HONDA_COUNTER, TOYOTA_CHECKSUM, PEDAL_CHECKSUM, - PEDAL_COUNTER + PEDAL_COUNTER, + VOLKSWAGEN_CHECKSUM, + VOLKSWAGEN_COUNTER cdef struct Signal: const char* name diff --git a/selfdrive/can/common_dbc.h b/selfdrive/can/common_dbc.h new file mode 100644 index 00000000000000..ae6f443ec90cd3 --- /dev/null +++ b/selfdrive/can/common_dbc.h @@ -0,0 +1,82 @@ +#pragma once + +#include +#include +#include + +#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) + +struct SignalPackValue { + const char* name; + double value; +}; + +struct SignalParseOptions { + uint32_t address; + const char* name; + double default_value; +}; + +struct MessageParseOptions { + uint32_t address; + int check_frequency; +}; + +struct SignalValue { + uint32_t address; + uint16_t ts; + const char* name; + double value; +}; + +enum SignalType { + DEFAULT, + HONDA_CHECKSUM, + HONDA_COUNTER, + TOYOTA_CHECKSUM, + PEDAL_CHECKSUM, + PEDAL_COUNTER, + VOLKSWAGEN_CHECKSUM, + VOLKSWAGEN_COUNTER, +}; + +struct Signal { + const char* name; + int b1, b2, bo; + bool is_signed; + double factor, offset; + bool is_little_endian; + SignalType type; +}; + +struct Msg { + const char* name; + uint32_t address; + unsigned int size; + size_t num_sigs; + const Signal *sigs; +}; + +struct Val { + const char* name; + uint32_t address; + const char* def_val; + const Signal *sigs; +}; + +struct DBC { + const char* name; + size_t num_msgs; + const Msg *msgs; + const Val *vals; + size_t num_vals; +}; + +const DBC* dbc_lookup(const std::string& dbc_name); + +void dbc_register(const DBC* dbc); + +#define dbc_init(dbc) \ +static void __attribute__((constructor)) do_dbc_init_ ## dbc(void) { \ + dbc_register(&dbc); \ +} diff --git a/selfdrive/can/dbc.cc b/selfdrive/can/dbc.cc index 95d5e4d791394a..6587de7fe0163a 100644 --- a/selfdrive/can/dbc.cc +++ b/selfdrive/can/dbc.cc @@ -1,7 +1,6 @@ -#include #include -#include "common.h" +#include "common_dbc.h" namespace { diff --git a/selfdrive/can/dbc_template.cc b/selfdrive/can/dbc_template.cc index 52351aef2ff79a..f9540fcee9af16 100644 --- a/selfdrive/can/dbc_template.cc +++ b/selfdrive/can/dbc_template.cc @@ -1,6 +1,4 @@ -#include - -#include "common.h" +#include "common_dbc.h" namespace { @@ -27,7 +25,7 @@ const Signal sigs_{{address}}[] = { .type = SignalType::HONDA_COUNTER, {% elif checksum_type == "toyota" and sig.name == "CHECKSUM" %} .type = SignalType::TOYOTA_CHECKSUM, - {% elif checksum_type == "volkswagen" and sig.name == "CHECKSUM" %} + {% elif checksum_type == "volkswagen" and sig.name == "CHECKSUM" %} .type = SignalType::VOLKSWAGEN_CHECKSUM, {% elif checksum_type == "volkswagen" and sig.name == "COUNTER" %} .type = SignalType::VOLKSWAGEN_COUNTER, diff --git a/selfdrive/can/packer.cc b/selfdrive/can/packer.cc index f6da562a7a5910..c658e56731f3f3 100644 --- a/selfdrive/can/packer.cc +++ b/selfdrive/can/packer.cc @@ -1,6 +1,4 @@ #include -#include -#include #include #include #include diff --git a/selfdrive/can/parser.cc b/selfdrive/can/parser.cc index 2df843e21308ee..e204112e3c3847 100644 --- a/selfdrive/can/parser.cc +++ b/selfdrive/can/parser.cc @@ -1,5 +1,3 @@ -#include -#include #include #include @@ -7,13 +5,8 @@ #include #include #include - -#include #include -#include -#include "cereal/gen/cpp/log.capnp.h" - #include "common.h" #define DEBUG(...) @@ -62,7 +55,6 @@ bool MessageState::parse(uint64_t sec, uint16_t ts_, uint8_t * dat) { } } else if (sig.type == SignalType::VOLKSWAGEN_COUNTER) { if (!update_counter_generic(tmp, sig.b2)) { - INFO("0x%X CHECKSUM FAIL\n", address); return false; } } else if (sig.type == SignalType::PEDAL_CHECKSUM) { @@ -91,7 +83,7 @@ bool MessageState::update_counter_generic(int64_t v, int cnt_size) { if (((old_counter+1) & ((1 << cnt_size) -1)) != v) { counter_fail += 1; if (counter_fail > 1) { - INFO("%X COUNTER FAIL %d -- %d vs %d\n", address, counter_fail, old_counter, (int)v); + INFO("0x%X COUNTER FAIL %d -- %d vs %d\n", address, counter_fail, old_counter, (int)v); } if (counter_fail >= MAX_BAD_COUNTER) { return false; @@ -132,7 +124,7 @@ CANParser::CANParser(int abus, const std::string& dbc_name, } } if (!msg) { - fprintf(stderr, "CANParser: could not find message 0x%X in dnc %s\n", op.address, dbc_name.c_str()); + fprintf(stderr, "CANParser: could not find message 0x%X in DBC %s\n", op.address, dbc_name.c_str()); assert(false); } @@ -200,7 +192,7 @@ void CANParser::UpdateValid(uint64_t sec) { const auto& state = kv.second; if (state.check_threshold > 0 && (sec - state.seen) > state.check_threshold) { if (state.seen > 0) { - DEBUG("%X TIMEOUT\n", state.address); + DEBUG("0x%X TIMEOUT\n", state.address); } can_valid = false; } diff --git a/selfdrive/can/process_dbc.py b/selfdrive/can/process_dbc.py index c1da3ce45c35db..dc544f741f65a4 100755 --- a/selfdrive/can/process_dbc.py +++ b/selfdrive/can/process_dbc.py @@ -28,7 +28,7 @@ def main(): msgs = [(address, msg_name, msg_size, sorted(msg_sigs, key=lambda s: s.name not in ("COUNTER", "CHECKSUM"))) # process counter and checksums first for address, ((msg_name, msg_size), msg_sigs) in sorted(can_dbc.msgs.items()) if msg_sigs] - def_vals = {a: set(b) for a,b in can_dbc.def_vals.items()} #remove duplicates + def_vals = {a: sorted(set(b)) for a, b in can_dbc.def_vals.items()} # remove duplicates def_vals = sorted(def_vals.items()) if can_dbc.name.startswith(("honda_", "acura_")): diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py index bc7d9676f5ea30..7e7ee64ed4540f 100644 --- a/selfdrive/car/car_helpers.py +++ b/selfdrive/car/car_helpers.py @@ -118,6 +118,7 @@ def get_car(logcan, sendcan, has_relay=False): if candidate is None: cloudlog.warning("car doesn't match any fingerprints: %r", fingerprints) candidate = "mock" + candidate = "CADILLAC ESCALADE 2018" CarInterface, CarController = interfaces[candidate] car_params = CarInterface.get_params(candidate, fingerprints, vin, has_relay) diff --git a/selfdrive/car/gm/carcontroller.py b/selfdrive/car/gm/carcontroller.py index c4647c8228d9cd..4572f2ef44a074 100644 --- a/selfdrive/car/gm/carcontroller.py +++ b/selfdrive/car/gm/carcontroller.py @@ -4,7 +4,7 @@ from selfdrive.config import Conversions as CV from selfdrive.car import apply_std_steer_torque_limits from selfdrive.car.gm import gmcan -from selfdrive.car.gm.values import DBC, SUPERCRUISE_CARS +from selfdrive.car.gm.values import DBC, SUPERCRUISE_CARS, CAR, NO_ASCM_CARS from selfdrive.can.packer import CANPacker VisualAlert = car.CarControl.HUDControl.VisualAlert @@ -18,12 +18,18 @@ def __init__(self, car_fingerprint): self.STEER_DELTA_UP = 2 # 0.75s time to peak torque self.STEER_DELTA_DOWN = 5 # 0.3s from peak torque to zero self.MIN_STEER_SPEED = -1. # can steer down to zero - else: + elif car_fingerprint in NO_ASCM_CARS: self.STEER_MAX = 300 self.STEER_STEP = 2 # how often we update the steer cmd self.STEER_DELTA_UP = 7 # ~0.75s time to peak torque (255/50hz/0.75s) self.STEER_DELTA_DOWN = 17 # ~0.3s from peak torque to zero self.MIN_STEER_SPEED = 3. + else: + self.STEER_MAX = 550 + self.STEER_STEP = 2 # how often we update the steer cmd + self.STEER_DELTA_UP = 7 # ~0.75s time to peak torque (255/50hz/0.75s) + self.STEER_DELTA_DOWN = 17 # ~0.3s from peak torque to zero + self.MIN_STEER_SPEED = 3. self.STEER_DRIVER_ALLOWANCE = 50 # allowed driver torque before start limiting self.STEER_DRIVER_MULTIPLIER = 4 # weight driver torque heavily @@ -136,39 +142,41 @@ def update(self, enabled, CS, frame, actuators, \ apply_gas = int(round(interp(final_pedal, P.GAS_LOOKUP_BP, P.GAS_LOOKUP_V))) apply_brake = int(round(interp(final_pedal, P.BRAKE_LOOKUP_BP, P.BRAKE_LOOKUP_V))) - # Gas/regen and brakes - all at 25Hz - if (frame % 4) == 0: - idx = (frame // 4) % 4 - - at_full_stop = enabled and CS.standstill - near_stop = enabled and (CS.v_ego < P.NEAR_STOP_BRAKE_PHASE) - can_sends.append(gmcan.create_friction_brake_command(self.packer_ch, canbus.chassis, apply_brake, idx, near_stop, at_full_stop)) - - at_full_stop = enabled and CS.standstill - can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, canbus.powertrain, apply_gas, idx, enabled, at_full_stop)) - - # Send dashboard UI commands (ACC status), 25hz - if (frame % 4) == 0: - can_sends.append(gmcan.create_acc_dashboard_command(self.packer_pt, canbus.powertrain, enabled, hud_v_cruise * CV.MS_TO_KPH, hud_show_car)) - - # Radar needs to know current speed and yaw rate (50hz), - # and that ADAS is alive (10hz) - time_and_headlights_step = 10 - tt = frame * DT_CTRL - - if frame % time_and_headlights_step == 0: - idx = (frame // time_and_headlights_step) % 4 - can_sends.append(gmcan.create_adas_time_status(canbus.obstacle, int((tt - self.start_time) * 60), idx)) - can_sends.append(gmcan.create_adas_headlights_status(canbus.obstacle)) - - speed_and_accelerometer_step = 2 - if frame % speed_and_accelerometer_step == 0: - idx = (frame // speed_and_accelerometer_step) % 4 - can_sends.append(gmcan.create_adas_steering_status(canbus.obstacle, idx)) - can_sends.append(gmcan.create_adas_accelerometer_speed_status(canbus.obstacle, CS.v_ego, idx)) - - if frame % P.ADAS_KEEPALIVE_STEP == 0: - can_sends += gmcan.create_adas_keepalive(canbus.powertrain) + #TODO: there may be other GM cars that lack ACC + if not self.car_fingerprint in NO_ASCM_CARS: + # Gas/regen and brakes - all at 25Hz + if (frame % 4) == 0: + idx = (frame // 4) % 4 + + at_full_stop = enabled and CS.standstill + near_stop = enabled and (CS.v_ego < P.NEAR_STOP_BRAKE_PHASE) + can_sends.append(gmcan.create_friction_brake_command(self.packer_ch, canbus.chassis, apply_brake, idx, near_stop, at_full_stop)) + + at_full_stop = enabled and CS.standstill + can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, canbus.powertrain, apply_gas, idx, enabled, at_full_stop)) + + # Send dashboard UI commands (ACC status), 25hz + if (frame % 4) == 0: + can_sends.append(gmcan.create_acc_dashboard_command(self.packer_pt, canbus.powertrain, enabled, hud_v_cruise * CV.MS_TO_KPH, hud_show_car)) + + # Radar needs to know current speed and yaw rate (50hz), + # and that ADAS is alive (10hz) + time_and_headlights_step = 10 + tt = frame * DT_CTRL + + if frame % time_and_headlights_step == 0: + idx = (frame // time_and_headlights_step) % 4 + can_sends.append(gmcan.create_adas_time_status(canbus.obstacle, int((tt - self.start_time) * 60), idx)) + can_sends.append(gmcan.create_adas_headlights_status(canbus.obstacle)) + + speed_and_accelerometer_step = 2 + if frame % speed_and_accelerometer_step == 0: + idx = (frame // speed_and_accelerometer_step) % 4 + can_sends.append(gmcan.create_adas_steering_status(canbus.obstacle, idx)) + can_sends.append(gmcan.create_adas_accelerometer_speed_status(canbus.obstacle, CS.v_ego, idx)) + + if frame % P.ADAS_KEEPALIVE_STEP == 0: + can_sends += gmcan.create_adas_keepalive(canbus.powertrain) # Show green icon when LKA torque is applied, and # alarming orange icon when approaching torque limit. diff --git a/selfdrive/car/gm/carstate.py b/selfdrive/car/gm/carstate.py index 7da8d6527257c6..6afab9343e96ba 100644 --- a/selfdrive/car/gm/carstate.py +++ b/selfdrive/car/gm/carstate.py @@ -31,7 +31,7 @@ def get_powertrain_can_parser(CP, canbus): ("LKATorqueDeliveredStatus", "PSCMStatus", 0), ] - if CP.carFingerprint == CAR.VOLT: + if CP.carFingerprint == CAR.VOLT or CP.carFingerprint == CAR.BOLT: signals += [ ("RegenPaddle", "EBCMRegenPaddle", 0), ] @@ -135,7 +135,7 @@ def update(self, pt_cp): self.acc_active = False self.esp_disabled = pt_cp.vl["ESPStatus"]['TractionControlOn'] != 1 self.pcm_acc_status = pt_cp.vl["AcceleratorPedal2"]['CruiseState'] - if self.car_fingerprint == CAR.VOLT: + if self.car_fingerprint == CAR.VOLT or self.car_fingerprint == CAR.BOLT: self.regen_pressed = bool(pt_cp.vl["EBCMRegenPaddle"]['RegenPaddle']) else: self.regen_pressed = False diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 213f7676520d2b..e8e056ef5355cc 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -4,7 +4,7 @@ from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET from selfdrive.controls.lib.vehicle_model import VehicleModel from selfdrive.car.gm.values import DBC, CAR, ECU, ECU_FINGERPRINT, \ - SUPERCRUISE_CARS, AccState, FINGERPRINTS + SUPERCRUISE_CARS, NO_ASCM_CARS, AccState, FINGERPRINTS from selfdrive.car.gm.carstate import CarState, CruiseButtons, get_powertrain_can_parser from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, is_ecu_disconnected, gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase @@ -72,6 +72,16 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), vin="", has_relay ret.steerRatioRear = 0. ret.centerToFront = ret.wheelbase * 0.4 # wild guess + elif candidate == CAR.BOLT: + # initial engage unkown - copied from Volt. Stop and go unknown. + ret.minEnableSpeed = 18 * CV.MPH_TO_MS + ret.mass = 1616. + STD_CARGO_KG + ret.safetyModel = car.CarParams.SafetyModel.gm + ret.wheelbase = 2.60096 + ret.steerRatio = 16.8 + ret.steerRatioRear = 0. + ret.centerToFront = ret.wheelbase * 0.4 # wild guess + elif candidate == CAR.MALIBU: # supports stop and go, but initial engage must be above 18mph (which include conservatism) ret.minEnableSpeed = 18 * CV.MPH_TO_MS @@ -110,6 +120,15 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), vin="", has_relay ret.steerRatioRear = 0. ret.centerToFront = ret.wheelbase * 0.4 # guess for tourx + elif candidate == CAR.EQUINOX: + ret.minEnableSpeed = 18 * CV.MPH_TO_MS + ret.mass = 3500. * CV.LB_TO_KG + STD_CARGO_KG # (3849+3708)/2 + ret.safetyModel = car.CarParams.SafetyModel.gm + ret.wheelbase = 2.72 #107.3 inches in meters + ret.steerRatio = 14.4 # guess for tourx + ret.steerRatioRear = 0. # unknown online + ret.centerToFront = ret.wheelbase * 0.4 # wild guess + elif candidate == CAR.CADILLAC_ATS: ret.minEnableSpeed = 18 * CV.MPH_TO_MS ret.mass = 1601. + STD_CARGO_KG @@ -128,6 +147,15 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), vin="", has_relay ret.steerRatio = 14.6 # it's 16.3 without rear active steering ret.steerRatioRear = 0. # TODO: there is RAS on this car! ret.centerToFront = ret.wheelbase * 0.465 + elif candidate == CAR.ESCALADE: + # supports stop and go, but initial engage must be above 18mph (which include conservatism) + ret.minEnableSpeed = 18 * CV.MPH_TO_MS + ret.mass = 2645. + STD_CARGO_KG + ret.safetyModel = car.CarParams.SafetyModel.gm + ret.wheelbase = 3.30 + ret.steerRatio = 17.3 + ret.steerRatioRear = 0. + ret.centerToFront = ret.wheelbase * 0.4 # wild guess # TODO: get actual value, for now starting with reasonable value for @@ -295,8 +323,9 @@ def update(self, c, can_strings): events.append(create_event('pedalPressed', [ET.PRE_ENABLE])) if ret.cruiseState.standstill: events.append(create_event('resumeRequired', [ET.WARNING])) - if self.CS.pcm_acc_status == AccState.FAULTED: - events.append(create_event('controlsFailed', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) + if not self.CS.car_fingerprint in NO_ASCM_CARS: + if self.CS.pcm_acc_status == AccState.FAULTED: + events.append(create_event('controlsFailed', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) # handle button presses for b in ret.buttonEvents: diff --git a/selfdrive/car/gm/radar_interface.py b/selfdrive/car/gm/radar_interface.py index 1fb39c5c439921..8d78feb4a3f193 100755 --- a/selfdrive/car/gm/radar_interface.py +++ b/selfdrive/car/gm/radar_interface.py @@ -20,7 +20,7 @@ def create_radar_can_parser(canbus, car_fingerprint): dbc_f = DBC[car_fingerprint]['radar'] - if car_fingerprint in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA, CAR.ACADIA, CAR.CADILLAC_ATS): + if car_fingerprint in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA, CAR.ACADIA, CAR.CADILLAC_ATS, CAR.ESCALADE): # C1A-ARS3-A by Continental radar_targets = list(range(SLOT_1_MSG, SLOT_1_MSG + NUM_SLOTS)) signals = list(zip(['FLRRNumValidTargets', diff --git a/selfdrive/car/gm/values.py b/selfdrive/car/gm/values.py index 126ae9e40b0cac..48b60a1c124c03 100644 --- a/selfdrive/car/gm/values.py +++ b/selfdrive/car/gm/values.py @@ -9,8 +9,12 @@ class CAR: MALIBU = "CHEVROLET MALIBU PREMIER 2017" ACADIA = "GMC ACADIA DENALI 2018" BUICK_REGAL = "BUICK REGAL ESSENCE 2018" + BOLT = "CHEVROLET BOLT" + EQUINOX = "CHEVROLET EQUINOX" + ESCALADE = "CADILLAC ESCALADE 2018" SUPERCRUISE_CARS = [CAR.CADILLAC_CT6] +NO_ASCM_CARS = [CAR.BOLT, CAR.EQUINOX] class CruiseButtons: UNPRESS = 1 @@ -59,6 +63,16 @@ def parse_gear_shifter(can_gear): { 170: 8, 171: 8, 189: 7, 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 288: 5, 298: 8, 304: 1, 308: 4, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 6, 384: 4, 386: 8, 388: 8, 389: 2, 390: 7, 417: 7, 419: 1, 426: 7, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 528: 4, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 5, 567: 3, 568: 1, 573: 1, 577: 8, 578: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 3, 707: 8, 711: 6, 715: 8, 717: 5, 761: 7, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 967: 4, 969: 8, 977: 8, 979: 7, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1017: 8, 1019: 2, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1273: 3, 1275: 3, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1516: 8, 1601: 8, 1618: 8, 1905: 7, 1906: 7, 1907: 7, 1910: 7, 1912: 7, 1922: 7, 1927: 7, 1930: 7, 2016: 8, 2018: 8, 2020: 8, 2024: 8, 2028: 8 }], + # Bolt Premier no ACC + CAR.BOLT: [ + # Bolt Premier no ACC 2019 + { + 170: 8, 188: 8, 189: 7, 190: 6, 193: 8, 197: 8, 201: 8, 209: 7, 211: 2, 241: 6, 288: 5, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 322: 7, 328: 1, 352: 5, 353: 3, 381: 8, 384: 4, 386: 8, 388: 8, 390: 7, 407: 7, 417: 7, 419: 1, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 503: 2, 508: 8, 528: 5, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 7, 567: 5, 568: 2, 569: 3, 573: 1, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 3, 707: 8, 711: 6, 717: 5, 753: 5, 761: 7, 800: 6, 810: 8, 840: 5, 842: 5, 844: 8, 848: 4, 866: 4, 869: 4, 872: 1, 961: 8, 967: 4, 969: 8, 975: 2, 977: 8, 979: 7, 985: 5, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1022: 1, 1037: 5, 1105: 5, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1236: 8, 1243: 3, 1249: 8, 1257: 6, 1265: 8, 1268: 2, 1275: 3, 1279: 4, 1280: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1904: 7, 1905: 7, 1906: 7, 1907: 7, 1912: 7, 1913: 7, 1927: 7, 2016: 8, 2024: 8 + }, + # Bolt EV Premier 2017 + { + 170: 8, 188: 8, 189: 7, 190: 6, 192: 5, 193: 8, 197: 8, 201: 6, 209: 7, 211: 2, 241: 6, 289: 1, 290: 1, 298: 8, 304: 8, 309: 8, 311: 8, 313: 8, 320: 8, 322: 7, 328: 1, 352: 5, 353: 3, 368: 8, 381: 6, 384: 8, 386: 8, 388: 8, 390: 7, 407: 7, 417: 7, 419: 1, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 458: 8, 463: 3, 479: 3, 481: 7, 485: 8, 489: 5, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 503: 1, 508: 8, 512: 3, 514: 2, 516: 4, 519: 2, 521: 3, 528: 5, 530: 8, 532: 7, 537: 5, 539: 8, 542: 7, 546: 7, 550: 8, 554: 3, 558: 8, 560: 6, 562: 4, 563: 5, 564: 5, 565: 8, 566: 6, 567: 5, 568: 1, 569: 3, 573: 1, 577: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 3, 707: 8, 711: 6, 717: 5, 753: 5, 761: 7, 800: 6, 810: 8, 832: 8, 840: 6, 842: 6, 844: 8, 866: 4, 869: 4, 872: 1, 961: 8, 967: 4, 969: 8, 977: 8, 979: 7, 985: 5, 988: 6, 989: 8, 995: 7, 1001: 5, 1003: 5, 1005: 6, 1009: 8, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1022: 1, 1105: 6, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1243: 3, 1249: 8, 1257: 6, 1265: 8, 1275: 3, 1280: 4, 1300: 8, 1322: 6, 1328: 4, 1601: 8, 1904: 7, 1905: 7, 1906: 7, 1907: 7, 1912: 7, 1913: 7, 1927: 7, 2016: 8, 2020: 8, 2024: 8, 2028: 8 + }], CAR.BUICK_REGAL : [ # Regal TourX Essence w/ ACC 2018 { @@ -82,6 +96,15 @@ def parse_gear_shifter(can_gear): { 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 208: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 289: 8, 298: 8, 304: 1, 309: 8, 313: 8, 320: 3, 322: 7, 328: 1, 338: 6, 340: 6, 352: 5, 381: 8, 384: 4, 386: 8, 388: 8, 393: 8, 398: 8, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 454: 8, 455: 7, 462: 4, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 567: 5, 573: 1, 577: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 753: 5, 761: 7, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1017: 8, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1225: 8, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1328: 4, 1417: 8, 1601: 8, 1906: 7, 1907: 7, 1912: 7, 1914: 7, 1919: 7, 1920: 7, 1930: 7, 2016: 8, 2024: 8 }], + CAR.EQUINOX: [ + # Equinox w/o ACC 2020 + { + 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 289: 8, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 322: 7, 328: 1, 352: 5, 381: 8, 384: 4, 386: 8, 388: 8, 393: 8,398: 8, 401: 8, 413: 8, 417: 7, 419: 1, 422: 4, 426:7, 431: 8, 442: 8, 444: 7, 451: 8, 452: 8, 453: 6, 455: 7, 456: 8, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 528: 5, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 569: 3, 573: 1, 647: 6, 707: 8, 715: 8, 717: 5, 753: 5, 761: 7, 789: 5, 800: 6, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 882: 8,890: 1, 892: 2, 893: 2, 894: 1, 961: 8, 969: 8, 977:8, 979: 8, 985: 5, 1001: 8, 1009: 8, 1017: 8, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1223:2, 1225: 8, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1273: 3, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1328: 4, 1417: 8, 1906: 7, 1907: 7, 1912: 7, 1914: 7, 1916: 7, 1919: 7, 1920: 7, 1930: 7 + }], + CAR.ESCALADE: [ + { + 170: 8, 190: 6, 192: 5, 193: 8, 197: 8, 199: 4, 201: 8, 208: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 289: 1, 290: 1, 298: 8, 300: 1, 304: 8, 309: 8, 311: 8, 313: 8, 320: 8, 328: 1, 352: 5, 368: 8, 369: 8, 381: 5, 384: 4, 386: 5, 388: 8, 393: 7, 398: 8, 407: 7, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 454: 8, 455: 7, 463: 3, 479: 3, 481: 7, 485: 8, 487: 8, 489: 8, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 512: 3, 530: 8, 532: 6, 534: 2, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 573: 1, 577: 8, 578: 8, 579: 8, 587: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 719: 5, 761: 7, 789: 5, 800: 6, 801: 5, 803: 8, 804: 3, 805: 8, 810: 8, 821: 4, 823: 7, 832: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 967: 4, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1223: 2, 1225: 7, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1601: 8, 1602: 8, 1603: 7, 1611: 8, 1618: 8, 1906: 7, 1907: 7, 1912: 7, 1917: 7, 1918: 7, 1919: 7, 1920: 7, 1930: 7, 2016: 8, 2018: 8, 2019: 8, 2024: 8, 2026: 8 + }] } STEER_THRESHOLD = 1.0 @@ -96,9 +119,12 @@ class ECU: DBC = { CAR.HOLDEN_ASTRA: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.VOLT: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), + CAR.BOLT: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.MALIBU: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.ACADIA: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.CADILLAC_ATS: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.BUICK_REGAL: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), + CAR.EQUINOX: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.CADILLAC_CT6: dbc_dict('cadillac_ct6_powertrain', 'cadillac_ct6_object', chassis_dbc='cadillac_ct6_chassis'), + CAR.ESCALADE: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), } diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index dae175db02095b..42852213d1aa98 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -95,6 +95,10 @@ class ECU: #2020 Prius Prime Limited { 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 800: 8, 810: 2, 814: 8, 824: 2, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 974: 8, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1649: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2024: 8, 2026: 8, 2027: 8, 2029: 8, 2030: 8, 2031: 8 + }, + #2012 + { + 32: 7, 36: 8, 37: 8, 170: 8, 180: 8, 182: 4, 295: 8, 426: 6, 452: 8, 548: 8, 560: 7, 565: 6, 581: 5, 583: 5, 608: 8, 610: 5, 800: 8, 810: 2, 849: 4, 865: 4, 899: 8, 903: 8, 910: 8, 911: 1, 916: 1, 921: 7, 944: 6, 945: 8, 947: 3, 950: 8, 951: 8, 953: 3, 955: 4, 956: 8, 957: 1, 979: 2, 1017: 8, 1056: 8, 1057: 8, 1059: 1, 1088: 8, 1090: 8, 1091: 8, 1101: 8, 1116: 8, 1119: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1190: 8, 1191: 8, 1192: 8, 1217: 8, 1219: 8, 1222: 8, 1223: 8, 1224: 8, 1245: 8, 1552: 8, 1553: 8, 1555: 8, 1558: 8, 1568: 8, 1569: 8, 1570: 8, 1572: 8, 1574: 8, 1584: 8, 1586: 8, 1587: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1664: 8, 1728: 8 }], #Corolla w/ added Pedal Support (512L and 513L) CAR.COROLLA: [{ @@ -180,7 +184,12 @@ class ECU: # 2019 Taiwan Altis Hybrid { 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 765: 8, 800: 8, 810: 2, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 885: 8, 896: 8, 898: 8, 918: 7, 921: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 987: 8, 993: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1082: 8, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1172: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1745: 8, 1775: 8, 1779: 8 - }], + }, + # 2019 Chinese Levin Hybrid + { + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 765: 8, 800: 8, 810: 2, 812: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 885: 8, 896: 8, 898: 8, 921: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1172: 8, 1235: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1600: 8, 1649: 8, 1745: 8, 1775: 8, 1779: 8 + } + ], CAR.LEXUS_ES_TSS2: [{ 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 765: 8, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 824: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 987: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1775: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8 }], diff --git a/selfdrive/car/volkswagen/carcontroller.py b/selfdrive/car/volkswagen/carcontroller.py index 4ec662dce4c6bf..c17b5f60a170ea 100644 --- a/selfdrive/car/volkswagen/carcontroller.py +++ b/selfdrive/car/volkswagen/carcontroller.py @@ -181,7 +181,7 @@ def update(self, enabled, CS, frame, actuators, visual_alert, audible_alert, lef idx = (CS.graMsgBusCounter + 1) % 16 can_sends.append(volkswagencan.create_mqb_acc_buttons_control(self.packer_gw, canbus.extended, self.graButtonStatesToSend, CS, idx)) self.graMsgSentCount += 1 - if self.graMsgSentCount >= 16: + if self.graMsgSentCount >= P.GRA_VBP_COUNT: self.graButtonStatesToSend = None self.graMsgSentCount = 0 diff --git a/selfdrive/car/volkswagen/values.py b/selfdrive/car/volkswagen/values.py index 6a1106076c384f..045e03ae33c89a 100644 --- a/selfdrive/car/volkswagen/values.py +++ b/selfdrive/car/volkswagen/values.py @@ -51,13 +51,6 @@ class CAR: }], } -class ECU: - CAM = 0 - -ECU_FINGERPRINT = { - ECU.CAM: [294, 919], # HCA_01 Heading Control Assist, LDW_02 Lane Departure Warning -} - DBC = { CAR.GOLF: dbc_dict('vw_mqb_2010', None), } diff --git a/selfdrive/common/visionbuf_cl.c b/selfdrive/common/visionbuf_cl.c new file mode 100644 index 00000000000000..58c66a854d9c3c --- /dev/null +++ b/selfdrive/common/visionbuf_cl.c @@ -0,0 +1,89 @@ +#include "visionbuf.h" + +#include +#include +#include + +#ifdef __APPLE__ +#include +#else +#include +#endif + +VisionBuf visionbuf_allocate(size_t len) { + // const size_t alignment = 4096; + // void* addr = aligned_alloc(alignment, alignment * ((len - 1) / alignment + 1)); + void* addr = calloc(1, len); + + return (VisionBuf){ + .len = len, .addr = addr, .handle = 1, .fd = -1, + }; +} + +cl_mem visionbuf_to_cl(const VisionBuf* buf, cl_device_id device_id, cl_context ctx) { + // HACK because this platform is just for convenience + VisionBuf *w_buf = (VisionBuf*)buf; + cl_mem ret; + *w_buf = visionbuf_allocate_cl(buf->len, device_id, ctx, &ret); + return ret; +} + +VisionBuf visionbuf_allocate_cl(size_t len, cl_device_id device_id, cl_context ctx, cl_mem *out_mem) { + int err; + assert(out_mem); + +#if __OPENCL_VERSION__ >= 200 + void* host_ptr = + clSVMAlloc(ctx, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER, len, 0); + assert(host_ptr); +#else + void* host_ptr = calloc(1, len); + + cl_command_queue q = clCreateCommandQueue(ctx, device_id, 0, &err); + assert(err == 0); +#endif + + cl_mem mem = clCreateBuffer(ctx, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, len, host_ptr, &err); + assert(err == 0); + + *out_mem = mem; + + return (VisionBuf){ + .len = len, .addr = host_ptr, .handle = 0, .fd = -1, + .device_id = device_id, .ctx = ctx, .buf_cl = mem, + +#if __OPENCL_VERSION__ < 200 + .copy_q = q, +#endif + + }; +} + +void visionbuf_sync(const VisionBuf* buf, int dir) { + int err = 0; + if (!buf->buf_cl) return; + +#if __OPENCL_VERSION__ < 200 + if (dir == VISIONBUF_SYNC_FROM_DEVICE) { + err = clEnqueueReadBuffer(buf->copy_q, buf->buf_cl, CL_FALSE, 0, buf->len, buf->addr, 0, NULL, NULL); + } else { + err = clEnqueueWriteBuffer(buf->copy_q, buf->buf_cl, CL_FALSE, 0, buf->len, buf->addr, 0, NULL, NULL); + } + assert(err == 0); + clFinish(buf->copy_q); +#endif +} + +void visionbuf_free(const VisionBuf* buf) { + if (buf->handle) { + free(buf->addr); + } else { + int err = clReleaseMemObject(buf->buf_cl); + assert(err == 0); +#if __OPENCL_VERSION__ >= 200 + clSVMFree(buf->ctx, buf->addr); +#else + free(buf->addr); +#endif + } +} diff --git a/selfdrive/controls/lib/latcontrol_indi.py b/selfdrive/controls/lib/latcontrol_indi.py index db1192f8396f1c..d98b2efd8e7d7f 100644 --- a/selfdrive/controls/lib/latcontrol_indi.py +++ b/selfdrive/controls/lib/latcontrol_indi.py @@ -32,7 +32,7 @@ def __init__(self, CP): self.A_K = A - np.dot(K, C) self.x = np.matrix([[0.], [0.], [0.]]) - self.enfore_rate_limit = CP.carName == "toyota" + self.enforce_rate_limit = CP.carName == "toyota" self.RC = CP.lateralTuning.indi.timeConstant self.G = CP.lateralTuning.indi.actuatorEffectiveness @@ -81,7 +81,7 @@ def update(self, active, v_ego, angle_steers, angle_steers_rate, eps_torque, ste delta_u = g_inv * accel_error # Enforce rate limit - if self.enfore_rate_limit: + if self.enforce_rate_limit: steer_max = float(SteerLimitParams.STEER_MAX) new_output_steer_cmd = steer_max * (self.delayed_output + delta_u) prev_output_steer_cmd = steer_max * self.output_steer diff --git a/selfdrive/manager.py b/selfdrive/manager.py index cb6b6b16e9e542..fbb37c51d2721d 100755 --- a/selfdrive/manager.py +++ b/selfdrive/manager.py @@ -377,8 +377,8 @@ def manager_thread(): running_list = [" running %s %s" % (p, running[p]) for p in running] cloudlog.debug('\n'.join(running_list)) - # is this still needed? - if params.get("DoUninstall") == "1": + # Exit main loop when uninstall is needed + if params.get("DoUninstall", encoding='utf8') == "1": break def get_installed_apks(): @@ -555,7 +555,7 @@ def main(): finally: cleanup_all_processes(None, None) - if params.get("DoUninstall") == "1": + if params.get("DoUninstall", encoding='utf8') == "1": uninstall() if __name__ == "__main__": diff --git a/selfdrive/thermald.py b/selfdrive/thermald.py index 0886335e136cc8..eeec3f3b11a1b8 100755 --- a/selfdrive/thermald.py +++ b/selfdrive/thermald.py @@ -189,11 +189,10 @@ def thermald_thread(): max_comp_temp = max(max_cpu_temp, msg.thermal.mem / 10., msg.thermal.gpu / 10.) bat_temp = msg.thermal.bat/1000. - if health is not None: - if health.health.hwType == log.HealthData.HwType.uno: - fan_speed = handle_fan_uno(max_cpu_temp, bat_temp, fan_speed) - else: - fan_speed = handle_fan_eon(max_cpu_temp, bat_temp, fan_speed) + if health is not None and health.health.hwType == log.HealthData.HwType.uno: + fan_speed = handle_fan_uno(max_cpu_temp, bat_temp, fan_speed) + else: + fan_speed = handle_fan_eon(max_cpu_temp, bat_temp, fan_speed) msg.thermal.fanSpeed = fan_speed diff --git a/selfdrive/visiond/build_from_src.mk b/selfdrive/visiond/build_from_src.mk index 639f0a95df7741..725b345fa42002 100644 --- a/selfdrive/visiond/build_from_src.mk +++ b/selfdrive/visiond/build_from_src.mk @@ -54,9 +54,9 @@ else OPENCL_LIBS = -lOpenCL - TF_FLAGS = -I$(EXTERNAL)/tensorflow/include - TF_LIBS = -L$(EXTERNAL)/tensorflow/lib -ltensorflow \ - -Wl,-rpath $(EXTERNAL)/tensorflow/lib + #TF_FLAGS = -I$(EXTERNAL)/tensorflow/include + #TF_LIBS = -L$(EXTERNAL)/tensorflow/lib -ltensorflow \ + # -Wl,-rpath $(EXTERNAL)/tensorflow/lib SNPE_FLAGS = -I$(PHONELIBS)/snpe/include/ SNPE_LIBS = -L$(PHONELIBS)/snpe/x86_64-linux-clang/ \ @@ -69,7 +69,7 @@ else PLATFORM_OBJS = cameras/camera_frame_stream.o \ ../common/visionbuf_cl.o \ ../common/visionimg.o \ - runners/tfmodel.o + # runners/tfmodel.o endif SSL_FLAGS = -I/usr/include/openssl/ diff --git a/selfdrive/visiond/cameras/camera_frame_stream.h b/selfdrive/visiond/cameras/camera_frame_stream.h index 6351a183d35c3c..5cb7e27c5fa72a 100644 --- a/selfdrive/visiond/cameras/camera_frame_stream.h +++ b/selfdrive/visiond/cameras/camera_frame_stream.h @@ -33,6 +33,8 @@ typedef struct CameraState { int fps; float digital_gain; + float cur_gain_frac; + mat3 transform; } CameraState; diff --git a/tools b/tools new file mode 160000 index 00000000000000..c9cb2aae4e9040 --- /dev/null +++ b/tools @@ -0,0 +1 @@ +Subproject commit c9cb2aae4e90402f04cd50bb7877be3a6d70c59d