Previously, under heavy CPU load the timing of the output trigger could become unstable as the timing thread was interrupted by the thread scheduler. This PR attempts to address this issue by adding two new features:
Setting thread priority to higher than standard user applications (requires root user or some system configuration changes, please refer to the updated README)
Applying CPU affinity to assign each trigger thread to a single CPU. This allows each trigger node instance to be run on a fixed CPU ID, reducing the probability of execution overlap and interrupts. It also allows prevention of running on CPU 0 which hosts system interrupts.
Review Procedure
If in docker as root:
Run as normal
If as a normal ROS user:
See README for how to configure your system to allow scheduler:
Allow thread schedule priority setting to the ROS2 user by adding the following line to /etc/security/limits.conf
<username> - rtprio 98
After saving the edited file (as sudo), a reboot will be required.
Check in htop the following:
The CPU used by the sensor trigger process matches the one that you selected in the parameters (note that htop CPU IDs start from 1, not 0 so the CPU ID will be offset by one from the one specified as a ROS parameter.
The priority of the sensor trigger process is -31 (negative priorities are real-time)
Remarks
Pre-Review Checklist for the PR Author
PR Author should check the checkboxes below when creating the PR.
[x] Assign PR to reviewer
Checklist for the PR Reviewer
Reviewers should check the checkboxes below before approval.
[ ] Commits are properly organized and messages are according to the guideline
[ ] (Optional) Unit tests have been written for new behavior
[ ] PR title describes the changes
Post-Review Checklist for the PR Author
PR Author should check the checkboxes below before merging.
[ ] All open points are addressed and tracked via issues or tickets
CI Checks
Build and test for PR: Required to pass before the merge.
PR Type
Related Links
Description
Previously, under heavy CPU load the timing of the output trigger could become unstable as the timing thread was interrupted by the thread scheduler. This PR attempts to address this issue by adding two new features:
Review Procedure
If in docker as root:
If as a normal ROS user:
/etc/security/limits.conf
Check in
htop
the following:htop
CPU IDs start from 1, not 0 so the CPU ID will be offset by one from the one specified as a ROS parameter.Remarks
Pre-Review Checklist for the PR Author
PR Author should check the checkboxes below when creating the PR.
Checklist for the PR Reviewer
Reviewers should check the checkboxes below before approval.
Post-Review Checklist for the PR Author
PR Author should check the checkboxes below before merging.
CI Checks