33namespace client_behavior_bases
52template <
typename TAction>
56 using Goal =
typename TAction::Goal;
57 using GoalHandle = rclcpp_action::ClientGoalHandle<TAction>;
62 template <
typename TOrthogonal,
typename TSourceObject>
100 getLogger(),
"[%s] State exited with the action goal still in flight - cancelling",
119 getLogger(),
"[%s] Action server not available, cannot send goal",
getName().c_str());
130 bool trackGoal(std::shared_future<typename GoalHandle::SharedPtr> goalHandleFuture)
153 if (goalHandleFuture.wait_for(std::chrono::milliseconds(50)) == std::future_status::ready)
155 if (goalHandleFuture.get() !=
nullptr)
161 RCLCPP_ERROR(
getLogger(),
"[%s] Goal was rejected by the action server",
getName().c_str());
177 "[%s] No goal response from the action server after %ld ms; assuming the goal was "
178 "accepted (a rejection responds promptly) - result signals will finish this behavior",
199 RCLCPP_INFO(
getLogger(),
"[%s] Action succeeded, propagating success event",
getName().c_str());
206 RCLCPP_INFO(
getLogger(),
"[%s] Action failed, propagating failure event",
getName().c_str());
222 rclcpp_action::ResultCode
actionResult_ = rclcpp_action::ResultCode::UNKNOWN;
257 std::shared_future<typename GoalHandle::SharedPtr> future;
263 const bool own = future.valid() &&
264 future.wait_for(std::chrono::seconds(0)) == std::future_status::ready &&
265 future.get() !=
nullptr && future.get()->get_goal_id() == result.goal_id;
269 getLogger(),
"[%s] Ignoring the result of a goal this behavior did not send",
std::string getName() const
virtual rclcpp::Logger getLogger() const
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
bool isShutdownRequested()
onEntry is executed in a new thread. However the current state cannot be left until the onEntry threa...
void onStateOrthogonalAllocation()
virtual ~CbActionClientBehaviorBase()
void onStateOrthogonalAllocation()
bool resultConnectionsInitialized_
ActionClientComponent * actionClient_
void dispatchActionAbort(const WrappedResult &result)
std::chrono::milliseconds goalResponseTimeout_
rclcpp_action::ClientGoalHandle< TAction > GoalHandle
std::shared_future< typename GoalHandle::SharedPtr > ownGoalHandleFuture_
bool trackGoal(std::shared_future< typename GoalHandle::SharedPtr > goalHandleFuture)
void dispatchActionFeedback(const Feedback &feedback)
std::string actionClientName_
virtual void onActionAbort(const WrappedResult &result)
void setActionClientName(std::string name)
bool isOwnGoal(const WrappedResult &result)
virtual void onActionFeedback(const Feedback &)
std::atomic< bool > goalActivitySeen_
typename GoalHandle::WrappedResult WrappedResult
typename TAction::Goal Goal
virtual void onActionSuccess(const WrappedResult &result)
std::atomic< bool > goalInFlight_
void dispatchActionSuccess(const WrappedResult &result)
typename TAction::Feedback Feedback
rclcpp_action::ResultCode actionResult_
bool sendGoal(Goal &goal)
smacc2::SmaccSignalConnection onSucceeded(void(T::*callback)(const WrappedResult &), T *object)
std::shared_future< typename GoalHandle::SharedPtr > sendGoal(Goal &goal, typename smacc2::SmaccSignal< void(const WrappedResult &)>::WeakPtr resultCallback=typename smacc2::SmaccSignal< void(const WrappedResult &)>::WeakPtr())
smacc2::SmaccSignalConnection onFeedback(void(T::*callback)(const Feedback &), T *object)
smacc2::SmaccSignalConnection onAborted(void(T::*callback)(const WrappedResult &), T *object)
smacc2::SmaccSignalConnection onCancelled(void(T::*callback)(const WrappedResult &), T *object)
bool isServerReady() const