Skip to content

Commit

Permalink
Merge pull request commaai#210 from ShaneSmiskol/release2
Browse files Browse the repository at this point in the history
Stop and go smoothness
  • Loading branch information
sshane authored Apr 15, 2019
2 parents 994205e + 2cb819e commit a44b625
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion selfdrive/car/car_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def fingerprint(logcan, timeout):
time.sleep(0.01)
try:
with open("/data/kegman.json", "r") as f:
cloudlog.warning(f.read())
cloudlog.warning(str(f.read()))
f.close()
except:
pass
Expand Down
6 changes: 0 additions & 6 deletions selfdrive/car/toyota/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,6 @@ def get_params(candidate, fingerprint):
#detect the Pedal address
ret.enableGasInterceptor = 0x201 in fingerprint

try:
with open("/data/openpilot/gas-interceptor", "w") as f: # write if the user has a pedal installed for d-f exception in planner
f.write(str(ret.enableGasInterceptor))
except:
pass

# min speed to enable ACC. if car can do stop and go, then set enabling speed
# to a negative value, so it won't matter.
ret.minEnableSpeed = -1. if (stop_and_go or ret.enableGasInterceptor) else 19. * CV.MPH_TO_MS
Expand Down
8 changes: 1 addition & 7 deletions selfdrive/controls/lib/long_mpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ def __init__(self, mpc_id, live_longitudinal_mpc):
self.relative_distance = None
#self.dict_builder = {}

try:
with open("/data/openpilot/gas-interceptor", "r") as f:
self.gas_interceptor = bool(f.read())
except:
self.gas_interceptor = False

def save_car_data(self, self_vel):
if len(self.dynamic_follow_dict["self_vels"]) >= 200: # 100hz, so 200 items is 2 seconds
del self.dynamic_follow_dict["self_vels"][0]
Expand Down Expand Up @@ -69,7 +63,7 @@ def calculate_tr(self, v_ego, car_state):
"""

read_distance_lines = car_state.readdistancelines
if v_ego < 2.0 and read_distance_lines != 2 and self.gas_interceptor: # if under 2m/s, not dynamic follow, and user has comma pedal
if v_ego < 2.0: # if under 2m/s
return 1.8 # under 7km/hr use a TR of 1.8 seconds

if car_state.leftBlinker or car_state.rightBlinker: # if car is changing lanes and not already .9s
Expand Down
8 changes: 4 additions & 4 deletions selfdrive/controls/lib/longcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,18 @@ def dynamic_gas(self, v_ego, v_rel, d_rel, gasinterceptor, gasbuttonstatus):

if dynamic and v_rel is not None: # dynamic gas profile specific operations, and if lead
if (v_ego) < 8.94086: # if under 20 mph
x = [0.0, 0.61945, 1.15771, 1.61479, 1.99067, 2.28537, 2.49888, 2.6312, 2.68224]
y = [-accel, -(accel / 1.04), -(accel / 1.095), -(accel / 1.195), -(accel / 1.36), -(accel / 1.69), -(accel / 2.35), -(accel / 4.4), 0] # array that matches current chosen accel value
x = [1.61479, 1.99067, 2.28537, 2.49888, 2.6312, 2.68224]
y = [-accel, -(accel / 1.06), -(accel / 1.2), -(accel / 1.8), -(accel / 4.4), 0] # array that matches current chosen accel value
accel += interp(v_rel, x, y)
else:
x = [-0.89408, 0, 0.89408, 4.4704]
y = [-.15, -.05, .005, .05]
accel += interp(v_rel, x, y)


min_return = 0.01
min_return = 0.0
max_return = 1.0
return round(max(min(accel, max_return), min_return), 4) # ensure we return a value between range
return round(max(min(accel, max_return), min_return), 5) # ensure we return a value between range

def update(self, active, v_ego, brake_pressed, standstill, cruise_standstill, v_cruise, v_target, v_target_future,
a_target, CP, gasinterceptor, gasbuttonstatus):
Expand Down
10 changes: 8 additions & 2 deletions selfdrive/crash.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ def install():
auth = json.loads(f.read())
f.close()
auth = json.loads(auth['commaUser'])
error_tags['username'] = auth['username'].decode('utf-8', 'ignore')
error_tags['email'] = auth['email']
try:
error_tags['username'] = auth['username'].decode('utf-8', 'ignore')
except:
pass
try:
error_tags['email'] = auth['email']
except:
pass
except:
pass

Expand Down
7 changes: 4 additions & 3 deletions selfdrive/kegman_conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import threading
from selfdrive.swaglog import cloudlog
lock = threading.Lock()

class kegman_conf():
Expand All @@ -9,14 +10,14 @@ def __init__(self):

def read_config(self):
self.element_updated = False
self.default_config = {"cameraOffset":"0.06", "lastTrMode":"1", "battChargeMin":"90", "battChargeMax":"95", "wheelTouchSeconds":"1800", "battPercOff":"25", "carVoltageMinEonShutdown":"11200", "brakeStoppingTarget":"0.25", "angle_steers_offset":"0" , "brake_distance_extra":"1" , "lastALCAMode":"1" , "brakefactor":"1.2", "lastGasMode":"0" , "lastSloMode":"1", "leadDistance":"5"}
default_config = {"cameraOffset":"0.06", "lastTrMode":"1", "battChargeMin":"90", "battChargeMax":"95", "wheelTouchSeconds":"1800", "battPercOff":"25", "carVoltageMinEonShutdown":"11200", "brakeStoppingTarget":"0.25", "angle_steers_offset":"0" , "brake_distance_extra":"1" , "lastALCAMode":"1" , "brakefactor":"1.2", "lastGasMode":"0" , "lastSloMode":"1", "leadDistance":"5"}

if os.path.isfile('/data/kegman.json'):
with open('/data/kegman.json', 'r') as f:
try:
self.config = json.load(f)
except:
self.config = self.default_config
self.config = default_config
if "battPercOff" not in self.config:
self.config.update({"battPercOff":"25"})
self.element_updated = True
Expand Down Expand Up @@ -66,7 +67,7 @@ def read_config(self):
self.write_config(self.config)

else:
self.config = self.default_config
self.config = default_config
self.write_config(self.config)
return self.config

Expand Down

0 comments on commit a44b625

Please sign in to comment.