Add Full GM GasRegenCmd

This commit is contained in:
garrettpall
2024-01-12 22:39:30 -07:00
committed by FrogAi
parent 955950381f
commit beb4faf213
6 changed files with 39 additions and 25 deletions

View File

@@ -215,6 +215,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"AccelerationProfile", PERSISTENT}, {"AccelerationProfile", PERSISTENT},
{"ApiCache_DriveStats", PERSISTENT}, {"ApiCache_DriveStats", PERSISTENT},
{"FrogPilotTogglesUpdated", PERSISTENT}, {"FrogPilotTogglesUpdated", PERSISTENT},
{"GasRegenCmd", PERSISTENT},
{"LateralTune", PERSISTENT}, {"LateralTune", PERSISTENT},
{"LongitudinalTune", PERSISTENT}, {"LongitudinalTune", PERSISTENT},
}; };

View File

@@ -207,15 +207,14 @@ BO_ 711 BECMBatteryVoltageCurrent: 6 K17_EBCM
SG_ HVBatteryCurrent : 12|13@0- (0.15,0) [-614.4|614.25] "A" NEO SG_ HVBatteryCurrent : 12|13@0- (0.15,0) [-614.4|614.25] "A" NEO
BO_ 715 ASCMGasRegenCmd: 8 K124_ASCM BO_ 715 ASCMGasRegenCmd: 8 K124_ASCM
SG_ GasRegenAlwaysOne2 : 9|1@0+ (1,0) [0|1] "" NEO
SG_ GasRegenAlwaysOne : 14|1@0+ (1,0) [0|1] "" NEO
SG_ GasRegenChecksum : 47|24@0+ (1,0) [0|0] "" NEO
SG_ GasRegenCmdActiveInv : 32|1@0+ (1,0) [0|0] "" NEO
SG_ GasRegenFullStopActive : 13|1@0+ (1,0) [0|0] "" NEO
SG_ GasRegenCmdActive : 0|1@0+ (1,0) [0|0] "" NEO SG_ GasRegenCmdActive : 0|1@0+ (1,0) [0|0] "" NEO
SG_ RollingCounter : 7|2@0+ (1,0) [0|0] "" NEO SG_ RollingCounter : 7|2@0+ (1,0) [0|0] "" NEO
SG_ GasRegenAlwaysOne3 : 23|1@0+ (1,0) [0|1] "" NEO SG_ GasRegenCmd : 8|14@0+ (1,0) [0|0] "" NEO
SG_ GasRegenCmd : 22|12@0+ (1,0) [0|0] "" NEO SG_ GasRegenAlwaysOne2 : 9|1@0+ (1,0) [0|1] "" NEO
SG_ GasRegenFullStopActive : 13|1@0+ (1,0) [0|0] "" NEO
SG_ GasRegenAlwaysOne : 14|1@0+ (1,0) [0|1] "" NEO
SG_ GasRegenCmdActiveInv : 32|1@0+ (1,0) [0|0] "" NEO
SG_ GasRegenChecksum : 47|24@0+ (1,0) [0|0] "" NEO
BO_ 717 ASCM_2CD: 5 K124_ASCM BO_ 717 ASCM_2CD: 5 K124_ASCM

View File

