Update251203 (#233)

This commit is contained in:
carrot
2025-12-03 10:28:27 +09:00
committed by GitHub
parent d6899edd97
commit c5ebcbcb97
347 changed files with 8678 additions and 13489 deletions
+110 -5
View File
@@ -4,6 +4,9 @@
#include <eigen3/Eigen/Dense>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include "selfdrive/ui/qt/maps/map_helpers.h"
#include "selfdrive/ui/qt/util.h"
@@ -13,7 +16,7 @@
const int INTERACTION_TIMEOUT = 100;
//const float MAX_ZOOM = 20;// 17;
const float MIN_ZOOM = 14;
const float MIN_ZOOM = 15; // 14;
const float MAX_PITCH = 50;
const float MIN_PITCH = 0;
const float MAP_SCALE = 2;
@@ -147,6 +150,40 @@ void MapWindow::initLayers() {
20, 0
};
if (!m_map->sourceExists("carrotSpeedSource")) {
qDebug() << "Initializing carrotSpeedSource";
// 빈 FeatureCollection GeoJSON (QVariantMap 버전)
QVariantMap fc;
fc["type"] = "FeatureCollection";
fc["features"] = QVariantList{}; // 빈 리스트
QVariantMap src;
src["type"] = "geojson";
src["data"] = fc;
m_map->addSource("carrotSpeedSource", src);
}
if (!m_map->layerExists("carrotSpeedLayer")) {
qDebug() << "Initializing carrotSpeedLayer";
QVariantMap layer;
layer["type"] = "symbol";
layer["source"] = "carrotSpeedSource";
m_map->addLayer("carrotSpeedLayer", layer);
// properties.speed 를 텍스트로 표시 (토큰 방식)
// "{speed}" 라고 쓰면 properties.speed 값을 문자열로 넣어줌
m_map->setLayoutProperty("carrotSpeedLayer", "text-field", "{speed}");
m_map->setLayoutProperty("carrotSpeedLayer", "text-size", 16.0);
m_map->setLayoutProperty("carrotSpeedLayer", "text-offset", QVariantList{ 0.0, -1.5 });
m_map->setLayoutProperty("carrotSpeedLayer", "text-anchor", "top");
m_map->setLayoutProperty("carrotSpeedLayer", "icon-allow-overlap", true);
m_map->setPaintProperty("carrotSpeedLayer", "text-color", QColor("white"));
m_map->setPaintProperty("carrotSpeedLayer", "text-halo-color", QColor("black"));
m_map->setPaintProperty("carrotSpeedLayer", "text-halo-width", 1.0);
m_map->setLayoutProperty("carrotSpeedLayer", "text-allow-overlap", true);
}
m_map->setPaintProperty("buildingsLayer", "fill-extrusion-color", QColor("grey"));
m_map->setPaintProperty("buildingsLayer", "fill-extrusion-opacity", fillExtrusionOpacity);
m_map->setPaintProperty("buildingsLayer", "fill-extrusion-height", fillExtrusionHight);
@@ -228,6 +265,74 @@ void MapWindow::updateState(const UIState &s) {
initLayers();
{
std::string raw = params_memory.get("CarrotSpeedViz");
if (!raw.empty()) {
QString qraw = QString::fromStdString(raw);
//printf("%s\n", qraw.toStdString().c_str());
if (qraw != last_viz_raw) {
last_viz_raw = qraw;
QJsonParseError err;
QJsonDocument doc = QJsonDocument::fromJson(qraw.toUtf8(), &err);
if (err.error == QJsonParseError::NoError && doc.isObject()) {
QJsonObject obj = doc.object();
QJsonArray pts = obj["pts"].toArray();
// GeoJSON FeatureCollection → QVariantMap 트리로 만들기
QVariantList features; // Feature 리스트
for (const QJsonValue& v : pts) {
QJsonArray arr = v.toArray();
if (arr.size() < 3) continue;
double plat = arr[0].toDouble();
double plon = arr[1].toDouble();
double spd = arr[2].toDouble();
// geometry: Point (GeoJSON: [lon, lat] 순서)
QVariantList coords;
coords.append(plon);
coords.append(plat);
QVariantMap geom;
geom["type"] = "Point";
geom["coordinates"] = coords;
// properties: speed
QVariantMap props;
props["speed"] = static_cast<int>(std::round(spd));
// Feature
QVariantMap feature;
feature["type"] = "Feature";
feature["geometry"] = geom;
feature["properties"] = props;
features.append(feature);
}
QVariantMap fc;
fc["type"] = "FeatureCollection";
fc["features"] = features;
QJsonDocument fc_doc = QJsonDocument::fromVariant(fc);
QByteArray fc_bytes = fc_doc.toJson(QJsonDocument::Compact);
QVariantMap src;
src["type"] = "geojson";
src["data"] = fc_bytes;
m_map->updateSource("carrotSpeedSource", src);
m_map->setLayoutProperty("carrotSpeedLayer", "visibility", "visible");
}
}
}
else {
// 필요하면 숨기기
// m_map->setLayoutProperty("carrotSpeedLayer", "visibility", "none");
}
}
if (!locationd_valid) {
setError(tr("Waiting for GPS(APN)"));
} else if (routing_problem) {
@@ -295,17 +400,17 @@ void MapWindow::updateState(const UIState &s) {
updateDestinationMarker();
}
if (loaded_once && (sm.rcv_frame("modelV2") != model_rcv_frame)) {
auto locationd_location = sm["liveLocationKalman"].getLiveLocationKalman();
if (locationd_location.getGpsOK()) {
//auto carrot_man = sm["carrotMan"].getCarrotMan();
/*
gps = (ublox_avaliable)? sm[gps_service].getGpsLocationExternal() : sm[gps_service].getGpsLocation();
if (gps.getHasFix()) {
auto model_path = model_to_collection(locationd_location.getCalibratedOrientationECEF(), locationd_location.getPositionECEF(), sm["modelV2"].getModelV2().getPosition(), carrotMan.getXPosLat(), carrotMan.getXPosLon());
//auto model_path = model_to_collection(sm["modelV2"].getModelV2().getPosition(), carrotMan.getXPosLat(), carrotMan.getXPosLon(), carrotMan.getXPosAngle());
QMapLibre::Feature model_path_feature(QMapLibre::Feature::LineStringType, model_path, {}, {});
QVariantMap modelV2Path;
modelV2Path["type"] = "geojson";
modelV2Path["data"] = QVariant::fromValue<QMapLibre::Feature>(model_path_feature);
m_map->updateSource("modelPathSource", modelV2Path);
}
*/
model_rcv_frame = sm.rcv_frame("modelV2");
}
}
+4 -1
View File
@@ -69,6 +69,7 @@ private:
MapInstructions* map_instructions;
MapETA* map_eta;
// Blue with normal nav, green when nav is input into the model
QColor getNavPathColor(bool nav_enabled) {
return nav_enabled ? QColor("#31ee73") : QColor("#31a1ee");
@@ -78,10 +79,12 @@ private:
void updateDestinationMarker();
uint64_t route_rcv_frame = 0;
// FrogPilot variables
Params params;
uint64_t model_rcv_frame = 0;
Params params_memory{ "/dev/shm/params" };
QString last_viz_raw;
float MAX_ZOOM = 17; // carrot
private slots:
void updateState(const UIState &s);
+15 -9
View File
@@ -215,19 +215,24 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) {
//QObject::connect(init_btn, &QPushButton::clicked, this, &DevicePanel::reboot);
QObject::connect(init_btn, &QPushButton::clicked, [&]() {
if (ConfirmationDialog::confirm(tr("Git pull & Reboot?"), tr("Yes"), this)) {
QString cmd =
"bash -c 'cd /data/openpilot && "
"git fetch && "
"if git status -uno | grep -q \"Your branch is behind\"; then "
"git pull && reboot; "
QString pullscript = "cd /data/openpilot && "
"git fetch origin && "
"LOCAL=$(git rev-parse HEAD) && "
"BRANCH=$(git branch --show-current) && "
"REMOTE=$(git rev-parse origin/$BRANCH) && "
"if [ $LOCAL != $REMOTE ]; then "
"echo 'Local is behind. Pulling updates...' && "
"git pull --ff-only && "
"sudo reboot; "
"else "
"echo \"Already up to date.\"; "
"echo 'Already up to date.'; "
"fi'";
if (!QProcess::startDetached(cmd)) {
bool success = QProcess::startDetached("/bin/sh", QStringList() << "-c" << pullscript);
if (!success) {
ConfirmationDialog::alert(tr("Failed to start update process."), this);
}
else {
} else {
ConfirmationDialog::alert(tr("Update process started. Device will reboot if updates are applied."), this);
}
}
@@ -858,6 +863,7 @@ CarrotPanel::CarrotPanel(QWidget* parent) : QWidget(parent) {
speedToggles->addItem(new CValueControl("AutoNaviSpeedBumpSpeed", tr("SpeedBumpSpeed(35Km/h)"), "", 10, 100, 5));
speedToggles->addItem(new CValueControl("AutoNaviCountDownMode", tr("NaviCountDown mode(2)"), tr("0: off, 1:tbt+camera, 2:tbt+camera+bump"), 0, 2, 1));
speedToggles->addItem(new CValueControl("TurnSpeedControlMode", tr("Turn Speed control mode(1)"), tr("0: off, 1:vision, 2:vision+route, 3: route"), 0, 3, 1));
speedToggles->addItem(new CValueControl("CarrotSmartSpeedControl", tr("Smart Speed Control(0)"), tr("0: off, 1:accel, 2:decel, 3: all"), 0, 3, 1));
speedToggles->addItem(new CValueControl("MapTurnSpeedFactor", tr("Map TurnSpeed Factor(100)"), "", 50, 300, 5));
speedToggles->addItem(new CValueControl("ModelTurnSpeedFactor", tr("Model TurnSpeed Factor(0)"), "", 0, 80, 10));
speedToggles->addItem(new CValueControl("AutoTurnControl", tr("ATC: Auto turn control(0)"), tr("0:None, 1: lane change, 2: lane change + speed, 3: speed"), 0, 3, 1));