Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FCA Giorgio: Alfa Romeo Stelvio #32898

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a7ed652
bump opendbc
jyoung8607 Apr 26, 2024
fd156fc
Merge branch 'master' of https://github.com/commaai/openpilot into al…
jyoung8607 May 2, 2024
cb6343b
bump opendbc
jyoung8607 May 15, 2024
cf21bc7
Merge branch 'master' of https://github.com/commaai/openpilot into al…
jyoung8607 May 15, 2024
63de6f5
bump opendbc
jyoung8607 May 15, 2024
52e6a57
bump cereal
jyoung8607 May 15, 2024
36ac538
hold my beer
jyoung8607 May 16, 2024
48845e1
bump opendbc
jyoung8607 May 16, 2024
c1e2a98
add turn signals, bump opendbc
jyoung8607 May 16, 2024
5457dbb
bump opendbc
jyoung8607 May 17, 2024
045dbed
bump opendbc
jyoung8607 May 17, 2024
94027fd
rename and bump opendbc
jyoung8607 May 22, 2024
b9852e0
bump opendbc
jyoung8607 May 22, 2024
45465f3
bump opendbc
jyoung8607 May 22, 2024
4cbfa8c
bump opendbc
jyoung8607 May 22, 2024
08e10f9
checkpoint
jyoung8607 May 22, 2024
8d5ff24
checkpoint
jyoung8607 May 22, 2024
f4358ec
switch to FCA Giorgio safety mode
jyoung8607 May 22, 2024
11d7ab1
bump submodules
jyoung8607 Jul 2, 2024
3f22626
Merge branch 'master' of https://github.com/commaai/openpilot into al…
jyoung8607 Jul 2, 2024
598b74e
re-add fcaGiorgio as a safety mode
jyoung8607 Jul 2, 2024
919e1f8
adjust driver torque threshold, update harness
jyoung8607 Jul 2, 2024
87e8925
bump panda
jyoung8607 Jul 2, 2024
1428802
checkpoint
jyoung8607 Jul 2, 2024
d923607
bump panda
jyoung8607 Jul 3, 2024
60eadd6
restore whitespace
jyoung8607 Jul 3, 2024
cee180d
bump panda
jyoung8607 Jul 3, 2024
856185b
bump limits for testing
jyoung8607 Jul 3, 2024
4242ece
bump opendbc
jyoung8607 Jul 3, 2024
19c5d35
detect EPS LKA faults
jyoung8607 Jul 3, 2024
54c9666
bump panda
jyoung8607 Jul 3, 2024
b5b9f46
set torque limits
jyoung8607 Jul 3, 2024
ec4ef87
fix Boolean type for fault flag
jyoung8607 Jul 3, 2024
56538a3
tweak lat accel constants
jyoung8607 Jul 4, 2024
fe10730
increase min torque for driver override
jyoung8607 Jul 4, 2024
dc51cee
bump opendbc
jyoung8607 Jul 9, 2024
e1e9860
Merge branch 'master' of https://github.com/commaai/openpilot into al…
jyoung8607 Jul 9, 2024
ef1c7ed
refine lat control constants
jyoung8607 Jul 9, 2024
b0bfab2
steer ratio closer to paramsd learned value
jyoung8607 Jul 9, 2024
c710cc9
retune steerActuatorDelay based on data
jyoung8607 Jul 9, 2024
5565b43
steerLimitTimer can be longer with lat accel control
jyoung8607 Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ struct CarParams {
volkswagenMqbEvo @29;
chryslerCusw @30;
psa @31;
fcaGiorgio @32; # certain FCA/Stellantis vehicles including Jeep, Alfa Romeo, and Maserati
}