@@ -10,16 +10,16 @@ const SteeringLimits GM_STEERING_LIMITS = {
}; };
const LongitudinalLimits GM_ASCM_LONG_LIMITS = { const LongitudinalLimits GM_ASCM_LONG_LIMITS = {
.max_gas = 3072, .max_gas = 7168,
.min_gas = 1404, .min_gas = 5500,
.inactive_gas = 1404, .inactive_gas = 5500,
.max_brake = 400, .max_brake = 400,
}; };
const LongitudinalLimits GM_CAM_LONG_LIMITS = { const LongitudinalLimits GM_CAM_LONG_LIMITS = {
.max_gas = 3400, .max_gas = 8650,
.min_gas = 1514, .min_gas = 5610,
.inactive_gas = 1554, .inactive_gas = 5650,
.max_brake = 400, .max_brake = 400,
}; };
@@ -163,7 +163,7 @@ static bool gm_tx_hook(CANPacket_t *to_send) {
// GAS/REGEN: safety check // GAS/REGEN: safety check
if (addr == 0x2CB) { if (addr == 0x2CB) {
bool apply = GET_BIT(to_send, 0U) != 0U; bool apply = GET_BIT(to_send, 0U) != 0U;
int gas_regen = ((GET_BYTE(to_send, 2) & 0x7FU) << 5) + ((GET_BYTE(to_send, 3) & 0xF8U) >> 3); int gas_regen = ((GET_BYTE(to_send, 1) & 0x1U) << 13) + ((GET_BYTE(to_send, 2) & 0xFFU) << 5) + ((GET_BYTE(to_send, 3) & 0xF8U) >> 3);
bool violation = false; bool violation = false;
// Allow apply bit in pre-enabled and overriding states // Allow apply bit in pre-enabled and overriding states

8
selfdrive/car/gm/interface.py Executable file → Normal file
View File

@@ -7,7 +7,7 @@ from openpilot.common.conversions import Conversions as CV
from openpilot.common.params import Params from openpilot.common.params import Params
from openpilot.selfdrive.car import create_button_events, get_safety_config from openpilot.selfdrive.car import create_button_events, get_safety_config
from openpilot.selfdrive.car.gm.radar_interface import RADAR_HEADER_MSG from openpilot.selfdrive.car.gm.radar_interface import RADAR_HEADER_MSG
from openpilot.selfdrive.car.gm.values import CAR, CruiseButtons, CarControllerParams, EV_CAR, CAMERA_ACC_CAR, CanBus, GMFlags, CC_ONLY_CAR from openpilot.selfdrive.car.gm.values import CAR, CruiseButtons, CarControllerParams, EV_CAR, CAMERA_ACC_CAR, CanBus, GMFlags, CC_ONLY_CAR, SLOW_ACC
from openpilot.selfdrive.car.interfaces import CarInterfaceBase, TorqueFromLateralAccelCallbackType, FRICTION_THRESHOLD from openpilot.selfdrive.car.interfaces import CarInterfaceBase, TorqueFromLateralAccelCallbackType, FRICTION_THRESHOLD
from openpilot.selfdrive.controls.lib.drive_helpers import get_friction from openpilot.selfdrive.controls.lib.drive_helpers import get_friction
@@ -78,6 +78,7 @@ class CarInterface(CarInterfaceBase):
def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs):
# FrogPilot variables # FrogPilot variables
params = params() params = params()
useGasRegenCmd = params.get_bool("GasRegenCmd")
ret.carName = "gm" ret.carName = "gm"
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.gm)] ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.gm)]
@@ -110,6 +111,9 @@ class CarInterface(CarInterfaceBase):
ret.vEgoStopping = 0.25 ret.vEgoStopping = 0.25
ret.vEgoStarting = 0.25 ret.vEgoStarting = 0.25
if candidate in SLOW_ACC and useGasRegenCmd:
ret.longitudinalTuning.kpV = [1.5, 1.125]
if experimental_long: if experimental_long:
ret.pcmCruise = False ret.pcmCruise = False
ret.openpilotLongitudinalControl = True ret.openpilotLongitudinalControl = True
@@ -239,6 +243,8 @@ class CarInterface(CarInterfaceBase):
ret.steerRatio = 16.3 ret.steerRatio = 16.3
ret.centerToFront = ret.wheelbase * 0.5 ret.centerToFront = ret.wheelbase * 0.5
ret.tireStiffnessFactor = 1.0 ret.tireStiffnessFactor = 1.0
if useGasRegenCmd:
ret.stopAccel = -0.25
# On the Bolt, the ECM and camera independently check that you are either above 5 kph or at a stop # On the Bolt, the ECM and camera independently check that you are either above 5 kph or at a stop
# with foot on brake to allow engagement, but this platform only has that check in the camera. # with foot on brake to allow engagement, but this platform only has that check in the camera.
# TODO: check if this is split by EV/ICE with more platforms in the future # TODO: check if this is split by EV/ICE with more platforms in the future

View File

