diff --git a/.github/PULL_REQUEST_TEMPLATE/car_port.md b/.github/PULL_REQUEST_TEMPLATE/car_port.md
index d275468395a70e..4264363ba29e8a 100644
--- a/.github/PULL_REQUEST_TEMPLATE/car_port.md
+++ b/.github/PULL_REQUEST_TEMPLATE/car_port.md
@@ -9,7 +9,7 @@ assignees: ''
**Checklist**
- [ ] added to README
-- [ ] test route added to [test_routes.py](https://github.com/commaai/openpilot/blob/master/selfdrive/test/test_models.py)
+- [ ] test route added to [routes.py](https://github.com/commaai/openpilot/blob/master/selfdrive/car/tests/routes.py)
- [ ] route with openpilot:
- [ ] route with stock system:
- [ ] car harness used (if comma doesn't sell it, put N/A):
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 38a6c7864395a3..efa947a91a83d6 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -22,8 +22,8 @@ Route: [a route with the bug fix]
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/plotjuggler/layouts/system_lag_debug.xml b/tools/plotjuggler/layouts/system_lag_debug.xml
new file mode 100644
index 00000000000000..b1699348cce46e
--- /dev/null
+++ b/tools/plotjuggler/layouts/system_lag_debug.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/replay/lib/ui_helpers.py b/tools/replay/lib/ui_helpers.py
index 7410c107c4be05..d66fe793061ac7 100644
--- a/tools/replay/lib/ui_helpers.py
+++ b/tools/replay/lib/ui_helpers.py
@@ -10,8 +10,7 @@
from common.transformations.camera import (eon_f_frame_size, eon_f_focal_length,
tici_f_frame_size, tici_f_focal_length,
get_view_frame_from_calib_frame)
-from selfdrive.config import UIParams as UP
-from selfdrive.config import RADAR_TO_CAMERA
+from selfdrive.controls.lib.radar_helpers import RADAR_TO_CAMERA
RED = (255, 0, 0)
@@ -24,6 +23,15 @@
_FULL_FRAME_SIZE = {
}
+class UIParams:
+ lidar_x, lidar_y, lidar_zoom = 384, 960, 6
+ lidar_car_x, lidar_car_y = lidar_x / 2., lidar_y / 1.1
+ car_hwidth = 1.7272 / 2 * lidar_zoom
+ car_front = 2.6924 * lidar_zoom
+ car_back = 1.8796 * lidar_zoom
+ car_color = 110
+UP = UIParams
+
_BB_TO_FULL_FRAME = {}
_CALIB_BB_TO_FULL = {}
_FULL_FRAME_TO_BB = {}
@@ -185,12 +193,12 @@ def plot_model(m, img, calibration, top_down):
if calibration is None or top_down is None:
return
- for lead in m.leads:
+ for lead in m.leadsV3:
if lead.prob < 0.5:
continue
- x, y, _, _ = lead.xyva
- x_std, _, _, _ = lead.xyvaStd
+ x, y = lead.x[0], lead.y[0]
+ x_std = lead.xStd[0]
x -= RADAR_TO_CAMERA
_, py_top = to_topdown_pt(x + x_std, y)
diff --git a/tools/replay/ui.py b/tools/replay/ui.py
index b39377ffdc6fb2..729d4cd0d844da 100755
--- a/tools/replay/ui.py
+++ b/tools/replay/ui.py
@@ -10,8 +10,7 @@
import cereal.messaging as messaging
from common.numpy_fast import clip
from common.basedir import BASEDIR
-from selfdrive.config import UIParams as UP
-from tools.replay.lib.ui_helpers import (_BB_TO_FULL_FRAME,
+from tools.replay.lib.ui_helpers import (_BB_TO_FULL_FRAME, UP,
_INTRINSICS, BLACK, GREEN,
YELLOW, Calibration,
get_blank_lid_overlay, init_plots,
@@ -100,7 +99,7 @@ def ui_thread(addr):
draw_plots = init_plots(plot_arr, name_to_arr_idx, plot_xlims, plot_ylims, plot_names, plot_colors, plot_styles)
- vipc_client = VisionIpcClient("camerad", VisionStreamType.VISION_STREAM_RGB_BACK, True)
+ vipc_client = VisionIpcClient("camerad", VisionStreamType.VISION_STREAM_RGB_ROAD, True)
while 1:
list(pygame.event.get())
diff --git a/tools/sim/bridge.py b/tools/sim/bridge.py
index 2e19faefcd33ab..13f10af9cd5468 100755
--- a/tools/sim/bridge.py
+++ b/tools/sim/bridge.py
@@ -48,6 +48,7 @@ def __init__(self):
self.vel = carla.Vector3D()
self.cruise_button = 0
self.is_engaged = False
+ self.ignition = True
def steer_rate_limit(old, new):
@@ -67,7 +68,7 @@ def __init__(self):
self.vipc_server = VisionIpcServer("camerad")
# TODO: remove RGB buffers once the last RGB vipc subscriber is removed
- self.vipc_server.create_buffers(VisionStreamType.VISION_STREAM_RGB_BACK, 4, True, W, H)
+ self.vipc_server.create_buffers(VisionStreamType.VISION_STREAM_RGB_ROAD, 4, True, W, H)
self.vipc_server.create_buffers(VisionStreamType.VISION_STREAM_ROAD, 40, False, W, H)
self.vipc_server.start_listener()
@@ -94,10 +95,10 @@ def cam_callback(self, image):
yuv_cl = cl_array.empty_like(rgb_cl)
self.krnl(self.queue, (np.int32(self.Wdiv4), np.int32(self.Hdiv4)), None, rgb_cl.data, yuv_cl.data).wait()
yuv = np.resize(yuv_cl.get(), np.int32(rgb.size / 2))
- eof = self.frame_id * 0.05
+ eof = int(self.frame_id * 0.05 * 1e9)
# TODO: remove RGB send once the last RGB vipc subscriber is removed
- self.vipc_server.send(VisionStreamType.VISION_STREAM_RGB_BACK, img.tobytes(), self.frame_id, eof, eof)
+ self.vipc_server.send(VisionStreamType.VISION_STREAM_RGB_ROAD, img.tobytes(), self.frame_id, eof, eof)
self.vipc_server.send(VisionStreamType.VISION_STREAM_ROAD, yuv.data.tobytes(), self.frame_id, eof, eof)
dat = messaging.new_message('roadCameraState')
@@ -126,13 +127,13 @@ def imu_callback(imu, vehicle_state):
pm.send('sensorEvents', dat)
-def panda_state_function(exit_event: threading.Event):
+def panda_state_function(vs: VehicleState, exit_event: threading.Event):
pm = messaging.PubMaster(['pandaStates'])
while not exit_event.is_set():
dat = messaging.new_message('pandaStates', 1)
dat.valid = True
dat.pandaStates[0] = {
- 'ignitionLine': True,
+ 'ignitionLine': vs.ignition,
'pandaType': "blackPanda",
'controlsAllowed': True,
'safetyModel': 'hondaNidec'
@@ -283,7 +284,7 @@ def bridge(q):
# launch fake car threads
threads = []
exit_event = threading.Event()
- threads.append(threading.Thread(target=panda_state_function, args=(exit_event,)))
+ threads.append(threading.Thread(target=panda_state_function, args=(vehicle_state, exit_event,)))
threads.append(threading.Thread(target=peripheral_state_function, args=(exit_event,)))
threads.append(threading.Thread(target=fake_driver_monitoring, args=(exit_event,)))
threads.append(threading.Thread(target=can_function_runner, args=(vehicle_state, exit_event,)))
@@ -346,6 +347,8 @@ def bridge(q):
elif m[1] == "cancel":
cruise_button = CruiseButtons.CANCEL
is_openpilot_engaged = False
+ elif m[0] == "ignition":
+ vehicle_state.ignition = not vehicle_state.ignition
elif m[0] == "quit":
break
diff --git a/tools/sim/lib/can.py b/tools/sim/lib/can.py
index 4873947d4b9f37..af0f415bbc1c97 100755
--- a/tools/sim/lib/can.py
+++ b/tools/sim/lib/can.py
@@ -12,11 +12,11 @@
def get_car_can_parser():
dbc_f = 'honda_civic_touring_2016_can_generated'
signals = [
- ("STEER_TORQUE", 0xe4, 0),
- ("STEER_TORQUE_REQUEST", 0xe4, 0),
- ("COMPUTER_BRAKE", 0x1fa, 0),
- ("COMPUTER_BRAKE_REQUEST", 0x1fa, 0),
- ("GAS_COMMAND", 0x200, 0),
+ ("STEER_TORQUE", 0xe4),
+ ("STEER_TORQUE_REQUEST", 0xe4),
+ ("COMPUTER_BRAKE", 0x1fa),
+ ("COMPUTER_BRAKE_REQUEST", 0x1fa),
+ ("GAS_COMMAND", 0x200),
]
checks = [
(0xe4, 100),
diff --git a/tools/sim/lib/keyboard_ctrl.py b/tools/sim/lib/keyboard_ctrl.py
index 08d120d61bf292..1c50b9b891a57f 100644
--- a/tools/sim/lib/keyboard_ctrl.py
+++ b/tools/sim/lib/keyboard_ctrl.py
@@ -53,6 +53,8 @@ def keyboard_poll_thread(q: 'Queue[str]'):
q.put("brake_%f" % 1.0)
elif c == 'd':
q.put("steer_%f" % -0.15)
+ elif c == 'i':
+ q.put("ignition")
elif c == 'q':
q.put("quit")
break
diff --git a/tools/sim/lib/manual_ctrl.py b/tools/sim/lib/manual_ctrl.py
index 7c47e2ba4a07d3..8f1bcc2b57655e 100755
--- a/tools/sim/lib/manual_ctrl.py
+++ b/tools/sim/lib/manual_ctrl.py
@@ -9,8 +9,8 @@
# Iterate over the joystick devices.
print('Available devices:')
for fn in os.listdir('/dev/input'):
- if fn.startswith('js'):
- print(f' /dev/input/{fn}')
+ if fn.startswith('js'):
+ print(f' /dev/input/{fn}')
# We'll store the states here.
axis_states = {}
@@ -18,74 +18,74 @@
# These constants were borrowed from linux/input.h
axis_names = {
- 0x00 : 'x',
- 0x01 : 'y',
- 0x02 : 'z',
- 0x03 : 'rx',
- 0x04 : 'ry',
- 0x05 : 'rz',
- 0x06 : 'trottle',
- 0x07 : 'rudder',
- 0x08 : 'wheel',
- 0x09 : 'gas',
- 0x0a : 'brake',
- 0x10 : 'hat0x',
- 0x11 : 'hat0y',
- 0x12 : 'hat1x',
- 0x13 : 'hat1y',
- 0x14 : 'hat2x',
- 0x15 : 'hat2y',
- 0x16 : 'hat3x',
- 0x17 : 'hat3y',
- 0x18 : 'pressure',
- 0x19 : 'distance',
- 0x1a : 'tilt_x',
- 0x1b : 'tilt_y',
- 0x1c : 'tool_width',
- 0x20 : 'volume',
- 0x28 : 'misc',
+ 0x00 : 'x',
+ 0x01 : 'y',
+ 0x02 : 'z',
+ 0x03 : 'rx',
+ 0x04 : 'ry',
+ 0x05 : 'rz',
+ 0x06 : 'trottle',
+ 0x07 : 'rudder',
+ 0x08 : 'wheel',
+ 0x09 : 'gas',
+ 0x0a : 'brake',
+ 0x10 : 'hat0x',
+ 0x11 : 'hat0y',
+ 0x12 : 'hat1x',
+ 0x13 : 'hat1y',
+ 0x14 : 'hat2x',
+ 0x15 : 'hat2y',
+ 0x16 : 'hat3x',
+ 0x17 : 'hat3y',
+ 0x18 : 'pressure',
+ 0x19 : 'distance',
+ 0x1a : 'tilt_x',
+ 0x1b : 'tilt_y',
+ 0x1c : 'tool_width',
+ 0x20 : 'volume',
+ 0x28 : 'misc',
}
button_names = {
- 0x120 : 'trigger',
- 0x121 : 'thumb',
- 0x122 : 'thumb2',
- 0x123 : 'top',
- 0x124 : 'top2',
- 0x125 : 'pinkie',
- 0x126 : 'base',
- 0x127 : 'base2',
- 0x128 : 'base3',
- 0x129 : 'base4',
- 0x12a : 'base5',
- 0x12b : 'base6',
- 0x12f : 'dead',
- 0x130 : 'a',
- 0x131 : 'b',
- 0x132 : 'c',
- 0x133 : 'x',
- 0x134 : 'y',
- 0x135 : 'z',
- 0x136 : 'tl',
- 0x137 : 'tr',
- 0x138 : 'tl2',
- 0x139 : 'tr2',
- 0x13a : 'select',
- 0x13b : 'start',
- 0x13c : 'mode',
- 0x13d : 'thumbl',
- 0x13e : 'thumbr',
-
- 0x220 : 'dpad_up',
- 0x221 : 'dpad_down',
- 0x222 : 'dpad_left',
- 0x223 : 'dpad_right',
-
- # XBox 360 controller uses these codes.
- 0x2c0 : 'dpad_left',
- 0x2c1 : 'dpad_right',
- 0x2c2 : 'dpad_up',
- 0x2c3 : 'dpad_down',
+ 0x120 : 'trigger',
+ 0x121 : 'thumb',
+ 0x122 : 'thumb2',
+ 0x123 : 'top',
+ 0x124 : 'top2',
+ 0x125 : 'pinkie',
+ 0x126 : 'base',
+ 0x127 : 'base2',
+ 0x128 : 'base3',
+ 0x129 : 'base4',
+ 0x12a : 'base5',
+ 0x12b : 'base6',
+ 0x12f : 'dead',
+ 0x130 : 'a',
+ 0x131 : 'b',
+ 0x132 : 'c',
+ 0x133 : 'x',
+ 0x134 : 'y',
+ 0x135 : 'z',
+ 0x136 : 'tl',
+ 0x137 : 'tr',
+ 0x138 : 'tl2',
+ 0x139 : 'tr2',
+ 0x13a : 'select',
+ 0x13b : 'start',
+ 0x13c : 'mode',
+ 0x13d : 'thumbl',
+ 0x13e : 'thumbr',
+
+ 0x220 : 'dpad_up',
+ 0x221 : 'dpad_down',
+ 0x222 : 'dpad_left',
+ 0x223 : 'dpad_right',
+
+ # XBox 360 controller uses these codes.
+ 0x2c0 : 'dpad_left',
+ 0x2c1 : 'dpad_right',
+ 0x2c2 : 'dpad_up',
+ 0x2c3 : 'dpad_down',
}
axis_map = []
@@ -118,18 +118,18 @@ def wheel_poll_thread(q: 'Queue[str]') -> NoReturn:
ioctl(jsdev, 0x80406a32, buf) # JSIOCGAXMAP
for _axis in buf[:num_axes]:
- axis_name = axis_names.get(_axis, f'unknown(0x{_axis:02x})')
- axis_map.append(axis_name)
- axis_states[axis_name] = 0.0
+ axis_name = axis_names.get(_axis, f'unknown(0x{_axis:02x})')
+ axis_map.append(axis_name)
+ axis_states[axis_name] = 0.0
# Get the button map.
buf = array.array('H', [0] * 200)
ioctl(jsdev, 0x80406a34, buf) # JSIOCGBTNMAP
for btn in buf[:num_buttons]:
- btn_name = button_names.get(btn, f'unknown(0x{btn:03x})')
- button_map.append(btn_name)
- button_states[btn_name] = 0
+ btn_name = button_names.get(btn, f'unknown(0x{btn:03x})')
+ button_map.append(btn_name)
+ button_states[btn_name] = 0
print('%d axes found: %s' % (num_axes, ', '.join(axis_map)))
print('%d buttons found: %s' % (num_buttons, ', '.join(button_map)))
diff --git a/tools/sim/start_carla.sh b/tools/sim/start_carla.sh
index 6418dacaee7bb8..8b2725950723b1 100755
--- a/tools/sim/start_carla.sh
+++ b/tools/sim/start_carla.sh
@@ -2,16 +2,16 @@
# Requires nvidia docker - https://github.com/NVIDIA/nvidia-docker
if ! $(apt list --installed | grep -q nvidia-container-toolkit); then
- if [ -z "$INSTALL" ]; then
- echo "Nvidia docker is required. Re-run with INSTALL=1 to automatically install."
- exit 0
- else
+ read -p "Nvidia docker is required. Do you want to install it now? (y/n)";
+ if [ "${REPLY}" == "y" ]; then
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
echo $distribution
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
- sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
+ sudo apt-get update && sudo apt-get install -y nvidia-docker2 # Also installs docker-ce and nvidia-container-toolkit
sudo systemctl restart docker
+ else
+ exit 0
fi
fi
diff --git a/tools/zookeeper/enable_and_wait.py b/tools/zookeeper/enable_and_wait.py
index 398ef412b1ab5c..6907e6017cfb2e 100755
--- a/tools/zookeeper/enable_and_wait.py
+++ b/tools/zookeeper/enable_and_wait.py
@@ -1,12 +1,16 @@
#!/usr/bin/env python3
-
import os
import sys
import time
+from socket import gethostbyname, gaierror
from tools.zookeeper import Zookeeper
def is_online(ip):
- return (os.system(f"ping -c 1 {ip} > /dev/null") == 0)
+ try:
+ addr = gethostbyname(ip)
+ return (os.system(f"ping -c 1 {addr} > /dev/null") == 0)
+ except gaierror:
+ return False
if __name__ == "__main__":
z = Zookeeper()
diff --git a/update_requirements.sh b/update_requirements.sh
index ac9472dca2e874..94b14496f151a9 100755
--- a/update_requirements.sh
+++ b/update_requirements.sh
@@ -1,5 +1,4 @@
#!/bin/bash
-
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
@@ -45,10 +44,11 @@ echo "pip packages install..."
pipenv install --dev --deploy --clear
pyenv rehash
-if [ -f "$DIR/.pre-commit-config.yaml" ]; then
- echo "precommit install ..."
- $RUN pre-commit install
- [ -d "./xx" ] && (cd xx && $RUN pre-commit install)
- [ -d "./notebooks" ] && (cd notebooks && $RUN pre-commit install)
- echo "pre-commit hooks installed"
-fi
+echo "pre-commit hooks install..."
+shopt -s nullglob
+for f in .pre-commit-config.yaml */.pre-commit-config.yaml; do
+ cd $DIR/$(dirname $f)
+ if [ -e ".git" ]; then
+ $RUN pre-commit install
+ fi
+done