mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-08-06 00:35:44 +08:00
prereq for matching speeds shown on cars dash (#25222)
* prereq for matching speeds shown on cars dash * also handle fallback in the ui for replay * update translations * update ref
This commit is contained in:
@@ -162,6 +162,12 @@ class CarInterfaceBase(ABC):
|
||||
ret.canValid = all(cp.can_valid for cp in self.can_parsers if cp is not None)
|
||||
ret.canTimeout = any(cp.bus_timeout for cp in self.can_parsers if cp is not None)
|
||||
|
||||
if ret.vEgoCluster == 0.0:
|
||||
ret.vEgoCluster = ret.vEgo
|
||||
|
||||
if ret.cruiseState.speedCluster == 0:
|
||||
ret.cruiseState.speedCluster = ret.cruiseState.speed
|
||||
|
||||
# copy back for next iteration
|
||||
reader = ret.as_reader()
|
||||
if self.CS is not None:
|
||||
|
||||
@@ -163,6 +163,7 @@ class Controls:
|
||||
self.can_rcv_error = False
|
||||
self.soft_disable_timer = 0
|
||||
self.v_cruise_kph = 255
|
||||
self.v_cruise_cluster_kph = 255
|
||||
self.v_cruise_kph_last = 0
|
||||
self.mismatch_counter = 0
|
||||
self.cruise_mismatch_counter = 0
|
||||
@@ -454,11 +455,14 @@ class Controls:
|
||||
if not self.CP.pcmCruise:
|
||||
self.v_cruise_kph = update_v_cruise(self.v_cruise_kph, CS.vEgo, CS.gasPressed, CS.buttonEvents,
|
||||
self.button_timers, self.enabled, self.is_metric)
|
||||
self.v_cruise_cluster_kph = self.v_cruise_kph
|
||||
else:
|
||||
if CS.cruiseState.available:
|
||||
self.v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH
|
||||
self.v_cruise_cluster_kph = CS.cruiseState.speedCluster * CV.MS_TO_KPH
|
||||
else:
|
||||
self.v_cruise_kph = 0
|
||||
self.v_cruise_cluster_kph = 0
|
||||
|
||||
# decrement the soft disable timer at every step, as it's reset on
|
||||
# entrance in SOFT_DISABLING state
|
||||
@@ -538,6 +542,7 @@ class Controls:
|
||||
self.current_alert_types.append(ET.ENABLE)
|
||||
if not self.CP.pcmCruise:
|
||||
self.v_cruise_kph = initialize_v_cruise(CS.vEgo, CS.buttonEvents, self.v_cruise_kph_last)
|
||||
self.v_cruise_cluster_kph = self.v_cruise_kph
|
||||
|
||||
# Check if openpilot is engaged and actuators are enabled
|
||||
self.enabled = self.state in ENABLED_STATES
|
||||
@@ -752,6 +757,7 @@ class Controls:
|
||||
controlsState.longControlState = self.LoC.long_control_state
|
||||
controlsState.vPid = float(self.LoC.v_pid)
|
||||
controlsState.vCruise = float(self.v_cruise_kph)
|
||||
controlsState.vCruiseCluster = float(self.v_cruise_cluster_kph)
|
||||
controlsState.upAccelCmd = float(self.LoC.pid.p)
|
||||
controlsState.uiAccelCmd = float(self.LoC.pid.i)
|
||||
controlsState.ufAccelCmd = float(self.LoC.pid.f)
|
||||
|
||||
@@ -1 +1 @@
|
||||
7c1168af0311d2fef67b82812cd863a0e97c030e
|
||||
c428493b2a46cb996a7565ea4395d7ad6cd79786
|
||||
|
||||
@@ -184,13 +184,17 @@ void NvgWindow::updateState(const UIState &s) {
|
||||
|
||||
const auto cs = sm["controlsState"].getControlsState();
|
||||
|
||||
float set_speed = cs_alive ? cs.getVCruise() : SET_SPEED_NA;
|
||||
// Handle older routes where vCruiseCluster is not set
|
||||
float v_cruise = cs.getVCruiseCluster() == 0.0 ? cs.getVCruise() : cs.getVCruiseCluster();
|
||||
float set_speed = cs_alive ? v_cruise : SET_SPEED_NA;
|
||||
bool cruise_set = set_speed > 0 && (int)set_speed != SET_SPEED_NA;
|
||||
if (cruise_set && !s.scene.is_metric) {
|
||||
set_speed *= KM_TO_MILE;
|
||||
}
|
||||
|
||||
float cur_speed = cs_alive ? std::max<float>(0.0, sm["carState"].getCarState().getVEgo()) : 0.0;
|
||||
// Handle older routes where vEgoCluster is not set
|
||||
float v_ego = sm["carState"].getCarState().getVEgoCluster() == 0.0 ? sm["carState"].getCarState().getVEgo() : sm["carState"].getCarState().getVEgoCluster();
|
||||
float cur_speed = cs_alive ? std::max<float>(0.0, v_ego) : 0.0;
|
||||
cur_speed *= s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH;
|
||||
|
||||
auto speed_limit_sign = sm["navInstruction"].getNavInstruction().getSpeedLimitSign();
|
||||
|
||||
@@ -488,30 +488,30 @@ location set</source>
|
||||
<context>
|
||||
<name>NvgWindow</name>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="208"/>
|
||||
<location filename="../qt/onroad.cc" line="212"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="208"/>
|
||||
<location filename="../qt/onroad.cc" line="212"/>
|
||||
<source>mph</source>
|
||||
<translation>mph</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="275"/>
|
||||
<location filename="../qt/onroad.cc" line="278"/>
|
||||
<location filename="../qt/onroad.cc" line="279"/>
|
||||
<location filename="../qt/onroad.cc" line="282"/>
|
||||
<source>MAX</source>
|
||||
<translation>MAX</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="322"/>
|
||||
<location filename="../qt/onroad.cc" line="325"/>
|
||||
<location filename="../qt/onroad.cc" line="326"/>
|
||||
<location filename="../qt/onroad.cc" line="329"/>
|
||||
<source>SPEED</source>
|
||||
<translation>SPEED</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="328"/>
|
||||
<location filename="../qt/onroad.cc" line="331"/>
|
||||
<location filename="../qt/onroad.cc" line="332"/>
|
||||
<location filename="../qt/onroad.cc" line="335"/>
|
||||
<source>LIMIT</source>
|
||||
<translation>LIMIT</translation>
|
||||
</message>
|
||||
|
||||
@@ -486,30 +486,30 @@ location set</source>
|
||||
<context>
|
||||
<name>NvgWindow</name>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="208"/>
|
||||
<location filename="../qt/onroad.cc" line="212"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="208"/>
|
||||
<location filename="../qt/onroad.cc" line="212"/>
|
||||
<source>mph</source>
|
||||
<translation>mph</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="275"/>
|
||||
<location filename="../qt/onroad.cc" line="278"/>
|
||||
<location filename="../qt/onroad.cc" line="279"/>
|
||||
<location filename="../qt/onroad.cc" line="282"/>
|
||||
<source>MAX</source>
|
||||
<translation>最高定速</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="322"/>
|
||||
<location filename="../qt/onroad.cc" line="325"/>
|
||||
<location filename="../qt/onroad.cc" line="326"/>
|
||||
<location filename="../qt/onroad.cc" line="329"/>
|
||||
<source>SPEED</source>
|
||||
<translation>SPEED</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="328"/>
|
||||
<location filename="../qt/onroad.cc" line="331"/>
|
||||
<location filename="../qt/onroad.cc" line="332"/>
|
||||
<location filename="../qt/onroad.cc" line="335"/>
|
||||
<source>LIMIT</source>
|
||||
<translation>LIMIT</translation>
|
||||
</message>
|
||||
|
||||
@@ -488,30 +488,30 @@ location set</source>
|
||||
<context>
|
||||
<name>NvgWindow</name>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="208"/>
|
||||
<location filename="../qt/onroad.cc" line="212"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="208"/>
|
||||
<location filename="../qt/onroad.cc" line="212"/>
|
||||
<source>mph</source>
|
||||
<translation>mph</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="275"/>
|
||||
<location filename="../qt/onroad.cc" line="278"/>
|
||||
<location filename="../qt/onroad.cc" line="279"/>
|
||||
<location filename="../qt/onroad.cc" line="282"/>
|
||||
<source>MAX</source>
|
||||
<translation>最高</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="322"/>
|
||||
<location filename="../qt/onroad.cc" line="325"/>
|
||||
<location filename="../qt/onroad.cc" line="326"/>
|
||||
<location filename="../qt/onroad.cc" line="329"/>
|
||||
<source>SPEED</source>
|
||||
<translation>速度</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qt/onroad.cc" line="328"/>
|
||||
<location filename="../qt/onroad.cc" line="331"/>
|
||||
<location filename="../qt/onroad.cc" line="332"/>
|
||||
<location filename="../qt/onroad.cc" line="335"/>
|
||||
<source>LIMIT</source>
|
||||
<translation>速限</translation>
|
||||
</message>
|
||||
|
||||
Reference in New Issue
Block a user