Skip to content

Commit

Permalink
Merge from kegman
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamezz committed Apr 8, 2019
2 parents b587657 + bc564ec commit d115873
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 37 deletions.
4 changes: 2 additions & 2 deletions selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
except ImportError:
CarController = None

A_ACC_MAX = 0.15
FOLLOW_AGGRESSION = 0.15 # (Acceleration/Decel aggression) Lower is more aggressive

class CanBus(object):
def __init__(self):
Expand Down Expand Up @@ -86,7 +86,7 @@ def calc_accel_override(a_ego, a_target, v_ego, v_target):
# accelOverride is more or less the max throttle allowed to pcm: usually set to a constant
# unless aTargetMax is very high and then we scale with it; this help in quicker restart

return float(max(max_accel, a_target / A_ACC_MAX)) * min(speedLimiter, accelLimiter)
return float(max(max_accel, a_target / FOLLOW_AGGRESSION)) * min(speedLimiter, accelLimiter)

@staticmethod
def get_params(candidate, fingerprint):
Expand Down
10 changes: 5 additions & 5 deletions selfdrive/car/honda/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from selfdrive.can.parser import CANParser, CANDefine
from selfdrive.config import Conversions as CV
from selfdrive.car.honda.values import CAR, DBC, STEER_THRESHOLD, SPEED_FACTOR, HONDA_BOSCH
from selfdrive.kegman_conf import kegman_conf

def parse_gear_shifter(gear, vals):

Expand Down Expand Up @@ -142,8 +141,9 @@ def get_cam_can_parser(CP):

class CarState(object):
def __init__(self, CP):
self.kegman = kegman_conf()
self.trMode = int(self.kegman.conf['lastTrMode']) # default to last distance interval on startup
#self.kegman = kegman_conf()
#self.trMode = int(self.kegman.conf['lastTrMode']) # default to last distance interval on startup
self.trMode = 1
self.lkMode = True
self.read_distance_lines_prev = 4
self.CP = CP
Expand Down Expand Up @@ -314,8 +314,8 @@ def update(self, cp, cp_cam):
if self.cruise_setting == 3:
if cp.vl["SCM_BUTTONS"]["CRUISE_SETTING"] == 0:
self.trMode = (self.trMode + 1 ) % 4
self.kegman.conf['lastTrMode'] = str(self.trMode) # write last distance bar setting to file
self.kegman.write_config(self.kegman.conf)
# self.kegman.conf['lastTrMode'] = str(self.trMode) # write last distance bar setting to file
# self.kegman.write_config(self.kegman.conf)

# when user presses LKAS button on steering wheel
if self.cruise_setting == 1:
Expand Down
9 changes: 3 additions & 6 deletions selfdrive/car/honda/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def get_params(candidate, fingerprint):
ret.steerKiBP, ret.steerKpBP = [[0.], [0.]]

ret.steerKf = 0.00006 # conservative feed-forward
ret.steerRateCost = 0.5

if candidate in [CAR.CIVIC, CAR.CIVIC_BOSCH]:
stop_and_go = True
Expand Down Expand Up @@ -307,12 +306,11 @@ def get_params(candidate, fingerprint):
ret.centerToFront = ret.wheelbase * 0.41
ret.steerRatio = 16.0 # as spec
tire_stiffness_factor = 0.82
ret.steerKpV, ret.steerKiV = [[0.40], [0.20]]
ret.steerKpV, ret.steerKiV = [[0.40], [0.29]]
ret.longitudinalKpBP = [0., 5., 35.]
ret.longitudinalKpV = [1.2, 0.8, 0.5]
ret.longitudinalKiBP = [0., 35.]
ret.longitudinalKiV = [0.18, 0.12]
ret.steerRateCost = 0.35

elif candidate == CAR.RIDGELINE:
stop_and_go = False
Expand All @@ -321,12 +319,11 @@ def get_params(candidate, fingerprint):
ret.centerToFront = ret.wheelbase * 0.41
ret.steerRatio = 15.59 # as spec
tire_stiffness_factor = 0.82
ret.steerKpV, ret.steerKiV = [[0.40], [0.20]]
ret.steerKpV, ret.steerKiV = [[0.40], [0.29]]
ret.longitudinalKpBP = [0., 5., 35.]
ret.longitudinalKpV = [1.2, 0.8, 0.5]
ret.longitudinalKiBP = [0., 35.]
ret.longitudinalKiV = [0.18, 0.12]
ret.steerRateCost = 0.35

else:
raise ValueError("unsupported car %s" % candidate)
Expand Down Expand Up @@ -383,7 +380,7 @@ def get_params(candidate, fingerprint):
ret.startAccel = 0.5

ret.steerActuatorDelay = 0.1

ret.steerRateCost = 0.5

return ret

Expand Down
12 changes: 8 additions & 4 deletions selfdrive/car/honda/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,21 @@ class CAR:
PILOT = "HONDA PILOT 2017 TOURING"
PILOT_2019 = "HONDA PILOT 2019 ELITE"
RIDGELINE = "HONDA RIDGELINE 2017 BLACK EDITION"


'''
# Removed Accord Hybrid because of conflict with Insight
CAR.ACCORDH: [{
148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 387: 8, 388: 8, 399: 7, 419: 8, 420: 8, 427: 3, 432: 7, 441: 5, 450: 8, 464: 8, 477: 8, 479: 8, 495: 8, 525: 8, 545: 6, 662: 4, 773: 7, 777: 8, 780: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 927: 8, 929: 8, 1302: 8, 1600: 5, 1601: 8, 1652: 8
}],
'''

