Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calibrationd: start faster by not waiting for carParams #24976

Merged
merged 3 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions selfdrive/locationd/calibrationd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
from typing import List, NoReturn, Optional

from cereal import car, log
from cereal import log
import cereal.messaging as messaging
from common.conversions import Conversions as CV
from common.params import Params, put_nonblocking
Expand Down Expand Up @@ -62,7 +62,7 @@ class Calibrator:
def __init__(self, param_put: bool = False):
self.param_put = param_put

self.CP = car.CarParams.from_bytes(Params().get("CarParams", block=True))
self.not_car = False

# Read saved calibration
params = Params()
Expand Down Expand Up @@ -192,7 +192,7 @@ def get_msg(self) -> capnp.lib.capnp._DynamicStructBuilder:
liveCalibration.rpyCalib = smooth_rpy.tolist()
liveCalibration.rpyCalibSpread = self.calib_spread.tolist()

if self.CP.notCar:
if self.not_car:
extrinsic_matrix = get_view_frame_from_road_frame(0, 0, 0, model_height)
liveCalibration.validBlocks = INPUTS_NEEDED
liveCalibration.calStatus = Calibration.CALIBRATED
Expand All @@ -212,7 +212,7 @@ def calibrationd_thread(sm: Optional[messaging.SubMaster] = None, pm: Optional[m
set_realtime_priority(1)

if sm is None:
sm = messaging.SubMaster(['cameraOdometry', 'carState'], poll=['cameraOdometry'])
sm = messaging.SubMaster(['cameraOdometry', 'carState', 'carParams'], poll=['cameraOdometry'])

if pm is None:
pm = messaging.PubMaster(['liveCalibration'])
Expand All @@ -223,6 +223,8 @@ def calibrationd_thread(sm: Optional[messaging.SubMaster] = None, pm: Optional[m
timeout = 0 if sm.frame == -1 else 100
sm.update(timeout)

calibrator.not_car = sm['carParams'].notCar

if sm.updated['cameraOdometry']:
calibrator.handle_v_ego(sm['carState'].vEgo)
new_rpy = calibrator.handle_cam_odom(sm['cameraOdometry'].trans,
Expand Down
3 changes: 2 additions & 1 deletion selfdrive/test/process_replay/process_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ def ublox_rcv_callback(msg):
proc_name="calibrationd",
pub_sub={
"carState": ["liveCalibration"],
"cameraOdometry": []
"cameraOdometry": [],
"carParams": [],
},
ignore=["logMonoTime", "valid"],
init_callback=get_car_params,
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/test/process_replay/ref_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
41161c8d151b0c2017214cad0aad3156533ab868
b55de9fdb2416e63ab554c95233a78219d8d3db9