ros2_control - jazzy
Loading...
Searching...
No Matches
async_function_handler.hpp
1// Copyright 2024 PAL Robotics S.L.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
16
17#ifndef REALTIME_TOOLS__ASYNC_FUNCTION_HANDLER_HPP_
18#define REALTIME_TOOLS__ASYNC_FUNCTION_HANDLER_HPP_
19
20#include <fmt/format.h>
21#include <fmt/ranges.h>
22#include <atomic>
23#include <cmath>
24#include <condition_variable>
25#include <functional>
26#include <limits>
27#include <memory>
28#include <mutex>
29#include <stdexcept>
30#include <string>
31#include <thread>
32#include <utility>
33#include <vector>
34
35#include "rclcpp/clock.hpp"
36#include "rclcpp/duration.hpp"
37#include "rclcpp/logging.hpp"
38#include "rclcpp/time.hpp"
39#include "realtime_tools/realtime_helpers.hpp"
40
42{
53class AsyncSchedulingPolicy
54{
55public:
56 enum Value : int8_t {
57 UNKNOWN = -1,
61 };
62
63 AsyncSchedulingPolicy() = default;
64 constexpr AsyncSchedulingPolicy(Value value) : value_(value) {} // NOLINT(runtime/explicit)
65 explicit AsyncSchedulingPolicy(const std::string & data_type)
66 {
67 if (data_type == "synchronized") {
68 value_ = SYNCHRONIZED;
69 } else if (data_type == "detached") {
70 value_ = DETACHED;
71 } else if (data_type == "self_paced") {
72 value_ = SELF_PACED;
73 } else {
74 value_ = UNKNOWN;
75 }
76 }
77
78 operator Value() const { return value_; }
79
80 explicit operator bool() const = delete;
81
82 constexpr bool operator==(AsyncSchedulingPolicy other) const { return value_ == other.value_; }
83 constexpr bool operator!=(AsyncSchedulingPolicy other) const { return value_ != other.value_; }
84
85 constexpr bool operator==(Value other) const { return value_ == other; }
86 constexpr bool operator!=(Value other) const { return value_ != other; }
87
88 std::string to_string() const
89 {
90 switch (value_) {
91 case SYNCHRONIZED:
92 return "synchronized";
93 case DETACHED:
94 return "detached";
95 case SELF_PACED:
96 return "self_paced";
97 default:
98 return "unknown";
99 }
100 }
101
102 AsyncSchedulingPolicy from_string(const std::string & data_type)
103 {
104 return AsyncSchedulingPolicy(data_type);
105 }
106
107private:
108 Value value_ = UNKNOWN;
109};
110
138{
144 bool validate() const
145 {
146 if (thread_priority < 0 || thread_priority > 99) {
147 RCLCPP_ERROR(
148 logger, "Invalid thread priority: %d. It should be between 0 and 99.", thread_priority);
149 return false;
150 }
151 if (
152 scheduling_policy == AsyncSchedulingPolicy::DETACHED ||
153 scheduling_policy == AsyncSchedulingPolicy::SELF_PACED) {
154 if (!clock) {
155 RCLCPP_ERROR(
156 logger, "Clock must be set when using DETACHED or SELF_PACED scheduling policy.");
157 return false;
158 }
159 if (exec_rate == 0u) {
160 RCLCPP_ERROR(
161 logger,
162 "Execution rate must be set when using DETACHED or SELF_PACED scheduling policy.");
163 return false;
164 }
165 }
166 if (scheduling_policy == AsyncSchedulingPolicy::UNKNOWN) {
167 throw std::runtime_error(
168 "AsyncFunctionHandlerParams: scheduling policy is unknown. "
169 "Please set it to either 'synchronized', 'detached' or 'self_paced'.");
170 }
171 if (trigger_predicate == nullptr) {
172 RCLCPP_ERROR(logger, "The parsed trigger predicate is not valid!");
173 return false;
174 }
175 for (const int & core : cpu_affinity_cores) {
176 if (core < 0) {
177 RCLCPP_ERROR(logger, "Invalid CPU core id: %d. It should be a non-negative integer.", core);
178 return false;
179 }
180 }
181 return true;
182 }
183
201 template <typename NodeT>
202 void initialize(NodeT & node, const std::string & prefix)
203 {
204 if (node->has_parameter(prefix + "thread_priority")) {
205 thread_priority = static_cast<int>(node->get_parameter(prefix + "thread_priority").as_int());
206 }
207 if (node->has_parameter(prefix + "cpu_affinity")) {
208 const auto cpu_affinity_param =
209 node->get_parameter(prefix + "cpu_affinity").as_integer_array();
210 for (const auto & core : cpu_affinity_param) {
211 cpu_affinity_cores.push_back(static_cast<int>(core));
212 }
213 }
214 if (node->has_parameter(prefix + "scheduling_policy")) {
215 scheduling_policy =
216 AsyncSchedulingPolicy(node->get_parameter(prefix + "scheduling_policy").as_string());
217 }
218 if (
219 (scheduling_policy == AsyncSchedulingPolicy::DETACHED ||
220 scheduling_policy == AsyncSchedulingPolicy::SELF_PACED) &&
221 node->has_parameter(prefix + "execution_rate")) {
222 const int execution_rate =
223 static_cast<int>(node->get_parameter(prefix + "execution_rate").as_int());
224 if (execution_rate <= 0) {
225 throw std::runtime_error(
226 "AsyncFunctionHandler: execution_rate parameter must be positive.");
227 }
228 exec_rate = static_cast<unsigned int>(execution_rate);
229 }
230 if (node->has_parameter(prefix + "wait_until_initial_trigger")) {
231 wait_until_initial_trigger =
232 node->get_parameter(prefix + "wait_until_initial_trigger").as_bool();
233 }
234 if (node->has_parameter(prefix + "print_warnings")) {
235 print_warnings = node->get_parameter(prefix + "print_warnings").as_bool();
236 }
237 if (node->has_parameter(prefix + "thread_name")) {
238 thread_name = node->get_parameter(prefix + "thread_name").as_string();
239 }
240 }
241
242 int thread_priority = 50;
243 std::vector<int> cpu_affinity_cores = {};
244 AsyncSchedulingPolicy scheduling_policy = AsyncSchedulingPolicy::SYNCHRONIZED;
245 unsigned int exec_rate = 0u;
246 rclcpp::Clock::SharedPtr clock = nullptr;
247 rclcpp::Logger logger = rclcpp::get_logger("AsyncFunctionHandler");
248 std::function<bool()> trigger_predicate = []() { return true; };
249 bool wait_until_initial_trigger = true;
250 bool print_warnings = true;
251 std::string thread_name = "";
252};
253
259template <typename T>
260class AsyncFunctionHandler
261{
262public:
263 AsyncFunctionHandler() = default;
264
265 ~AsyncFunctionHandler() { stop_thread(); }
266
268
274 void init(
275 std::function<T(const rclcpp::Time &, const rclcpp::Duration &)> callback,
276 int thread_priority = 50)
277 {
278 if (callback == nullptr) {
279 throw std::runtime_error(
280 "AsyncFunctionHandler: parsed function to call asynchronously is not valid!");
281 }
282 if (thread_.joinable()) {
283 throw std::runtime_error(
284 "AsyncFunctionHandler: Cannot reinitialize while the thread is "
285 "running. Please stop the async callback first!");
286 }
287 async_function_ = callback;
288 thread_priority_ = thread_priority;
289 }
290
292
305 void init(
306 std::function<T(const rclcpp::Time &, const rclcpp::Duration &)> callback,
307 std::function<bool()> trigger_predicate, int thread_priority = 50)
308 {
309 if (trigger_predicate == nullptr) {
310 throw std::runtime_error("AsyncFunctionHandler: parsed trigger predicate is not valid!");
311 }
312 init(callback, thread_priority);
313 trigger_predicate_ = trigger_predicate;
314 }
315
316 void init(
317 std::function<T(const rclcpp::Time &, const rclcpp::Duration &)> callback,
318 const AsyncFunctionHandlerParams & params)
319 {
320 params.validate();
321 init(callback, params.trigger_predicate, params.thread_priority);
322 params_ = params;
323 pause_thread_ = params.wait_until_initial_trigger;
324 }
325
327
346 std::pair<bool, T> trigger_async_callback(
347 const rclcpp::Time & time, const rclcpp::Duration & period)
348 {
349 if (!is_initialized()) {
350 throw std::runtime_error("AsyncFunctionHandler: need to be initialized first!");
351 }
352 if (async_exception_ptr_) {
353 RCLCPP_ERROR(
354 params_.logger, "AsyncFunctionHandler: Exception caught in the async callback thread!");
355 std::rethrow_exception(async_exception_ptr_);
356 }
357 if (
358 params_.scheduling_policy == AsyncSchedulingPolicy::DETACHED ||
359 params_.scheduling_policy == AsyncSchedulingPolicy::SELF_PACED) {
360 RCLCPP_WARN_ONCE(
361 params_.logger,
362 "AsyncFunctionHandler is configured with DETACHED or SELF_PACED scheduling policy. "
363 "This means that the async callback may not be synchronized with the main thread.");
364 if (pause_thread_.load(std::memory_order_relaxed)) {
365 {
366 std::unique_lock<std::mutex> lock(async_mtx_);
367 pause_thread_ = false;
368 RCLCPP_INFO(params_.logger, "AsyncFunctionHandler: Resuming the async callback thread.");
369 async_callback_return_ = T();
370 auto const sync_period = std::chrono::nanoseconds(1'000'000'000 / params_.exec_rate);
371 previous_time_ = params_.clock->now() - rclcpp::Duration(sync_period);
372 }
373 async_callback_condition_.notify_one();
374 }
375 return std::make_pair(true, async_callback_return_.load(std::memory_order_relaxed));
376 }
377 if (!is_running()) {
378 throw std::runtime_error(
379 "AsyncFunctionHandler: need to start the async callback thread first before triggering!");
380 }
381 std::unique_lock<std::mutex> lock(async_mtx_, std::try_to_lock);
382 bool trigger_status = false;
383 if (lock.owns_lock() && !trigger_in_progress_ && trigger_predicate_()) {
384 {
385 std::unique_lock<std::mutex> scoped_lock(std::move(lock));
386 trigger_in_progress_ = true;
387 current_callback_time_ = time;
388 current_callback_period_ = period;
389 }
390 async_callback_condition_.notify_one();
391 trigger_status = true;
392 }
393 const T return_value = async_callback_return_;
394 return std::make_pair(trigger_status, return_value);
395 }
396
398
401 T get_last_return_value() const { return async_callback_return_; }
402
404
407 const rclcpp::Time & get_current_callback_time() const { return current_callback_time_; }
408
410
413 const rclcpp::Duration & get_current_callback_period() const { return current_callback_period_; }
414
416
424 {
425 std::unique_lock<std::mutex> lock(async_mtx_);
426 stop_async_callback_ = false;
427 trigger_in_progress_ = false;
428 current_callback_time_ = rclcpp::Time(0, 0, RCL_CLOCK_UNINITIALIZED);
429 current_callback_period_ = rclcpp::Duration(0, 0);
430 last_execution_time_ = std::chrono::nanoseconds(0);
431 async_callback_return_ = T();
432 async_exception_ptr_ = nullptr;
433 }
434
436
440 {
441 if (is_running()) {
442 std::unique_lock<std::mutex> lock(async_mtx_);
443 cycle_end_condition_.wait(lock, [this] { return !trigger_in_progress_; });
444 return true;
445 }
446 return false;
447 }
448
450
458 {
459 RCLCPP_INFO_EXPRESSION(
460 params_.logger, !pause_thread_, "AsyncFunctionHandler: Pausing the async callback thread.");
461 if (params_.scheduling_policy == AsyncSchedulingPolicy::SYNCHRONIZED) {
462 pause_thread_ = true;
464 } else {
465 if (is_running()) {
466 pause_thread_.store(true, std::memory_order_relaxed);
467 std::unique_lock<std::mutex> lock(async_mtx_);
468 return true;
469 }
470 }
471 return pause_thread_.load(std::memory_order_relaxed);
472 }
473
475
478 bool is_initialized() const { return async_function_ && trigger_predicate_; }
479
481
486 {
487 if (is_running()) {
488 thread_.join();
489 }
490 }
491
493
496 bool is_running() const { return thread_.joinable(); }
497
499
502 bool is_stopped() const { return stop_async_callback_.load(std::memory_order_relaxed); }
503
505
508 bool is_paused() const { return pause_thread_.load(std::memory_order_relaxed); }
509
511
514 std::thread & get_thread() { return thread_; }
515
517
520 const std::thread & get_thread() const { return thread_; }
521
523
526 const AsyncFunctionHandlerParams & get_params() const { return params_; }
527
529
532 bool is_trigger_cycle_in_progress() const { return trigger_in_progress_; }
533
535
540 {
541 if (is_running()) {
542 {
543 stop_async_callback_.store(true, std::memory_order_relaxed);
544 std::unique_lock<std::mutex> lock(async_mtx_);
545 }
546 async_callback_condition_.notify_one();
547 thread_.join();
548 }
549 }
550
552
555 std::chrono::nanoseconds get_last_execution_time() const
556 {
557 return last_execution_time_.load(std::memory_order_relaxed);
558 }
559
561
567 {
568 if (!is_initialized()) {
569 throw std::runtime_error("AsyncFunctionHandler: need to be initialized first!");
570 }
571 if (!thread_.joinable()) {
573 thread_ = std::thread([this]() -> void {
574 if (!realtime_tools::configure_sched_fifo(thread_priority_)) {
575 RCLCPP_WARN(
576 params_.logger,
577 "Could not enable FIFO RT scheduling policy. Consider setting up your user to do FIFO "
578 "RT scheduling. See "
579 "[https://control.ros.org/master/doc/ros2_control/controller_manager/doc/userdoc.html] "
580 "for details.");
581 }
582 if (!params_.cpu_affinity_cores.empty()) {
583 const auto affinity_result =
584 realtime_tools::set_current_thread_affinity(params_.cpu_affinity_cores);
585 RCLCPP_WARN_EXPRESSION(
586 params_.logger, !affinity_result.first,
587 "Could not set CPU affinity for the async worker thread. Error: %s",
588 affinity_result.second.c_str());
589
590 std::string cores_list_print =
591 fmt::format("[{}]", fmt::join(params_.cpu_affinity_cores, ", "));
592
593 RCLCPP_WARN_EXPRESSION(
594 params_.logger, affinity_result.first,
595 "Async worker thread successfully pinned to Cores: %s", cores_list_print.c_str());
596 }
597 if (!params_.thread_name.empty()) {
598 const auto rename_result = realtime_tools::set_current_thread_name(params_.thread_name);
599
600 if (!rename_result.first) {
601 RCLCPP_WARN(
602 params_.logger, "Could not set thread name for the async worker thread. Error: %s",
603 rename_result.second.c_str());
604 } else {
605 RCLCPP_INFO(params_.logger, "%s", rename_result.second.c_str());
606 }
607 }
608
609 switch (static_cast<AsyncSchedulingPolicy::Value>(params_.scheduling_policy)) {
611 execute_synchronized_callback();
612 break;
615 execute_detached_callback();
616 break;
617 default:
618 throw std::runtime_error(
619 "AsyncFunctionHandler: start_thread(): Not a valid scheduling policy, this should "
620 "never happen!");
621 break;
622 }
623 });
624 }
625 }
626
627private:
628 void execute_synchronized_callback()
629 {
630 while (!stop_async_callback_.load(std::memory_order_relaxed)) {
631 {
632 std::unique_lock<std::mutex> lock(async_mtx_);
633 async_callback_condition_.wait(
634 lock, [this] { return trigger_in_progress_ || stop_async_callback_; });
635 if (!stop_async_callback_) {
636 const auto start_time = std::chrono::steady_clock::now();
637 try {
638 async_callback_return_ =
639 async_function_(current_callback_time_, current_callback_period_);
640 } catch (...) {
641 async_exception_ptr_ = std::current_exception();
642 }
643 const auto end_time = std::chrono::steady_clock::now();
644 last_execution_time_ =
645 std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time);
646 }
647 trigger_in_progress_ = false;
648 }
649 cycle_end_condition_.notify_all();
650 }
651 }
652
653 void execute_detached_callback()
654 {
655 if (!params_.clock) {
656 throw std::runtime_error(
657 "AsyncFunctionHandler: Clock must be set when using DETACHED or SELF_PACED scheduling "
658 "policy.");
659 }
660 if (params_.exec_rate == 0u) {
661 throw std::runtime_error(
662 "AsyncFunctionHandler: Execution rate must be set when using DETACHED or SELF_PACED "
663 "scheduling "
664 "policy.");
665 }
666
667 auto const period = std::chrono::nanoseconds(1'000'000'000 / params_.exec_rate);
668
669 if (pause_thread_) {
670 std::unique_lock<std::mutex> lock(async_mtx_);
671 async_callback_condition_.wait(
672 lock, [this] { return !pause_thread_ || stop_async_callback_; });
673 }
674 // for calculating the measured period of the loop
675 previous_time_ = params_.clock->now();
676 if (params_.scheduling_policy == AsyncSchedulingPolicy::DETACHED) {
677 std::this_thread::sleep_for(period);
678 } else if (params_.scheduling_policy == AsyncSchedulingPolicy::SELF_PACED) {
679 previous_time_ = params_.clock->now() - rclcpp::Duration(period);
680 }
681 std::chrono::steady_clock::time_point next_iteration_time{std::chrono::steady_clock::now()};
682 while (!stop_async_callback_.load(std::memory_order_relaxed)) {
683 {
684 std::unique_lock<std::mutex> lock(async_mtx_);
685 async_callback_condition_.wait(
686 lock, [this] { return !pause_thread_ || stop_async_callback_; });
687 if (!stop_async_callback_) {
688 // calculate measured period
689 auto const current_time = params_.clock->now();
690 auto const measured_period = current_time - previous_time_;
691 previous_time_ = current_time;
692 current_callback_time_ = current_time;
693 current_callback_period_ = measured_period;
694
695 const auto start_time = std::chrono::steady_clock::now();
696 try {
697 async_callback_return_ = async_function_(current_time, measured_period);
698 } catch (...) {
699 async_exception_ptr_ = std::current_exception();
700 }
701 last_execution_time_ = std::chrono::duration_cast<std::chrono::nanoseconds>(
702 std::chrono::steady_clock::now() - start_time);
703
704 if (params_.scheduling_policy == AsyncSchedulingPolicy::DETACHED) {
705 next_iteration_time += period;
706 const auto time_now = std::chrono::steady_clock::now();
707 if (next_iteration_time < time_now) {
708 const double time_diff =
709 std::chrono::duration<double, std::milli>(time_now - next_iteration_time).count();
710 const double cm_period = 1.e3 / static_cast<double>(params_.exec_rate);
711 const int overrun_count = static_cast<int>(std::ceil(time_diff / cm_period));
712 if (params_.print_warnings) {
713 RCLCPP_WARN_THROTTLE(
714 params_.logger, *params_.clock, 1000,
715 "Overrun detected! The async callback missed its desired rate of %d Hz. The loop "
716 "took %f ms (missed cycles : %d).",
717 params_.exec_rate, time_diff + cm_period, overrun_count + 1);
718 }
719 next_iteration_time += (overrun_count * period);
720 }
721 std::this_thread::sleep_until(next_iteration_time);
722 } else if (params_.scheduling_policy == AsyncSchedulingPolicy::SELF_PACED) {
723 const auto minimum_period = period / 10;
724 const auto last_period = last_execution_time_.load(std::memory_order_relaxed);
725 if (last_period < minimum_period) {
726 if (params_.print_warnings) {
727 RCLCPP_WARN_THROTTLE(
728 params_.logger, *params_.clock, 1000,
729 "The SELF_PACED callback took less than 10%% of the cycle period. Check whether "
730 "your read() blocks. The handler sleeps for 100 us to protect the CPU.");
731 }
732 std::this_thread::sleep_for(std::chrono::microseconds(100));
733 }
734 }
735 }
736 trigger_in_progress_ = false;
737 }
738 cycle_end_condition_.notify_all();
739 }
740 }
741
742 rclcpp::Time current_callback_time_ = rclcpp::Time(0, 0, RCL_CLOCK_UNINITIALIZED);
743 rclcpp::Duration current_callback_period_{0, 0};
744
745 std::function<T(const rclcpp::Time &, const rclcpp::Duration &)> async_function_;
746 std::function<bool()> trigger_predicate_ = []() { return true; };
747
748 // Async related variables
749 std::thread thread_;
750 AsyncFunctionHandlerParams params_;
751 rclcpp::Time previous_time_{0, 0, RCL_CLOCK_UNINITIALIZED};
752 int thread_priority_ = std::numeric_limits<int>::quiet_NaN();
753 std::atomic_bool stop_async_callback_{false};
754 std::atomic_bool trigger_in_progress_{false};
755 std::atomic_bool pause_thread_{false};
756 std::atomic<T> async_callback_return_;
757 std::condition_variable async_callback_condition_;
758 std::condition_variable cycle_end_condition_;
759 std::mutex async_mtx_;
760 std::atomic<std::chrono::nanoseconds> last_execution_time_;
761 std::atomic<double> periodicity_;
762 std::exception_ptr async_exception_ptr_;
763};
764} // namespace realtime_tools
765
766#endif // REALTIME_TOOLS__ASYNC_FUNCTION_HANDLER_HPP_
bool wait_for_trigger_cycle_to_finish()
Waits until the current async callback method trigger cycle is finished.
Definition async_function_handler.hpp:439
std::pair< bool, T > trigger_async_callback(const rclcpp::Time &time, const rclcpp::Duration &period)
Triggers the async callback method cycle.
Definition async_function_handler.hpp:346
std::thread & get_thread()
Get the async worker thread.
Definition async_function_handler.hpp:514
bool is_trigger_cycle_in_progress() const
Check if the async callback method is in progress.
Definition async_function_handler.hpp:532
std::chrono::nanoseconds get_last_execution_time() const
Get the last execution time of the async callback method.
Definition async_function_handler.hpp:555
const rclcpp::Time & get_current_callback_time() const
Get the current callback time.
Definition async_function_handler.hpp:407
void start_thread()
Initializes and starts the callback thread.
Definition async_function_handler.hpp:566
void init(std::function< T(const rclcpp::Time &, const rclcpp::Duration &)> callback, std::function< bool()> trigger_predicate, int thread_priority=50)
Initialize the AsyncFunctionHandler with the callback, trigger_predicate and thread_priority.
Definition async_function_handler.hpp:305
const AsyncFunctionHandlerParams & get_params() const
Get the parameters used to configure the AsyncFunctionHandler.
Definition async_function_handler.hpp:526
void reset_variables()
Resets the internal variables of the AsyncFunctionHandler.
Definition async_function_handler.hpp:423
bool is_running() const
Check if the async worker thread is running.
Definition async_function_handler.hpp:496
bool is_paused() const
Check if the async callback thread is paused.
Definition async_function_handler.hpp:508
bool pause_execution()
Pauses the execution of the async callback thread.
Definition async_function_handler.hpp:457
const rclcpp::Duration & get_current_callback_period() const
Get the current callback period.
Definition async_function_handler.hpp:413
void init(std::function< T(const rclcpp::Time &, const rclcpp::Duration &)> callback, int thread_priority=50)
Initialize the AsyncFunctionHandler with the callback and thread_priority.
Definition async_function_handler.hpp:274
void stop_thread()
Stops the callback thread.
Definition async_function_handler.hpp:539
void join_async_callback_thread()
Join the async callback thread.
Definition async_function_handler.hpp:485
bool is_stopped() const
Check if the async callback is triggered to stop the cycle.
Definition async_function_handler.hpp:502
bool is_initialized() const
Check if the AsyncFunctionHandler is initialized.
Definition async_function_handler.hpp:478
const std::thread & get_thread() const
Get the const version of async worker thread.
Definition async_function_handler.hpp:520
T get_last_return_value() const
Get the last return value of the async callback method.
Definition async_function_handler.hpp:401
Enum class to define the scheduling policy for the async worker thread. SYNCHRONIZED: The async worke...
Definition async_function_handler.hpp:54
Value
Definition async_function_handler.hpp:56
@ SELF_PACED
Detached scheduling policy.
Definition async_function_handler.hpp:60
@ DETACHED
Synchronized scheduling policy.
Definition async_function_handler.hpp:59
@ SYNCHRONIZED
Unknown scheduling policy.
Definition async_function_handler.hpp:58
A pthread mutex wrapper that provides a mutex with the priority inheritance protocol and a priority c...
Definition async_function_handler.hpp:42
std::pair< bool, std::string > set_current_thread_name(const std::string &name)
Definition realtime_helpers.cpp:288
std::pair< bool, std::string > set_current_thread_affinity(int core)
Definition realtime_helpers.cpp:270
bool configure_sched_fifo(int priority)
Definition realtime_helpers.cpp:74
The AsyncFunctionHandlerParams struct is used to configure the AsyncFunctionHandler....
Definition async_function_handler.hpp:138
void initialize(NodeT &node, const std::string &prefix)
Initialize the parameters from a node's parameters. The node should have the following parameters:
Definition async_function_handler.hpp:202
bool validate() const
Validate the parameters.
Definition async_function_handler.hpp:144