feat(distortion_corrector_node): replace imu and twist callback with polling subscriber #10057
+33
−28
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.
Description
Background
The distortion corrector node subscribes to twist and IMU topics using callbacks.
When these topics are published at a high frequency (e.g., 100Hz), the overhead of calling the callback function is significant.
Changed
Replaced the subscription callback function with polling using
take()
.Related links
Private Links:
How was this PR tested?
Test Item 1: Output Unchanged
Verified that the output topics (IMU, twist, and point cloud) remain the same before and after the change using a pytest launch test.
The test script is shown below:
Test Item 2: CPU Usage Improvement
Performance was measured using the perf command. Topics were published using a rosbag.
Measurement commands:
Before change:
After change:
The test results show a significant reduction (approximately 300 times/sec) in context switches due to interrupts, which led to the expected decrease in CPU usage.
Test Item 3: Rosbag Replay Simulator Functionality
Confirmed that the rosbag replay simulator functions as expected.
Notes for reviewers
The queue size for the IMU and twist topics is currently hardcoded for the reason stated in the comment.
Interface changes
None.
Effects on system behavior