mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-09-12 11:10:19 +08:00
feat: update the output timing for frame drop notifications
This commit is contained in:
@@ -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<int64_t> updateDelta(std::optional<int64_t> &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_;
|
||||
|
||||
@@ -38,13 +38,6 @@ FrameTimestampCsvLogger::FrameTimestampCsvLogger(bool enabled, const std::string
|
||||
return;
|
||||
}
|
||||
|
||||
RCLCPP_INFO_STREAM(
|
||||
logger_,
|
||||
"Frame drop log enabled. Format: <SDK|PUB> drop <color|depth>: idx=<frame_index> "
|
||||
"ts=<device_timestamp_us> gap=<actual_interval_ms> ideal=<expected_interval_ms> "
|
||||
"total=<total_dropped_frames>. 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<int64_t>(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<int64_t>(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: <SDK|PUB> drop <color|depth>: idx=<frame_index> "
|
||||
"ts=<device_timestamp_us> gap=<actual_interval_ms> ideal=<expected_interval_ms> "
|
||||
"total=<total_dropped_frames>. SDK means frame arrival from SDK; PUB means before ROS "
|
||||
"image publish.");
|
||||
}
|
||||
|
||||
std::optional<int64_t> FrameTimestampCsvLogger::updateDelta(std::optional<int64_t> &previous,
|
||||
int64_t current) {
|
||||
std::optional<int64_t> delta;
|
||||
|
||||
Reference in New Issue
Block a user