mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-12 04:42:13 +08:00
Track FrogPilot drives
This commit is contained in:
@@ -275,6 +275,9 @@ std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"ForceFingerprint", PERSISTENT},
|
||||
{"ForceMPHDashboard", PERSISTENT},
|
||||
{"FPSCounter", PERSISTENT},
|
||||
{"FrogPilotDrives", PERSISTENT},
|
||||
{"FrogPilotKilometers", PERSISTENT},
|
||||
{"FrogPilotMinutes", PERSISTENT},
|
||||
{"FrogPilotTogglesUpdated", PERSISTENT},
|
||||
{"FrogsGoMooTune", PERSISTENT},
|
||||
{"FullMap", PERSISTENT},
|
||||
|
||||
@@ -210,7 +210,7 @@ def crash_log(candidate):
|
||||
params = Params()
|
||||
serial_id = params.get("HardwareSerial", encoding='utf-8')
|
||||
|
||||
control_keys, vehicle_keys, visual_keys = [
|
||||
control_keys, vehicle_keys, visual_keys, tracking_keys = [
|
||||
"AdjustablePersonalities", "PersonalitiesViaWheel", "PersonalitiesViaScreen", "AlwaysOnLateral", "AlwaysOnLateralMain",
|
||||
"ConditionalExperimental", "CESpeed", "CESpeedLead", "CECurves", "CECurvesLead", "CENavigation", "CENavigationIntersections",
|
||||
"CENavigationLead", "CENavigationTurns", "CESlowerLead", "CEStopLights", "CEStopLightsLead", "CESignal", "CustomPersonalities",
|
||||
@@ -233,14 +233,16 @@ def crash_log(candidate):
|
||||
"ModelUI", "DynamicPathWidth", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength", "QOLVisuals", "DriveStats",
|
||||
"FullMap", "HideSpeed", "HideSpeedUI", "ShowSLCOffset", "SpeedLimitChangedAlert", "WheelSpeed", "RandomEvents", "ScreenBrightness", "WheelIcon",
|
||||
"RotatingWheel", "NumericalTemp", "Fahrenheit", "ShowCPU", "ShowGPU", "ShowIP", "ShowMemoryUsage", "ShowStorageLeft", "ShowStorageUsed", "Sidebar"
|
||||
], [
|
||||
"FrogPilotDrives", "FrogPilotKilometers", "FrogPilotMinutes"
|
||||
]
|
||||
|
||||
control_params, vehicle_params, visual_params = map(lambda keys: get_frogpilot_params(params, keys), [control_keys, vehicle_keys, visual_keys])
|
||||
control_values, vehicle_values, visual_values = map(format_params, [control_params, vehicle_params, visual_params])
|
||||
control_chunks, vehicle_chunks, visual_chunks = map(lambda data: chunk_data(data, 50), [control_values, vehicle_values, visual_values])
|
||||
control_params, vehicle_params, visual_params, tracking_params = map(lambda keys: get_frogpilot_params(params, keys), [control_keys, vehicle_keys, visual_keys, tracking_keys])
|
||||
control_values, vehicle_values, visual_values, tracking_values = map(format_params, [control_params, vehicle_params, visual_params, tracking_params])
|
||||
control_chunks, vehicle_chunks, visual_chunks, tracking_chunks = map(lambda data: chunk_data(data, 50), [control_values, vehicle_values, visual_values, tracking_values])
|
||||
|
||||
with sentry_sdk.configure_scope() as scope:
|
||||
for chunks, label in zip([control_chunks, vehicle_chunks, visual_chunks], ["FrogPilot Controls", "FrogPilot Vehicles", "FrogPilot Visuals"]):
|
||||
for chunks, label in zip([control_chunks, vehicle_chunks, visual_chunks, tracking_chunks], ["FrogPilot Controls", "FrogPilot Vehicles", "FrogPilot Visuals", "FrogPilot Tracking"]):
|
||||
set_sentry_scope(scope, chunks, label)
|
||||
sentry.capture_warning(f"Fingerprinted: {candidate}", serial_id)
|
||||
|
||||
|
||||
@@ -188,6 +188,8 @@ class Controls:
|
||||
self.stopped_for_light_previously = False
|
||||
self.vCruise69_alert_played = False
|
||||
|
||||
self.drive_distance = 0
|
||||
self.previous_drive_distance = 0
|
||||
self.previous_lead_distance = 0
|
||||
self.previous_speed_limit = SpeedLimitController.desired_speed_limit
|
||||
self.random_event_timer = 0
|
||||
@@ -573,6 +575,13 @@ class Controls:
|
||||
if self.sm['modelV2'].frameDropPerc > 20:
|
||||
self.events.add(EventName.modeldLagging)
|
||||
|
||||
# Store the total distance traveled
|
||||
self.drive_distance += CS.vEgo * DT_CTRL
|
||||
|
||||
if self.drive_distance != self.previous_drive_distance:
|
||||
self.params_memory.put_float("FrogPilotKilometers", self.drive_distance / 1000)
|
||||
self.params_memory.put_float("FrogPilotMinutes", self.sm.frame * DT_CTRL / 60)
|
||||
|
||||
# Green light alert
|
||||
if self.green_light_alert:
|
||||
stopped_for_light = frogpilot_plan.redLight and CS.standstill
|
||||
|
||||
Regular → Executable
+18
@@ -360,6 +360,24 @@ def manager_thread() -> None:
|
||||
if os.path.isfile(os.path.join(sentry.CRASHES_DIR, 'error.txt')):
|
||||
os.remove(os.path.join(sentry.CRASHES_DIR, 'error.txt'))
|
||||
|
||||
# Store the previous drive's data
|
||||
keys = ["FrogPilotKilometers", "FrogPilotMinutes"]
|
||||
for key in keys:
|
||||
current_value = params.get_float(key)
|
||||
value_to_add = params_memory.get_float(key)
|
||||
new_value = current_value + value_to_add
|
||||
|
||||
params.put_float(key, new_value)
|
||||
params_storage.put_float(key, new_value)
|
||||
params_memory.remove(key)
|
||||
|
||||
# Only count the drive if it lasted longer than 5 minutes
|
||||
if key == "FrogPilotMinutes" and value_to_add >= 5:
|
||||
new_frogpilot_drives = params.get_int("FrogPilotDrives") + 1
|
||||
|
||||
params.put_int("FrogPilotDrives", new_frogpilot_drives)
|
||||
params_storage.put_int("FrogPilotDrives", new_frogpilot_drives)
|
||||
|
||||
# update onroad params, which drives boardd's safety setter thread
|
||||
if started != started_prev:
|
||||
write_onroad_params(started, params)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <QJsonObject>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "common/params.h"
|
||||
#include "selfdrive/ui/qt/request_repeater.h"
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
|
||||
@@ -16,19 +15,19 @@ static QLabel* newLabel(const QString& text, const QString &type) {
|
||||
}
|
||||
|
||||
DriveStats::DriveStats(QWidget* parent) : QFrame(parent) {
|
||||
metric_ = Params().getBool("IsMetric");
|
||||
metric_ = params.getBool("IsMetric");
|
||||
|
||||
QVBoxLayout* main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(50, 50, 50, 60);
|
||||
main_layout->setContentsMargins(50, 25, 50, 20);
|
||||
|
||||
auto add_stats_layouts = [=](const QString &title, StatsLabels& labels) {
|
||||
auto add_stats_layouts = [=](const QString &title, StatsLabels& labels, bool FrogPilot=false) {
|
||||
QGridLayout* grid_layout = new QGridLayout;
|
||||
grid_layout->setVerticalSpacing(10);
|
||||
grid_layout->setContentsMargins(0, 10, 0, 10);
|
||||
|
||||
int row = 0;
|
||||
grid_layout->addWidget(newLabel(title, "title"), row++, 0, 1, 3);
|
||||
grid_layout->addItem(new QSpacerItem(0, 50), row++, 0, 1, 1);
|
||||
grid_layout->addWidget(newLabel(title, FrogPilot ? "frogpilot_title" : "title"), row++, 0, 1, 3);
|
||||
grid_layout->addItem(new QSpacerItem(0, 10), row++, 0, 1, 1);
|
||||
|
||||
grid_layout->addWidget(labels.routes = newLabel("0", "number"), row, 0, Qt::AlignLeft);
|
||||
grid_layout->addWidget(labels.distance = newLabel("0", "number"), row, 1, Qt::AlignLeft);
|
||||
@@ -39,11 +38,12 @@ DriveStats::DriveStats(QWidget* parent) : QFrame(parent) {
|
||||
grid_layout->addWidget(newLabel(tr("Hours"), "unit"), row + 1, 2, Qt::AlignLeft);
|
||||
|
||||
main_layout->addLayout(grid_layout);
|
||||
main_layout->addStretch(1);
|
||||
};
|
||||
|
||||
add_stats_layouts(tr("ALL TIME"), all_);
|
||||
main_layout->addStretch();
|
||||
add_stats_layouts(tr("PAST WEEK"), week_);
|
||||
add_stats_layouts(tr("FROGPILOT"), frogPilot_, true);
|
||||
|
||||
if (auto dongleId = getDongleId()) {
|
||||
QString url = CommaApi::BASE_URL + "/v1.1/devices/" + *dongleId + "/stats";
|
||||
@@ -57,9 +57,10 @@ DriveStats::DriveStats(QWidget* parent) : QFrame(parent) {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
QLabel[type="title"] { font-size: 51px; font-weight: 500; }
|
||||
QLabel[type="number"] { font-size: 78px; font-weight: 500; }
|
||||
QLabel[type="unit"] { font-size: 51px; font-weight: 300; color: #A0A0A0; }
|
||||
QLabel[type="title"] { font-size: 50px; font-weight: 500; }
|
||||
QLabel[type="frogpilot_title"] { font-size: 50px; font-weight: 500; color: #178643; }
|
||||
QLabel[type="number"] { font-size: 65px; font-weight: 400; }
|
||||
QLabel[type="unit"] { font-size: 50px; font-weight: 300; color: #A0A0A0; }
|
||||
)");
|
||||
}
|
||||
|
||||
@@ -74,6 +75,16 @@ void DriveStats::updateStats() {
|
||||
QJsonObject json = stats_.object();
|
||||
update(json["all"].toObject(), all_);
|
||||
update(json["week"].toObject(), week_);
|
||||
|
||||
auto updateFrogPilot = [this](const QJsonObject& obj, StatsLabels& labels) {
|
||||
labels.routes->setText(QString::number(params.getInt("FrogPilotDrives")));
|
||||
labels.distance->setText(QString::number(int(params.getFloat("FrogPilotKilometers") * (metric_ ? 1 : KM_TO_MILE))));
|
||||
labels.distance_unit->setText(getDistanceUnit());
|
||||
labels.hours->setText(QString::number(int(params.getFloat("FrogPilotMinutes") / 60)));
|
||||
};
|
||||
|
||||
QJsonObject frogPilotJson = stats_.object();
|
||||
updateFrogPilot(json["frogpilot"].toObject(), frogPilot_);
|
||||
}
|
||||
|
||||
void DriveStats::parseResponse(const QString& response, bool success) {
|
||||
@@ -89,9 +100,6 @@ void DriveStats::parseResponse(const QString& response, bool success) {
|
||||
}
|
||||
|
||||
void DriveStats::showEvent(QShowEvent* event) {
|
||||
bool metric = Params().getBool("IsMetric");
|
||||
if (metric_ != metric) {
|
||||
metric_ = metric;
|
||||
updateStats();
|
||||
}
|
||||
metric_ = params.getBool("IsMetric");
|
||||
updateStats();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QLabel>
|
||||
|
||||
#include "common/params.h"
|
||||
|
||||
class DriveStats : public QFrame {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -15,10 +17,11 @@ private:
|
||||
inline QString getDistanceUnit() const { return metric_ ? tr("KM") : tr("Miles"); }
|
||||
|
||||
bool metric_;
|
||||
Params params;
|
||||
QJsonDocument stats_;
|
||||
struct StatsLabels {
|
||||
QLabel *routes, *distance, *distance_unit, *hours;
|
||||
} all_, week_;
|
||||
} all_, week_, frogPilot_;
|
||||
|
||||
private slots:
|
||||
void parseResponse(const QString &response, bool success);
|
||||
|
||||
Reference in New Issue
Block a user