mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-15 13:12:07 +08:00
ee5c1c4507
* allow re-regage * bump opendbc * bump panda * apply pause/resume fix for hyundai (should do this in a separate PR) * bump opendbc * fix * rename * Fix? * make sure to disengage for allow always cars * fix * combine * more fix * not needed * check if engagement is from openpilot's state machine * Rename * fix panda safety * fix * no fake lfa button for @devtekve ;) * fix non drive gear re-engage * fix settings * combine * add replace method * use replace * remoev already checks if it exists * fix * group * add todo * reserve events * cleaner * hyundai: only allow for cars with lfa button * sunnyParams * make sure it's car only * Move car-specific changes to opendbc * no need * bump opendbc * more fixes * no more available * more! * final? * always emit user disable * no longer needed * move unit test * add sunnypilot to unit tests * bump opendbc * use new cereal * bump opendbc * static analysis * no unittest * no need available * UI border update * show MADS updates * Add TODO * no longer needed * fix changed events * fix cluster enabled * don't add pre enable if not long * should use enabled * enabled <-> active * better format * bump opendbc * static analysis * static analysis * Rename test as collector was dying * Show our overriding * Revert "show MADS updates" This reverts commitdaf0ad62Revert "fix changed events" This reverts commit31d8c97f* ignoring reserved events * adjusting creation delays * back to stock removing allow_cancel * should be enabled * revert * silent lkas disable * no need * user disable tests * just warning * MUST REMOVE test process replay * fix no entry * fixme * bump opendbc * need this check * cleanup * allow entering paused state if no entry from disabled * brake hold should apply to all * in lists * update unit test * simpler * unused * same thing * fix * only mads in enabled state and long in disabled state * unify silent enable * do this for dlob * bump submodules * fix * bump submodules * bump opendbc * less frequent * more events * fix * allow no entry to paused for non-drive gears * fix * use cereal * Revert "allow no entry to paused for non-drive gears" This reverts commit6d64a4dd9c. * allow in all * Revert "allow in all" This reverts commit6375f14891. * should not be all! * rename for clarity * silent park brake * flipped * bump submodules * Bump to latest mads-new panda * bump panda * more nissan * bump panda * bump msgq * bump panda * bump submodules * bump opendbc * bump opendbc * improving the state * Revert "PlayStation® model (#34133)" This reverts commit5160bee543. * should be none * bump panda * bump opendbc * Apply suggestions from code review * bump panda * bump ref panda * add todo-sp * bump panda ref * bump more panda * changing refs * nuke nuke nuke * use sunny's newer states * bump with new panda * bump panda * Parse more flags from alt exp, more tests, hyundai main cruise allowed * Parse more flags from alt exp, more tests, hyundai main cruise allowed * missed * mutation for controls allowed rising edge * ford mutation * license * remove * unused * bump submodules * use always allowed mads button alt exp * fix * whitelist jason's lastname to codespell * test_processes: update ref logs to82c0278* bump submodules * bump submodules * bump submodules * bump panda * add controls mismatch lateral event * Simplify lateral disengagement logic for MADS configuration Reversed the conditional to align the logic with the `disengage_lateral_on_brake` parameter. This ensures that lateral disengagement behavior is more intuitive and matches the expected configuration. Improves code readability and reduces potential misconfigurations. * remove unified engagement mode in panda * controls allow should be allowed at all times * squash! treat MADS button as user entry * heartbeat for mads * heartbeat mismatch exit control * remove always allow mads button from alt * move to safety_mads * remove main cruise allowed from alt * bump panda * heartbeat engaged mads mismatch mutation test * bump panda * use mads the third panda * ignore pre enable with mads * only force exit if actually actuating * use brake signal instead of pedal events when dlob is active * fix tests * fix panda tests * bump panda * new events to retain long blocks * format * uem: do not engage mads if long is engaged * bump submodules * fix not allowed engaged bug * block uem from engaging * flipped * use different heartbeat check if dlob * hard code to skip heartbeat check * remove toyota lta status for lkas, causes weird behaviors * block tesla * bump panda * bump to merged panda * bump opendbc * bump opendbc * bump opendbc * bump opendbc * Apply suggestions from code review * code ignore spells * needs to be in carstate * Bump opendbc * Update MADS toggle descriptions for clarity. Added notes to clarify behavior of the "MadsMainCruiseAllowed" setting, particularly its impact on vehicles without LFA/LKAS buttons. This ensures users are informed about potential implications when disabling this feature. * Updating translations + Adding spanish * Disengage Lateral on Brake -> Pause Lateral on Brake * test_processes: update ref logs todd41005* Apply suggestions from code review * fix mads button not allowed * bump submodules * bump submodule * test_processes: update ref logs to0a0b998* has multiple lists * Revert "has multiple lists" This reverts commita37c1d26fe. * base * Reapply "has multiple lists" This reverts commitd1cd8dcc81. * migrate mads toggles to sp panel * this is why it keeps crashing * house keeping * more housekeeping * more housekeeping * don't show description by default (yet) * reset to main panel when clicked away * more * some more with interactions * don't stretch cause it looks weird with descriptions * simpler to handle offroad transition * some are toggleable while onroad * remove unused event * slight cleanup * default to true for HKG main cruise toggle * append to list after * add Customize MADS to UI preview * simpler * move to sp list * how tf was this removed * update mads settings button on show event * test_processes: update ref logs toefa9c32--------- Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
144 lines
3.2 KiB
C++
144 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include <eigen3/Eigen/Dense>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include <QTimer>
|
|
#include <QColor>
|
|
#include <QFuture>
|
|
|
|
#include "cereal/messaging/messaging.h"
|
|
#include "common/mat.h"
|
|
#include "common/params.h"
|
|
#include "common/util.h"
|
|
#include "system/hardware/hw.h"
|
|
#include "selfdrive/ui/qt/prime_state.h"
|
|
|
|
const int UI_BORDER_SIZE = 30;
|
|
const int UI_HEADER_HEIGHT = 420;
|
|
|
|
const int UI_FREQ = 20; // Hz
|
|
const int BACKLIGHT_OFFROAD = 50;
|
|
|
|
const Eigen::Matrix3f VIEW_FROM_DEVICE = (Eigen::Matrix3f() <<
|
|
0.0, 1.0, 0.0,
|
|
0.0, 0.0, 1.0,
|
|
1.0, 0.0, 0.0).finished();
|
|
|
|
const Eigen::Matrix3f FCAM_INTRINSIC_MATRIX = (Eigen::Matrix3f() <<
|
|
2648.0, 0.0, 1928.0 / 2,
|
|
0.0, 2648.0, 1208.0 / 2,
|
|
0.0, 0.0, 1.0).finished();
|
|
|
|
// tici ecam focal probably wrong? magnification is not consistent across frame
|
|
// Need to retrain model before this can be changed
|
|
const Eigen::Matrix3f ECAM_INTRINSIC_MATRIX = (Eigen::Matrix3f() <<
|
|
567.0, 0.0, 1928.0 / 2,
|
|
0.0, 567.0, 1208.0 / 2,
|
|
0.0, 0.0, 1.0).finished();
|
|
|
|
typedef enum UIStatus {
|
|
STATUS_DISENGAGED,
|
|
STATUS_OVERRIDE,
|
|
STATUS_ENGAGED,
|
|
STATUS_LAT_ONLY,
|
|
STATUS_LONG_ONLY,
|
|
} UIStatus;
|
|
|
|
const QColor bg_colors [] = {
|
|
[STATUS_DISENGAGED] = QColor(0x17, 0x33, 0x49, 0xc8),
|
|
[STATUS_OVERRIDE] = QColor(0x91, 0x9b, 0x95, 0xf1),
|
|
[STATUS_ENGAGED] = QColor(0x17, 0x86, 0x44, 0xf1),
|
|
[STATUS_LAT_ONLY] = QColor(0x00, 0xc8, 0xc8, 0xf1),
|
|
[STATUS_LONG_ONLY] = QColor(0x96, 0x1C, 0xA8, 0xf1),
|
|
};
|
|
|
|
typedef struct UIScene {
|
|
Eigen::Matrix3f view_from_calib = VIEW_FROM_DEVICE;
|
|
Eigen::Matrix3f view_from_wide_calib = VIEW_FROM_DEVICE;
|
|
cereal::PandaState::PandaType pandaType;
|
|
|
|
cereal::LongitudinalPersonality personality;
|
|
|
|
float light_sensor = -1;
|
|
bool started, ignition, is_metric;
|
|
uint64_t started_frame;
|
|
} UIScene;
|
|
|
|
class UIState : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
UIState(QObject* parent = 0);
|
|
virtual void updateStatus();
|
|
inline bool engaged() const {
|
|
return scene.started && (*sm)["selfdriveState"].getSelfdriveState().getEnabled();
|
|
}
|
|
|
|
std::unique_ptr<SubMaster> sm;
|
|
UIStatus status;
|
|
UIScene scene = {};
|
|
QString language;
|
|
PrimeState *prime_state;
|
|
|
|
signals:
|
|
void uiUpdate(const UIState &s);
|
|
void offroadTransition(bool offroad);
|
|
|
|
protected slots:
|
|
virtual void update();
|
|
|
|
protected:
|
|
QTimer *timer;
|
|
|
|
private:
|
|
bool started_prev = false;
|
|
};
|
|
|
|
#ifndef SUNNYPILOT
|
|
UIState *uiState();
|
|
#endif
|
|
|
|
// device management class
|
|
class Device : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
Device(QObject *parent = 0);
|
|
bool isAwake() { return awake; }
|
|
void setOffroadBrightness(int brightness) {
|
|
offroad_brightness = std::clamp(brightness, 0, 100);
|
|
}
|
|
|
|
protected:
|
|
bool awake = false;
|
|
int interactive_timeout = 0;
|
|
bool ignition_on = false;
|
|
|
|
int offroad_brightness = BACKLIGHT_OFFROAD;
|
|
int last_brightness = 0;
|
|
FirstOrderFilter brightness_filter;
|
|
QFuture<void> brightness_future;
|
|
|
|
void updateBrightness(const UIState &s);
|
|
void updateWakefulness(const UIState &s);
|
|
void setAwake(bool on);
|
|
|
|
signals:
|
|
void displayPowerChanged(bool on);
|
|
void interactiveTimeout();
|
|
|
|
public slots:
|
|
void resetInteractiveTimeout(int timeout = -1);
|
|
void update(const UIState &s);
|
|
};
|
|
|
|
#ifndef SUNNYPILOT
|
|
Device *device();
|
|
#endif
|
|
|
|
void ui_update_params(UIState *s);
|
|
void update_state(UIState *s);
|
|
void update_sockets(UIState *s);
|