SMACC2
Loading...
Searching...
No Matches
cl_px4_mr::CbPx4ClientBehaviorBase Class Reference

#include <cb_px4_client_behavior_base.hpp>

Inheritance diagram for cl_px4_mr::CbPx4ClientBehaviorBase:
Inheritance graph
Collaboration diagram for cl_px4_mr::CbPx4ClientBehaviorBase:
Collaboration graph

Public Member Functions

template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
virtual ~CbPx4ClientBehaviorBase ()
 
void setTimeout (std::chrono::milliseconds timeout)
 
void update () override
 
- Public Member Functions inherited from smacc2::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
virtual ~SmaccAsyncClientBehavior ()
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onSuccess (TCallback callback, T *object)
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onFinished (TCallback callback, T *object)
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onFailure (TCallback callback, T *object)
 
void requestForceFinish ()
 
void executeOnEntry () override
 
void executeOnExit () override
 
void waitOnEntryThread (bool requestFinish)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onSuccess (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onFinished (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onFailure (TCallbackMethod callback, T *object)
 
- Public Member Functions inherited from smacc2::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
ISmaccStateMachinegetStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
template<typename SmaccComponentType >
void requiresComponent (std::string name, SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
virtual void onEntry ()
 
virtual void onExit ()
 
- Public Member Functions inherited from smacc2::ISmaccUpdatable
 ISmaccUpdatable ()
 
 ISmaccUpdatable (rclcpp::Duration duration)
 
void executeUpdate (rclcpp::Node::SharedPtr node)
 
void setUpdatePeriod (rclcpp::Duration duration)
 

Protected Member Functions

virtual void wireCompletionSignals ()
 
void postPx4Success ()
 
void postPx4Failure ()
 
- Protected Member Functions inherited from smacc2::SmaccAsyncClientBehavior
void postSuccessEvent ()
 
void postFailureEvent ()
 
virtual void dispose () override
 
bool isShutdownRequested ()
 onEntry is executed in a new thread. However the current state cannot be left until the onEntry thread finishes. This flag can be checked from the onEntry thread to force finishing the thread.
 
- Protected Member Functions inherited from smacc2::ISmaccClientBehavior
virtual void runtimeConfigure ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
ISmaccStategetCurrentState ()
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 
- Protected Member Functions inherited from smacc2::ISmaccUpdatable

Protected Attributes

CpVehicleCommandvehicleCommand_ = nullptr
 
CpVehicleStatusvehicleStatus_ = nullptr
 
CpTrajectorySetpointtrajectorySetpoint_ = nullptr
 
CpGoalCheckergoalChecker_ = nullptr
 
CpVehicleLocalPositionlocalPosition_ = nullptr
 
CpOffboardKeepAliveoffboardKeepAlive_ = nullptr
 

Private Attributes

std::atomic< boolcompleted_ {false}
 
std::optional< std::chrono::milliseconds > timeout_
 
std::optional< std::chrono::steady_clock::time_point > watchdogStart_
 

Detailed Description

Definition at line 59 of file cb_px4_client_behavior_base.hpp.

Constructor & Destructor Documentation

◆ ~CbPx4ClientBehaviorBase()

virtual cl_px4_mr::CbPx4ClientBehaviorBase::~CbPx4ClientBehaviorBase ( )
inlinevirtual

Definition at line 79 of file cb_px4_client_behavior_base.hpp.

79{}

Member Function Documentation

◆ onStateOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void cl_px4_mr::CbPx4ClientBehaviorBase::onStateOrthogonalAllocation ( )
inline

Definition at line 64 of file cb_px4_client_behavior_base.hpp.

65 {
66 // shared component set; SOFT because each behavior uses a subset
73
75
77 }
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)

References goalChecker_, localPosition_, offboardKeepAlive_, smacc2::SmaccAsyncClientBehavior::onStateOrthogonalAllocation(), smacc2::ISmaccClientBehavior::requiresComponent(), smacc2::SOFT, trajectorySetpoint_, vehicleCommand_, vehicleStatus_, and wireCompletionSignals().

Referenced by cl_px4_mr::CbConnectMicroRosAgent::onStateOrthogonalAllocation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ postPx4Failure()

void cl_px4_mr::CbPx4ClientBehaviorBase::postPx4Failure ( )
inlineprotected

Definition at line 121 of file cb_px4_client_behavior_base.hpp.

122 {
123 if (!completed_.exchange(true))
124 {
125 this->postFailureEvent();
126 }
127 }

References completed_, and smacc2::SmaccAsyncClientBehavior::postFailureEvent().

Referenced by cl_px4_mr::CbArmPX4::onEntry(), cl_px4_mr::CbConnectMicroRosAgent::onEntry(), and update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ postPx4Success()

◆ setTimeout()

void cl_px4_mr::CbPx4ClientBehaviorBase::setTimeout ( std::chrono::milliseconds timeout)
inline

Definition at line 83 of file cb_px4_client_behavior_base.hpp.

83{ timeout_ = timeout; }
std::optional< std::chrono::milliseconds > timeout_

References timeout_.

◆ update()

void cl_px4_mr::CbPx4ClientBehaviorBase::update ( )
inlineoverridevirtual

Implements smacc2::ISmaccUpdatable.

Reimplemented in cl_px4_mr::CbSpiralPattern, and cl_px4_mr::CbYawRotate.

Definition at line 85 of file cb_px4_client_behavior_base.hpp.

86 {
87 if (!timeout_ || completed_)
88 {
89 return;
90 }
91
92 auto now = std::chrono::steady_clock::now();
93 if (!watchdogStart_)
94 {
95 watchdogStart_ = now;
96 return;
97 }
98
99 if (now - *watchdogStart_ > *timeout_)
100 {
101 RCLCPP_ERROR(
102 getLogger(), "[%s] Timed out after %ld ms without completing - posting failure",
103 getName().c_str(), static_cast<long>(timeout_->count()));
104 this->postPx4Failure();
105 }
106 }
std::optional< std::chrono::steady_clock::time_point > watchdogStart_
virtual rclcpp::Logger getLogger() const

References completed_, smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getName(), postPx4Failure(), timeout_, and watchdogStart_.

Referenced by cl_px4_mr::CbFigureEight::update(), cl_px4_mr::CbHoldPosition::update(), cl_px4_mr::CbOrbitLocation::update(), cl_px4_mr::CbSpiralPattern::update(), and cl_px4_mr::CbYawRotate::update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wireCompletionSignals()

virtual void cl_px4_mr::CbPx4ClientBehaviorBase::wireCompletionSignals ( )
inlineprotectedvirtual

Member Data Documentation

◆ completed_

std::atomic<bool> cl_px4_mr::CbPx4ClientBehaviorBase::completed_ {false}
private

Definition at line 137 of file cb_px4_client_behavior_base.hpp.

137{false};

Referenced by postPx4Failure(), postPx4Success(), and update().

◆ goalChecker_

◆ localPosition_

◆ offboardKeepAlive_

CpOffboardKeepAlive* cl_px4_mr::CbPx4ClientBehaviorBase::offboardKeepAlive_ = nullptr
protected

◆ timeout_

std::optional<std::chrono::milliseconds> cl_px4_mr::CbPx4ClientBehaviorBase::timeout_
private

Definition at line 138 of file cb_px4_client_behavior_base.hpp.

Referenced by setTimeout(), and update().

◆ trajectorySetpoint_

◆ vehicleCommand_

◆ vehicleStatus_

◆ watchdogStart_

std::optional<std::chrono::steady_clock::time_point> cl_px4_mr::CbPx4ClientBehaviorBase::watchdogStart_
private

Definition at line 139 of file cb_px4_client_behavior_base.hpp.

Referenced by update().


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