Using lgtm.com and fixing found alerts (#1452)

* lgtm in readme, and mac nui fixes

* call super inits in radars

* unused imports, dup lines

* more radars, more unused imports

* pass CP into RadarInterfaceBase

* more fixups

* unused imports

* delete unused lines

* ugh, new unused import

Co-authored-by: George Hotz <geohot@gmail.com>
This commit is contained in:
George Hotz
2020-05-02 12:07:34 -07:00
committed by GitHub
parent 846a58507f
commit 1295cfe06c
33 changed files with 27 additions and 164 deletions
@@ -2,8 +2,7 @@
import os
import argparse
import signal
from collections import deque, defaultdict
from statistics import mean
from collections import defaultdict
import cereal.messaging as messaging
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
import os
import sys
import argparse
import struct
from collections import deque
@@ -8,7 +7,6 @@ from statistics import mean
from cereal import log
import cereal.messaging as messaging
from cereal.services import service_list
if __name__ == "__main__":
+2 -3
View File
@@ -3,7 +3,6 @@ import numpy as np
import matplotlib.pyplot as plt
from selfdrive.controls.lib.longitudinal_mpc import libmpc_py
from selfdrive.controls.lib.drive_helpers import MPC_COST_LONG
import math
# plot liongitudinal MPC trajectory by defining boundary conditions:
# ego and lead vehicles state. Use this script to tune MPC costs
@@ -16,7 +15,7 @@ def RW(v_ego, v_l):
def NORM_RW_ERROR(v_ego, v_l, p):
return (RW(v_ego, v_l) + 4.0 - p)
return (RW(v_ego, v_l) + 4.0 - p) / (np.sqrt(v_ego + 0.5) + 0.1)
#return (RW(v_ego, v_l) + 4.0 - p) / (np.sqrt(v_ego + 0.5) + 0.1)
v_ego = 20.0
@@ -36,7 +35,7 @@ a_lead_tau = 0.
# a_lead_tau = 2.90729817665
min_a_lead_tau = (a_lead**2 * math.pi) / (2 * (v_lead + 0.01)**2)
#min_a_lead_tau = (a_lead**2 * math.pi) / (2 * (v_lead + 0.01)**2)
min_a_lead_tau = 0.0
print(a_lead_tau, min_a_lead_tau)
-67
View File
@@ -1,67 +0,0 @@
#!/usr/bin/env python3
"""
This tool can be used to quickly changes the values in a JSON file used for tuning
Keys like in vim:
- h: decrease by 0.05
- l: increase by 0.05
- k: move pointer up
- j: move pointer down
"""
import tty
import sys
import json
import termios
from collections import OrderedDict
FILENAME = '/data/tuning.json'
def read_tuning():
while True:
try:
return json.loads(open(FILENAME).read())
except:
pass
def main():
dat = json.loads(open(FILENAME, 'r').read())
dat = OrderedDict(sorted(dat.items(), key=lambda i: i[0]))
cur = 0
while True:
sys.stdout.write("\x1Bc")
for i, (k, v) in enumerate(dat.items()):
prefix = "> " if cur == i else " "
print((prefix + k).ljust(20) + "%.2f" % v)
key = sys.stdin.read(1)[0]
write = False
if key == "k":
cur = max(0, cur - 1)
elif key == "j":
cur = min(len(dat.keys()) - 1, cur + 1)
elif key == "l":
dat[dat.keys()[cur]] += 0.05
write = True
elif key == "h":
dat[dat.keys()[cur]] -= 0.05
write = True
elif key == "q":
break
if write:
open(FILENAME, 'w').write(json.dumps(dat))
if __name__ == "__main__":
orig_settings = termios.tcgetattr(sys.stdin)
tty.setcbreak(sys.stdin)
try:
main()
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, orig_settings)
except:
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, orig_settings)
raise