ros2_control - rolling
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
realtime_tools::RealtimeServerGoalHandle< Action > Class Template Reference

Public Member Functions

 RealtimeServerGoalHandle (std::shared_ptr< GoalHandle > &gh, const ResultSharedPtr &preallocated_result=nullptr, const FeedbackSharedPtr &preallocated_feedback=nullptr)
 
 RealtimeServerGoalHandle (std::shared_ptr< GoalHandle > &gh, const ResultSharedPtr &preallocated_result, const FeedbackSharedPtr &preallocated_feedback, rclcpp::Logger logger)
 
void setAborted (ResultSharedPtr result=nullptr)
 
void setCanceled (ResultSharedPtr result=nullptr)
 
void setSucceeded (ResultSharedPtr result=nullptr)
 
bool setFeedback (FeedbackSharedPtr feedback=nullptr)
 Set feedback to be published by runNonRealtime().
 
void execute ()
 
bool valid ()
 
void runNonRealtime ()
 

Public Attributes

std::shared_ptr< GoalHandle > gh_
 
ResultSharedPtr preallocated_result_
 
FeedbackSharedPtr preallocated_feedback_
 

Member Function Documentation

◆ setFeedback()

template<class Action >
bool realtime_tools::RealtimeServerGoalHandle< Action >::setFeedback ( FeedbackSharedPtr  feedback = nullptr)
inline

Set feedback to be published by runNonRealtime().

This method uses a non-blocking lock acquisition with try_to_lock() and is safe to call from real-time context without causing thread blocking or priority inversion. If the lock cannot be acquired (because runNonRealtime() is holding it), the update is silently skipped to avoid blocking the real-time thread.

The feedback pointer is stored and the non-RT thread will publish it on the next runNonRealtime() call, provided the goal handle is in executing state.

Parameters
feedbackShared pointer to feedback message. Can be nullptr to clear pending feedback. If a valid pointer is provided, the caller must ensure the feedback object remains valid until runNonRealtime() processes it. Using a preallocated feedback message (stored in preallocated_feedback_) is recommended to avoid dynamic allocations in the real-time thread.
Returns
true if the lock was acquired and feedback was successfully set, false if the lock could not be acquired (feedback update was dropped).
Note
If the mutex lock cannot be acquired, the feedback update is dropped without notification. This is intentional to preserve real-time guarantees. Check the return value if you need to know whether the update succeeded.
Feedback is only published if the goal is currently executing. If feedback is set after the goal transitions out of executing state, it will be discarded.
See also
runNonRealtime() for the counterpart that publishes the feedback.
preallocated_feedback_ for recommended pre-allocated feedback usage.

The documentation for this class was generated from the following file: