Skip to content

Commit 5b216b0

Browse files
committed
no rounding errors
1 parent d07b3bb commit 5b216b0

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

selfdrive/modeld/modeld.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ mat3 update_calibration(Eigen::Matrix<float, 3, 4> &extrinsics, bool wide_camera
5151
return matmul3(yuv_transform, transform);
5252
}
5353

54-
uint64_t frame_id_from_ts(const VisionIpcBufExtra &extra) {
55-
uint64_t frame_ts = Hardware::TICI() ? extra.timestamp_sof : extra.timestamp_eof;
56-
return (frame_ts + 25000000) / 50000000;
54+
static uint64_t get_ts(const VisionIpcBufExtra &extra) {
55+
return Hardware::TICI() ? extra.timestamp_sof : extra.timestamp_eof;
5756
}
5857

5958

@@ -80,11 +79,8 @@ void run_model(ModelState &model, VisionIpcClient &vipc_client_main, VisionIpcCl
8079
VisionIpcBufExtra meta_extra = {0};
8180

8281
while (!do_exit) {
83-
// TODO: change sync logic to use timestamp start of frame in case camerad skips a frame
84-
// log frame id in model packet
85-
8682
// Keep receiving frames until we are at least 1 frame ahead of previous extra frame
87-
while (frame_id_from_ts(meta_main) <= frame_id_from_ts(meta_extra)) {
83+
while (get_ts(meta_main) < get_ts(meta_extra) + 25000000ULL) {
8884
buf_main = vipc_client_main.recv(&meta_main);
8985
if (buf_main == nullptr) break;
9086
}
@@ -98,7 +94,7 @@ void run_model(ModelState &model, VisionIpcClient &vipc_client_main, VisionIpcCl
9894
// Keep receiving extra frames until frame id matches main camera
9995
do {
10096
buf_extra = vipc_client_extra.recv(&meta_extra);
101-
} while (buf_extra != nullptr && frame_id_from_ts(meta_main) > frame_id_from_ts(meta_extra));
97+
} while (buf_extra != nullptr && get_ts(meta_main) > get_ts(meta_extra) + 25000000ULL);
10298

10399
if (buf_extra == nullptr) {
104100
LOGE("vipc_client_extra no frame");

0 commit comments

Comments
 (0)