FrogPilot Setup

This commit is contained in:
FrogAi
2024-03-01 09:26:59 -07:00
parent 505ad1fbfe
commit 6c946fc97a
106 changed files with 2349 additions and 185 deletions

View File

@@ -12,7 +12,6 @@
#include "common/util.h"
#include "common/watchdog.h"
#include "system/hardware/hw.h"
#define BACKLIGHT_DT 0.05
#define BACKLIGHT_TS 10.00
@@ -201,6 +200,23 @@ static void update_state(UIState *s) {
if (sm.updated("carParams")) {
scene.longitudinal_control = sm["carParams"].getCarParams().getOpenpilotLongitudinalControl();
}
if (sm.updated("carState")) {
auto carState = sm["carState"].getCarState();
}
if (sm.updated("controlsState")) {
auto controlsState = sm["controlsState"].getControlsState();
scene.enabled = controlsState.getEnabled();
scene.experimental_mode = controlsState.getExperimentalMode();
}
if (sm.updated("frogpilotCarControl")) {
auto frogpilotCarControl = sm["frogpilotCarControl"].getFrogpilotCarControl();
}
if (sm.updated("frogpilotPlan")) {
auto frogpilotPlan = sm["frogpilotPlan"].getFrogpilotPlan();
}
if (sm.updated("liveLocationKalman")) {
auto liveLocationKalman = sm["liveLocationKalman"].getLiveLocationKalman();
}
if (sm.updated("wideRoadCameraState")) {
auto cam_state = sm["wideRoadCameraState"].getWideRoadCameraState();
float scale = (cam_state.getSensor() == cereal::FrameData::ImageSensor::AR0231) ? 6.0f : 1.0f;
@@ -221,6 +237,19 @@ void ui_update_params(UIState *s) {
s->scene.map_on_left = params.getBool("NavSettingLeftSide");
}
void ui_update_frogpilot_params(UIState *s) {
ui_update_params(s);
Params params = Params();
UIScene &scene = s->scene;
bool custom_onroad_ui = params.getBool("CustomUI");
bool quality_of_life_controls = params.getBool("QOLControls");
bool quality_of_life_visuals = params.getBool("QOLVisuals");
}
void UIState::updateStatus() {
if (scene.started && sm->updated("controlsState")) {
auto controls_state = (*sm)["controlsState"].getControlsState();
@@ -249,6 +278,7 @@ UIState::UIState(QObject *parent) : QObject(parent) {
"modelV2", "controlsState", "liveCalibration", "radarState", "deviceState",
"pandaStates", "carParams", "driverMonitoringState", "carState", "liveLocationKalman", "driverStateV2",
"wideRoadCameraState", "managerState", "navInstruction", "navRoute", "uiPlan",
"frogpilotCarControl", "frogpilotDeviceState", "frogpilotPlan",
});
Params params;
@@ -262,6 +292,8 @@ UIState::UIState(QObject *parent) : QObject(parent) {
timer = new QTimer(this);
QObject::connect(timer, &QTimer::timeout, this, &UIState::update);
timer->start(1000 / UI_FREQ);
ui_update_frogpilot_params(this);
}
void UIState::update() {
@@ -273,6 +305,15 @@ void UIState::update() {
watchdog_kick(nanos_since_boot());
}
emit uiUpdate(*this);
// Update FrogPilot variables when they are changed
Params paramsMemory{"/dev/shm/params"};
if (paramsMemory.getBool("FrogPilotTogglesUpdated")) {
std::thread updateFrogPilotParams(ui_update_frogpilot_params, this);
updateFrogPilotParams.detach();
}
// FrogPilot live variables that need to be constantly checked
}
void UIState::setPrimeType(PrimeType type) {