From 66ee6186175a26f1a523768da83e5c2c4330a29d Mon Sep 17 00:00:00 2001 From: Shane Date: Tue, 9 Apr 2019 20:01:03 -0500 Subject: [PATCH 01/24] add back dynamic gas --- selfdrive/car/toyota/carstate.py | 2 +- selfdrive/controls/lib/longcontrol.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index cb75efbe0fa409..3231908bde4d34 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -145,7 +145,7 @@ def __init__(self, CP): self.Angle_Speed = [255,160,100,80,70,60,55,50,40,33,27,17,12] #labels for gas mode self.gasMode = 0 - self.gasLabels = ["normal","sport","eco"] + self.gasLabels = ["dynamic","sport","eco"] #labelslabels for ALCA modes self.alcaLabels = ["MadMax","Normal","Wifey","off"] self.alcaMode = int(self.kegman.conf['lastALCAMode']) # default to last ALCAmode on startup diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index b63d5ca0480c1f..2914fd522ad212 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -84,10 +84,15 @@ def dynamic_gas(self, v_ego, v_rel, d_rel, gasinterceptor, gasbuttonstatus): dynamic = False if gasinterceptor: if gasbuttonstatus == 0: - #dynamic = True - #x = [0, 2.2863, 4.5373, 7.3644, 9.0393, 35.0] - #y = [0.2, 0.2199, 0.2631, 0.3572, 0.5, 0.7] - y = [0.2, 0.5, 0.7] + dynamic = True + #x = [0.0, 0.5588, 1.1176, 1.9223, 2.5481, 3.3975, 4.0234, 5.1921, 6.0797, 7.1526, 9.388, 12.964, 15.423, 18.119, 20.117, 24.4661, 29.058, 32.7101, 35.7632] # velocity/gasMaxBP + #y = [0.12, 0.1275, 0.135, 0.149, 0.1635, 0.185, 0.206, 0.257, 0.2858, 0.31, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] # accel values/gasMaxV + #x = [0.0, 0.5588, 1.1176, 1.9223, 2.5481, 3.3975, 4.0234, 5.1921, 6.0797, 7.1526, 9.388, 12.964, 15.423, 18.119, 20.117, 24.4661, 29.058, 32.7101, 35.7632] + #y = [0.12, 0.1275, 0.135, 0.149, 0.1635, 0.1845, 0.203, 0.243, 0.282, 0.31, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] + #x = [0.0, 1.4082, 2.8031, 4.2266, 5.3827, 6.1656, 7.2478, 9.3878, 12.964, 15.423, 18.119, 20.117, 24.4661, 29.058, 32.7101, 35.7632] + #y = [0.15, 0.1593, 0.175, 0.1972, 0.2253, 0.2505, 0.3001, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] + x = [0, 2.2863, 4.5373, 7.3644, 9.0393, 35.0] + y = [0.2, 0.2199, 0.2631, 0.3572, 0.5, 0.7] elif gasbuttonstatus == 1: y = [0.25, 0.9, 0.9] elif gasbuttonstatus == 2: From 4f7f30e772c3fc8c713e7bcf3c80f6ab574bb1ac Mon Sep 17 00:00:00 2001 From: Kumar <36933347+rav4kumar@users.noreply.github.com> Date: Tue, 9 Apr 2019 18:14:01 -0700 Subject: [PATCH 02/24] clean white ui. --- selfdrive/ui/ui.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index 44ee2234508a15..64e5d6f0e1f003 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -74,7 +74,7 @@ const int UI_FREQ = 60; // Hz const uint8_t bg_colors[][4] = { [STATUS_STOPPED] = {0x07, 0x23, 0x39, 0xff}, [STATUS_DISENGAGED] = {0x17, 0x33, 0x49, 0xff}, - [STATUS_ENGAGED] = {0x17, 0x86, 0x44, 0xff}, + [STATUS_ENGAGED] = {0xFF, 0xFF, 0xFF, 0xff}, [STATUS_WARNING] = {0xDA, 0x6F, 0x25, 0xff}, [STATUS_ALERT] = {0xC9, 0x22, 0x31, 0xff}, }; @@ -82,7 +82,7 @@ const uint8_t bg_colors[][4] = { const uint8_t alert_colors[][4] = { [STATUS_STOPPED] = {0x07, 0x23, 0x39, 0xf1}, [STATUS_DISENGAGED] = {0x17, 0x33, 0x49, 0xc8}, - [STATUS_ENGAGED] = {0x17, 0x86, 0x44, 0xf1}, + [STATUS_ENGAGED] = {0xFF, 0xFF, 0xFF, 0xf1}, [STATUS_WARNING] = {0xDA, 0x6F, 0x25, 0xf1}, [STATUS_ALERT] = {0xC9, 0x22, 0x31, 0xf1}, }; From 41401c3b8601eb65d493bf72c3684982963030c8 Mon Sep 17 00:00:00 2001 From: Shane Date: Tue, 9 Apr 2019 22:07:31 -0500 Subject: [PATCH 03/24] reduced relative velocity array as lead accel profile should average out --- selfdrive/controls/lib/long_mpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py index 71cf6b65a32769..1533e7778b4d00 100644 --- a/selfdrive/controls/lib/long_mpc.py +++ b/selfdrive/controls/lib/long_mpc.py @@ -171,8 +171,8 @@ def dynamic_follow(self, velocity): # in m/s TR = interpolate.interp1d(x, y, fill_value='extrapolate')(velocity)[()] # extrapolate above 90 mph if self.relative_velocity is not None: - x = [-11.2235, -9.4102, -7.1051, -5.7221, -4.3391, -3.5093, -2.7716, -2.2491, -2.0033, -1.6959, -1.0198, 0.0, 0.1788, 0.7935, 1.8692, 2.6683] # relative velocity values - y = [0.423, 0.4037, 0.3566, 0.3266, 0.2859, 0.2623, 0.23, 0.1787, 0.1251, 0.078, 0.036, 0, -0.0613, -0.1384, -0.2413, -0.2991] # modification values + x = [6.0064, 4.1456, 1.7336, 0.2863, 0.0107, -2.5393, -4.4, -5.5716, -6.6743, -9.7755, -13.0146, -16.9428, -20.5265, -24.4547] # relative velocity values + y = [-0.3004, -0.2402, -0.1371, -0.0554, 0.0005, 0.0327, 0.0757, 0.1402, 0.1961, 0.2584, 0.3057, 0.34, 0.3766, 0.3852] # modification values TR = TR + interp(self.relative_velocity, x, y) # interpolate as to not modify too much x = [-4.4704, -2.2352, -0.8941, 0.0, 1.3411] # self acceleration values From c10361937b294d4650ce129ca2d88430d13ee75c Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 10 Apr 2019 17:14:08 -0500 Subject: [PATCH 04/24] add op-tools.py, you can use your laptop to view live statistics from openpilot --- op-tools.py | 55 ++++++++++++++++++++++++++++++ selfdrive/controls/lib/long_mpc.py | 17 +++++++-- 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 op-tools.py diff --git a/op-tools.py b/op-tools.py new file mode 100644 index 00000000000000..aa0d90d9137cdf --- /dev/null +++ b/op-tools.py @@ -0,0 +1,55 @@ +import time, sys, json +from os import system, name + +def main_menu(): + print("Please chooce a category:") + while True: + print("1. Dynamic follow\n2. GPS\n3. Other") + c = input("[1-3]: ") + try: + int(c) + except: + return + if int(c) - 1 in range(3): + break + if int(c) == 1: + dynamic_follow() + +def dynamic_follow(): + clear() + print("\nPress Ctrl + C at any time to quit!") + time.sleep(3) + try: + while True: + clear() + print("\nDynamic follow data:\n") + try: + with open("/data/op-tools-data/dynamic-follow.json", "r") as f: + data = json.loads(f.read()) + for i in data: + print(i + ": " + str(data[i])) + except: + print("\nReading error, waiting a second...") + time.sleep(1) + time.sleep(.15) + except KeyboardInterrupt: + print() + main_menu() + +def clear(): + # for windows + if name == 'nt': + system('cls') + + # for mac and linux(here, os.name is 'posix') + else: + system('clear') + + +main_menu() + + +'''while True: + sys.stdout.write("\r\r\r" + time.ctime()+"\n"+time.ctime()) + sys.stdout.flush() + time.sleep(1)''' \ No newline at end of file diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py index 1533e7778b4d00..d0cde2ee695f5f 100644 --- a/selfdrive/controls/lib/long_mpc.py +++ b/selfdrive/controls/lib/long_mpc.py @@ -8,6 +8,7 @@ from selfdrive.controls.lib.drive_helpers import MPC_COST_LONG from scipy import interpolate import math +import json class LongitudinalMpc(object): @@ -30,6 +31,7 @@ def __init__(self, mpc_id, live_longitudinal_mpc): self.mpc_frame = 0 # idea thanks to kegman self.relative_velocity = None self.relative_distance = None + self.dict_builder = {} try: with open("/data/openpilot/gas-interceptor", "r") as f: @@ -135,6 +137,7 @@ def set_cur_state(self, v, a): def get_traffic_level(self, lead_vels): # generate a value to modify TR by based on fluctuations in lead speed if len(lead_vels) < 40: + self.dict_builder["traffic_modifier"] = None return 1.0 # if less than 20 seconds of traffic data do nothing to TR lead_vel_diffs = [] for idx, vel in enumerate(lead_vels): @@ -143,7 +146,7 @@ def get_traffic_level(self, lead_vels): # generate a value to modify TR by base x = [0, len(lead_vels)] y = [1.25, .9] # min and max values to modify TR by, need to tune traffic = interp(sum(lead_vel_diffs), x, y) - + self.dict_builder["traffic_modifier"] = traffic return traffic def get_acceleration(self, velocity_list, is_self): # calculate acceleration to generate more accurate following distances @@ -178,13 +181,17 @@ def dynamic_follow(self, velocity): # in m/s x = [-4.4704, -2.2352, -0.8941, 0.0, 1.3411] # self acceleration values y = [0.158, 0.058, 0.016, 0, -0.13] # modification values TR = TR + interp(self.get_acceleration(self.dynamic_follow_dict["self_vels"], True), x, y) # factor in self acceleration + self.dict_builder["self_accel"] = self.get_acceleration(self.dynamic_follow_dict["self_vels"], True) x = [-4.4704, -2.2, -0.958, -0.447, -0.2235, 0.0, 0.5588, 1.3411] # lead acceleration values y = [0.3555, 0.2788, 0.165, 0.1, 0.0375, 0, -0.115, -0.195] # modification values TR = TR + interp(self.get_acceleration(self.dynamic_follow_dict["lead_vels"], False), x, y) # factor in lead car's acceleration; should perform better + self.dict_builder["lead_accel"] = self.get_acceleration(self.dynamic_follow_dict["lead_vels"], False) TR = TR * self.get_traffic_level(self.dynamic_follow_dict["traffic_vels"]) # modify TR based on last minute of traffic data + self.dict_builder["TR"] = TR + if TR < 0.65: return 0.65 else: @@ -197,7 +204,10 @@ def generate_cost(self, TR, v_ego): real_TR = self.relative_distance / float(v_ego) # switched to cost generation using actual distance from lead car; should be safer if abs(real_TR - TR) >= .25: # use real TR if diff is greater than x safety threshold TR = real_TR - return round(float(interp(TR, x, y)), 3) + + cost = round(float(interp(TR, x, y)), 3) + self.dict_builder["generated_cost"] = cost + return cost def update(self, CS, lead, v_cruise_setpoint): v_ego = CS.carState.vEgo @@ -242,6 +252,9 @@ def update(self, CS, lead, v_cruise_setpoint): # Calculate mpc t = sec_since_boot() TR = self.calculate_tr(v_ego, CS.carState) + with open("/data/op-tools-data/dynamic-follow.json", "w") as d_f: + d_f.write(json.dumps(self.dict_builder)) + self.dict_builder = {} n_its = self.libmpc.run_mpc(self.cur_state, self.mpc_solution, self.a_lead_tau, a_lead, TR) duration = int((sec_since_boot() - t) * 1e9) self.send_mpc_solution(n_its, duration) From 219ace33c8c1903ea6490dd4cb48b431d41c36ac Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 10 Apr 2019 22:12:55 -0500 Subject: [PATCH 05/24] retuned dynamic gas, should be fast in the low end, but not too fast around 15 to 25 mph like last profile was. widened safety accel limits --- panda/board/safety/safety_toyota.h | 4 ++-- selfdrive/controls/lib/long_mpc.py | 4 ++-- selfdrive/controls/lib/longcontrol.py | 23 +++++++++++------------ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/panda/board/safety/safety_toyota.h b/panda/board/safety/safety_toyota.h index 67238efd466a63..86866972ecf6f9 100644 --- a/panda/board/safety/safety_toyota.h +++ b/panda/board/safety/safety_toyota.h @@ -16,8 +16,8 @@ const int TOYOTA_MAX_RT_DELTA = 375; // max delta torque allowed for real t const int TOYOTA_RT_INTERVAL = 250000; // 250ms between real time checks // longitudinal limits -const int TOYOTA_MAX_ACCEL = 1800; // 1.8 m/s2 -const int TOYOTA_MIN_ACCEL = -3600; // 3.6 m/s2 +const int TOYOTA_MAX_ACCEL = 3500; // 1.8 m/s2 +const int TOYOTA_MIN_ACCEL = -4000; // 3.6 m/s2 // global actuation limit state int toyota_actuation_limits = 1; // by default steer limits are imposed diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py index d0cde2ee695f5f..266e1b4add3c71 100644 --- a/selfdrive/controls/lib/long_mpc.py +++ b/selfdrive/controls/lib/long_mpc.py @@ -252,8 +252,8 @@ def update(self, CS, lead, v_cruise_setpoint): # Calculate mpc t = sec_since_boot() TR = self.calculate_tr(v_ego, CS.carState) - with open("/data/op-tools-data/dynamic-follow.json", "w") as d_f: - d_f.write(json.dumps(self.dict_builder)) + '''with open("/data/op-tools-data/dynamic-follow.json", "w") as d_f: + d_f.write(json.dumps(self.dict_builder))''' self.dict_builder = {} n_its = self.libmpc.run_mpc(self.cur_state, self.mpc_solution, self.a_lead_tau, a_lead, TR) duration = int((sec_since_boot() - t) * 1e9) diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 2914fd522ad212..450aac1606560a 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -91,8 +91,8 @@ def dynamic_gas(self, v_ego, v_rel, d_rel, gasinterceptor, gasbuttonstatus): #y = [0.12, 0.1275, 0.135, 0.149, 0.1635, 0.1845, 0.203, 0.243, 0.282, 0.31, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] #x = [0.0, 1.4082, 2.8031, 4.2266, 5.3827, 6.1656, 7.2478, 9.3878, 12.964, 15.423, 18.119, 20.117, 24.4661, 29.058, 32.7101, 35.7632] #y = [0.15, 0.1593, 0.175, 0.1972, 0.2253, 0.2505, 0.3001, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] - x = [0, 2.2863, 4.5373, 7.3644, 9.0393, 35.0] - y = [0.2, 0.2199, 0.2631, 0.3572, 0.5, 0.7] + x = [0.0, 1.40822, 2.80312, 4.22663, 5.38272, 6.16562, 6.89779, 7.36051, 8.11676, 9.3878, 10.88714, 12.96403, 15.42301, 18.0172, 20.11702, 24.46614, 29.05805, 32.71014, 35.7632] # velocity/gasMaxBP + y = [0.2, 0.21031, 0.22876, 0.25516, 0.2891, 0.3196, 0.3526, 0.37986, 0.40577, 0.43303, 0.4497, 0.46075, 0.47107, 0.47771, 0.48698, 0.521, 0.58437, 0.63867, 0.7] # accel values/gasMaxV elif gasbuttonstatus == 1: y = [0.25, 0.9, 0.9] elif gasbuttonstatus == 2: @@ -109,16 +109,15 @@ def dynamic_gas(self, v_ego, v_rel, d_rel, gasinterceptor, gasbuttonstatus): x = [0., 9., 35.] # default BP values accel = interp(v_ego, x, y) - if dynamic: # dynamic gas profile specific operations - if v_rel is not None: # if lead - if (v_ego) < 6.7056: # if under 15 mph - x = [0.0, 0.3072, 0.5173, 0.9337, 1.7882] - y = [-0.1, -0.0799, -0.0463, -0.0171, 0] - accel = accel + interp(v_rel, x, y) - else: - x = [-0.89408, 0, 0.89408, 4.4704] - y = [-.05, 0, .005, .02] - accel = accel + interp(v_rel, x, y) + if dynamic and v_rel is not None: # dynamic gas profile specific operations, and if lead + if (v_ego) < 6.7056: # if under 15 mph + x = [0.0, 0.3072, 0.5173, 0.9337, 1.7882] + y = [-0.1, -0.0799, -0.0463, -0.0171, 0] + accel = accel + interp(v_rel, x, y) + else: + x = [-0.89408, 0, 0.89408, 4.4704] + y = [-.05, 0, .005, .02] + accel = accel + interp(v_rel, x, y) min_return = 0.05 From d5a8a8c0eb379940d7c602fe50680c9c6a12af03 Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 10 Apr 2019 22:19:20 -0500 Subject: [PATCH 06/24] dual error reporting --- selfdrive/crash.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/selfdrive/crash.py b/selfdrive/crash.py index 9d98431f3f0a5e..912646bc92eef2 100644 --- a/selfdrive/crash.py +++ b/selfdrive/crash.py @@ -32,24 +32,32 @@ def install(): except: pass - client = Client('https://137e8e621f114f858f4c392c52e18c6d:8aba82f49af040c8aac45e95a8484970@sentry.io/1404547', + client_arne = Client('https://137e8e621f114f858f4c392c52e18c6d:8aba82f49af040c8aac45e95a8484970@sentry.io/1404547', install_sys_hook=False, transport=HTTPTransport, release=version, tags=error_tags) + client_shane = Client('https://c58740a8bcc54e3c86dec0cbc8a4ac82:37f4566213e9478080043b693e098942@sentry.io/1405746', + install_sys_hook=False, transport=HTTPTransport, release=version, tags=error_tags) + def capture_exception(*args, **kwargs): - client.captureException(*args, **kwargs) + client_arne.captureException(*args, **kwargs) + client_shane.captureException(*args, **kwargs) cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1)) def capture_warning(warning_string): - client.captureMessage(warning_string, level='warning') + client_arne.captureMessage(warning_string, level='warning') + client_shane.captureMessage(warning_string, level='warning') def capture_info(info_string): - client.captureMessage(info_string, level='info') + client_arne.captureMessage(info_string, level='info') + client_shane.captureMessage(info_string, level='info') def bind_user(**kwargs): - client.user_context(kwargs) + client_arne.user_context(kwargs) + client_shane.user_context(kwargs) def bind_extra(**kwargs): - client.extra_context(kwargs) + client_arne.extra_context(kwargs) + client_shane.extra_context(kwargs) def install(): # installs a sys.excepthook From d3fd922ff0bc827a87cdc89ca19fbd126b908ffc Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 10 Apr 2019 22:23:40 -0500 Subject: [PATCH 07/24] cleaner dual error reporting --- selfdrive/crash.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/selfdrive/crash.py b/selfdrive/crash.py index 912646bc92eef2..f96d77028ab19a 100644 --- a/selfdrive/crash.py +++ b/selfdrive/crash.py @@ -32,32 +32,27 @@ def install(): except: pass - client_arne = Client('https://137e8e621f114f858f4c392c52e18c6d:8aba82f49af040c8aac45e95a8484970@sentry.io/1404547', - install_sys_hook=False, transport=HTTPTransport, release=version, tags=error_tags) - client_shane = Client('https://c58740a8bcc54e3c86dec0cbc8a4ac82:37f4566213e9478080043b693e098942@sentry.io/1405746', - install_sys_hook=False, transport=HTTPTransport, release=version, tags=error_tags) + dsns = ['https://137e8e621f114f858f4c392c52e18c6d:8aba82f49af040c8aac45e95a8484970@sentry.io/1404547', + 'https://c58740a8bcc54e3c86dec0cbc8a4ac82:37f4566213e9478080043b693e098942@sentry.io/1405746'] + + clients = [Client(dsn, install_sys_hook=False, transport=HTTPTransport, release=version, tags=error_tags) for dsn in dsns] def capture_exception(*args, **kwargs): - client_arne.captureException(*args, **kwargs) - client_shane.captureException(*args, **kwargs) + [client.captureException(*args, **kwargs) for client in clients] cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1)) def capture_warning(warning_string): - client_arne.captureMessage(warning_string, level='warning') - client_shane.captureMessage(warning_string, level='warning') + [client.captureMessage(warning_string, level='warning') for client in clients] def capture_info(info_string): - client_arne.captureMessage(info_string, level='info') - client_shane.captureMessage(info_string, level='info') + [client.captureMessage(info_string, level='info') for client in clients] def bind_user(**kwargs): - client_arne.user_context(kwargs) - client_shane.user_context(kwargs) + [client.user_context(kwargs) for client in clients] def bind_extra(**kwargs): - client_arne.extra_context(kwargs) - client_shane.extra_context(kwargs) + [client.extra_context(kwargs) for client in clients] def install(): # installs a sys.excepthook From 6f48c81fd13f6c0d7944e2eb786daf78c244c3a5 Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 10 Apr 2019 22:28:47 -0500 Subject: [PATCH 08/24] testing error reporting --- selfdrive/controls/lib/long_mpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py index 266e1b4add3c71..bde0e980c2d7d4 100644 --- a/selfdrive/controls/lib/long_mpc.py +++ b/selfdrive/controls/lib/long_mpc.py @@ -252,8 +252,8 @@ def update(self, CS, lead, v_cruise_setpoint): # Calculate mpc t = sec_since_boot() TR = self.calculate_tr(v_ego, CS.carState) - '''with open("/data/op-tools-data/dynamic-follow.json", "w") as d_f: - d_f.write(json.dumps(self.dict_builder))''' + with open("/data/op-tools-data-error-test/dynamic-follow.json", "w") as d_f: + d_f.write(json.dumps(self.dict_builder)) self.dict_builder = {} n_its = self.libmpc.run_mpc(self.cur_state, self.mpc_solution, self.a_lead_tau, a_lead, TR) duration = int((sec_since_boot() - t) * 1e9) From 2eab0cd05409823688b84de68ce1cd0962116ef2 Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 10 Apr 2019 22:31:48 -0500 Subject: [PATCH 09/24] working! --- selfdrive/controls/lib/long_mpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py index bde0e980c2d7d4..266e1b4add3c71 100644 --- a/selfdrive/controls/lib/long_mpc.py +++ b/selfdrive/controls/lib/long_mpc.py @@ -252,8 +252,8 @@ def update(self, CS, lead, v_cruise_setpoint): # Calculate mpc t = sec_since_boot() TR = self.calculate_tr(v_ego, CS.carState) - with open("/data/op-tools-data-error-test/dynamic-follow.json", "w") as d_f: - d_f.write(json.dumps(self.dict_builder)) + '''with open("/data/op-tools-data/dynamic-follow.json", "w") as d_f: + d_f.write(json.dumps(self.dict_builder))''' self.dict_builder = {} n_its = self.libmpc.run_mpc(self.cur_state, self.mpc_solution, self.a_lead_tau, a_lead, TR) duration = int((sec_since_boot() - t) * 1e9) From 94f1fc63787aaa0a571d12392c88154726a3831a Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 10 Apr 2019 22:36:18 -0500 Subject: [PATCH 10/24] gas tuning --- selfdrive/controls/lib/longcontrol.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 450aac1606560a..17687bbdb58ee9 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -91,8 +91,10 @@ def dynamic_gas(self, v_ego, v_rel, d_rel, gasinterceptor, gasbuttonstatus): #y = [0.12, 0.1275, 0.135, 0.149, 0.1635, 0.1845, 0.203, 0.243, 0.282, 0.31, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] #x = [0.0, 1.4082, 2.8031, 4.2266, 5.3827, 6.1656, 7.2478, 9.3878, 12.964, 15.423, 18.119, 20.117, 24.4661, 29.058, 32.7101, 35.7632] #y = [0.15, 0.1593, 0.175, 0.1972, 0.2253, 0.2505, 0.3001, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] - x = [0.0, 1.40822, 2.80312, 4.22663, 5.38272, 6.16562, 6.89779, 7.36051, 8.11676, 9.3878, 10.88714, 12.96403, 15.42301, 18.0172, 20.11702, 24.46614, 29.05805, 32.71014, 35.7632] # velocity/gasMaxBP - y = [0.2, 0.21031, 0.22876, 0.25516, 0.2891, 0.3196, 0.3526, 0.37986, 0.40577, 0.43303, 0.4497, 0.46075, 0.47107, 0.47771, 0.48698, 0.521, 0.58437, 0.63867, 0.7] # accel values/gasMaxV + x = [0.0, 1.40822, 2.80312, 4.22663, 5.38272, 6.16562, 6.89779, 7.36051, 8.11676, 9.3878, 10.88714, 12.96403, + 15.42301, 18.0172, 20.11702, 24.46614, 29.05805, 32.71014, 35.7632] # velocity/gasMaxBP + y = [0.2, 0.21031, 0.22876, 0.25516, 0.2891, 0.3196, 0.3526, 0.37986, 0.40577, 0.43303, 0.4497, 0.46075, + 0.47107, 0.47771, 0.48698, 0.521, 0.58437, 0.63867, 0.7] # accel values/gasMaxV elif gasbuttonstatus == 1: y = [0.25, 0.9, 0.9] elif gasbuttonstatus == 2: @@ -112,7 +114,7 @@ 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) < 6.7056: # if under 15 mph x = [0.0, 0.3072, 0.5173, 0.9337, 1.7882] - y = [-0.1, -0.0799, -0.0463, -0.0171, 0] + y = [-0.125, -0.0799, -0.0463, -0.0171, 0] accel = accel + interp(v_rel, x, y) else: x = [-0.89408, 0, 0.89408, 4.4704] From 978ce39bae4c61259ddea9fbca1372b364e58455 Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 10 Apr 2019 22:56:03 -0500 Subject: [PATCH 11/24] gas tuning, less overall --- selfdrive/controls/lib/longcontrol.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 17687bbdb58ee9..0ea18a86fa2118 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -91,10 +91,10 @@ def dynamic_gas(self, v_ego, v_rel, d_rel, gasinterceptor, gasbuttonstatus): #y = [0.12, 0.1275, 0.135, 0.149, 0.1635, 0.1845, 0.203, 0.243, 0.282, 0.31, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] #x = [0.0, 1.4082, 2.8031, 4.2266, 5.3827, 6.1656, 7.2478, 9.3878, 12.964, 15.423, 18.119, 20.117, 24.4661, 29.058, 32.7101, 35.7632] #y = [0.15, 0.1593, 0.175, 0.1972, 0.2253, 0.2505, 0.3001, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] - x = [0.0, 1.40822, 2.80312, 4.22663, 5.38272, 6.16562, 6.89779, 7.36051, 8.11676, 9.3878, 10.88714, 12.96403, - 15.42301, 18.0172, 20.11702, 24.46614, 29.05805, 32.71014, 35.7632] # velocity/gasMaxBP - y = [0.2, 0.21031, 0.22876, 0.25516, 0.2891, 0.3196, 0.3526, 0.37986, 0.40577, 0.43303, 0.4497, 0.46075, - 0.47107, 0.47771, 0.48698, 0.521, 0.58437, 0.63867, 0.7] # accel values/gasMaxV + #x = [0.0, 1.40822, 2.80312, 4.22663, 5.38272, 6.16562, 6.89779, 7.36051, 8.11676, 9.3878, 10.88714, 12.96403, 15.42301, 18.0172, 20.11702, 24.46614, 29.05805, 32.71014, 35.7632] # velocity/gasMaxBP + #y = [0.2, 0.21031, 0.22876, 0.25516, 0.2891, 0.3196, 0.3526, 0.37986, 0.40577, 0.43303, 0.4497, 0.46075, 0.47107, 0.47771, 0.48698, 0.521, 0.58437, 0.63867, 0.7] # accel values/gasMaxV + x = [0.0, 3.15006, 6.27037, 9.45465, 12.04078, 13.79208, 16.21289, 18.528711170501101, 22.916628030302903, 28.99969, 34.50033, 40.53112, 45.00052, 54.7292, 65.001, 73.17053, 80.00013] + y = [0.2, 0.20443, 0.21592, 0.23334, 0.25734, 0.27916, 0.3229, 0.34783614203257063, 0.36764520202020201, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] elif gasbuttonstatus == 1: y = [0.25, 0.9, 0.9] elif gasbuttonstatus == 2: From 789b03adeaad76337ab9f3aee8a244f3a96229e7 Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 10 Apr 2019 22:56:44 -0500 Subject: [PATCH 12/24] gas tuning, less overall --- selfdrive/controls/lib/longcontrol.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 0ea18a86fa2118..56b349bd0598e3 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -93,8 +93,8 @@ def dynamic_gas(self, v_ego, v_rel, d_rel, gasinterceptor, gasbuttonstatus): #y = [0.15, 0.1593, 0.175, 0.1972, 0.2253, 0.2505, 0.3001, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] #x = [0.0, 1.40822, 2.80312, 4.22663, 5.38272, 6.16562, 6.89779, 7.36051, 8.11676, 9.3878, 10.88714, 12.96403, 15.42301, 18.0172, 20.11702, 24.46614, 29.05805, 32.71014, 35.7632] # velocity/gasMaxBP #y = [0.2, 0.21031, 0.22876, 0.25516, 0.2891, 0.3196, 0.3526, 0.37986, 0.40577, 0.43303, 0.4497, 0.46075, 0.47107, 0.47771, 0.48698, 0.521, 0.58437, 0.63867, 0.7] # accel values/gasMaxV - x = [0.0, 3.15006, 6.27037, 9.45465, 12.04078, 13.79208, 16.21289, 18.528711170501101, 22.916628030302903, 28.99969, 34.50033, 40.53112, 45.00052, 54.7292, 65.001, 73.17053, 80.00013] - y = [0.2, 0.20443, 0.21592, 0.23334, 0.25734, 0.27916, 0.3229, 0.34783614203257063, 0.36764520202020201, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] + x = [0.0, 1.4082, 2.80311, 4.22661, 5.38271, 6.16561, 7.24781, 8.28308, 10.24465, 12.96402, 15.42303, 18.11903, 20.11703, 24.46614, 29.05805, 32.71015, 35.76326] + y = [0.2, 0.20443, 0.21592, 0.23334, 0.25734, 0.27916, 0.3229, 0.34784, 0.36765, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] elif gasbuttonstatus == 1: y = [0.25, 0.9, 0.9] elif gasbuttonstatus == 2: From 6c8f0f4de77f29bd5e09397af48797e8d0a06033 Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 10 Apr 2019 23:12:45 -0500 Subject: [PATCH 13/24] added future array --- selfdrive/controls/lib/longcontrol.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 56b349bd0598e3..738e1f61a671ac 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -85,16 +85,10 @@ def dynamic_gas(self, v_ego, v_rel, d_rel, gasinterceptor, gasbuttonstatus): if gasinterceptor: if gasbuttonstatus == 0: dynamic = True - #x = [0.0, 0.5588, 1.1176, 1.9223, 2.5481, 3.3975, 4.0234, 5.1921, 6.0797, 7.1526, 9.388, 12.964, 15.423, 18.119, 20.117, 24.4661, 29.058, 32.7101, 35.7632] # velocity/gasMaxBP - #y = [0.12, 0.1275, 0.135, 0.149, 0.1635, 0.185, 0.206, 0.257, 0.2858, 0.31, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] # accel values/gasMaxV - #x = [0.0, 0.5588, 1.1176, 1.9223, 2.5481, 3.3975, 4.0234, 5.1921, 6.0797, 7.1526, 9.388, 12.964, 15.423, 18.119, 20.117, 24.4661, 29.058, 32.7101, 35.7632] - #y = [0.12, 0.1275, 0.135, 0.149, 0.1635, 0.1845, 0.203, 0.243, 0.282, 0.31, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] - #x = [0.0, 1.4082, 2.8031, 4.2266, 5.3827, 6.1656, 7.2478, 9.3878, 12.964, 15.423, 18.119, 20.117, 24.4661, 29.058, 32.7101, 35.7632] - #y = [0.15, 0.1593, 0.175, 0.1972, 0.2253, 0.2505, 0.3001, 0.343, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] - #x = [0.0, 1.40822, 2.80312, 4.22663, 5.38272, 6.16562, 6.89779, 7.36051, 8.11676, 9.3878, 10.88714, 12.96403, 15.42301, 18.0172, 20.11702, 24.46614, 29.05805, 32.71014, 35.7632] # velocity/gasMaxBP - #y = [0.2, 0.21031, 0.22876, 0.25516, 0.2891, 0.3196, 0.3526, 0.37986, 0.40577, 0.43303, 0.4497, 0.46075, 0.47107, 0.47771, 0.48698, 0.521, 0.58437, 0.63867, 0.7] # accel values/gasMaxV x = [0.0, 1.4082, 2.80311, 4.22661, 5.38271, 6.16561, 7.24781, 8.28308, 10.24465, 12.96402, 15.42303, 18.11903, 20.11703, 24.46614, 29.05805, 32.71015, 35.76326] y = [0.2, 0.20443, 0.21592, 0.23334, 0.25734, 0.27916, 0.3229, 0.34784, 0.36765, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] + #x = [0.0, 0.6422, 1.36595, 2.25989, 3.22941, 4.06505, 5.64084, 7.00847, 9.2202, 12.96404, 15.42305, 18.11906, 20.11706, 24.46618, 29.0581, 32.7102, 35.76332] # future + #y = [0.2, 0.20443, 0.21592, 0.23334, 0.25734, 0.27916, 0.3229, 0.34784, 0.36765, 0.38, 0.396, 0.409, 0.425, 0.478, 0.55, 0.621, 0.7] elif gasbuttonstatus == 1: y = [0.25, 0.9, 0.9] elif gasbuttonstatus == 2: From f6930508e1fff9ccc3c08b58fb11dbc7e1ed331e Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 11 Apr 2019 01:59:15 -0500 Subject: [PATCH 14/24] fix dirty and add branch logging thanks to arne --- selfdrive/common/version.h | 2 +- selfdrive/crash.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/selfdrive/common/version.h b/selfdrive/common/version.h index b1cb55d122aa18..85bbddbf9333f3 100644 --- a/selfdrive/common/version.h +++ b/selfdrive/common/version.h @@ -1 +1 @@ -#define COMMA_VERSION "0.5.10-release" +#define COMMA_VERSION "0.5.10-arne182" diff --git a/selfdrive/crash.py b/selfdrive/crash.py index f96d77028ab19a..d4124a28bd34ba 100644 --- a/selfdrive/crash.py +++ b/selfdrive/crash.py @@ -32,6 +32,12 @@ def install(): except: pass + try: + with open("/data/params/d/GitBranch", "r") as f: + error_tags['branch'] = str(f.read()) + except: + pass + dsns = ['https://137e8e621f114f858f4c392c52e18c6d:8aba82f49af040c8aac45e95a8484970@sentry.io/1404547', 'https://c58740a8bcc54e3c86dec0cbc8a4ac82:37f4566213e9478080043b693e098942@sentry.io/1405746'] From c260cf49b1465c05a0df08d1c2ab11c3c9808b6d Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 11 Apr 2019 02:08:12 -0500 Subject: [PATCH 15/24] add extra error tags --- selfdrive/crash.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/selfdrive/crash.py b/selfdrive/crash.py index d4124a28bd34ba..d8036a24659d3f 100644 --- a/selfdrive/crash.py +++ b/selfdrive/crash.py @@ -32,11 +32,14 @@ def install(): except: pass - try: - with open("/data/params/d/GitBranch", "r") as f: - error_tags['branch'] = str(f.read()) - except: - pass + logging_data = {"branch": "/data/params/d/GitBranch", "commit": "/data/params/d/GitCommit", "remote": "/data/params/d/GitRemote"} + + for key in logging_data: + try: + with open(logging_data[key], "r") as f: + error_tags[key] = str(f.read()) + except: + pass dsns = ['https://137e8e621f114f858f4c392c52e18c6d:8aba82f49af040c8aac45e95a8484970@sentry.io/1404547', 'https://c58740a8bcc54e3c86dec0cbc8a4ac82:37f4566213e9478080043b693e098942@sentry.io/1405746'] From c9ef838ed2b17799fc3a550d116acfdcefd62e1d Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 11 Apr 2019 02:12:18 -0500 Subject: [PATCH 16/24] test error and default branch to 'unknown' --- selfdrive/controls/lib/long_mpc.py | 4 ++-- selfdrive/crash.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py index 266e1b4add3c71..87266a2e477162 100644 --- a/selfdrive/controls/lib/long_mpc.py +++ b/selfdrive/controls/lib/long_mpc.py @@ -252,8 +252,8 @@ def update(self, CS, lead, v_cruise_setpoint): # Calculate mpc t = sec_since_boot() TR = self.calculate_tr(v_ego, CS.carState) - '''with open("/data/op-tools-data/dynamic-follow.json", "w") as d_f: - d_f.write(json.dumps(self.dict_builder))''' + with open("/data/op-tools-data-error/dynamic-follow.json", "w") as d_f: + d_f.write(json.dumps(self.dict_builder)) self.dict_builder = {} n_its = self.libmpc.run_mpc(self.cur_state, self.mpc_solution, self.a_lead_tau, a_lead, TR) duration = int((sec_since_boot() - t) * 1e9) diff --git a/selfdrive/crash.py b/selfdrive/crash.py index d8036a24659d3f..5d023cc8c00408 100644 --- a/selfdrive/crash.py +++ b/selfdrive/crash.py @@ -21,7 +21,7 @@ def install(): from raven import Client from raven.transport.http import HTTPTransport - error_tags = {'dirty': dirty, 'branch': 'release2'} + error_tags = {'dirty': dirty, 'branch': 'unknown'} try: with open("/data/data/ai.comma.plus.offroad/files/persistStore/persist-auth", "r") as f: From 9f9ec10f0ac79373833d5a8d18bd0d6f5ae7e527 Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 11 Apr 2019 02:26:38 -0500 Subject: [PATCH 17/24] remove error --- selfdrive/controls/lib/long_mpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py index 87266a2e477162..266e1b4add3c71 100644 --- a/selfdrive/controls/lib/long_mpc.py +++ b/selfdrive/controls/lib/long_mpc.py @@ -252,8 +252,8 @@ def update(self, CS, lead, v_cruise_setpoint): # Calculate mpc t = sec_since_boot() TR = self.calculate_tr(v_ego, CS.carState) - with open("/data/op-tools-data-error/dynamic-follow.json", "w") as d_f: - d_f.write(json.dumps(self.dict_builder)) + '''with open("/data/op-tools-data/dynamic-follow.json", "w") as d_f: + d_f.write(json.dumps(self.dict_builder))''' self.dict_builder = {} n_its = self.libmpc.run_mpc(self.cur_state, self.mpc_solution, self.a_lead_tau, a_lead, TR) duration = int((sec_since_boot() - t) * 1e9) From 82937a8227680f1bbb43c14887dd5aa8727b358b Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 11 Apr 2019 02:37:00 -0500 Subject: [PATCH 18/24] fix relative velocity being mph, whoops --- selfdrive/controls/lib/long_mpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py index 266e1b4add3c71..83dad793476891 100644 --- a/selfdrive/controls/lib/long_mpc.py +++ b/selfdrive/controls/lib/long_mpc.py @@ -174,8 +174,8 @@ def dynamic_follow(self, velocity): # in m/s TR = interpolate.interp1d(x, y, fill_value='extrapolate')(velocity)[()] # extrapolate above 90 mph if self.relative_velocity is not None: - x = [6.0064, 4.1456, 1.7336, 0.2863, 0.0107, -2.5393, -4.4, -5.5716, -6.6743, -9.7755, -13.0146, -16.9428, -20.5265, -24.4547] # relative velocity values - y = [-0.3004, -0.2402, -0.1371, -0.0554, 0.0005, 0.0327, 0.0757, 0.1402, 0.1961, 0.2584, 0.3057, 0.34, 0.3766, 0.3852] # modification values + x = [-10.93223, -9.17617, -7.57411, -5.81805, -4.37004, -2.98368, -2.49073, -1.96698, -1.13517, 0.0, 0.12799, 0.77499, 1.85325, 2.6851] # relative velocity values + y = [0.3852, 0.3766, 0.34, 0.3057, 0.2584, 0.1961, 0.1402, 0.0757, 0.0327, 0, -0.0554, -0.1371, -0.2402, -0.3004] # modification values TR = TR + interp(self.relative_velocity, x, y) # interpolate as to not modify too much x = [-4.4704, -2.2352, -0.8941, 0.0, 1.3411] # self acceleration values From d73fd1f29df32244fd126f0dd0db4555f360c158 Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 11 Apr 2019 02:59:16 -0500 Subject: [PATCH 19/24] on kegman_conf error, use empty dict --- selfdrive/kegman_conf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/selfdrive/kegman_conf.py b/selfdrive/kegman_conf.py index 5e523d151eb219..3ca8b515a6b485 100644 --- a/selfdrive/kegman_conf.py +++ b/selfdrive/kegman_conf.py @@ -10,7 +10,10 @@ def read_config(self): if os.path.isfile('/data/kegman.json'): with open('/data/kegman.json', 'r') as f: - self.config = json.load(f) + try: + self.config = json.load(f) + except: + self.config = {} if "battPercOff" not in self.config: self.config.update({"battPercOff":"25"}) self.element_updated = True From 4d1e34a6ee63d39ac0f725403481fe87affc0842 Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 11 Apr 2019 03:13:43 -0500 Subject: [PATCH 20/24] test error reporting --- selfdrive/crash.py | 5 +++-- selfdrive/kegman_conf.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/selfdrive/crash.py b/selfdrive/crash.py index 322e942a52e5fe..2b1f471d50b1b9 100644 --- a/selfdrive/crash.py +++ b/selfdrive/crash.py @@ -49,8 +49,9 @@ def install(): def capture_exception(*args, **kwargs): - [client.captureException(*args, **kwargs) for client in clients] - cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1)) + for client in clients: + client.captureException(*args, **kwargs) + cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1)) def capture_warning(warning_string): [client.captureMessage(warning_string, level='warning') for client in clients] diff --git a/selfdrive/kegman_conf.py b/selfdrive/kegman_conf.py index a7a953ad2f9469..1637705535bee4 100644 --- a/selfdrive/kegman_conf.py +++ b/selfdrive/kegman_conf.py @@ -29,16 +29,16 @@ def read_config(self): if "brake_distance_extra" not in self.config: # extra braking distance in m self.config.update({"brake_distance_extra":"1"}) self.element_updated = True - if "lastALCAMode" not in self.config: # extra braking distance in m + if "lastALCAMode" not in self.config: self.config.update({"lastALCAMode":"1"}) self.element_updated = True if "brakefactor" not in self.config: # brake at 20% higher speeds than what I like self.config.update({"brakefactor":"1.2"}) self.element_updated = True - if "lastGasMode" not in self.config: # brake at 20% higher speeds than what I like + if "lastGasMode" not in self.config: self.config.update({"lastGasMode":"0"}) self.element_updated = True - if "lastSloMode" not in self.config: # brake at 20% higher speeds than what I like + if "lastSloMode" not in self.config: self.config.update({"lastSloMode":"1"}) self.element_updated = True From df0d38cde8dbadfc97ef38103c823f69a06000ec Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 11 Apr 2019 03:14:45 -0500 Subject: [PATCH 21/24] test error reporting --- selfdrive/controls/lib/long_mpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py index 83dad793476891..ad7be9e13879b1 100644 --- a/selfdrive/controls/lib/long_mpc.py +++ b/selfdrive/controls/lib/long_mpc.py @@ -252,8 +252,8 @@ def update(self, CS, lead, v_cruise_setpoint): # Calculate mpc t = sec_since_boot() TR = self.calculate_tr(v_ego, CS.carState) - '''with open("/data/op-tools-data/dynamic-follow.json", "w") as d_f: - d_f.write(json.dumps(self.dict_builder))''' + with open("/datafd/op-tools-data-756/dynamic-follow.json", "w") as d_f: + d_f.write(json.dumps(self.dict_builder)) self.dict_builder = {} n_its = self.libmpc.run_mpc(self.cur_state, self.mpc_solution, self.a_lead_tau, a_lead, TR) duration = int((sec_since_boot() - t) * 1e9) From 03280bfcac6d9eaf5f726e5baa6362a82bc72324 Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 11 Apr 2019 03:22:11 -0500 Subject: [PATCH 22/24] revert error; test successful --- selfdrive/controls/lib/long_mpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/controls/lib/long_mpc.py b/selfdrive/controls/lib/long_mpc.py index ad7be9e13879b1..83dad793476891 100644 --- a/selfdrive/controls/lib/long_mpc.py +++ b/selfdrive/controls/lib/long_mpc.py @@ -252,8 +252,8 @@ def update(self, CS, lead, v_cruise_setpoint): # Calculate mpc t = sec_since_boot() TR = self.calculate_tr(v_ego, CS.carState) - with open("/datafd/op-tools-data-756/dynamic-follow.json", "w") as d_f: - d_f.write(json.dumps(self.dict_builder)) + '''with open("/data/op-tools-data/dynamic-follow.json", "w") as d_f: + d_f.write(json.dumps(self.dict_builder))''' self.dict_builder = {} n_its = self.libmpc.run_mpc(self.cur_state, self.mpc_solution, self.a_lead_tau, a_lead, TR) duration = int((sec_since_boot() - t) * 1e9) From 60125d66ff8b95d0de5f1e690b2d53a884585824 Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 11 Apr 2019 03:39:59 -0500 Subject: [PATCH 23/24] fix kegman error --- selfdrive/kegman_conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/selfdrive/kegman_conf.py b/selfdrive/kegman_conf.py index 1637705535bee4..53cb4e9fed134c 100644 --- a/selfdrive/kegman_conf.py +++ b/selfdrive/kegman_conf.py @@ -7,13 +7,14 @@ def __init__(self): def read_config(self): self.element_updated = False + self.default_config = self.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"} 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.config = self.default_config if "battPercOff" not in self.config: self.config.update({"battPercOff":"25"}) self.element_updated = True From 26b359b5639e251efb0b977699b14f2c1dc5608d Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 11 Apr 2019 03:59:50 -0500 Subject: [PATCH 24/24] fix kegman error 2 --- panda/board/safety/safety_toyota.h | 4 ++-- selfdrive/kegman_conf.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/panda/board/safety/safety_toyota.h b/panda/board/safety/safety_toyota.h index 86866972ecf6f9..cf0a116f06ee05 100644 --- a/panda/board/safety/safety_toyota.h +++ b/panda/board/safety/safety_toyota.h @@ -16,8 +16,8 @@ const int TOYOTA_MAX_RT_DELTA = 375; // max delta torque allowed for real t const int TOYOTA_RT_INTERVAL = 250000; // 250ms between real time checks // longitudinal limits -const int TOYOTA_MAX_ACCEL = 3500; // 1.8 m/s2 -const int TOYOTA_MIN_ACCEL = -4000; // 3.6 m/s2 +const int TOYOTA_MAX_ACCEL = 3500; // 3.5 m/s2 +const int TOYOTA_MIN_ACCEL = -4000; // 4.0 m/s2 // global actuation limit state int toyota_actuation_limits = 1; // by default steer limits are imposed diff --git a/selfdrive/kegman_conf.py b/selfdrive/kegman_conf.py index 53cb4e9fed134c..75e4eeca2c08d5 100644 --- a/selfdrive/kegman_conf.py +++ b/selfdrive/kegman_conf.py @@ -7,7 +7,7 @@ def __init__(self): def read_config(self): self.element_updated = False - self.default_config = self.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"} + 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"} if os.path.isfile('/data/kegman.json'): with open('/data/kegman.json', 'r') as f: @@ -61,7 +61,7 @@ def read_config(self): self.write_config(self.config) else: - self.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"} + self.config = self.default_config self.write_config(self.config) return self.config