fix(sync): avoid startup image publish backpressure#2
Merged
Conversation
Reviewer's GuideRefactors CameraFrameSync’s RAW_PROBE sync state machine and subscriber to use IMU-first waiting and drop-old image semantics, restructures IMU ingress/pending queues and sync relations for clearer state, and updates documentation and tests to match the new behavior and naming. Class diagram for updated CameraFrameSync RAW_PROBE state and queuesclassDiagram
class CameraFrameSync {
+SyncMode sync_mode_
+int32 offset_us_
+SyncState state_
+ImageData current_image_
+DropOldestQueue_GyroSample_ pending_gyros_
+DropOldestQueue_AcclSample_ pending_accls_
+DropOldestQueue_QuatReading_ pending_quats_
+DropOldestQueue_ImageSample_ image_events_
+SampleHistory_AssembledImu_ imu_history_
+ObservedPeriods periods_
+LockedSync locked_sync_
+bool last_image_valid_
+uint64 last_image_timestamp_us_
+PendingFrame pending_frame_
+bool overflowed_
+ProcessImageEvents()
+ProcessLatestImage(frame)
+ProcessRawProbeImage(frame)
+TryProbeImage(frame)
+TryLatestImuMatch(frame)
+TrySyncedImage(frame)
+ResumePendingMatch(frame)
+PublishOrRememberMatch(frame,match)
+PublishMatchedImage(image,match)
}
class PendingFrame {
+bool valid
+ImageSample image
+bool cadence_consumed
+PendingMatch match
}
class PendingMatch {
+bool valid
+uint64 imu_timestamp_us
+uint64 period_us
}
class ImageSample {
+uint64 sensor_timestamp_us
}
class GyroSample {
+uint64 sensor_timestamp_us
+ImuVector angular_velocity_xyz
}
class AcclSample {
+uint64 sensor_timestamp_us
+ImuVector linear_acceleration_xyz
}
class QuatReading {
+uint64 sensor_timestamp_us
+QuatSample rotation_wxyz
}
class AssembledImu {
+uint64 sensor_timestamp_us
+QuatSample rotation_wxyz
+ImuVector angular_velocity_xyz
+ImuVector linear_acceleration_xyz
}
class ObservedPeriods {
+uint64 image_us
+uint64 imu_us
}
class LockedSync {
+uint64 period_us
+uint64 last_imu_timestamp_us
}
class SyncMatch {
+AssembledImu* imu
+uint64 period_us
}
class DropOldestQueue_T_ {
+DropOldestQueue_T_(capacity)
+bool Empty()
+bool Front(out)
+void PopFront()
+void Clear()
+bool PushBackDropOldest(value)
}
CameraFrameSync --> PendingFrame : has
CameraFrameSync --> ObservedPeriods : has
CameraFrameSync --> LockedSync : has
CameraFrameSync --> "*" AssembledImu : history
CameraFrameSync --> "*" GyroSample : queues
CameraFrameSync --> "*" AcclSample : queues
CameraFrameSync --> "*" QuatReading : queues
PendingFrame --> ImageSample : image
PendingFrame --> PendingMatch : match
SyncMatch --> AssembledImu : imu
class DropOldestQueue_GyroSample_ {
}
class DropOldestQueue_AcclSample_ {
}
class DropOldestQueue_QuatReading_ {
}
class DropOldestQueue_ImageSample_ {
}
DropOldestQueue_GyroSample_ --|> DropOldestQueue_T_ : T=GyroSample
DropOldestQueue_AcclSample_ --|> DropOldestQueue_T_ : T=AcclSample
DropOldestQueue_QuatReading_ --|> DropOldestQueue_T_ : T=QuatReading
DropOldestQueue_ImageSample_ --|> DropOldestQueue_T_ : T=ImageSample
Class diagram for updated CameraFrameSyncSubscriber image/IMU waitingclassDiagram
class CameraFrameSyncSubscriber {
+string image_topic_name_
+string imu_topic_name_
+string host_topic_domain_name_
+LinuxSharedTopicSubscriber image_sub_
+ImuStampedT latest_imu_
+SyncSubscriber_ImuStampedT_ imu_sub_
+bool last_imu_valid_
+uint64 last_imu_timestamp_us_
+ImageData pending_image_
+Wait(out,timeout_ms)
+WaitForNextImu(deadline_ms,timeout_ms,imu)
+WaitForMatchingImage(imu_timestamp_us,deadline_ms,timeout_ms,image)
}
class SyncedFrame {
+ImageData image
+ImuStampedT imu
}
class ImageData {
+ImageFrame* GetData()
+void Reset()
}
class ImuStampedT {
+uint64 timestamp_us
}
class LinuxSharedTopicSubscriber {
+Wait(timeout_ms)
}
class SyncSubscriber_ImuStampedT_ {
+Wait(timeout_ms)
}
CameraFrameSyncSubscriber --> SyncedFrame : fills
CameraFrameSyncSubscriber --> ImageData : uses
CameraFrameSyncSubscriber --> ImuStampedT : uses
CameraFrameSyncSubscriber --> LinuxSharedTopicSubscriber : image_sub_
CameraFrameSyncSubscriber --> SyncSubscriber_ImuStampedT_ : imu_sub_
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
RAW_PROBE 启动阶段 detector 从第 0 帧接入时,消费者可能先拿到未同步图像并等待 IMU,导致图像共享 topic 出现 publish backpressure。
修改
验证
依赖 libxr PR:修 BROADCAST_DROP_OLD 并发竞态。
Summary by Sourcery
Refine camera frame/IMU sync to avoid image-topic backpressure during RAW_PROBE startup and clarify consumer behavior.
New Features:
Enhancements:
Documentation:
Tests: