Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into odyssey_bosch
Browse files Browse the repository at this point in the history
  • Loading branch information
csouers committed Oct 26, 2024
2 parents dc5d6ef + 92da02f commit 679dfb1
Show file tree
Hide file tree
Showing 50 changed files with 772 additions and 526 deletions.
28 changes: 17 additions & 11 deletions docs/CARS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--- AUTOGENERATED FROM selfdrive/car/CARS_template.md, DO NOT EDIT. --->

# Support Information for 341 Known Cars
# Support Information for 343 Known Cars

|Make|Model|Package|Support Level|
|---|---|---|:---:|
Expand Down Expand Up @@ -72,6 +72,7 @@
|Honda|Civic 2022-24|All|[Upstream](#upstream)|
|Honda|Civic Hatchback 2017-21|Honda Sensing|[Upstream](#upstream)|
|Honda|Civic Hatchback 2022-24|All|[Upstream](#upstream)|
|Honda|Clarity 2018-21|All|[Community](#community)|
|Honda|CR-V 2015-16|Touring Trim|[Upstream](#upstream)|
|Honda|CR-V 2017-22|Honda Sensing|[Upstream](#upstream)|
|Honda|CR-V 2024|All|[Community](#community)|
Expand All @@ -85,6 +86,7 @@
|Honda|Insight 2019-22|All|[Upstream](#upstream)|
|Honda|Inspire 2018|All|[Upstream](#upstream)|
|Honda|Odyssey 2018-20|Honda Sensing|[Upstream](#upstream)|
|Honda|Odyssey 2021-25|All|[Community](#community)|
|Honda|Passport 2019-23|All|[Upstream](#upstream)|
|Honda|Pilot 2016-22|Honda Sensing|[Upstream](#upstream)|
|Honda|Pilot 2023-24|All|[Community](#community)|
Expand Down Expand Up @@ -383,17 +385,21 @@ Although they're not upstream, the community has openpilot running on other make
Supported Models' section of each make [on our wiki](https://wiki.comma.ai/).

Some notable works-in-progress:
* Honda CAN-FD vehicles
* Honda
* 2024 Acura Integra, commaai/openpilot#32056
* 2023-24 Honda Accord, commaai/openpilot#32229
* 2024 Honda CR-V, commaai/openpilot#32806
* 2024 Honda CR-V Hybrid, commaai/openpilot#31527, which depends on:
* commaai/opendbc#1100
* 2023-24 Honda Pilot, commaai/openpilot#30324
* Honda camera ACC stability improvements
* commaai/openpilot#31022, which depends on:
* commaai/panda#1814
* commaai/opendbc#998
* 2023-24 Honda Accord (CAN-FD), commaai/openpilot#32229
* 2024 Honda CR-V (CAN-FD), commaai/openpilot#32806
* 2024 Honda CR-V Hybrid (CAN-FD), commaai/openpilot#31527
* Depends on commaai/opendbc#1100
* 2021-25 Honda Odyssey, commaai/opendbc#1330
* 2023-24 Honda Pilot (CAN-FD), commaai/openpilot#30324
* Camera ACC stability improvements, commaai/openpilot#31022
* Depends on commaai/panda#1814
* Depends on commaai/opendbc#998
* These are being reworked for full-time proxy through openpilot
* Manual transmission support (Civic, Integra)
* Depends on commaai/opendbc#1034 (merged)
* Car port support PR not yet filed

## Incompatible

Expand Down
24 changes: 14 additions & 10 deletions opendbc/car/CARS_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,21 @@ Although they're not upstream, the community has openpilot running on other make
Supported Models' section of each make [on our wiki](https://wiki.comma.ai/).

Some notable works-in-progress:
* Honda CAN-FD vehicles
* Honda
* 2024 Acura Integra, commaai/openpilot#32056
* 2023-24 Honda Accord, commaai/openpilot#32229
* 2024 Honda CR-V, commaai/openpilot#32806
* 2024 Honda CR-V Hybrid, commaai/openpilot#31527, which depends on:
* commaai/opendbc#1100
* 2023-24 Honda Pilot, commaai/openpilot#30324
* Honda camera ACC stability improvements
* commaai/openpilot#31022, which depends on:
* commaai/panda#1814
* commaai/opendbc#998
* 2023-24 Honda Accord (CAN-FD), commaai/openpilot#32229
* 2024 Honda CR-V (CAN-FD), commaai/openpilot#32806
* 2024 Honda CR-V Hybrid (CAN-FD), commaai/openpilot#31527
* Depends on commaai/opendbc#1100
* 2021-25 Honda Odyssey, commaai/opendbc#1330
* 2023-24 Honda Pilot (CAN-FD), commaai/openpilot#30324
* Camera ACC stability improvements, commaai/openpilot#31022
* Depends on commaai/panda#1814
* Depends on commaai/opendbc#998
* These are being reworked for full-time proxy through openpilot
* Manual transmission support (Civic, Integra)
* Depends on commaai/opendbc#1034 (merged)
* Car port support PR not yet filed

## Incompatible

Expand Down
2 changes: 2 additions & 0 deletions opendbc/car/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
# kg of standard extra cargo to count for drive, gas, etc...
STD_CARGO_KG = 136.

ACCELERATION_DUE_TO_GRAVITY = 9.81 # m/s^2

ButtonType = structs.CarState.ButtonEvent.Type
AngleRateLimit = namedtuple('AngleRateLimit', ['speed_bp', 'angle_v'])

Expand Down
64 changes: 3 additions & 61 deletions opendbc/car/body/carcontroller.py
Original file line number Diff line number Diff line change
@@ -1,70 +1,12 @@
import numpy as np
from numbers import Number

from opendbc.can.packer import CANPacker
from opendbc.car import DT_CTRL
from opendbc.car.common.numpy_fast import clip, interp
from opendbc.car.common.pid import PIDController
from opendbc.car.body import bodycan
from opendbc.car.body.values import SPEED_FROM_RPM
from opendbc.car.interfaces import CarControllerBase


class PIController:
def __init__(self, k_p, k_i, pos_limit=1e308, neg_limit=-1e308, rate=100):
self._k_p = k_p
self._k_i = k_i
if isinstance(self._k_p, Number):
self._k_p = [[0], [self._k_p]]
if isinstance(self._k_i, Number):
self._k_i = [[0], [self._k_i]]

self.pos_limit = pos_limit
self.neg_limit = neg_limit

self.i_unwind_rate = 0.3 / rate
self.i_rate = 1.0 / rate
self.speed = 0.0

self.reset()

@property
def k_p(self):
return interp(self.speed, self._k_p[0], self._k_p[1])

@property
def k_i(self):
return interp(self.speed, self._k_i[0], self._k_i[1])

@property
def error_integral(self):
return self.i/self.k_i

def reset(self):
self.p = 0.0
self.i = 0.0
self.control = 0

def update(self, error, speed=0.0, freeze_integrator=False):
self.speed = speed

self.p = float(error) * self.k_p

i = self.i + error * self.k_i * self.i_rate
control = self.p + i

# Update when changing i will move the control away from the limits
# or when i will move towards the sign of the error
if ((error >= 0 and (control <= self.pos_limit or i < 0.0)) or
(error <= 0 and (control >= self.neg_limit or i > 0.0))) and \
not freeze_integrator:
self.i = i

control = self.p + self.i

self.control = clip(control, self.neg_limit, self.pos_limit)
return self.control


MAX_TORQUE = 500
MAX_TORQUE_RATE = 50
MAX_ANGLE_ERROR = np.radians(7)
Expand All @@ -78,8 +20,8 @@ def __init__(self, dbc_name, CP):
self.packer = CANPacker(dbc_name)

# PIDs
self.turn_pid = PIController(110, k_i=11.5, rate=1/DT_CTRL)
self.wheeled_speed_pid = PIController(110, k_i=11.5, rate=1/DT_CTRL)
self.turn_pid = PIDController(110, k_i=11.5, rate=1/DT_CTRL)
self.wheeled_speed_pid = PIDController(110, k_i=11.5, rate=1/DT_CTRL)

self.torque_r_filtered = 0.
self.torque_l_filtered = 0.
Expand Down
4 changes: 2 additions & 2 deletions opendbc/car/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ struct CarState {
accelCruise @3;
decelCruise @4;
cancel @5;
altButton1 @6;
lkas @6;
altButton2 @7;
mainCruise @8;
setCruise @9;
Expand Down Expand Up @@ -508,7 +508,6 @@ struct CarParams {
transmissionType @43 :TransmissionType;
carFw @44 :List(CarFw);

radarTimeStep @45: Float32 = 0.05; # time delta between radar updates, 20Hz is very standard
radarDelay @74 :Float32;
fingerprintSource @49: FingerprintSource;
networkLocation @50 :NetworkLocation; # Where Panda/C2 is integrated into the car's CAN network
Expand Down Expand Up @@ -719,4 +718,5 @@ struct CarParams {
maxSteeringAngleDegDEPRECATED @54 :Float32;
longitudinalActuatorDelayLowerBoundDEPRECATED @61 :Float32;
stoppingControlDEPRECATED @31 :Bool; # Does the car allow full control even at lows speeds when stopping
radarTimeStepDEPRECATED @45: Float32 = 0.05; # time delta between radar updates, 20Hz is very standard
}
7 changes: 7 additions & 0 deletions opendbc/car/chrysler/fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@
b'68402703AB',
b'68402704AB',
b'68402708AB',
b'68402714AB',
b'68402971AD',
b'68454144AD',
b'68454145AB',
Expand Down Expand Up @@ -362,6 +363,7 @@
],
(Ecu.engine, 0x7e0, None): [
b'05035674AB ',
b'68412635AE ',
b'68412635AG ',
b'68412660AD ',
b'68422860AB',
Expand Down Expand Up @@ -468,6 +470,7 @@
b'68535470AC',
b'68548900AB',
b'68586307AB',
b'68586307AC',
],
(Ecu.fwdRadar, 0x753, None): [
b'04672892AB',
Expand Down Expand Up @@ -545,6 +548,7 @@
b'68378710AL ',
b'68378742AI ',
b'68378742AK ',
b'68378743AI ',
b'68378743AM ',
b'68378748AL ',
b'68378758AM ',
Expand All @@ -559,6 +563,7 @@
b'68455145AE ',
b'68455146AC ',
b'68460927AA ',
b'68467909AB ',
b'68467915AC ',
b'68467916AC ',
b'68467936AC ',
Expand Down Expand Up @@ -598,6 +603,7 @@
b'68360081AM',
b'68360085AJ',
b'68360085AL',
b'68360085AO',
b'68360086AH',
b'68360086AK',
b'68360086AN',
Expand All @@ -608,6 +614,7 @@
b'68445536AB',
b'68445537AB',
b'68466081AB',
b'68466086AB',
b'68466087AB',
b'68484466AC',
b'68484467AC',
Expand Down
58 changes: 58 additions & 0 deletions opendbc/car/common/pid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from numbers import Number
from opendbc.car.common.numpy_fast import clip, interp


class PIDController:
def __init__(self, k_p, k_i, pos_limit=1e308, neg_limit=-1e308, rate=100):
self._k_p = k_p
self._k_i = k_i
if isinstance(self._k_p, Number):
self._k_p = [[0], [self._k_p]]
if isinstance(self._k_i, Number):
self._k_i = [[0], [self._k_i]]

self.pos_limit = pos_limit
self.neg_limit = neg_limit

self.i_unwind_rate = 0.3 / rate
self.i_rate = 1.0 / rate
self.speed = 0.0

self.reset()

@property
def k_p(self):
return interp(self.speed, self._k_p[0], self._k_p[1])

@property
def k_i(self):
return interp(self.speed, self._k_i[0], self._k_i[1])

@property
def error_integral(self):
return self.i/self.k_i

def reset(self):
self.p = 0.0
self.i = 0.0
self.control = 0

def update(self, error, speed=0.0, freeze_integrator=False):
self.speed = speed

self.p = float(error) * self.k_p

i = self.i + error * self.k_i * self.i_rate
control = self.p + i

# Update when changing i will move the control away from the limits
# or when i will move towards the sign of the error
if ((error >= 0 and (control <= self.pos_limit or i < 0.0)) or
(error <= 0 and (control >= self.neg_limit or i > 0.0))) and \
not freeze_integrator:
self.i = i

control = self.p + self.i

self.control = clip(control, self.neg_limit, self.pos_limit)
return self.control
10 changes: 6 additions & 4 deletions opendbc/car/extra_cars.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,26 @@ def init_make(self, CP: structs.CarParams):
class CAR(Platforms):
config: ExtraPlatformConfig

HONDA_CANFD = ExtraPlatformConfig(
EXTRA_HONDA = ExtraPlatformConfig(
[
CommunityCarDocs("Acura Integra 2024", "All"),
CommunityCarDocs("Honda Accord 2023-24", "All"),
CommunityCarDocs("Honda Clarity 2018-21", "All"),
CommunityCarDocs("Honda CR-V 2024", "All"),
CommunityCarDocs("Honda CR-V Hybrid 2024", "All"),
CommunityCarDocs("Honda Odyssey 2021-25", "All"),
CommunityCarDocs("Honda Pilot 2023-24", "All"),
],
)

HYUNDAI_PALISADE_FACELIFT = ExtraPlatformConfig(
EXTRA_HYUNDAI = ExtraPlatformConfig(
[
CommunityCarDocs("Hyundai Palisade 2023-24", package="HDA2"),
CommunityCarDocs("Kia Telluride 2023-24", package="HDA2"),
],
)

TOYOTA_SECURITY_CARS = ExtraPlatformConfig(
EXTRA_TOYOTA = ExtraPlatformConfig(
[
ToyotaSecurityCarDocs("Subaru Solterra 2023-25"),
ToyotaSecurityCarDocs("Lexus NS 2022-25"),
Expand All @@ -63,7 +65,7 @@ class CAR(Platforms):
],
)

AUDI_FLEXRAY = ExtraPlatformConfig(
EXTRA_VOLKSWAGEN = ExtraPlatformConfig(
[
FlexRayCarDocs("Audi A4 2016-24", package="All"),
FlexRayCarDocs("Audi A5 2016-24", package="All"),
Expand Down
Loading

0 comments on commit 679dfb1

Please sign in to comment.