Compare commits
3 Commits
fps20
...
modelrevert
| Author | SHA1 | Date | |
|---|---|---|---|
| cea422b075 | |||
| dc7e0a2db7 | |||
| f896dfe25a |
@@ -485,13 +485,16 @@ class Controls:
|
|||||||
# generic catch-all. ideally, a more specific event should be added above instead
|
# generic catch-all. ideally, a more specific event should be added above instead
|
||||||
has_disable_events = self.events.contains(ET.NO_ENTRY) and (self.events.contains(ET.SOFT_DISABLE) or self.events.contains(ET.IMMEDIATE_DISABLE))
|
has_disable_events = self.events.contains(ET.NO_ENTRY) and (self.events.contains(ET.SOFT_DISABLE) or self.events.contains(ET.IMMEDIATE_DISABLE))
|
||||||
no_system_errors = (not has_disable_events) or (len(self.events) == num_events)
|
no_system_errors = (not has_disable_events) or (len(self.events) == num_events)
|
||||||
if (not self.sm.all_checks() or self.card.can_rcv_timeout) and no_system_errors and not model_suppress:
|
# CLEARPILOT: fire commIssue ONLY when messages actually aren't flowing (not_alive)
|
||||||
|
# or CAN RX is timing out. Don't fire on self-declared valid=False — that's the
|
||||||
|
# polling-pattern / all_checks cascade that paramsd/torqued/plannerd/frogpilot
|
||||||
|
# propagate even while their publish rate and content are fine.
|
||||||
|
comms_really_broken = (not self.sm.all_alive()) or self.card.can_rcv_timeout
|
||||||
|
if comms_really_broken and no_system_errors and not model_suppress:
|
||||||
if not self.sm.all_alive():
|
if not self.sm.all_alive():
|
||||||
self.events.add(EventName.commIssue)
|
self.events.add(EventName.commIssue)
|
||||||
elif not self.sm.all_freq_ok():
|
else:
|
||||||
self.events.add(EventName.commIssueAvgFreq)
|
self.events.add(EventName.commIssue) # can_rcv_timeout path
|
||||||
else: # invalid or can_rcv_timeout.
|
|
||||||
self.events.add(EventName.commIssue)
|
|
||||||
|
|
||||||
logs = {
|
logs = {
|
||||||
'invalid': [s for s, valid in self.sm.valid.items() if not valid],
|
'invalid': [s for s, valid in self.sm.valid.items() if not valid],
|
||||||
@@ -662,6 +665,25 @@ class Controls:
|
|||||||
def state_control(self, CS):
|
def state_control(self, CS):
|
||||||
"""Given the state, this function returns a CarControl packet"""
|
"""Given the state, this function returns a CarControl packet"""
|
||||||
|
|
||||||
|
# CLEARPILOT: short-circuit while parked. Skip LaC/LoC PID, MPC, model_v2
|
||||||
|
# reads, lane-change logic — none of it matters when the car isn't moving.
|
||||||
|
# publish_logs still runs and still triggers carcontroller.apply via
|
||||||
|
# card.controls_update, so the sendcan heartbeats / tester-present messages
|
||||||
|
# keep flowing at 100Hz and the car doesn't fault. Saves ~30% controlsd CPU
|
||||||
|
# in park.
|
||||||
|
if CS.gearShifter == car.CarState.GearShifter.park:
|
||||||
|
CC = car.CarControl.new_message()
|
||||||
|
CC.enabled = False
|
||||||
|
CC.latActive = False
|
||||||
|
CC.longActive = False
|
||||||
|
CC.actuators.longControlState = self.LoC.long_control_state
|
||||||
|
self.LaC.reset()
|
||||||
|
self.LoC.reset(v_pid=CS.vEgo)
|
||||||
|
self.frogpilot_variables.no_lat_lane_change = False
|
||||||
|
self.FPCC.noLatLaneChange = False
|
||||||
|
lac_log = log.ControlsState.LateralDebugState.new_message()
|
||||||
|
return CC, lac_log
|
||||||
|
|
||||||
# Update VehicleModel
|
# Update VehicleModel
|
||||||
lp = self.sm['liveParameters']
|
lp = self.sm['liveParameters']
|
||||||
x = max(lp.stiffnessFactor, 0.1)
|
x = max(lp.stiffnessFactor, 0.1)
|
||||||
@@ -702,8 +724,10 @@ class Controls:
|
|||||||
if model_v2.meta.laneChangeState == LaneChangeState.laneChangeStarting and clearpilot_disable_lat_on_lane_change:
|
if model_v2.meta.laneChangeState == LaneChangeState.laneChangeStarting and clearpilot_disable_lat_on_lane_change:
|
||||||
CC.latActive = False
|
CC.latActive = False
|
||||||
self.frogpilot_variables.no_lat_lane_change = True
|
self.frogpilot_variables.no_lat_lane_change = True
|
||||||
|
self.FPCC.noLatLaneChange = True
|
||||||
else:
|
else:
|
||||||
self.frogpilot_variables.no_lat_lane_change = False
|
self.frogpilot_variables.no_lat_lane_change = False
|
||||||
|
self.FPCC.noLatLaneChange = False
|
||||||
|
|
||||||
if CS.leftBlinker or CS.rightBlinker:
|
if CS.leftBlinker or CS.rightBlinker:
|
||||||
self.last_blinker_frame = self.sm.frame
|
self.last_blinker_frame = self.sm.frame
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ def plannerd_thread():
|
|||||||
while True:
|
while True:
|
||||||
sm.update()
|
sm.update()
|
||||||
if sm.updated['modelV2']:
|
if sm.updated['modelV2']:
|
||||||
|
# CLEARPILOT: skip planning while parked. The downstream consumer (controlsd)
|
||||||
|
# already short-circuits in park, so longitudinalPlan/uiPlan staleness is fine.
|
||||||
|
if sm['carState'].gearShifter == car.CarState.GearShifter.park:
|
||||||
|
continue
|
||||||
longitudinal_planner.update(sm)
|
longitudinal_planner.update(sm)
|
||||||
longitudinal_planner.publish(sm, pm)
|
longitudinal_planner.publish(sm, pm)
|
||||||
publish_ui_plan(sm, pm, longitudinal_planner)
|
publish_ui_plan(sm, pm, longitudinal_planner)
|
||||||
|
|||||||
@@ -85,7 +85,9 @@ def frogpilot_thread():
|
|||||||
frogpilot_planner = FrogPilotPlanner(CP)
|
frogpilot_planner = FrogPilotPlanner(CP)
|
||||||
frogpilot_planner.update_frogpilot_params()
|
frogpilot_planner.update_frogpilot_params()
|
||||||
|
|
||||||
if sm.updated['modelV2']:
|
# CLEARPILOT: skip planner work while parked.
|
||||||
|
parked = sm['carState'].gearShifter == car.CarState.GearShifter.park
|
||||||
|
if sm.updated['modelV2'] and not parked:
|
||||||
frogpilot_planner.update(sm['carState'], sm['controlsState'], sm['frogpilotCarControl'], sm['frogpilotNavigation'],
|
frogpilot_planner.update(sm['carState'], sm['controlsState'], sm['frogpilotCarControl'], sm['frogpilotNavigation'],
|
||||||
sm['liveLocationKalman'], sm['modelV2'], sm['radarState'])
|
sm['liveLocationKalman'], sm['modelV2'], sm['radarState'])
|
||||||
frogpilot_planner.publish(sm, pm)
|
frogpilot_planner.publish(sm, pm)
|
||||||
|
|||||||
@@ -284,7 +284,14 @@ def main() -> NoReturn:
|
|||||||
|
|
||||||
# 4Hz driven by cameraOdometry
|
# 4Hz driven by cameraOdometry
|
||||||
if sm.frame % 5 == 0:
|
if sm.frame % 5 == 0:
|
||||||
calibrator.send_data(pm, sm.all_checks())
|
# CLEARPILOT: publish valid based on calibration status, not upstream sm.all_checks().
|
||||||
|
# The original gate cascaded upstream freq glitches into liveCalibration.valid=False,
|
||||||
|
# which kept locationd.filterInitialized False, which fed garbage into paramsd, which
|
||||||
|
# corrupted steerRatio and caused erratic steering (and controlsd commIssue banners).
|
||||||
|
# "valid" here semantically means "the calibration data is trustworthy" — a question
|
||||||
|
# about convergence, not input freshness.
|
||||||
|
cal_valid = calibrator.cal_status == log.LiveCalibrationData.Status.calibrated
|
||||||
|
calibrator.send_data(pm, cal_valid)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -308,12 +308,18 @@ void Localizer::input_fake_gps_observations(double current_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Localizer::handle_gps(double current_time, const cereal::GpsLocationData::Reader& log, const double sensor_time_offset) {
|
void Localizer::handle_gps(double current_time, const cereal::GpsLocationData::Reader& log, const double sensor_time_offset) {
|
||||||
|
// CLEARPILOT: GPS disabled as a Kalman input. gpsd still publishes real GPS for
|
||||||
|
// UI / dashcam / clock / night-mode; only locationd ignores it. Falls through to
|
||||||
|
// determine_gps_mode() which is openpilot's existing no-GPS path (fake observations
|
||||||
|
// to bound position uncertainty). To re-enable, set this to false.
|
||||||
|
const bool clearpilot_disable_gps = true;
|
||||||
|
|
||||||
bool gps_unreasonable = (Vector2d(log.getHorizontalAccuracy(), log.getVerticalAccuracy()).norm() >= SANE_GPS_UNCERTAINTY);
|
bool gps_unreasonable = (Vector2d(log.getHorizontalAccuracy(), log.getVerticalAccuracy()).norm() >= SANE_GPS_UNCERTAINTY);
|
||||||
bool gps_accuracy_insane = ((log.getVerticalAccuracy() <= 0) || (log.getSpeedAccuracy() <= 0) || (log.getBearingAccuracyDeg() <= 0));
|
bool gps_accuracy_insane = ((log.getVerticalAccuracy() <= 0) || (log.getSpeedAccuracy() <= 0) || (log.getBearingAccuracyDeg() <= 0));
|
||||||
bool gps_lat_lng_alt_insane = ((std::abs(log.getLatitude()) > 90) || (std::abs(log.getLongitude()) > 180) || (std::abs(log.getAltitude()) > ALTITUDE_SANITY_CHECK));
|
bool gps_lat_lng_alt_insane = ((std::abs(log.getLatitude()) > 90) || (std::abs(log.getLongitude()) > 180) || (std::abs(log.getAltitude()) > ALTITUDE_SANITY_CHECK));
|
||||||
bool gps_vel_insane = (floatlist2vector(log.getVNED()).norm() > TRANS_SANITY_CHECK);
|
bool gps_vel_insane = (floatlist2vector(log.getVNED()).norm() > TRANS_SANITY_CHECK);
|
||||||
|
|
||||||
if (!log.getHasFix() || gps_unreasonable || gps_accuracy_insane || gps_lat_lng_alt_insane || gps_vel_insane) {
|
if (clearpilot_disable_gps || !log.getHasFix() || gps_unreasonable || gps_accuracy_insane || gps_lat_lng_alt_insane || gps_vel_insane) {
|
||||||
//this->gps_valid = false;
|
//this->gps_valid = false;
|
||||||
this->determine_gps_mode(current_time);
|
this->determine_gps_mode(current_time);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import ctypes
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from cereal import messaging
|
from cereal import car, messaging
|
||||||
from cereal.messaging import PubMaster, SubMaster
|
from cereal.messaging import PubMaster, SubMaster
|
||||||
from cereal.visionipc import VisionIpcClient, VisionStreamType, VisionBuf
|
from cereal.visionipc import VisionIpcClient, VisionStreamType, VisionBuf
|
||||||
from openpilot.common.swaglog import cloudlog
|
from openpilot.common.swaglog import cloudlog
|
||||||
@@ -128,10 +128,15 @@ def main():
|
|||||||
assert vipc_client.is_connected()
|
assert vipc_client.is_connected()
|
||||||
cloudlog.warning(f"connected with buffer size: {vipc_client.buffer_len}")
|
cloudlog.warning(f"connected with buffer size: {vipc_client.buffer_len}")
|
||||||
|
|
||||||
sm = SubMaster(["liveCalibration"])
|
sm = SubMaster(["liveCalibration", "carState"])
|
||||||
pm = PubMaster(["driverStateV2"])
|
pm = PubMaster(["driverStateV2"])
|
||||||
|
|
||||||
calib = np.zeros(CALIB_LEN, dtype=np.float32)
|
calib = np.zeros(CALIB_LEN, dtype=np.float32)
|
||||||
|
# CLEARPILOT: cache last model output to serve while gear is in park —
|
||||||
|
# mirrors the same trick modeld uses. Skips DSP inference on the driver
|
||||||
|
# camera when the car is stationary; downstream dmonitoringd still gets
|
||||||
|
# a fresh publish each frame.
|
||||||
|
last_model_output = None
|
||||||
# last = 0
|
# last = 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@@ -143,8 +148,13 @@ def main():
|
|||||||
if sm.updated["liveCalibration"]:
|
if sm.updated["liveCalibration"]:
|
||||||
calib[:] = np.array(sm["liveCalibration"].rpyCalib)
|
calib[:] = np.array(sm["liveCalibration"].rpyCalib)
|
||||||
|
|
||||||
|
parked = sm["carState"].gearShifter == car.CarState.GearShifter.park
|
||||||
t1 = time.perf_counter()
|
t1 = time.perf_counter()
|
||||||
|
if parked and last_model_output is not None:
|
||||||
|
model_output, dsp_execution_time = last_model_output
|
||||||
|
else:
|
||||||
model_output, dsp_execution_time = model.run(buf, calib)
|
model_output, dsp_execution_time = model.run(buf, calib)
|
||||||
|
last_model_output = (model_output, dsp_execution_time)
|
||||||
t2 = time.perf_counter()
|
t2 = time.perf_counter()
|
||||||
|
|
||||||
pm.send("driverStateV2", get_driverstate_packet(model_output, vipc_client.frame_id, vipc_client.timestamp_sof, t2 - t1, dsp_execution_time))
|
pm.send("driverStateV2", get_driverstate_packet(model_output, vipc_client.frame_id, vipc_client.timestamp_sof, t2 - t1, dsp_execution_time))
|
||||||
|
|||||||
@@ -183,6 +183,10 @@ def main(demo=False):
|
|||||||
model_transform_main = np.zeros((3, 3), dtype=np.float32)
|
model_transform_main = np.zeros((3, 3), dtype=np.float32)
|
||||||
model_transform_extra = np.zeros((3, 3), dtype=np.float32)
|
model_transform_extra = np.zeros((3, 3), dtype=np.float32)
|
||||||
live_calib_seen = False
|
live_calib_seen = False
|
||||||
|
# CLEARPILOT: cache last model output to serve while gear is in park — saves
|
||||||
|
# GPU inference cost while still giving downstream a constant publish rate so
|
||||||
|
# freq_ok / valid checks don't cascade.
|
||||||
|
last_model_output = None
|
||||||
nav_features = np.zeros(ModelConstants.NAV_FEATURE_LEN, dtype=np.float32)
|
nav_features = np.zeros(ModelConstants.NAV_FEATURE_LEN, dtype=np.float32)
|
||||||
nav_instructions = np.zeros(ModelConstants.NAV_INSTRUCTION_LEN, dtype=np.float32)
|
nav_instructions = np.zeros(ModelConstants.NAV_INSTRUCTION_LEN, dtype=np.float32)
|
||||||
buf_main, buf_extra = None, None
|
buf_main, buf_extra = None, None
|
||||||
@@ -314,12 +318,21 @@ def main(demo=False):
|
|||||||
**({'radar_tracks': radar_tracks,} if DISABLE_RADAR else {}),
|
**({'radar_tracks': radar_tracks,} if DISABLE_RADAR else {}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# CLEARPILOT: in park, serve the cached last model output instead of running
|
||||||
|
# GPU inference. First cycle (no cache yet) still runs once so we have
|
||||||
|
# something to serve. Out-of-park resumes fresh inference every frame.
|
||||||
|
parked = sm['carState'].gearShifter == car.CarState.GearShifter.park
|
||||||
|
if parked and last_model_output is not None:
|
||||||
|
model_output = last_model_output
|
||||||
|
model_execution_time = 0.0
|
||||||
|
else:
|
||||||
mt1 = time.perf_counter()
|
mt1 = time.perf_counter()
|
||||||
model_output = model.run(buf_main, buf_extra, model_transform_main, model_transform_extra, inputs, prepare_only)
|
model_output = model.run(buf_main, buf_extra, model_transform_main, model_transform_extra, inputs, prepare_only)
|
||||||
mt2 = time.perf_counter()
|
mt2 = time.perf_counter()
|
||||||
model_execution_time = mt2 - mt1
|
model_execution_time = mt2 - mt1
|
||||||
|
|
||||||
if model_output is not None:
|
if model_output is not None:
|
||||||
|
last_model_output = model_output
|
||||||
modelv2_send = messaging.new_message('modelV2')
|
modelv2_send = messaging.new_message('modelV2')
|
||||||
posenet_send = messaging.new_message('cameraOdometry')
|
posenet_send = messaging.new_message('cameraOdometry')
|
||||||
fill_model_msg(modelv2_send, model_output, publish_state, meta_main.frame_id, meta_extra.frame_id, frame_id, frame_drop_ratio,
|
fill_model_msg(modelv2_send, model_output, publish_state, meta_main.frame_id, meta_extra.frame_id, frame_id, frame_drop_ratio,
|
||||||
|
|||||||
Reference in New Issue
Block a user