Skip to content

Commit 7c65b2f

Browse files
authored
background Enable FIFO scheduling by default for RTDE producer thread (#536)
Improves the scheduling configuration of the thread responsible for receiving and processing robot communication data. 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.
1 parent 8b4495c commit 7c65b2f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/rtde/rtde_client.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "ur_client_library/exceptions.h"
3131
#include "ur_client_library/log.h"
3232
#include "ur_client_library/rtde/data_package.h"
33+
#include "ur_client_library/helpers.h"
3334
#include <algorithm>
3435
#include <chrono>
3536
#include <string>
@@ -964,6 +965,10 @@ void RTDEClient::stopBackgroundRead()
964965

965966
void RTDEClient::backgroundReadThreadFunc()
966967
{
968+
pthread_t this_thread = pthread_self();
969+
const int max_thread_priority = sched_get_priority_max(SCHED_FIFO);
970+
setFiFoScheduling(this_thread, max_thread_priority);
971+
967972
while (background_read_running_)
968973
{
969974
std::unique_lock<std::mutex> lock(reconnect_mutex_, std::defer_lock);

0 commit comments

Comments
 (0)