mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-10-01 03:43:42 +08:00
Enable more flake8 checks (#1602)
* enable some more flake8 checks * some more quick ones * bump opendbc * e401 * e711 e712 * e115 e116 * e222 * e301 * remove that * e129 * e701 e702 * e125 e131 * e227 * e306 * e262 * W503 * e713 * e704 * e731 * bump opendbc * fix some e722
This commit is contained in:
@@ -51,7 +51,7 @@ pygame.joystick.init()
|
||||
textPrint = TextPrint()
|
||||
|
||||
# -------- Main Program Loop -----------
|
||||
while done==False:
|
||||
while not done:
|
||||
# EVENT PROCESSING STEP
|
||||
for event in pygame.event.get(): # User did something
|
||||
if event.type == pygame.QUIT: # If user clicked close
|
||||
@@ -122,4 +122,4 @@ while done==False:
|
||||
# Close the window and quit.
|
||||
# If you forget this line, the program will 'hang'
|
||||
# on exit if running from IDLE.
|
||||
pygame.quit ()
|
||||
pygame.quit()
|
||||
|
||||
+8
-4
@@ -111,10 +111,12 @@ class RouteSegment(object):
|
||||
self.camera_path = camera_path
|
||||
|
||||
@property
|
||||
def name(self): return str(self._name)
|
||||
def name(self):
|
||||
return str(self._name)
|
||||
|
||||
@property
|
||||
def canonical_name(self): return self._name
|
||||
def canonical_name(self):
|
||||
return self._name
|
||||
|
||||
class RouteSegmentName(object):
|
||||
def __init__(self, name_str):
|
||||
@@ -123,6 +125,8 @@ class RouteSegmentName(object):
|
||||
self._num = int(num_str)
|
||||
|
||||
@property
|
||||
def segment_num(self): return self._num
|
||||
def segment_num(self):
|
||||
return self._num
|
||||
|
||||
def __str__(self): return self._segment_name_str
|
||||
def __str__(self):
|
||||
return self._segment_name_str
|
||||
|
||||
@@ -82,5 +82,8 @@ class RouteFrameReader(object):
|
||||
for fr in frs:
|
||||
fr.close()
|
||||
|
||||
def __enter__(self): return self
|
||||
def __exit__(self, type, value, traceback): self.close()
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
self.close()
|
||||
|
||||
@@ -73,7 +73,7 @@ def draw_path(y, x, color, img, calibration, top_down, lid_color=None):
|
||||
uv_model > 0, axis=1), uv_model[:, 0] < img.shape[1] - 1, uv_model[:, 1] <
|
||||
img.shape[0] - 1))]
|
||||
|
||||
for i, j in ((-1, 0), (0, -1), (0, 0), (0, 1), (1, 0)):
|
||||
for i, j in ((-1, 0), (0, -1), (0, 0), (0, 1), (1, 0)):
|
||||
img[uv_model_dots[:, 1] + i, uv_model_dots[:, 0] + j] = color
|
||||
|
||||
# draw lidar path point on lidar
|
||||
@@ -88,12 +88,12 @@ def draw_path(y, x, color, img, calibration, top_down, lid_color=None):
|
||||
def draw_steer_path(speed_ms, curvature, color, img,
|
||||
calibration, top_down, VM, lid_color=None):
|
||||
path_x = np.arange(101.)
|
||||
path_y = np.multiply(path_x, np.tan(np.arcsin(np.clip(path_x * curvature, -0.999, 0.999)) / 2.))
|
||||
path_y = np.multiply(path_x, np.tan(np.arcsin(np.clip(path_x * curvature, -0.999, 0.999)) / 2.))
|
||||
|
||||
draw_path(path_y, path_x, color, img, calibration, top_down, lid_color)
|
||||
|
||||
def draw_lead_car(closest, top_down):
|
||||
if closest != None:
|
||||
if closest is not None:
|
||||
closest_y = int(round(UP.lidar_car_y - closest * UP.lidar_zoom))
|
||||
if closest_y > 0:
|
||||
top_down[1][int(round(UP.lidar_car_x - METER_WIDTH * 2)):int(
|
||||
@@ -118,12 +118,10 @@ def init_plots(arr, name_to_arr_idx, plot_xlims, plot_ylims, plot_names, plot_co
|
||||
"p": (0,1,1),
|
||||
"m": (1,0,1) }
|
||||
|
||||
if bigplots == True:
|
||||
if bigplots:
|
||||
fig = plt.figure(figsize=(6.4, 7.0))
|
||||
elif bigplots == False:
|
||||
fig = plt.figure()
|
||||
else:
|
||||
fig = plt.figure(figsize=bigplots)
|
||||
fig = plt.figure()
|
||||
|
||||
fig.set_facecolor((0.2,0.2,0.2))
|
||||
|
||||
@@ -135,7 +133,7 @@ def init_plots(arr, name_to_arr_idx, plot_xlims, plot_ylims, plot_names, plot_co
|
||||
ax.patch.set_facecolor((0.4, 0.4, 0.4))
|
||||
axs.append(ax)
|
||||
|
||||
plots = [] ;idxs = [] ;plot_select = []
|
||||
plots, idxs, plot_select = [], [], []
|
||||
for i, pl_list in enumerate(plot_names):
|
||||
for j, item in enumerate(pl_list):
|
||||
plot, = axs[i].plot(arr[:, name_to_arr_idx[item]],
|
||||
|
||||
@@ -341,15 +341,19 @@ def get_arg_parser():
|
||||
parser.add_argument("route_name", type=(lambda x: x.replace("#", "|")), nargs="?",
|
||||
help="The route whose messages will be published.")
|
||||
parser.add_argument("data_dir", nargs='?', default=os.getenv('UNLOGGER_DATA_DIR'),
|
||||
help="Path to directory in which log and camera files are located.")
|
||||
help="Path to directory in which log and camera files are located.")
|
||||
|
||||
parser.add_argument("--no-loop", action="store_true", help="Stop at the end of the replay.")
|
||||
|
||||
key_value_pair = lambda x: x.split("=")
|
||||
def key_value_pair(x):
|
||||
return x.split("=")
|
||||
|
||||
parser.add_argument("address_mapping", nargs="*", type=key_value_pair,
|
||||
help="Pairs <service>=<zmq_addr> to publish <service> on <zmq_addr>.")
|
||||
|
||||
comma_list = lambda x: x.split(",")
|
||||
def comma_list(x):
|
||||
return x.split(",")
|
||||
|
||||
to_mock_group = parser.add_mutually_exclusive_group()
|
||||
to_mock_group.add_argument("--min", action="store_true", default=os.getenv("MIN"))
|
||||
to_mock_group.add_argument("--enabled", default=os.getenv("ENABLED"), type=comma_list)
|
||||
|
||||
+1
-1
@@ -200,7 +200,7 @@ def go(q):
|
||||
speed = math.sqrt(vel.x**2 + vel.y**2 + vel.z**2) * 3.6
|
||||
can_function(pm, speed, fake_wheel.angle, rk.frame, cruise_button=cruise_button, is_engaged=is_openpilot_engaged)
|
||||
|
||||
if rk.frame%1 == 0: # 20Hz?
|
||||
if rk.frame % 1 == 0: # 20Hz?
|
||||
throttle_op, brake_op, steer_torque_op = sendcan_function(sendcan)
|
||||
# print(" === torq, ",steer_torque_op, " ===")
|
||||
if is_openpilot_engaged:
|
||||
|
||||
@@ -28,8 +28,8 @@ def can_function(pm, speed, angle, idx, cruise_button=0, is_engaged=False):
|
||||
|
||||
msg.append(packer.make_can_msg("SCM_BUTTONS", 0, {"CRUISE_BUTTONS": cruise_button}, idx))
|
||||
|
||||
values = {"COUNTER_PEDAL": idx&0xF}
|
||||
checksum = crc8_pedal(packer.make_can_msg("GAS_SENSOR", 0, {"COUNTER_PEDAL": idx&0xF}, -1)[2][:-1])
|
||||
values = {"COUNTER_PEDAL": idx & 0xF}
|
||||
checksum = crc8_pedal(packer.make_can_msg("GAS_SENSOR", 0, {"COUNTER_PEDAL": idx & 0xF}, -1)[2][:-1])
|
||||
values["CHECKSUM_PEDAL"] = checksum
|
||||
msg.append(packer.make_can_msg("GAS_SENSOR", 0, values, -1))
|
||||
|
||||
@@ -56,7 +56,7 @@ def can_function(pm, speed, angle, idx, cruise_button=0, is_engaged=False):
|
||||
msg.append(packer.make_can_msg("BRAKE_COMMAND", 2, {}, idx))
|
||||
|
||||
# radar
|
||||
if idx%5 == 0:
|
||||
if idx % 5 == 0:
|
||||
msg.append(rpacker.make_can_msg("RADAR_DIAGNOSTIC", 1, {"RADAR_STATE": 0x79}, -1))
|
||||
for i in range(16):
|
||||
msg.append(rpacker.make_can_msg("TRACK_%d" % i, 1, {"LONG_DIST": 255.5}, -1))
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# set up wheel
|
||||
import os, struct, array
|
||||
import array
|
||||
import os
|
||||
import struct
|
||||
from fcntl import ioctl
|
||||
|
||||
# Iterate over the joystick devices.
|
||||
|
||||
@@ -6,4 +6,4 @@ if __name__ == '__main__':
|
||||
params = Params()
|
||||
params.put("HasAcceptedTerms", str(terms_version, 'utf-8'))
|
||||
params.put("CompletedTrainingVersion", str(training_version, 'utf-8'))
|
||||
print("Terms Accepted!")
|
||||
print("Terms Accepted!")
|
||||
|
||||
Reference in New Issue
Block a user