FINGERPRINTS = {
CAR.ACCORD: [{
148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 419: 8, 420: 8, 427: 3, 432: 7, 441: 5, 446: 3, 450: 8, 464: 8, 477: 8, 479: 8, 495: 8, 545: 6, 662: 4, 773: 7, 777: 8, 780: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 927: 8, 929: 8, 1302: 8, 1600: 5, 1601: 8, 1652: 8
}],
CAR.ACCORD_15: [{
148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 427: 3, 432: 7, 441: 5, 446: 3, 450: 8, 464: 8, 477: 8, 479: 8, 495: 8, 545: 6, 662: 4, 773: 7, 777: 8, 780: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 927: 8, 929: 8, 1302: 8, 1600: 5, 1601: 8, 1652: 8
}],
CAR.ACCORDH: [{
148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 387: 8, 388: 8, 399: 7, 419: 8, 420: 8, 427: 3, 432: 7, 441: 5, 450: 8, 464: 8, 477: 8, 479: 8, 495: 8, 525: 8, 545: 6, 662: 4, 773: 7, 777: 8, 780: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 927: 8, 929: 8, 1302: 8, 1600: 5, 1601: 8, 1652: 8
}],
CAR.ACURA_ILX: [{
57: 3, 145: 8, 228: 5, 304: 8, 316: 8, 342: 6, 344: 8, 380: 8, 398: 3, 399: 7, 419: 8, 420: 8, 422: 8, 428: 8, 432: 7, 464: 8, 476: 4, 490: 8, 506: 8, 512: 6, 513: 6, 542: 7, 545: 4, 597: 8, 660: 8, 773: 7, 777: 8, 780: 8, 800: 8, 804: 8, 808: 8, 819: 7, 821: 5, 829: 5, 882: 2, 884: 7, 887: 8, 888: 8, 892: 8, 923: 2, 929: 4, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1030: 5, 1034: 5, 1036: 8, 1039: 8, 1057: 5, 1064: 7, 1108: 8, 1365: 5,
}],
Expand Down
34 changes: 14 additions & 20 deletions selfdrive/controls/lib/long_mpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ def __init__(self, mpc_id, live_longitudinal_mpc):
self.last_cloudlog_t = 0.0
self.v_rel = 10
self.last_cloudlog_t = 0.0
self.currentTR = 2
self.mpc_frame = 0

def send_mpc_solution(self, qp_iterations, calculation_time):
qp_iterations = max(0, qp_iterations)
Expand Down Expand Up @@ -126,48 +124,44 @@ def update(self, CS, lead, v_cruise_setpoint):
else:
self.street_speed = 0

# ensure that the bar interval isn't evaluated too quickly or braking may occur while changing
if CS.carState.readdistancelines != self.lastTR and self.mpc_frame % 200 == 0:
self.currentTR = CS.carState.readdistancelines
self.mpc_frame = 0

self.mpc_frame += 1

# Calculate mpc
# Adjust distance from lead car when distance button pressed
if self.currentTR == 1:
if CS.carState.readdistancelines == 1:
#if self.street_speed and (self.lead_car_gap_shrinking or self.tailgating):
if self.street_speed:
TR = interp(-self.v_rel, ONE_BAR_PROFILE_BP, ONE_BAR_PROFILE)
else:
TR = ONE_BAR_DISTANCE
if self.currentTR != self.lastTR:
if CS.carState.readdistancelines != self.lastTR:
self.libmpc.init(MPC_COST_LONG.TTC, 1.0, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.lastTR = self.currentTR
self.lastTR = CS.carState.readdistancelines

elif self.currentTR == 2:
elif CS.carState.readdistancelines == 2:
#if self.street_speed and (self.lead_car_gap_shrinking or self.tailgating):
if self.street_speed:
TR = interp(-self.v_rel, TWO_BAR_PROFILE_BP, TWO_BAR_PROFILE)
else:
TR = TWO_BAR_DISTANCE
if self.currentTR != self.lastTR:
if CS.carState.readdistancelines != self.lastTR:
self.libmpc.init(MPC_COST_LONG.TTC, MPC_COST_LONG.DISTANCE, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.lastTR = self.currentTR
self.lastTR = CS.carState.readdistancelines

elif self.currentTR == 3:
elif CS.carState.readdistancelines == 3:
if self.street_speed:
#if self.street_speed and (self.lead_car_gap_shrinking or self.tailgating):
TR = interp(-self.v_rel, THREE_BAR_PROFILE_BP, THREE_BAR_PROFILE)
else:
TR = THREE_BAR_DISTANCE
if self.currentTR != self.lastTR:
if CS.carState.readdistancelines != self.lastTR:
self.libmpc.init(MPC_COST_LONG.TTC, MPC_COST_LONG.DISTANCE, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.lastTR = self.currentTR
self.lastTR = CS.carState.readdistancelines

elif self.currentTR == 4:
elif CS.carState.readdistancelines == 4:
TR = FOUR_BAR_DISTANCE
if self.currentTR != self.lastTR:
if CS.carState.readdistancelines != self.lastTR:
self.libmpc.init(MPC_COST_LONG.TTC, 0.05, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.lastTR = self.currentTR
self.lastTR = CS.carState.readdistancelines

else:
TR = TWO_BAR_DISTANCE # if readdistancelines != 1,2,3,4
Expand Down
Binary file added selfdrive/visiond/visiond.058
Binary file not shown.

0 comments on commit d115873

Please sign in to comment.