Skip to content

Commit

Permalink
Merge branch 'master' into PA-dev2
Browse files Browse the repository at this point in the history
  • Loading branch information
Edison-CBS committed Oct 19, 2024
2 parents 2e03278 + 0ec1c87 commit f57909b
Show file tree
Hide file tree
Showing 49 changed files with 1,628 additions and 769 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/tools_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ env:
jobs:
simulator_driving:
name: simulator driving
runs-on: ${{ ((github.repository == 'commaai/openpilot') &&
((github.event_name != 'pull_request') ||
(github.event.pull_request.head.repo.full_name == 'commaai/openpilot'))) && 'namespace-profile-amd64-8x16' || 'ubuntu-latest' }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ui_preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
open=true
convert ${{ github.workspace }}/pr_ui/${A[$i]}_diff.png -transparent black mask.png
composite mask.png ${{ github.workspace }}/master_ui/${A[$i]}.png composite_diff.png
convert -delay 20 ${{ github.workspace }}/master_ui/${A[$i]}.png composite_diff.png -loop 0 ${{ github.workspace }}/pr_ui/${A[$i]}_diff.gif
convert -delay 100 ${{ github.workspace }}/master_ui/${A[$i]}.png composite_diff.png -loop 0 ${{ github.workspace }}/pr_ui/${A[$i]}_diff.gif
mv ${{ github.workspace }}/master_ui/${A[$i]}.png ${{ github.workspace }}/pr_ui/${A[$i]}_master_ref.png
Expand Down
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ def retryWithDelay(int maxRetries, int delay, Closure body) {
def device(String ip, String step_label, String cmd) {
withCredentials([file(credentialsId: 'id_rsa', variable: 'key_file')]) {
def ssh_cmd = """
ssh -tt -o ConnectTimeout=5 -o ServerAliveInterval=5 -o ServerAliveCountMax=2 -o BatchMode=yes -o StrictHostKeyChecking=no -i ${key_file} 'comma@${ip}' /usr/bin/bash <<'END'
ssh -o ConnectTimeout=5 -o ServerAliveInterval=5 -o ServerAliveCountMax=2 -o BatchMode=yes -o StrictHostKeyChecking=no -i ${key_file} 'comma@${ip}' exec /usr/bin/bash <<'END'
set -e
export TERM=xterm-256color
shopt -s huponexit # kill all child processes when the shell exits
export CI=1
Expand Down Expand Up @@ -65,8 +67,6 @@ ln -snf ${env.TEST_DIR} /data/pythonpath
cd ${env.TEST_DIR} || true
${cmd}
exit 0
END"""

sh script: ssh_cmd, label: step_label
Expand Down
2 changes: 1 addition & 1 deletion msgq_repo
2 changes: 1 addition & 1 deletion opendbc_repo
Submodule opendbc_repo updated 35 files
+17 −11 docs/CARS.md
+14 −10 opendbc/car/CARS_template.md
+3 −61 opendbc/car/body/carcontroller.py
+3 −0 opendbc/car/chrysler/fingerprints.py
+58 −0 opendbc/car/common/pid.py
+6 −4 opendbc/car/extra_cars.py
+5 −0 opendbc/car/ford/carcontroller.py
+1 −0 opendbc/car/honda/fingerprints.py
+10 −1 opendbc/car/hyundai/fingerprints.py
+6 −5 opendbc/car/tesla/carcontroller.py
+4 −8 opendbc/car/tesla/carstate.py
+2 −2 opendbc/car/tesla/fingerprints.py
+12 −2 opendbc/car/tesla/teslacan.py
+1 −0 opendbc/car/tests/routes.py
+1 −0 opendbc/car/torque_data/substitute.toml
+1 −1 opendbc/car/toyota/carcontroller.py
+35 −0 opendbc/car/toyota/fingerprints.py
+1 −1 opendbc/car/toyota/interface.py
+10 −1 opendbc/car/toyota/values.py
+8 −5 opendbc/dbc/acura_rdx_2020_can_generated.dbc
+8 −4 opendbc/dbc/generator/honda/_bosch_2018.dbc
+12 −0 opendbc/dbc/generator/honda/honda_civic_ex_2022_can.dbc
+5 −1 opendbc/dbc/generator/toyota/_toyota_2017.dbc
+1 −1 opendbc/dbc/generator/toyota/toyota_rav4_prime.dbc
+8 −5 opendbc/dbc/honda_accord_2018_can_generated.dbc
+20 −5 opendbc/dbc/honda_civic_ex_2022_can_generated.dbc
+8 −5 opendbc/dbc/honda_civic_hatchback_ex_2017_can_generated.dbc
+8 −5 opendbc/dbc/honda_crv_ex_2017_can_generated.dbc
+8 −5 opendbc/dbc/honda_insight_ex_2019_can_generated.dbc
+8 −5 opendbc/dbc/honda_pilot_2023_can_generated.dbc
+339 −333 opendbc/dbc/tesla_model3_party.dbc
+5 −1 opendbc/dbc/toyota_new_mc_pt_generated.dbc
+5 −1 opendbc/dbc/toyota_nodsu_pt_generated.dbc
+1 −1 opendbc/dbc/toyota_rav4_prime_generated.dbc
+5 −1 opendbc/dbc/toyota_tnga_k_pt_generated.dbc
2 changes: 1 addition & 1 deletion panda
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openpilot"
requires-python = ">= 3.11"
requires-python = ">= 3.11, <= 3.12"
license = {text = "MIT License"}
version = "0.1.0"
description = "an open source driver assistance system"
Expand Down
2 changes: 0 additions & 2 deletions selfdrive/car/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def __init__(self, CI=None, RI=None) -> None:
self.can_rcv_cum_timeout_counter = 0

self.CC_prev = car.CarControl.new_message()
self.CS_prev = car.CarState.new_message()
self.initialized_prev = False

self.last_actuators_output = structs.CarControl.Actuators()
Expand Down Expand Up @@ -250,7 +249,6 @@ def step(self):
self.controls_update(CS, self.sm['carControl'])

self.initialized_prev = initialized
self.CS_prev = CS.as_reader()

def params_thread(self, evt):
while not evt.is_set():
Expand Down
5 changes: 3 additions & 2 deletions selfdrive/controls/lib/longitudinal_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ def update(self, sm):
# Compute model v_ego error
self.v_model_error = get_speed_error(sm['modelV2'], v_ego)
x, v, a, j, throttle_prob = self.parse_model(sm['modelV2'], self.v_model_error)
self.allow_throttle = throttle_prob > ALLOW_THROTTLE_THRESHOLD
# Don't clip at low speeds since throttle_prob doesn't account for creep
self.allow_throttle = throttle_prob > ALLOW_THROTTLE_THRESHOLD or v_ego <= 5.0

if not self.allow_throttle and v_ego > 5.0: # Don't clip at low speeds since throttle_prob doesn't account for creep
if not self.allow_throttle:
# MPC breaks when accel limits would cause negative velocity within the MPC horizon, so we clip the max accel limit at vEgo/T_MAX plus a bit of margin
clipped_accel_coast = max(accel_coast, accel_limits_turns[0], -v_ego / T_IDXS_MPC[-1] + ACCEL_LIMIT_MARGIN)
accel_limits_turns[1] = min(accel_limits_turns[1], clipped_accel_coast)
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/modeld/models/supercombo.onnx
Git LFS file not shown
2 changes: 1 addition & 1 deletion selfdrive/test/process_replay/ref_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
36bb37715542677db4a42464128ca10968f2c589
4e595fcc2e8e4ef1564d915f697ddd9334067a7f
2 changes: 1 addition & 1 deletion selfdrive/test/test_onroad.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# Baseline CPU usage by process
"selfdrive.controls.controlsd": 16.0,
"selfdrive.selfdrived.selfdrived": 16.0,
"selfdrive.car.card": 30.0,
"selfdrive.car.card": 26.0,
"./loggerd": 14.0,
"./encoderd": 17.0,
"./camerad": 14.5,
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/ui/qt/network/wifi_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ void WifiManager::tetheringActivated(QDBusPendingCallWatcher *call) {
});
}
call->deleteLater();
tethering_on = true;
}

void WifiManager::setTetheringEnabled(bool enabled) {
Expand All @@ -465,6 +466,7 @@ void WifiManager::setTetheringEnabled(bool enabled) {

} else {
deactivateConnectionBySsid(tethering_ssid);
tethering_on = false;
}
}

Expand Down
1 change: 1 addition & 0 deletions selfdrive/ui/qt/network/wifi_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class WifiManager : public QObject {
QMap<QString, Network> seenNetworks;
QMap<QDBusObjectPath, QString> knownConnections;
QString ipv4_address;
bool tethering_on = false;
bool ipv4_forward = false;

explicit WifiManager(QObject* parent);
Expand Down
11 changes: 2 additions & 9 deletions selfdrive/ui/qt/offroad/driverview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

#include "selfdrive/ui/qt/util.h"

const int FACE_IMG_SIZE = 130;

DriverViewWindow::DriverViewWindow(QWidget* parent) : CameraWidget("camerad", VISION_STREAM_DRIVER, parent) {
face_img = loadPixmap("../assets/img_driver_face_static.png", {FACE_IMG_SIZE, FACE_IMG_SIZE});
QObject::connect(this, &CameraWidget::clicked, this, &DriverViewWindow::done);
QObject::connect(device(), &Device::interactiveTimeout, this, [this]() {
if (isVisible()) {
Expand Down Expand Up @@ -68,12 +65,8 @@ void DriverViewWindow::paintGL() {
p.drawRoundedRect(fbox_x - box_size / 2, fbox_y - box_size / 2, box_size, box_size, 35.0, 35.0);
}

// icon
const int img_offset = 60;
const int img_x = is_rhd ? rect().right() - FACE_IMG_SIZE - img_offset : rect().left() + img_offset;
const int img_y = rect().bottom() - FACE_IMG_SIZE - img_offset;
p.setOpacity(face_detected ? 1.0 : 0.2);
p.drawPixmap(img_x, img_y, face_img);
driver_monitor.updateState(*uiState());
driver_monitor.draw(p, rect());
}

mat4 DriverViewWindow::calcFrameMatrix() {
Expand Down
3 changes: 2 additions & 1 deletion selfdrive/ui/qt/offroad/driverview.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "selfdrive/ui/qt/widgets/cameraview.h"
#include "selfdrive/ui/qt/onroad/driver_monitoring.h"

class DriverViewWindow : public CameraWidget {
Q_OBJECT
Expand All @@ -18,5 +19,5 @@ class DriverViewWindow : public CameraWidget {
void paintGL() override;

Params params;
QPixmap face_img;
DriverMonitorRenderer driver_monitor;
};
2 changes: 1 addition & 1 deletion selfdrive/ui/qt/onroad/hud.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void HudRenderer::updateState(const UIState &s) {
status = s.status;

const SubMaster &sm = *(s.sm);
if (!sm.alive("carState")) {
if (sm.rcv_frame("carState") < s.scene.started_frame) {
is_cruise_set = false;
set_speed = SET_SPEED_NA;
speed = 0.0;
Expand Down
59 changes: 50 additions & 9 deletions selfdrive/ui/qt/onroad/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ static int get_path_length_idx(const cereal::XYZTData::Reader &line, const float
}

void ModelRenderer::draw(QPainter &painter, const QRect &surface_rect) {
auto &sm = *(uiState()->sm);
if (sm.updated("carParams")) {
longitudinal_control = sm["carParams"].getCarParams().getOpenpilotLongitudinalControl();
}

auto *s = uiState();
auto &sm = *(s->sm);
// Check if data is up-to-date
if (!(sm.alive("liveCalibration") && sm.alive("modelV2"))) {
if (sm.rcv_frame("liveCalibration") < s->scene.started_frame ||
sm.rcv_frame("modelV2") < s->scene.started_frame) {
return;
}

clip_region = surface_rect.adjusted(-CLIP_MARGIN, -CLIP_MARGIN, CLIP_MARGIN, CLIP_MARGIN);
experimental_mode = sm["selfdriveState"].getSelfdriveState().getExperimentalMode();
longitudinal_control = sm["carParams"].getCarParams().getOpenpilotLongitudinalControl();

painter.save();

Expand Down Expand Up @@ -135,15 +134,57 @@ void ModelRenderer::drawPath(QPainter &painter, const cereal::ModelDataV2::Reade
}

} else {
bg.setColorAt(0.0, QColor::fromHslF(148 / 360., 0.94, 0.51, 0.4));
bg.setColorAt(0.5, QColor::fromHslF(112 / 360., 1.0, 0.68, 0.35));
bg.setColorAt(1.0, QColor::fromHslF(112 / 360., 1.0, 0.68, 0.0));
updatePathGradient(bg);
}

painter.setBrush(bg);
painter.drawPolygon(track_vertices);
}

void ModelRenderer::updatePathGradient(QLinearGradient &bg) {
static const QColor throttle_colors[] = {
QColor::fromHslF(148. / 360., 0.94, 0.51, 0.4),
QColor::fromHslF(112. / 360., 1.0, 0.68, 0.35),
QColor::fromHslF(112. / 360., 1.0, 0.68, 0.0)};

static const QColor no_throttle_colors[] = {
QColor::fromHslF(148. / 360., 0.0, 0.95, 0.4),
QColor::fromHslF(112. / 360., 0.0, 0.95, 0.35),
QColor::fromHslF(112. / 360., 0.0, 0.95, 0.0),
};

// Transition speed; 0.1 corresponds to 0.5 seconds at UI_FREQ
constexpr float transition_speed = 0.1f;

// Start transition if throttle state changes
bool allow_throttle = (*uiState()->sm)["longitudinalPlan"].getLongitudinalPlan().getAllowThrottle() || !longitudinal_control;
if (allow_throttle != prev_allow_throttle) {
prev_allow_throttle = allow_throttle;
// Invert blend factor for a smooth transition when the state changes mid-animation
blend_factor = std::max(1.0f - blend_factor, 0.0f);
}

const QColor *begin_colors = allow_throttle ? no_throttle_colors : throttle_colors;
const QColor *end_colors = allow_throttle ? throttle_colors : no_throttle_colors;
if (blend_factor < 1.0f) {
blend_factor = std::min(blend_factor + transition_speed, 1.0f);
}

// Set gradient colors by blending the start and end colors
bg.setColorAt(0.0f, blendColors(begin_colors[0], end_colors[0], blend_factor));
bg.setColorAt(0.5f, blendColors(begin_colors[1], end_colors[1], blend_factor));
bg.setColorAt(1.0f, blendColors(begin_colors[2], end_colors[2], blend_factor));
}

QColor ModelRenderer::blendColors(const QColor &start, const QColor &end, float t) {
if (t == 1.0f) return end;
return QColor::fromRgbF(
(1 - t) * start.redF() + t * end.redF(),
(1 - t) * start.greenF() + t * end.greenF(),
(1 - t) * start.blueF() + t * end.blueF(),
(1 - t) * start.alphaF() + t * end.alphaF());
}

void ModelRenderer::drawLead(QPainter &painter, const cereal::RadarState::LeadData::Reader &lead_data,
const QPointF &vd, const QRect &surface_rect) {
const float speedBuff = 10.;
Expand Down
4 changes: 4 additions & 0 deletions selfdrive/ui/qt/onroad/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ class ModelRenderer {
void update_model(const cereal::ModelDataV2::Reader &model, const cereal::RadarState::LeadData::Reader &lead);
void drawLaneLines(QPainter &painter);
void drawPath(QPainter &painter, const cereal::ModelDataV2::Reader &model, int height);
void updatePathGradient(QLinearGradient &bg);
QColor blendColors(const QColor &start, const QColor &end, float t);

bool longitudinal_control = false;
bool experimental_mode = false;
float blend_factor = 1.0f;
bool prev_allow_throttle = true;
float lane_line_probs[4] = {};
float road_edge_stds[2] = {};
QPolygonF track_vertices;
Expand Down
10 changes: 6 additions & 4 deletions selfdrive/ui/qt/sidebar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ void Sidebar::updateState(const UIState &s) {

auto &sm = *(s.sm);

networking = networking ? networking : window()->findChild<Networking *>("");
bool tethering_on = networking && networking->wifi->tethering_on;
auto deviceState = sm["deviceState"].getDeviceState();
setProperty("netType", network_type[deviceState.getNetworkType()]);
int strength = (int)deviceState.getNetworkStrength();
setProperty("netType", tethering_on ? "Hotspot": network_type[deviceState.getNetworkType()]);
int strength = tethering_on ? 4 : (int)deviceState.getNetworkStrength();
setProperty("netStrength", strength > 0 ? strength + 1 : 0);

ItemStatus connectStatus;
Expand Down Expand Up @@ -131,8 +133,8 @@ void Sidebar::paintEvent(QPaintEvent *event) {

p.setFont(InterFont(35));
p.setPen(QColor(0xff, 0xff, 0xff));
const QRect r = QRect(50, 247, 100, 50);
p.drawText(r, Qt::AlignCenter, net_type);
const QRect r = QRect(58, 247, width() - 100, 50);
p.drawText(r, Qt::AlignLeft | Qt::AlignVCenter, net_type);

// metrics
drawMetric(p, temp_status.first, temp_status.second, 338);
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/ui/qt/sidebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QMap>

#include "selfdrive/ui/ui.h"
#include "selfdrive/ui/qt/network/networking.h"

typedef QPair<QPair<QString, QString>, QColor> ItemStatus;
Q_DECLARE_METATYPE(ItemStatus);
Expand Down Expand Up @@ -59,4 +60,5 @@ public slots:

private:
std::unique_ptr<PubMaster> pm;
Networking *networking = nullptr;
};
2 changes: 1 addition & 1 deletion selfdrive/ui/ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ UIState::UIState(QObject *parent) : QObject(parent) {
sm = std::make_unique<SubMaster>(std::vector<const char*>{
"modelV2", "controlsState", "liveCalibration", "radarState", "deviceState",
"pandaStates", "carParams", "driverMonitoringState", "carState", "driverStateV2",
"wideRoadCameraState", "managerState", "selfdriveState",
"wideRoadCameraState", "managerState", "selfdriveState", "longitudinalPlan",
});
prime_state = new PrimeState(this);
language = QString::fromStdString(Params().get("LanguageSetting"));
Expand Down
6 changes: 5 additions & 1 deletion system/athena/athenad.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

ATHENA_HOST = os.getenv('ATHENA_HOST', 'wss://athena.comma.ai')
HANDLER_THREADS = int(os.getenv('HANDLER_THREADS', "4"))
LOCAL_PORT_WHITELIST = {8022}
LOCAL_PORT_WHITELIST = {22, } # SSH

LOG_ATTR_NAME = 'user.upload'
LOG_ATTR_VALUE_MAX_UNIX_TIME = int.to_bytes(2147483647, 4, sys.byteorder)
Expand Down Expand Up @@ -445,6 +445,10 @@ def setRouteViewed(route: str) -> dict[str, int | str]:

def startLocalProxy(global_end_event: threading.Event, remote_ws_uri: str, local_port: int) -> dict[str, int]:
try:
# migration, can be removed once 0.9.8 is out for a while
if local_port == 8022:
local_port = 22

if local_port not in LOCAL_PORT_WHITELIST:
raise Exception("Requested local port not whitelisted")

Expand Down
2 changes: 1 addition & 1 deletion system/camerad/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Import('env', 'arch', 'messaging', 'common', 'gpucommon', 'visionipc')
libs = ['pthread', common, 'jpeg', 'OpenCL', messaging, visionipc, gpucommon]

camera_obj = env.Object(['cameras/camera_qcom2.cc', 'cameras/camera_common.cc', 'cameras/spectra.cc',
'sensors/ar0231.cc', 'sensors/ox03c10.cc', 'sensors/os04c10.cc'])
'cameras/cdm.cc', 'sensors/ar0231.cc', 'sensors/ox03c10.cc', 'sensors/os04c10.cc'])
env.Program('camerad', ['main.cc', camera_obj], LIBS=libs)

if GetOption("extras") and arch == "x86_64":
Expand Down
Loading

0 comments on commit f57909b

Please sign in to comment.