enum SteerControlType {
Expand Down
3 changes: 2 additions & 1 deletion docs/CARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

A supported vehicle is one that just works when you install a comma device. All supported cars provide a better experience than any stock system. Supported vehicles reference the US market unless otherwise specified.

# 287 Supported Cars
# 288 Supported Cars

|Make|Model|Supported Package|ACC|No ACC accel below|No ALC below|Steering Torque|Resume from stop|<a href="##"><img width=2000></a>Hardware Needed<br>&nbsp;|Video|
|---|---|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|Acura|ILX 2016-19|AcuraWatch Plus|openpilot|25 mph|25 mph|[![star](assets/icon-star-empty.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<details><summary>Parts</summary><sub>- 1 Honda Nidec connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Acura&model=ILX 2016-19">Buy Here</a></sub></details>||
|Acura|RDX 2016-18|AcuraWatch Plus|openpilot|25 mph|12 mph|[![star](assets/icon-star-empty.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<details><summary>Parts</summary><sub>- 1 Honda Nidec connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Acura&model=RDX 2016-18">Buy Here</a></sub></details>||
|Acura|RDX 2019-22|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|3 mph|[![star](assets/icon-star-empty.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Honda Bosch A connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Acura&model=RDX 2019-22">Buy Here</a></sub></details>||
|Alfa|Romeo Stelvio 2017-24|Adaptive Cruise Control (ACC) & Lane Assist|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 RJ45 cable (7 ft)<br>- 1 VW A connector<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Alfa&model=Romeo Stelvio 2017-24">Buy Here</a></sub></details>||
|Audi|A3 2014-19|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[<sup>1,12</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 USB-C coupler<br>- 1 VW J533 connector<br>- 1 comma 3X<br>- 1 harness box<br>- 1 long OBD-C cable<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Audi&model=A3 2014-19">Buy Here</a></sub></details>||
|Audi|A3 Sportback e-tron 2017-18|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[<sup>1,12</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 USB-C coupler<br>- 1 VW J533 connector<br>- 1 comma 3X<br>- 1 harness box<br>- 1 long OBD-C cable<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Audi&model=A3 Sportback e-tron 2017-18">Buy Here</a></sub></details>||
|Audi|Q2 2018|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[<sup>1,12</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 USB-C coupler<br>- 1 VW J533 connector<br>- 1 comma 3X<br>- 1 harness box<br>- 1 long OBD-C cable<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Audi&model=Q2 2018">Buy Here</a></sub></details>||
Expand Down
2 changes: 2 additions & 0 deletions launch_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ if [ -z "$AGNOS_VERSION" ]; then
fi

export STAGING_ROOT="/data/safe_staging"

export FINGERPRINT="ALFA_ROMEO_STELVIO_1ST_GEN"
2 changes: 1 addition & 1 deletion opendbc
2 changes: 1 addition & 1 deletion panda
Empty file.
46 changes: 46 additions & 0 deletions selfdrive/car/fca_giorgio/carcontroller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from opendbc.can.packer import CANPacker
from openpilot.selfdrive.car import apply_driver_steer_torque_limits
from openpilot.selfdrive.car.interfaces import CarControllerBase

from openpilot.selfdrive.car.fca_giorgio import fca_giorgiocan
from openpilot.selfdrive.car.fca_giorgio.values import CANBUS, CarControllerParams


class CarController(CarControllerBase):
def __init__(self, dbc_name, CP, VM):
self.CP = CP
self.CCP = CarControllerParams(CP)
self.packer_pt = CANPacker(dbc_name)

self.apply_steer_last = 0
self.frame = 0

def update(self, CC, CS, now_nanos):
actuators = CC.actuators
can_sends = []

# **** Steering Controls ************************************************ #

if self.frame % self.CCP.STEER_STEP == 0:
if CC.latActive:
new_steer = int(round(actuators.steer * self.CCP.STEER_MAX))
apply_steer = apply_driver_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, self.CCP)
else:
apply_steer = 0

self.apply_steer_last = apply_steer
can_sends.append(fca_giorgiocan.create_steering_control(self.packer_pt, CANBUS.pt, apply_steer, CC.latActive))

# **** HUD Controls ***************************************************** #

if self.frame % self.CCP.HUD_1_STEP == 0:
can_sends.append(fca_giorgiocan.create_lka_hud_1_control(self.packer_pt, CANBUS.pt, CC.latActive))
if self.frame % self.CCP.HUD_2_STEP == 0:
can_sends.append(fca_giorgiocan.create_lka_hud_2_control(self.packer_pt, CANBUS.pt, CC.latActive))

new_actuators = actuators.as_builder()
new_actuators.steer = self.apply_steer_last / self.CCP.STEER_MAX
new_actuators.steerOutputCan = self.apply_steer_last

self.frame += 1
return new_actuators, can_sends
88 changes: 88 additions & 0 deletions selfdrive/car/fca_giorgio/carstate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import numpy as np
from cereal import car
from openpilot.common.conversions import Conversions as CV
from openpilot.selfdrive.car.interfaces import CarStateBase
from opendbc.can.parser import CANParser
from openpilot.selfdrive.car.fca_giorgio.values import DBC, CANBUS, CarControllerParams


GearShifter = car.CarState.GearShifter

class CarState(CarStateBase):
def __init__(self, CP):
super().__init__(CP)
self.frame = 0
self.CCP = CarControllerParams(CP)

def update(self, pt_cp, cam_cp):
ret = car.CarState.new_message()
# Update vehicle speed and acceleration from ABS wheel speeds.
ret.wheelSpeeds = self.get_wheel_speeds(
pt_cp.vl["ABS_1"]["WHEEL_SPEED_FL"],
pt_cp.vl["ABS_1"]["WHEEL_SPEED_FR"],
pt_cp.vl["ABS_1"]["WHEEL_SPEED_RL"],
pt_cp.vl["ABS_1"]["WHEEL_SPEED_RR"],
unit=1.0
)

ret.vEgoRaw = float(np.mean([ret.wheelSpeeds.fl, ret.wheelSpeeds.fr, ret.wheelSpeeds.rl, ret.wheelSpeeds.rr]))
ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw)
ret.standstill = ret.vEgoRaw == 0

ret.steeringAngleDeg = pt_cp.vl["EPS_1"]["STEERING_ANGLE"]
ret.steeringRateDeg = pt_cp.vl["EPS_1"]["STEERING_RATE"]
ret.steeringTorque = pt_cp.vl["EPS_2"]["DRIVER_TORQUE"]
ret.steeringTorqueEps = pt_cp.vl["EPS_3"]["EPS_TORQUE"]
ret.steeringPressed = ret.steeringTorque > 80
ret.yawRate = pt_cp.vl["ABS_2"]["YAW_RATE"]
ret.steerFaultPermanent = bool(pt_cp.vl["EPS_2"]["LKA_FAULT"])

# TODO: unsure if this is accel pedal or engine throttle
#ret.gas = pt_cp.vl["ENGINE_1"]["ACCEL_PEDAL"]
ret.gasPressed = ret.gas > 0
ret.brake = pt_cp.vl["ABS_4"]["BRAKE_PRESSURE"]
ret.brakePressed = bool(pt_cp.vl["ABS_3"]["BRAKE_PEDAL_SWITCH"])
#ret.parkingBrake = TODO

if bool(pt_cp.vl["ENGINE_1"]["REVERSE"]):
ret.gearShifter = GearShifter.reverse
else:
ret.gearShifter = GearShifter.drive

ret.cruiseState.available = pt_cp.vl["ACC_1"]["CRUISE_STATUS"] in (1, 2, 3)
ret.cruiseState.enabled = pt_cp.vl["ACC_1"]["CRUISE_STATUS"] in (2, 3)
ret.cruiseState.speed = pt_cp.vl["ACC_1"]["HUD_SPEED"] * CV.KPH_TO_MS

ret.leftBlinker = bool(pt_cp.vl["BCM_1"]["LEFT_TURN_STALK"])
ret.rightBlinker = bool(pt_cp.vl["BCM_1"]["RIGHT_TURN_STALK"])
# ret.buttonEvents = TODO
# ret.espDisabled = TODO

self.frame += 1
return ret


@staticmethod
def get_can_parser(CP):
messages = [
# sig_address, frequency
("ABS_1", 100),
("ABS_2", 100),
("ABS_3", 100),
("ABS_4", 100),
("ENGINE_1", 100),
("EPS_1", 100),
("EPS_2", 100),
("EPS_3", 100),
("ACC_1", 12), # 12hz inactive / 50hz active
("BCM_1", 4), # 4Hz plus triggered updates
]

return CANParser(DBC[CP.carFingerprint]["pt"], messages, CANBUS.pt)


@staticmethod
def get_cam_can_parser(CP):
messages = []

return CANParser(DBC[CP.carFingerprint]["pt"], messages, CANBUS.cam)
24 changes: 24 additions & 0 deletions selfdrive/car/fca_giorgio/fca_giorgiocan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def create_steering_control(packer, bus, apply_steer, lkas_enabled):
values = {
"LKA_ACTIVE": lkas_enabled,
"LKA_TORQUE": apply_steer,
}

return packer.make_can_msg("LKA_COMMAND", bus, values)


def create_lka_hud_1_control(packer, bus, lat_active):
values = {
"NEW_SIGNAL_5": 1,
"NEW_SIGNAL_4": 6,
}

return packer.make_can_msg("LKA_HUD_1", bus, values)


def create_lka_hud_2_control(packer, bus, lat_active):
values = {
"NEW_SIGNAL_1": 1,
}

return packer.make_can_msg("LKA_HUD_2", bus, values)
12 changes: 12 additions & 0 deletions selfdrive/car/fca_giorgio/fingerprints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from cereal import car
from openpilot.selfdrive.car.fca_giorgio.values import CAR

Ecu = car.CarParams.Ecu

FW_VERSIONS = {
CAR.ALFA_ROMEO_STELVIO_1ST_GEN: {
(Ecu.engine, 0x7e0, None): [
b'PLACEHOLDER',
],
}
}
37 changes: 37 additions & 0 deletions selfdrive/car/fca_giorgio/interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from cereal import car
from openpilot.selfdrive.car import get_safety_config
from openpilot.selfdrive.car.interfaces import CarInterfaceBase
from openpilot.selfdrive.car.fca_giorgio.values import CAR


class CarInterface(CarInterfaceBase):
@staticmethod
def _get_params(ret, candidate: CAR, fingerprint, car_fw, experimental_long, docs):
ret.carName = "fca_giorgio"
ret.radarUnavailable = True

# Set global parameters

ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.fcaGiorgio)]

# Global lateral tuning defaults, can be overridden per-vehicle

ret.steerLimitTimer = 1.0
ret.steerActuatorDelay = 0.1
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)

# Global longitudinal tuning defaults, can be overridden per-vehicle

ret.pcmCruise = not ret.openpilotLongitudinalControl

return ret

# returns a car.CarState
def _update(self, c):
ret = self.CS.update(self.cp, self.cp_cam)

events = self.create_common_events(ret, pcm_enable=not self.CS.CP.openpilotLongitudinalControl)

ret.events = events.to_msg()
return ret

4 changes: 4 additions & 0 deletions selfdrive/car/fca_giorgio/radar_interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from openpilot.selfdrive.car.interfaces import RadarInterfaceBase

class RadarInterface(RadarInterfaceBase):
pass
67 changes: 67 additions & 0 deletions selfdrive/car/fca_giorgio/values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from dataclasses import dataclass, field

from openpilot.selfdrive.car import dbc_dict, CarSpecs, DbcDict, PlatformConfig, Platforms
from openpilot.selfdrive.car.docs_definitions import CarHarness, CarDocs, CarParts
from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries


class CarControllerParams:
STEER_STEP = 1
HUD_1_STEP = 50
HUD_2_STEP = 25

STEER_MAX = 300
STEER_DRIVER_ALLOWANCE = 80
STEER_DRIVER_MULTIPLIER = 3 # weight driver torque heavily
STEER_DRIVER_FACTOR = 1 # from dbc
STEER_DELTA_UP = 4
STEER_DELTA_DOWN = 4

def __init__(self, CP):
pass


class CANBUS:
pt = 0
cam = 2


@dataclass
class FcaGiorgioPlatformConfig(PlatformConfig):
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('fca_giorgio', None))


@dataclass(frozen=True, kw_only=True)
class FcaGiorgioCarSpecs(CarSpecs):
centerToFrontRatio: float = 0.45
steerRatio: float = 14.2


@dataclass
class FcaGiorgioCarDocs(CarDocs):
package: str = "Adaptive Cruise Control (ACC) & Lane Assist"
car_parts: CarParts = field(default_factory=CarParts.common([CarHarness.vw_a]))


class CAR(Platforms):
config: FcaGiorgioPlatformConfig

ALFA_ROMEO_STELVIO_1ST_GEN = FcaGiorgioPlatformConfig(
[FcaGiorgioCarDocs("Alfa Romeo Stelvio 2017-24")],
FcaGiorgioCarSpecs(mass=1660, wheelbase=2.82),
)


FW_QUERY_CONFIG = FwQueryConfig(
requests=[
# TODO: check data to ensure ABS does not skip ISO-TP frames on bus 0
Request(
[StdQueries.MANUFACTURER_SOFTWARE_VERSION_REQUEST],
[StdQueries.MANUFACTURER_SOFTWARE_VERSION_RESPONSE],
bus=0,
),
],
)


DBC = CAR.create_dbc_map()
1 change: 1 addition & 0 deletions selfdrive/car/torque_data/override.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"]
"VOLKSWAGEN_CADDY_MK3" = [1.2, 1.2, 0.1]
"VOLKSWAGEN_PASSAT_NMS" = [2.5, 2.5, 0.1]
"VOLKSWAGEN_SHARAN_MK2" = [2.5, 2.5, 0.1]
"ALFA_ROMEO_STELVIO_1ST_GEN" = [1.9, 1.9, 0.11]
"HYUNDAI_SANTA_CRUZ_1ST_GEN" = [2.7, 2.7, 0.1]
"KIA_SPORTAGE_5TH_GEN" = [2.6, 2.6, 0.1]
"GENESIS_GV70_1ST_GEN" = [2.42, 2.42, 0.1]
Expand Down
3 changes: 2 additions & 1 deletion selfdrive/car/values.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import get_args
from openpilot.selfdrive.car.body.values import CAR as BODY
from openpilot.selfdrive.car.chrysler.values import CAR as CHRYSLER
from openpilot.selfdrive.car.fca_giorgio.values import CAR as FCA_GIORGIO
from openpilot.selfdrive.car.ford.values import CAR as FORD
from openpilot.selfdrive.car.gm.values import CAR as GM
from openpilot.selfdrive.car.honda.values import CAR as HONDA
Expand All @@ -13,7 +14,7 @@
from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA
from openpilot.selfdrive.car.volkswagen.values import CAR as VOLKSWAGEN

Platform = BODY | CHRYSLER | FORD | GM | HONDA | HYUNDAI | MAZDA | MOCK | NISSAN | SUBARU | TESLA | TOYOTA | VOLKSWAGEN
Platform = BODY | CHRYSLER | FCA_GIORGIO | FORD | GM | HONDA | HYUNDAI | MAZDA | MOCK | NISSAN | SUBARU | TESLA | TOYOTA | VOLKSWAGEN
BRANDS = get_args(Platform)

PLATFORMS: dict[str, Platform] = {str(platform): platform for brand in BRANDS for platform in brand}
Loading