Skip to content

Commit

Permalink
Merge pull request commaai#25 from arne182/release2
Browse files Browse the repository at this point in the history
Release2
  • Loading branch information
sshane authored Mar 30, 2019
2 parents c20a196 + 16c577e commit 6a7817d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
25 changes: 23 additions & 2 deletions selfdrive/car/toyota/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def get_can_parser(CP):
signals = [
# sig_name, sig_address, default
("GEAR", "GEAR_PACKET", 0),
("SPORT_ON", "GEAR_PACKET", 0),
("ECON_ON", "GEAR_PACKET", 0),
("BRAKE_PRESSED", "BRAKE_MODULE", 0),
("GAS_PEDAL", "GAS_PEDAL", 0),
("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0),
Expand Down Expand Up @@ -141,7 +143,10 @@ def __init__(self, CP):
self.Angle_counter = 0
self.Angle = [0, 5, 10, 15,20,25,30,35,60,100,180,270,500]
self.Angle_Speed = [255,160,100,80,70,60,55,50,40,33,27,17,12]
#labels for ALCA modes
#labels for gas mode
self.gasMode = 0
self.gasLabels = ["normal","sport","eco"]
#labelslabels for ALCA modes
self.alcaLabels = ["MadMax","Normal","Wifey"]
self.alcaMode = int(self.kegman.conf['lastALCAMode']) # default to last ALCAmode on startup
#if (CP.carFingerprint == CAR.MODELS):
Expand Down Expand Up @@ -201,6 +206,9 @@ def __init__(self, CP):
self.approachradius = 100
self.includeradius = 22
self.blind_spot_on = bool(0)
self.econ_on = 0
self.sport_on = 0

self.distance_toggle_prev = 2
self.read_distance_lines_prev = 3
self.lane_departure_toggle_on_prev = True
Expand Down Expand Up @@ -237,7 +245,7 @@ def init_ui_buttons(self):
btns.append(UIButton("slow", "SLO", 1, "", 2))
btns.append(UIButton("lka", "LKA", 1, "", 3))
btns.append(UIButton("tr", "TR", 0, "", 4))
btns.append(UIButton("gas", "GAS", 0, "", 5))
btns.append(UIButton("gas", "GAS", 1, self.gasLabels[self.gasMode], 5))
return btns

#BB update ui buttons
Expand All @@ -253,6 +261,12 @@ def update_ui_buttons(self,id,btn_status):
self.kegman.conf['lastALCAMode'] = str(self.alcaMode) # write last ALCAMode setting to file
self.kegman.write_config(self.kegman.conf)
self.cstm_btns.btns[id].btn_label2 = self.alcaLabels[self.alcaMode]
elif (id == 5) and (btn_status == 0) and self.cstm_btns.btns[id].btn_name=="gas":
if self.cstm_btns.btns[id].btn_label2 == self.gasLabels[self.gasMode]:
self.gasMode = (self.gasMode + 1 ) % 3
else:
self.gasMode = 0
self.cstm_btns.btns[id].btn_label2 = self.gasLabels[self.gasMode]
self.cstm_btns.hasChanges = True
else:
self.cstm_btns.btns[id].btn_status = btn_status * self.cstm_btns.btns[id].btn_status
Expand Down Expand Up @@ -317,6 +331,13 @@ def update(self, cp, cp_cam):
self.angle_steers = cp.vl["STEER_ANGLE_SENSOR"]['STEER_ANGLE'] + cp.vl["STEER_ANGLE_SENSOR"]['STEER_FRACTION']
self.angle_steers_rate = cp.vl["STEER_ANGLE_SENSOR"]['STEER_RATE']
can_gear = int(cp.vl["GEAR_PACKET"]['GEAR'])
self.econ_on = cp.vl["GEAR_PACKET"]['ECON_ON']
self.sport_on = cp.vl["GEAR_PACKET"]['SPORT_ON']
if self.econ_on == 0 and self.sport_on == 0:
if gasMode == 1:
self.sport_on = 1
elif gasMode == 2:
self.econ_on = 1
self.gear_shifter = parse_gear_shifter(can_gear, self.shifter_values)
self.main_on = cp.vl["PCM_CRUISE_2"]['MAIN_ON']
self.left_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 1
Expand Down
5 changes: 4 additions & 1 deletion selfdrive/car/toyota/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,10 @@ def update(self, c):
ret.accSlowToggle = self.CS.acc_slow_on
ret.readdistancelines = self.CS.read_distance_lines
ret.gasbuttonstatus = self.CS.cstm_btns.get_button_status("gas")

if self.CS.sport_on == 1:
ret.gasbuttonstatus = 1
if self.CS.econ_on == 1:
ret.gasbuttonstatus = 2
# events
events = []
if not self.CS.can_valid:
Expand Down
18 changes: 11 additions & 7 deletions selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,20 @@ def state_control(plan, path_plan, CS, CP, state, events, v_cruise_kph, v_cruise
except AttributeError:
gasinterceptor = False

if CS.gasbuttonstatus == 0:
if gasinterceptor:
if gasinterceptor:
if CS.gasbuttonstatus == 0:
CP.gasMaxV = [0.2, 0.5, 0.7]
else:
CP.gasMaxV = [0.5, 0.7, 0.9]
else:
if gasinterceptor:
elif CS.gasbuttonstatus == 1:
CP.gasMaxV = [0.25, 0.9, 0.9]
else:
elif CS.gasbuttonstatus == 2:
CP.gasMaxV = [0.2, 0.2, 0.2]
else:
if CS.gasbuttonstatus == 0:
CP.gasMaxV = [0.5, 0.7, 0.9]
elif CS.gasbuttonstatus == 1:
CP.gasMaxV = [0.7, 0.9, 0.9]
elif CS.gasbuttonstatus == 2:
CP.gasMaxV = [0.2, 0.2, 0.2]

cur_time = sec_since_boot() # TODO: This won't work in replay
mpc_time = plan.l20MonoTime / 1e9
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/mapd/mapd.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ def query_thread():
if dist < 1000: #updated when we are 1km from the edge of the downloaded circle
continue

if dist > 3000:
if dist > 4000:
cache_valid = False

q = build_way_query(last_gps.latitude, last_gps.longitude, radius=3000)
q = build_way_query(last_gps.latitude, last_gps.longitude, radius=4000)
try:
new_result = api.query(q)

Expand Down

0 comments on commit 6a7817d

Please sign in to comment.