Skip to content

Enable FIFO scheduling by default for RTDE communication thread#536

Merged
urfeex merged 3 commits into
UniversalRobots:masterfrom
srvald:rtde_background_fifo
Jul 6, 2026
Merged

Enable FIFO scheduling by default for RTDE communication thread#536
urfeex merged 3 commits into
UniversalRobots:masterfrom
srvald:rtde_background_fifo

Conversation

@srvald

@srvald srvald commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

This PR improves the scheduling configuration of the thread responsible for receiving and processing robot communication data.

RTDE background read thread

When read_packages_in_background is enabled, the RTDE client creates a dedicated background thread for continuously receiving RTDE data packages.

Previously, this thread was executed using the operating system's default scheduling policy. Under system load, scheduling delays could introduce additional latency and timing jitter while processing incoming RTDE data.

This PR configures the RTDE background read thread to request the highest available FIFO scheduling priority using the existing helper functions.

pthread_t this_thread = pthread_self();
const int max_thread_priority = sched_get_priority_max(SCHED_FIFO);
setFiFoScheduling(this_thread, max_thread_priority);

This follows the same approach already used by the producer thread inside Pipeline::runProducer().

void runProducer()
{
URCL_LOG_DEBUG("Starting up producer");
if (producer_fifo_scheduling_)
{
pthread_t this_thread = pthread_self();
const int max_thread_priority = sched_get_priority_max(SCHED_FIFO);
setFiFoScheduling(this_thread, max_thread_priority);
}

Pipeline default scheduling

The Pipeline constructor previously defaulted producer_fifo_scheduling to false, meaning that FIFO scheduling was not requested unless explicitly enabled.

Pipeline(IProducer<T>& producer, IConsumer<T>* consumer, std::string name, INotifier& notifier,
const bool producer_fifo_scheduling = false)

This PR changes the default value to true, making the producer thread request FIFO scheduling by default.

As a result, both the RTDE background read thread and the pipeline producer thread now consistently request FIFO scheduling unless explicitly disabled.


Note

Low Risk
Change is limited to thread scheduling hints with graceful fallback on failure; no protocol, auth, or data-path logic changes.

Overview
When background RTDE package reading is enabled, the dedicated read thread now requests maximum SCHED_FIFO priority at thread entry via setFiFoScheduling, matching the approach already used in the pipeline producer thread.

This adds the helpers.h include needed for that helper. The goal is to reduce scheduling latency and jitter on incoming RTDE data under system load; if the process lacks permission for FIFO scheduling, existing helper behavior applies (warning, thread continues with default scheduling).

Reviewed by Cursor Bugbot for commit 8d93a85. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.90%. Comparing base (8b4495c) to head (8d93a85).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #536      +/-   ##
==========================================
- Coverage   79.10%   78.90%   -0.21%     
==========================================
  Files         115      115              
  Lines        6766     6768       +2     
  Branches     2988     2991       +3     
==========================================
- Hits         5352     5340      -12     
- Misses       1045     1055      +10     
- Partials      369      373       +4     
Flag Coverage Δ
check_version_ur10-3.15.8 11.15% <0.00%> (-0.31%) ⬇️
check_version_ur10e-10.11.0 11.10% <0.00%> (-0.06%) ⬇️
check_version_ur10e-5.15.2 11.34% <0.00%> (-0.01%) ⬇️
check_version_ur12e-10.12.1 11.15% <0.00%> (-0.01%) ⬇️
check_version_ur12e-5.25.1 11.29% <0.00%> (+0.08%) ⬆️
check_version_ur15-10.12.1 11.10% <0.00%> (-0.01%) ⬇️
check_version_ur15-5.25.1 11.29% <0.00%> (-0.59%) ⬇️
check_version_ur16e-10.12.1 11.10% <0.00%> (-0.06%) ⬇️
check_version_ur16e-5.25.1 11.10% <0.00%> (-0.01%) ⬇️
check_version_ur18-10.12.1 11.10% <0.00%> (-0.01%) ⬇️
check_version_ur18-5.25.1 11.10% <0.00%> (-0.06%) ⬇️
check_version_ur20-10.12.1 11.15% <0.00%> (-0.01%) ⬇️
check_version_ur20-5.25.1 11.10% <0.00%> (-0.17%) ⬇️
check_version_ur3-3.14.3 11.10% <0.00%> (-0.48%) ⬇️
check_version_ur30-10.12.1 11.10% <0.00%> (-0.01%) ⬇️
check_version_ur30-5.25.1 11.29% <0.00%> (+0.18%) ⬆️
check_version_ur3e-10.11.0 11.10% <0.00%> (-0.01%) ⬇️
check_version_ur3e-5.9.4 11.10% <0.00%> (-0.06%) ⬇️
check_version_ur5-3.15.8 11.15% <0.00%> (-0.26%) ⬇️
check_version_ur5e-10.11.0 11.10% <0.00%> (-0.01%) ⬇️
check_version_ur5e-5.12.8 11.10% <0.00%> (-0.42%) ⬇️
check_version_ur7e-10.11.0 11.15% <0.00%> (-0.01%) ⬇️
check_version_ur7e-5.22.2 11.10% <0.00%> (-0.01%) ⬇️
check_version_ur8long-10.12.1 11.15% <0.00%> (-0.01%) ⬇️
check_version_ur8long-5.25.1 11.10% <0.00%> (-0.24%) ⬇️
python_scripts 75.90% <ø> (ø)
start_ursim 82.90% <ø> (-1.88%) ⬇️
ur5-3.14.3 74.63% <100.00%> (-0.02%) ⬇️
ur5e-10.11.0 69.25% <100.00%> (-0.10%) ⬇️
ur5e-10.12.0 70.42% <100.00%> (+0.07%) ⬆️
ur5e-10.7.0 68.76% <100.00%> (-0.02%) ⬇️
ur5e-5.9.4 75.24% <100.00%> (-0.17%) ⬇️
ur7e-10.13.0 70.39% <100.00%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@mergify

mergify Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@urfeex
urfeex merged commit 7c65b2f into UniversalRobots:master Jul 6, 2026
56 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants