onroad UI: GPS speed display, hidden when no fix
Speed indicator now uses gpsLocation speed (MPH) instead of carState vEgo. Hides completely when no GPS fix is available. Added gpsLocation to UI SubMaster subscriptions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -341,6 +341,7 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
|
|||||||
const bool cs_alive = sm.alive("controlsState");
|
const bool cs_alive = sm.alive("controlsState");
|
||||||
const auto cs = sm["controlsState"].getControlsState();
|
const auto cs = sm["controlsState"].getControlsState();
|
||||||
const auto car_state = sm["carState"].getCarState();
|
const auto car_state = sm["carState"].getCarState();
|
||||||
|
(void)car_state; // CLEARPILOT: suppress unused warning, will use later
|
||||||
|
|
||||||
// Handle older routes where vCruiseCluster is not set
|
// Handle older routes where vCruiseCluster is not set
|
||||||
float v_cruise = cs.getVCruiseCluster() == 0.0 ? cs.getVCruise() : cs.getVCruiseCluster();
|
float v_cruise = cs.getVCruiseCluster() == 0.0 ? cs.getVCruise() : cs.getVCruiseCluster();
|
||||||
@@ -350,11 +351,15 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
|
|||||||
setSpeed *= KM_TO_MILE;
|
setSpeed *= KM_TO_MILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle older routes where vEgoCluster is not set
|
// CLEARPILOT: use GPS speed if available, hide speed display if no GPS fix
|
||||||
v_ego_cluster_seen = v_ego_cluster_seen || car_state.getVEgoCluster() != 0.0;
|
has_gps_speed = sm.valid("gpsLocation") && sm["gpsLocation"].getGpsLocation().getHasFix();
|
||||||
float v_ego = v_ego_cluster_seen && !scene.wheel_speed ? car_state.getVEgoCluster() : car_state.getVEgo();
|
if (has_gps_speed) {
|
||||||
speed = cs_alive ? std::max<float>(0.0, v_ego) : 0.0;
|
float gps_speed_ms = sm["gpsLocation"].getGpsLocation().getSpeed();
|
||||||
|
speed = std::max<float>(0.0, gps_speed_ms);
|
||||||
speed *= s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH;
|
speed *= s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH;
|
||||||
|
} else {
|
||||||
|
speed = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
// auto speed_limit_sign = nav_instruction.getSpeedLimitSign();
|
// auto speed_limit_sign = nav_instruction.getSpeedLimitSign();
|
||||||
// speedLimit = slcOverridden ? scene.speed_limit_overridden_speed : speedLimitController ? scene.speed_limit : nav_alive ? nav_instruction.getSpeedLimit() : 0.0;
|
// speedLimit = slcOverridden ? scene.speed_limit_overridden_speed : speedLimitController ? scene.speed_limit : nav_alive ? nav_instruction.getSpeedLimit() : 0.0;
|
||||||
@@ -449,13 +454,10 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
|
|||||||
// Todo: lead speed
|
// Todo: lead speed
|
||||||
// Todo: Experimental speed
|
// Todo: Experimental speed
|
||||||
|
|
||||||
// // current speed
|
// CLEARPILOT: show GPS speed, hide when no fix
|
||||||
if (!(scene.hide_speed)) {
|
if (has_gps_speed && !scene.hide_speed) {
|
||||||
// CLEARPILOT changes to 120 from ~176
|
|
||||||
// Maybe we want to hide this?
|
|
||||||
p.setFont(InterFont(140, QFont::Bold));
|
p.setFont(InterFont(140, QFont::Bold));
|
||||||
drawText(p, rect().center().x(), 210, speedStr);
|
drawText(p, rect().center().x(), 210, speedStr);
|
||||||
// CLEARPILOT changes to 40 from 66
|
|
||||||
p.setFont(InterFont(50));
|
p.setFont(InterFont(50));
|
||||||
drawText(p, rect().center().x(), 290, speedUnit, 200);
|
drawText(p, rect().center().x(), 290, speedUnit, 200);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ private:
|
|||||||
QVBoxLayout *main_layout;
|
QVBoxLayout *main_layout;
|
||||||
QPixmap dm_img;
|
QPixmap dm_img;
|
||||||
float speed;
|
float speed;
|
||||||
|
bool has_gps_speed = false;
|
||||||
QString speedUnit;
|
QString speedUnit;
|
||||||
float setSpeed;
|
float setSpeed;
|
||||||
float speedLimit;
|
float speedLimit;
|
||||||
|
|||||||
@@ -442,6 +442,7 @@ UIState::UIState(QObject *parent) : QObject(parent) {
|
|||||||
"pandaStates", "carParams", "driverMonitoringState", "carState", "liveLocationKalman", "driverStateV2",
|
"pandaStates", "carParams", "driverMonitoringState", "carState", "liveLocationKalman", "driverStateV2",
|
||||||
"wideRoadCameraState", "managerState", "uiPlan", "liveTorqueParameters",
|
"wideRoadCameraState", "managerState", "uiPlan", "liveTorqueParameters",
|
||||||
"frogpilotCarControl", "frogpilotDeviceState", "frogpilotPlan",
|
"frogpilotCarControl", "frogpilotDeviceState", "frogpilotPlan",
|
||||||
|
"gpsLocation",
|
||||||
});
|
});
|
||||||
|
|
||||||
Params params;
|
Params params;
|
||||||
|
|||||||
Reference in New Issue
Block a user