VW: match openpilot standstill check (#1064)

* VW: match openpilot standstill check

* fixes

* check > 0

* fix comments

* misra

* better
This commit is contained in:
Shane Smiskol 2023-01-10 22:00:20 -08:00 committed by GitHub
parent 744b21ef69
commit 0b3b906036
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 12 deletions

View File

@ -120,15 +120,16 @@ static int volkswagen_mqb_rx_hook(CANPacket_t *to_push) {
if (valid && (GET_BUS(to_push) == 0U)) {
int addr = GET_ADDR(to_push);
// Update in-motion state by sampling front wheel speeds
// Signal: ESP_19.ESP_VL_Radgeschw_02 (front left) in scaled km/h
// Signal: ESP_19.ESP_VR_Radgeschw_02 (front right) in scaled km/h
// Update in-motion state by sampling wheel speeds
if (addr == MSG_ESP_19) {
int wheel_speed_fl = GET_BYTE(to_push, 4) | (GET_BYTE(to_push, 5) << 8);
int wheel_speed_fr = GET_BYTE(to_push, 6) | (GET_BYTE(to_push, 7) << 8);
// Check for average front speed in excess of 0.3m/s, 1.08km/h
// DBC speed scale 0.0075: 0.3m/s = 144, sum both wheels to compare
vehicle_moving = (wheel_speed_fl + wheel_speed_fr) > 288;
// sum 4 wheel speeds
int speed = 0;
for (uint8_t i = 0U; i < 8U; i += 2U) {
int wheel_speed = GET_BYTE(to_push, i) | (GET_BYTE(to_push, i + 1U) << 8);
speed += wheel_speed;
}
// Check all wheel speeds for any movement
vehicle_moving = speed > 0;
}
// Update driver input torque samples

View File

@ -109,8 +109,7 @@ static int volkswagen_pq_rx_hook(CANPacket_t *to_push) {
// Signal: Bremse_1.Geschwindigkeit_neu__Bremse_1_
if (addr == MSG_BREMSE_1) {
int speed = ((GET_BYTE(to_push, 2) & 0xFEU) >> 1) | (GET_BYTE(to_push, 3) << 7);
// DBC speed scale 0.01: 0.3m/s = 108.
vehicle_moving = speed > 108;
vehicle_moving = speed > 0;
}
// Update driver input torque samples

View File

@ -23,7 +23,7 @@ MSG_LDW_02 = 0x397 # TX by OP, Lane line recognition and text alerts
class TestVolkswagenMqbSafety(common.PandaSafetyTest, common.DriverTorqueSteeringSafetyTest):
STANDSTILL_THRESHOLD = 1
STANDSTILL_THRESHOLD = 0
RELAY_MALFUNCTION_ADDR = MSG_HCA_01
RELAY_MALFUNCTION_BUS = 0

View File

@ -23,7 +23,7 @@ MIN_ACCEL = -3.5
class TestVolkswagenPqSafety(common.PandaSafetyTest, common.DriverTorqueSteeringSafetyTest):
cruise_engaged = False
STANDSTILL_THRESHOLD = 1
STANDSTILL_THRESHOLD = 0
RELAY_MALFUNCTION_ADDR = MSG_HCA_1
RELAY_MALFUNCTION_BUS = 0