From b77285475b0866ae708c9166b6cd9f5b8d2a8a1f Mon Sep 17 00:00:00 2001 From: slz Date: Thu, 21 May 2026 16:55:36 +0800 Subject: [PATCH] feat: update the output timing for frame drop notifications --- .../frame_timestamp_csv_logger.h | 2 ++ .../src/frame_timestamp_csv_logger.cpp | 22 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/orbbec_camera/include/orbbec_camera/frame_timestamp_csv_logger.h b/orbbec_camera/include/orbbec_camera/frame_timestamp_csv_logger.h index 5ede4045..dfeb1a9c 100644 --- a/orbbec_camera/include/orbbec_camera/frame_timestamp_csv_logger.h +++ b/orbbec_camera/include/orbbec_camera/frame_timestamp_csv_logger.h @@ -120,6 +120,7 @@ class FrameTimestampCsvLogger { int64_t arrival_steady_us, bool publish_expected); void populatePublishData(StreamState &state, TrackedStream stream, int64_t publish_system_us, int64_t publish_steady_us); + void reportDropLogFormatOnce(); std::optional updateDelta(std::optional &previous, int64_t current); @@ -143,6 +144,7 @@ class FrameTimestampCsvLogger { std::atomic_bool shutdown_requested_{false}; bool writer_failed_ = false; bool queue_warning_active_ = false; + bool drop_log_format_reported_ = false; std::string csv_file_path_; std::ofstream csv_stream_; std::thread writer_thread_; diff --git a/orbbec_camera/src/frame_timestamp_csv_logger.cpp b/orbbec_camera/src/frame_timestamp_csv_logger.cpp index 03ca0132..e628c5ab 100644 --- a/orbbec_camera/src/frame_timestamp_csv_logger.cpp +++ b/orbbec_camera/src/frame_timestamp_csv_logger.cpp @@ -38,13 +38,6 @@ FrameTimestampCsvLogger::FrameTimestampCsvLogger(bool enabled, const std::string return; } - RCLCPP_INFO_STREAM( - logger_, - "Frame drop log enabled. Format: drop : idx= " - "ts= gap= ideal= " - "total=. SDK means frame arrival from SDK; PUB means before ROS " - "image publish."); - if (csv_file_path_.empty()) { RCLCPP_INFO_STREAM(logger_, "Frame timestamp CSV file is empty; only frame lost logs are enabled."); @@ -324,6 +317,7 @@ void FrameTimestampCsvLogger::populateArrivalData(StreamState &state, TrackedStr const auto lost_frames = std::max(1, device_ts_delta_us / state.expected_interval_us - 1); previous.dropped_frames += lost_frames; + reportDropLogFormatOnce(); RCLCPP_WARN_STREAM( logger_, "SDK drop " << (stream == TrackedStream::COLOR ? "color" : "depth") << ": idx=" << state.frame_index << " ts=" << state.device_ts_us << "us" @@ -376,6 +370,7 @@ void FrameTimestampCsvLogger::populatePublishData(StreamState &state, TrackedStr const auto lost_frames = std::max(1, device_ts_delta_us / state.expected_interval_us - 1); previous.publish_dropped_frames += lost_frames; + reportDropLogFormatOnce(); RCLCPP_WARN_STREAM( logger_, "PUB drop " << (stream == TrackedStream::COLOR ? "color" : "depth") << ": idx=" << state.frame_index << " ts=" << state.device_ts_us << "us" @@ -396,6 +391,19 @@ void FrameTimestampCsvLogger::populatePublishData(StreamState &state, TrackedStr state.arrival_to_publish_steady_us = state.publish_steady_us.value() - state.arrival_steady_us; } +void FrameTimestampCsvLogger::reportDropLogFormatOnce() { + if (drop_log_format_reported_) { + return; + } + drop_log_format_reported_ = true; + RCLCPP_INFO_STREAM( + logger_, + "Frame drop log enabled. Format: drop : idx= " + "ts= gap= ideal= " + "total=. SDK means frame arrival from SDK; PUB means before ROS " + "image publish."); +} + std::optional FrameTimestampCsvLogger::updateDelta(std::optional &previous, int64_t current) { std::optional delta;