@@ -4,6 +4,7 @@ from enum import Enum, StrEnum
from typing import Dict, List, Union from typing import Dict, List, Union
from cereal import car from cereal import car
from openpilot.common.params import Params
from openpilot.selfdrive.car import dbc_dict from openpilot.selfdrive.car import dbc_dict
from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column
Ecu = car.CarParams.Ecu Ecu = car.CarParams.Ecu
@@ -35,21 +36,24 @@ class CarControllerParams:
def __init__(self, CP): def __init__(self, CP):
# Gas/brake lookups # Gas/brake lookups
self.ZERO_GAS = 2048 # Coasting self.ZERO_GAS = 6144 # Coasting
self.MAX_BRAKE = 400 # ~ -4.0 m/s^2 with regen self.MAX_BRAKE = 400 # ~ -4.0 m/s^2 with regen
if CP.carFingerprint in CAMERA_ACC_CAR and CP.carFingerprint not in CC_ONLY_CAR: if CP.carFingerprint in CAMERA_ACC_CAR and CP.carFingerprint not in CC_ONLY_CAR:
self.MAX_GAS = 3400 self.MAX_GAS = 7496
self.MAX_ACC_REGEN = 1514 self.MAX_ACC_REGEN = 5610
self.INACTIVE_REGEN = 1554 self.INACTIVE_REGEN = 5650
# Camera ACC vehicles have no regen while enabled. # Camera ACC vehicles have no regen while enabled.
# Camera transitions to MAX_ACC_REGEN from ZERO_GAS and uses friction brakes instantly # Camera transitions to MAX_ACC_REGEN from ZERO_GAS and uses friction brakes instantly
max_regen_acceleration = 0. max_regen_acceleration = 0.
if CP.carFingerprint in SLOW_ACC and Params().get_bool("GasRegenCmd"):
self.MAX_GAS = 8650
else: else:
self.MAX_GAS = 3072 # Safety limit, not ACC max. Stock ACC >4096 from standstill. self.MAX_GAS = 7168 # Safety limit, not ACC max. Stock ACC >8192 from standstill.
self.MAX_ACC_REGEN = 1404 # Max ACC regen is slightly less than max paddle regen self.MAX_ACC_REGEN = 5500 # Max ACC regen is slightly less than max paddle regen
self.INACTIVE_REGEN = 1404 self.INACTIVE_REGEN = 5500
# ICE has much less engine braking force compared to regen in EVs, # ICE has much less engine braking force compared to regen in EVs,
# lower threshold removes some braking deadzone # lower threshold removes some braking deadzone
max_regen_acceleration = -1. if CP.carFingerprint in EV_CAR else -0.1 max_regen_acceleration = -1. if CP.carFingerprint in EV_CAR else -0.1
@@ -175,6 +179,9 @@ DBC[CAR.VOLT_CC] = DBC[CAR.VOLT]
EV_CAR = {CAR.VOLT, CAR.BOLT_EUV, CAR.VOLT_CC, CAR.BOLT_CC} EV_CAR = {CAR.VOLT, CAR.BOLT_EUV, CAR.VOLT_CC, CAR.BOLT_CC}
CC_ONLY_CAR = {CAR.VOLT_CC, CAR.BOLT_CC, CAR.EQUINOX_CC, CAR.SUBURBAN_CC, CAR.YUKON_CC, CAR.CT6_CC, CAR.TRAILBLAZER_CC} CC_ONLY_CAR = {CAR.VOLT_CC, CAR.BOLT_CC, CAR.EQUINOX_CC, CAR.SUBURBAN_CC, CAR.YUKON_CC, CAR.CT6_CC, CAR.TRAILBLAZER_CC}
# Slow acceleration cars
SLOW_ACC = {CAR.SILVERADO}
# We're integrated at the camera with VOACC on these cars (instead of ASCM w/ OBD-II harness) # We're integrated at the camera with VOACC on these cars (instead of ASCM w/ OBD-II harness)
CAMERA_ACC_CAR = {CAR.BOLT_EUV, CAR.SILVERADO, CAR.EQUINOX, CAR.TRAILBLAZER} CAMERA_ACC_CAR = {CAR.BOLT_EUV, CAR.SILVERADO, CAR.EQUINOX, CAR.TRAILBLAZER}
CAMERA_ACC_CAR.update({CAR.VOLT_CC, CAR.BOLT_CC, CAR.EQUINOX_CC, CAR.YUKON_CC, CAR.CT6_CC, CAR.TRAILBLAZER_CC}) CAMERA_ACC_CAR.update({CAR.VOLT_CC, CAR.BOLT_CC, CAR.EQUINOX_CC, CAR.YUKON_CC, CAR.CT6_CC, CAR.TRAILBLAZER_CC})

View File

@@ -3,6 +3,7 @@
FrogPilotVehiclesPanel::FrogPilotVehiclesPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) { FrogPilotVehiclesPanel::FrogPilotVehiclesPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) {
std::vector<std::tuple<QString, QString, QString, QString>> vehicleToggles { std::vector<std::tuple<QString, QString, QString, QString>> vehicleToggles {
{"GasRegenCmd", "Gas Regen Cmd", "", ""},
}; };
for (auto &[param, title, desc, icon] : vehicleToggles) { for (auto &[param, title, desc, icon] : vehicleToggles) {
@@ -17,7 +18,7 @@ FrogPilotVehiclesPanel::FrogPilotVehiclesPanel(SettingsWindow *parent) : FrogPil
}); });
} }
gmKeys = {}; gmKeys = {"GasRegenCmd"};
toyotaKeys = {}; toyotaKeys = {};
std::set<std::string> rebootKeys = {}; std::set<std::string> rebootKeys = {};