Custom UI
Added toggles to customize the lane lines, path, road edges, path edges, show the acceleration/deceleration on the path, lead info, driving logics, adjacent lanes, blind spot path, fps tracker, and an "Unlimited Length" mode that extends the road UI out as far as the model can see.
This commit is contained in:
@@ -34,6 +34,19 @@ def get_min_accel_sport_tune(v_ego):
|
||||
def get_max_accel_sport_tune(v_ego):
|
||||
return interp(v_ego, A_CRUISE_MAX_BP_CUSTOM, A_CRUISE_MAX_VALS_SPORT_TUNE)
|
||||
|
||||
def calculate_lane_width(lane, current_lane, road_edge):
|
||||
lane_x, lane_y = np.array(lane.x), np.array(lane.y)
|
||||
edge_x, edge_y = np.array(road_edge.x), np.array(road_edge.y)
|
||||
current_x, current_y = np.array(current_lane.x), np.array(current_lane.y)
|
||||
|
||||
lane_y_interp = np.interp(current_x, lane_x[lane_x.argsort()], lane_y[lane_x.argsort()])
|
||||
road_edge_y_interp = np.interp(current_x, edge_x[edge_x.argsort()], edge_y[edge_x.argsort()])
|
||||
|
||||
distance_to_lane = np.mean(np.abs(current_y - lane_y_interp))
|
||||
distance_to_road_edge = np.mean(np.abs(current_y - road_edge_y_interp))
|
||||
|
||||
return min(distance_to_lane, distance_to_road_edge)
|
||||
|
||||
|
||||
class FrogPilotPlanner:
|
||||
def __init__(self, params):
|
||||
@@ -80,6 +93,9 @@ class FrogPilotPlanner:
|
||||
frogpilot_lateral_plan_send.valid = sm.all_checks(service_list=['carState', 'controlsState', 'modelV2'])
|
||||
frogpilotLateralPlan = frogpilot_lateral_plan_send.frogpilotLateralPlan
|
||||
|
||||
frogpilotLateralPlan.laneWidthLeft = float(DH.lane_width_left)
|
||||
frogpilotLateralPlan.laneWidthRight = float(DH.lane_width_right)
|
||||
|
||||
pm.send('frogpilotLateralPlan', frogpilot_lateral_plan_send)
|
||||
|
||||
def publish_longitudinal(self, sm, pm, mpc):
|
||||
@@ -90,11 +106,18 @@ class FrogPilotPlanner:
|
||||
frogpilotLongitudinalPlan.conditionalExperimental = self.cem.experimental_mode
|
||||
frogpilotLongitudinalPlan.distances = self.x_desired_trajectory.tolist()
|
||||
|
||||
frogpilotLongitudinalPlan.safeObstacleDistance = mpc.safe_obstacle_distance
|
||||
frogpilotLongitudinalPlan.stoppedEquivalenceFactor = mpc.stopped_equivalence_factor
|
||||
frogpilotLongitudinalPlan.desiredFollowDistance = mpc.safe_obstacle_distance - mpc.stopped_equivalence_factor
|
||||
frogpilotLongitudinalPlan.safeObstacleDistanceStock = mpc.safe_obstacle_distance_stock
|
||||
|
||||
pm.send('frogpilotLongitudinalPlan', frogpilot_longitudinal_plan_send)
|
||||
|
||||
def update_frogpilot_params(self, params):
|
||||
self.is_metric = params.get_bool("IsMetric")
|
||||
|
||||
self.blindspot_path = params.get_bool("CustomUI") and params.get_bool("BlindSpotPath")
|
||||
|
||||
self.conditional_experimental_mode = params.get_bool("ConditionalExperimental")
|
||||
if self.conditional_experimental_mode:
|
||||
self.cem.update_frogpilot_params(self.is_metric, params)
|
||||
|
||||
@@ -4,6 +4,20 @@
|
||||
FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) {
|
||||
const std::vector<std::tuple<QString, QString, QString, QString>> visualToggles {
|
||||
{"CameraView", "Camera View", "Choose your preferred camera view for the onroad UI. This is a visual change only and doesn't impact openpilot.", "../frogpilot/assets/toggle_icons/icon_camera.png"},
|
||||
|
||||
{"CustomUI", "Custom Onroad UI", "Customize the Onroad UI with some additional visual functions.", "../assets/offroad/icon_road.png"},
|
||||
{"AdjacentPath", "Adjacent Paths", "Display paths to the left and right of your car, visualizing where the model detects lanes.", ""},
|
||||
{"BlindSpotPath", "Blind Spot Path", "Visualize your blind spots with a red path when another vehicle is detected nearby.", ""},
|
||||
{"ShowFPS", "FPS Counter", "Display the Frames Per Second (FPS) of your onroad UI for monitoring system performance.", ""},
|
||||
{"LeadInfo", "Lead Info and Logics", "Get detailed information about the vehicle ahead, including speed and distance, and the logic behind your following distance.", ""},
|
||||
|
||||
{"ModelUI", "Model UI", "Personalize how the model's visualizations appear on your screen.", "../assets/offroad/icon_calibration.png"},
|
||||
{"AccelerationPath", "Acceleration Path", "Visualize the car's intended acceleration or deceleration with a color-coded path.", ""},
|
||||
{"LaneLinesWidth", "Lane Lines", "Adjust the visual thickness of lane lines on your display.\n\nDefault matches the MUTCD average of 4 inches.", ""},
|
||||
{"PathEdgeWidth", "Path Edges", "Adjust the width of the path edges shown on your UI to represent different driving modes and statuses.\n\nDefault is 20% of the total path.\n\nBlue = Navigation\nLight Blue = Always On Lateral\nGreen = Default with 'FrogPilot Colors'\nLight Green = Default with stock colors\nOrange = Experimental Mode Active\nYellow = Conditional Overriden", ""},
|
||||
{"PathWidth", "Path Width", "Customize the width of the driving path shown on your UI.\n\nDefault matches the width of a 2019 Lexus ES 350.", ""},
|
||||
{"RoadEdgesWidth", "Road Edges", "Adjust the visual thickness of road edges on your display.\n\nDefault is 1/2 of the MUTCD average lane line width of 4 inches.", ""},
|
||||
{"UnlimitedLength", "'Unlimited' Road UI Length", "Extend the display of the path, lane lines, and road edges as far as the system can detect, providing a more expansive view of the road ahead.", ""},
|
||||
};
|
||||
|
||||
for (const auto &[param, title, desc, icon] : visualToggles) {
|
||||
@@ -14,6 +28,36 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
|
||||
FrogPilotButtonParamControl *preferredCamera = new FrogPilotButtonParamControl(param, title, desc, icon, cameraOptions);
|
||||
toggle = preferredCamera;
|
||||
|
||||
} else if (param == "CustomUI") {
|
||||
FrogPilotParamManageControl *customUIToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(customUIToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(customOnroadUIKeys.find(key.c_str()) != customOnroadUIKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = customUIToggle;
|
||||
} else if (param == "LeadInfo") {
|
||||
std::vector<QString> leadInfoToggles{tr("UseSI")};
|
||||
std::vector<QString> leadInfoToggleNames{tr("Use SI Values")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, leadInfoToggles, leadInfoToggleNames);
|
||||
|
||||
} else if (param == "ModelUI") {
|
||||
FrogPilotParamManageControl *modelUIToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(modelUIToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(modelUIKeys.find(key.c_str()) != modelUIKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = modelUIToggle;
|
||||
} else if (param == "LaneLinesWidth" || param == "RoadEdgesWidth") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 24, std::map<int, QString>(), this, false, " inches");
|
||||
} else if (param == "PathEdgeWidth") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map<int, QString>(), this, false, "%");
|
||||
} else if (param == "PathWidth") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map<int, QString>(), this, false, " feet", 10);
|
||||
|
||||
} else {
|
||||
toggle = new ParamControl(param, title, desc, icon, this);
|
||||
}
|
||||
@@ -38,9 +82,9 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
|
||||
});
|
||||
}
|
||||
|
||||
customOnroadUIKeys = {};
|
||||
customOnroadUIKeys = {"AdjacentPath", "BlindSpotPath", "ShowFPS", "LeadInfo"};
|
||||
customThemeKeys = {};
|
||||
modelUIKeys = {};
|
||||
modelUIKeys = {"AccelerationPath", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength"};
|
||||
|
||||
QObject::connect(device(), &Device::interactiveTimeout, this, &FrogPilotVisualsPanel::hideSubToggles);
|
||||
QObject::connect(parent, &SettingsWindow::closeParentToggle, this, &FrogPilotVisualsPanel::hideSubToggles);
|
||||
@@ -65,12 +109,34 @@ void FrogPilotVisualsPanel::updateMetric() {
|
||||
if (isMetric != previousIsMetric) {
|
||||
double distanceConversion = isMetric ? INCH_TO_CM : CM_TO_INCH;
|
||||
double speedConversion = isMetric ? FOOT_TO_METER : METER_TO_FOOT;
|
||||
params.putInt("LaneLinesWidth", std::nearbyint(params.getInt("LaneLinesWidth") * distanceConversion));
|
||||
params.putInt("RoadEdgesWidth", std::nearbyint(params.getInt("RoadEdgesWidth") * distanceConversion));
|
||||
params.putInt("PathWidth", std::nearbyint(params.getInt("PathWidth") * speedConversion));
|
||||
}
|
||||
|
||||
FrogPilotParamValueControl *laneLinesWidthToggle = static_cast<FrogPilotParamValueControl*>(toggles["LaneLinesWidth"]);
|
||||
FrogPilotParamValueControl *roadEdgesWidthToggle = static_cast<FrogPilotParamValueControl*>(toggles["RoadEdgesWidth"]);
|
||||
FrogPilotParamValueControl *pathWidthToggle = static_cast<FrogPilotParamValueControl*>(toggles["PathWidth"]);
|
||||
|
||||
if (isMetric) {
|
||||
laneLinesWidthToggle->setDescription("Customize the lane line width.\n\nDefault matches the Vienna average of 10 centimeters.");
|
||||
roadEdgesWidthToggle->setDescription("Customize the road edges width.\n\nDefault is 1/2 of the Vienna average lane line width of 10 centimeters.");
|
||||
|
||||
laneLinesWidthToggle->updateControl(0, 60, " centimeters");
|
||||
roadEdgesWidthToggle->updateControl(0, 60, " centimeters");
|
||||
pathWidthToggle->updateControl(0, 30, " meters");
|
||||
} else {
|
||||
laneLinesWidthToggle->setDescription("Customize the lane line width.\n\nDefault matches the MUTCD average of 4 inches.");
|
||||
roadEdgesWidthToggle->setDescription("Customize the road edges width.\n\nDefault is 1/2 of the MUTCD average lane line width of 4 inches.");
|
||||
|
||||
laneLinesWidthToggle->updateControl(0, 24, " inches");
|
||||
roadEdgesWidthToggle->updateControl(0, 24, " inches");
|
||||
pathWidthToggle->updateControl(0, 100, " feet");
|
||||
}
|
||||
|
||||
laneLinesWidthToggle->refresh();
|
||||
roadEdgesWidthToggle->refresh();
|
||||
|
||||
previousIsMetric = isMetric;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user