Skip to content

Commit

Permalink
openpilot v0.8.9/v0.8.10 combo
Browse files Browse the repository at this point in the history
  • Loading branch information
spektor56 authored and Aragon7777 committed Oct 21, 2021
1 parent 58bdb27 commit d674f4e
Show file tree
Hide file tree
Showing 155 changed files with 7,887 additions and 933 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: spektor56
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ['https://www.buymeacoffee.com/spektor56', 'https://paypal.me/spektor56']
565 changes: 175 additions & 390 deletions README.md

Large diffs are not rendered by default.

42 changes: 32 additions & 10 deletions cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ struct CarEvent @0x9b1657f34caf3ad3 {
highCpuUsage @105;

driverMonitorLowAccDEPRECATED @68;
manualSteeringRequired @106;
manualLongitudinalRequired @107;
silentPedalPressed @108;
silentButtonEnable @109;
silentBrakeHold @110;
silentWrongGear @111;
parkGear @112;

radarCanErrorDEPRECATED @15;
radarCommIssueDEPRECATED @67;
gasUnavailableDEPRECATED @3;
Expand Down Expand Up @@ -189,6 +197,16 @@ struct CarState {
# clutch (manual transmission only)
clutchPressed @28 :Bool;

lkasEnabled @38 :Bool;
leftBlinkerOn @39 :Bool;
rightBlinkerOn @40 :Bool;
disengageByBrake @41 :Bool;
automaticLaneChange @42 :Bool;
belowLaneChangeSpeed @43 :Bool;
accEnabled @44 :Bool;
readdistancelines @45 :Int16;
engineRPM @46 :Float32;

# which packets this state came from
canMonoTimes @12: List(UInt64);

Expand Down Expand Up @@ -299,7 +317,7 @@ struct CarControl {

struct Actuators {
# range from 0.0 - 1.0
gas @0: Float32;
gasDEPRECATED @0: Float32;
brake @1: Float32;
# range from -1.0 - 1.0
steer @2: Float32;
Expand Down Expand Up @@ -380,10 +398,10 @@ struct CarParams {

steerMaxBP @11 :List(Float32);
steerMaxV @12 :List(Float32);
gasMaxBP @13 :List(Float32);
gasMaxV @14 :List(Float32);
brakeMaxBP @15 :List(Float32);
brakeMaxV @16 :List(Float32);
gasMaxBPDEPRECATED @13 :List(Float32);
gasMaxVDEPRECATED @14 :List(Float32);
brakeMaxBPDEPRECATED @15 :List(Float32);
brakeMaxVDEPRECATED @16 :List(Float32);

# things about the car in the manual
mass @17 :Float32; # [kg] curb weight: all fluids no cargo
Expand Down Expand Up @@ -416,8 +434,8 @@ struct CarParams {
steerControlType @34 :SteerControlType;
radarOffCan @35 :Bool; # True when radar objects aren't visible on CAN
minSpeedCan @51 :Float32; # Minimum vehicle speed from CAN (below this value drops to 0)
stoppingBrakeRate @52 :Float32; # brake_travel/s while trying to stop
startingBrakeRate @53 :Float32; # brake_travel/s while releasing on restart
stoppingDecelRate @52 :Float32; # m/s^2/s while trying to stop
startingAccelRate @53 :Float32; # m/s^2/s while trying to start

steerActuatorDelay @36 :Float32; # Steering wheel actuator delay in seconds
openpilotLongitudinalControl @37 :Bool; # is openpilot doing the longitudinal control?
Expand All @@ -441,16 +459,20 @@ struct CarParams {
kpV @1 :List(Float32);
kiBP @2 :List(Float32);
kiV @3 :List(Float32);
kf @4 :Float32;
kdBP @4 :List(Float32) = [0.];
kdV @5 :List(Float32) = [0.];
kf @6 :Float32;
}

struct LongitudinalPIDTuning {
kpBP @0 :List(Float32);
kpV @1 :List(Float32);
kiBP @2 :List(Float32);
kiV @3 :List(Float32);
deadzoneBP @4 :List(Float32);
deadzoneV @5 :List(Float32);
kdBP @4 :List(Float32) = [0.];
kdV @5 :List(Float32) = [0.];
deadzoneBP @6 :List(Float32);
deadzoneV @7 :List(Float32);
}

struct LateralINDITuning {
Expand Down
4 changes: 3 additions & 1 deletion cereal/log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ struct ControlsState @0x97ff69c53601abf1 {
mapValidDEPRECATED @49 :Bool;
jerkFactorDEPRECATED @12 :Float32;
steerOverrideDEPRECATED @20 :Bool;
steeringAngleDesiredDegDEPRECATED @29 :Float32;
steeringAngleDesiredDeg @29 :Float32;
}

struct ModelDataV2 {
Expand Down Expand Up @@ -873,6 +873,8 @@ struct LateralPlan @0xe1e9318e2ae8b51e {
curvatures @27 :List(Float32);
curvatureRates @28 :List(Float32);

lanelessMode @29 :Bool;

enum Desire {
none @0;
turnLeft @1;
Expand Down
44 changes: 32 additions & 12 deletions common/numpy_fast.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,39 @@ def int_rnd(x):
def clip(x, lo, hi):
return max(lo, min(hi, x))

def mean(x):
return sum(x) / len(x)

def get_interp(xv, xp, fp):
hi = 0
while hi < len(xp) and xv > xp[hi]:
hi += 1
low = hi - 1
if hi == len(xp) and xv > xp[low]:
return fp[-1]
if hi == 0:
return fp[0]
return (xv - xp[low]) * (fp[hi] - fp[low]) / (xp[hi] - xp[low]) + fp[low]

def interp(x, xp, fp):
N = len(xp)
return [get_interp(v, xp, fp) for v in x] if hasattr(x, '__iter__') else get_interp(x, xp, fp)

def get_interp(xv):
hi = 0
while hi < N and xv > xp[hi]:
hi += 1
low = hi - 1
return fp[-1] if hi == N and xv > xp[low] else (
fp[0] if hi == 0 else
(xv - xp[low]) * (fp[hi] - fp[low]) / (xp[hi] - xp[low]) + fp[low])

return [get_interp(v) for v in x] if hasattr(x, '__iter__') else get_interp(x)
def get_interp2d(xv, yv, yp, xzp):
hi = 0
while hi < len(yp) and yv > yp[hi]:
hi += 1
low = hi - 1
if hi == len(yp) and yv > yp[low]:
return get_interp(xv, *xzp[-1])

def mean(x):
return sum(x) / len(x)
if hi == 0:
return get_interp(xv, *xzp[0])

zlow = get_interp(xv, *xzp[low])
zhi = get_interp(xv, *xzp[hi])

return zlow + (zhi - zlow) * (yv - yp[low]) / (yp[hi] - yp[low])

def interp2d(xy, yp, xzp):
return [get_interp2d(xv, yv, yp, xzp) for xv, yv in xy] if hasattr(xy[0], '__iter__') else get_interp2d(*xy, yp, xzp)
2 changes: 1 addition & 1 deletion launch_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if [ -z "$REQUIRED_NEOS_VERSION" ]; then
fi

if [ -z "$AGNOS_VERSION" ]; then
export AGNOS_VERSION="1.3"
export AGNOS_VERSION="2"
fi

if [ -z "$PASSIVE" ]; then
Expand Down
2 changes: 2 additions & 0 deletions models/dmonitoring_model.current
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
3d4f9cab-ba54-4871-9449-37f440329ca1
2d400e7514d044cd6cfc1fbafb756e04bb161d0a
3 changes: 3 additions & 0 deletions models/dmonitoring_model.onnx
Git LFS file not shown
Binary file modified models/supercombo.dlc
Binary file not shown.
11 changes: 11 additions & 0 deletions panda/board/safety.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ void safety_tick(const safety_hooks *hooks) {
bool lagging = elapsed_time > MAX(hooks->addr_check[i].msg[hooks->addr_check[i].index].expected_timestep * MAX_MISSED_MSGS, 1e6);
hooks->addr_check[i].lagging = lagging;
if (lagging) {
disengageFromBrakes = false;
controls_allowed = 0;
}
}
Expand All @@ -157,6 +158,7 @@ bool is_msg_valid(AddrCheckStruct addr_list[], int index) {
if (index != -1) {
if ((!addr_list[index].valid_checksum) || (addr_list[index].wrong_counters >= MAX_WRONG_COUNTERS)) {
valid = false;
disengageFromBrakes = false;
controls_allowed = 0;
}
}
Expand Down Expand Up @@ -204,13 +206,22 @@ bool addr_safety_check(CAN_FIFOMailBox_TypeDef *to_push,
void generic_rx_checks(bool stock_ecu_detected) {
// exit controls on rising edge of gas press
if (gas_pressed && !gas_pressed_prev && !(unsafe_mode & UNSAFE_DISABLE_DISENGAGE_ON_GAS)) {
disengageFromBrakes = false;
controls_allowed = 0;
}
gas_pressed_prev = gas_pressed;

// exit controls on rising edge of brake press
if (brake_pressed && (!brake_pressed_prev || vehicle_moving)) {
if(controls_allowed == 1)
{
disengageFromBrakes = true;
}
controls_allowed = 0;
}else if (!brake_pressed && disengageFromBrakes)
{
disengageFromBrakes = false;
controls_allowed = 1;
}
brake_pressed_prev = brake_pressed;

Expand Down
12 changes: 11 additions & 1 deletion panda/board/safety/safety_honda.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,25 @@ static int honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
// 0x1A6 for the ILX, 0x296 for the Civic Touring
if ((addr == 0x1A6) || (addr == 0x296)) {
int button = (GET_BYTE(to_push, 0) & 0xE0) >> 5;
int button2 = (GET_BYTE(to_push, 0) & 0x0C) >> 2;
switch (button) {
case 2: // cancel
case 1: // main
disengageFromBrakes = false;
controls_allowed = 0;
break;
case 3: // set
case 4: // resume
controls_allowed = 1;
break;
default:
switch(button2)
{
case 1: //lkas_button
controls_allowed = 1;
break;
default:
break;
}
break; // any other button is irrelevant
}
}
Expand Down
1 change: 1 addition & 0 deletions panda/board/safety_declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ typedef struct {
void safety_tick(const safety_hooks *hooks);

// This can be set by the safety hooks
bool disengageFromBrakes = false;
bool controls_allowed = false;
bool relay_malfunction = false;
bool gas_interceptor_detected = false;
Expand Down
Binary file added selfdrive/assets/img_brake_disc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added selfdrive/assets/lock_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified selfdrive/assets/sounds/disengaged.wav
Binary file not shown.
Binary file modified selfdrive/assets/sounds/engaged.wav
Binary file not shown.
Binary file modified selfdrive/assets/sounds/error.wav
Binary file not shown.
Binary file modified selfdrive/assets/sounds/warning_1.wav
Binary file not shown.
Binary file modified selfdrive/assets/sounds/warning_2.wav
Binary file not shown.
Binary file modified selfdrive/assets/sounds/warning_repeat.wav
Binary file not shown.
Binary file modified selfdrive/assets/sounds_tici/disengaged.wav
Binary file not shown.
Binary file modified selfdrive/assets/sounds_tici/engaged.wav
Binary file not shown.
Binary file modified selfdrive/assets/sounds_tici/error.wav
Binary file not shown.
Binary file modified selfdrive/assets/sounds_tici/warning_1.wav
Binary file not shown.
Binary file modified selfdrive/assets/sounds_tici/warning_2.wav
Binary file not shown.
Binary file modified selfdrive/assets/sounds_tici/warning_repeat.wav
Binary file not shown.
2 changes: 1 addition & 1 deletion selfdrive/boardd/boardd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void safety_setter_thread() {
cereal::CarParams::Reader car_params = cmsg.getRoot<cereal::CarParams>();
cereal::CarParams::SafetyModel safety_model = car_params.getSafetyModel();

panda->set_unsafe_mode(0); // see safety_declarations.h for allowed values
panda->set_unsafe_mode(1); // see safety_declarations.h for allowed values

auto safety_param = car_params.getSafetyParam();
LOGW("setting safety model: %d with param %d", (int)safety_model, safety_param);
Expand Down
4 changes: 0 additions & 4 deletions selfdrive/car/chrysler/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@


class CarInterface(CarInterfaceBase):
@staticmethod
def compute_gb(accel, speed):
return float(accel) / 3.0

@staticmethod
def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None):
ret = CarInterfaceBase.get_std_params(candidate, fingerprint)
Expand Down
5 changes: 0 additions & 5 deletions selfdrive/car/ford/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@


class CarInterface(CarInterfaceBase):

@staticmethod
def compute_gb(accel, speed):
return float(accel) / 3.0

@staticmethod
def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None):
ret = CarInterfaceBase.get_std_params(candidate, fingerprint)
Expand Down
9 changes: 2 additions & 7 deletions selfdrive/car/gm/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,13 @@ def update(self, enabled, CS, frame, actuators,

can_sends.append(gmcan.create_steering_control(self.packer_pt, CanBus.POWERTRAIN, apply_steer, idx, lkas_enabled))

# GAS/BRAKE
# no output if not enabled, but keep sending keepalive messages
# treat pedals as one
final_pedal = actuators.gas - actuators.brake

if not enabled:
# Stock ECU sends max regen when not enabled.
apply_gas = P.MAX_ACC_REGEN
apply_brake = 0
else:
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)))
apply_gas = int(round(interp(actuators.accel, P.GAS_LOOKUP_BP, P.GAS_LOOKUP_V)))
apply_brake = int(round(interp(actuators.accel, P.BRAKE_LOOKUP_BP, P.BRAKE_LOOKUP_V)))

# Gas/regen and brakes - all at 25Hz
if (frame % 4) == 0:
Expand Down
4 changes: 0 additions & 4 deletions selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@

class CarInterface(CarInterfaceBase):

@staticmethod
def compute_gb(accel, speed):
return float(accel) / 4.0

@staticmethod
def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None):
ret = CarInterfaceBase.get_std_params(candidate, fingerprint)
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/gm/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def __init__(self):
ZERO_GAS = 2048
MAX_BRAKE = 350 # Should be around 3.5m/s^2, including regen
self.MAX_ACC_REGEN = 1404 # ACC Regen braking is slightly less powerful than max regen paddle
self.GAS_LOOKUP_BP = [-0.25, 0., 0.5]
self.GAS_LOOKUP_BP = [-1.0, 0., 2.0]
self.GAS_LOOKUP_V = [self.MAX_ACC_REGEN, ZERO_GAS, MAX_GAS]
self.BRAKE_LOOKUP_BP = [-1., -0.25]
self.BRAKE_LOOKUP_BP = [-4., -1.0]
self.BRAKE_LOOKUP_V = [MAX_BRAKE, 0]

class CAR:
Expand Down
Loading

0 comments on commit d674f4e

Please sign in to comment.