mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 08:16:06 +08:00
ui onroad: utilize local variables for repeated capnp reader access (#29325)
This commit is contained in:
@@ -270,6 +270,8 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
|
||||
const bool nav_alive = sm.alive("navInstruction") && sm["navInstruction"].getValid();
|
||||
|
||||
const auto cs = sm["controlsState"].getControlsState();
|
||||
const auto car_state = sm["carState"].getCarState();
|
||||
const auto nav_instruction = sm["navInstruction"].getNavInstruction();
|
||||
|
||||
// Handle older routes where vCruiseCluster is not set
|
||||
float v_cruise = cs.getVCruiseCluster() == 0.0 ? cs.getVCruise() : cs.getVCruiseCluster();
|
||||
@@ -281,17 +283,17 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
|
||||
|
||||
// Handle older routes where vEgoCluster is not set
|
||||
float v_ego;
|
||||
if (sm["carState"].getCarState().getVEgoCluster() == 0.0 && !v_ego_cluster_seen) {
|
||||
v_ego = sm["carState"].getCarState().getVEgo();
|
||||
if (car_state.getVEgoCluster() == 0.0 && !v_ego_cluster_seen) {
|
||||
v_ego = car_state.getVEgo();
|
||||
} else {
|
||||
v_ego = sm["carState"].getCarState().getVEgoCluster();
|
||||
v_ego = car_state.getVEgoCluster();
|
||||
v_ego_cluster_seen = true;
|
||||
}
|
||||
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();
|
||||
float speed_limit = nav_alive ? sm["navInstruction"].getNavInstruction().getSpeedLimit() : 0.0;
|
||||
auto speed_limit_sign = nav_instruction.getSpeedLimitSign();
|
||||
float speed_limit = nav_alive ? nav_instruction.getSpeedLimit() : 0.0;
|
||||
speed_limit *= (s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH);
|
||||
|
||||
setProperty("speedLimit", speed_limit);
|
||||
|
||||
Reference in New Issue
Block a user