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)
 
bool hasTimeout () const
 
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 ()
 
ISmaccStateMachine * getStateMachine ()
 
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 ()
 
ISmaccState * getCurrentState ()
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 
- Protected Member Functions inherited from smacc2::ISmaccUpdatable

Protected Attributes

CpVehicleCommand * vehicleCommand_ = nullptr
 
CpVehicleStatus * vehicleStatus_ = nullptr
 
CpTrajectorySetpoint * trajectorySetpoint_ = nullptr
 
CpGoalChecker * goalChecker_ = nullptr
 
CpVehicleLocalPosition * localPosition_ = nullptr
 
CpOffboardKeepAlive * offboardKeepAlive_ = nullptr
 

Private Attributes

std::atomic< bool > completed_ {false}
 
std::atomic< int64_t > timeoutMs_ {0}
 
std::optional< std::chrono::steady_clock::time_point > watchdogStart_
 

Detailed Description

Definition at line 60 of file cb_px4_client_behavior_base.hpp.

Constructor & Destructor Documentation

◆ ~CbPx4ClientBehaviorBase()

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

Definition at line 80 of file cb_px4_client_behavior_base.hpp.

80{}

Member Function Documentation

◆ hasTimeout()

bool cl_px4_mr::CbPx4ClientBehaviorBase::hasTimeout ( ) const
inline

Definition at line 90 of file cb_px4_client_behavior_base.hpp.

90{ return timeoutMs_.load() > 0; }

References timeoutMs_.

Referenced by cl_px4_mr::CbPx4PathFollowerBase::onEntry().

Here is the caller graph for this function:

◆ onStateOrthogonalAllocation()

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

Definition at line 65 of file cb_px4_client_behavior_base.hpp.

66 {
67 // shared component set; SOFT because each behavior uses a subset
74
76
78 }
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(), and cl_px4_mr::CbLoadKmlMission::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

◆ postPx4Success()

◆ setTimeout()

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

Definition at line 87 of file cb_px4_client_behavior_base.hpp.

87{ timeoutMs_ = timeout.count(); }

References timeoutMs_.

Referenced by cl_px4_mr::CbPx4PathFollowerBase::onEntry().

Here is the caller graph for this function:

◆ update()

void cl_px4_mr::CbPx4ClientBehaviorBase::update ( )
inlineoverridevirtual

Implements smacc2::ISmaccUpdatable.

Reimplemented in cl_px4_mr::CbPx4PathFollowerBase, cl_px4_mr::CbSineAltitudeCruise, cl_px4_mr::CbSpiralPattern, cl_px4_mr::CbYawRotate, and cl_px4_mr::CbYawScan.

Definition at line 92 of file cb_px4_client_behavior_base.hpp.

93 {
94 const int64_t timeoutMs = timeoutMs_.load();
95 if (timeoutMs <= 0 || completed_)
96 {
97 return;
98 }
99
100 auto now = std::chrono::steady_clock::now();
101 if (!watchdogStart_)
102 {
103 watchdogStart_ = now;
104 return;
105 }
106
107 if (now - *watchdogStart_ > std::chrono::milliseconds(timeoutMs))
108 {
109 RCLCPP_ERROR(
110 getLogger(), "[%s] Timed out after %ld ms without completing - posting failure",
111 getName().c_str(), static_cast<long>(timeoutMs));
112 this->postPx4Failure();
113 }
114 }
std::optional< std::chrono::steady_clock::time_point > watchdogStart_
virtual rclcpp::Logger getLogger() const

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

Referenced by cl_px4_mr::CbFigureEight::update(), cl_px4_mr::CbHoldPosition::update(), cl_px4_mr::CbOrbitLocation::update(), cl_px4_mr::CbPx4PathFollowerBase::update(), cl_px4_mr::CbSineAltitudeCruise::update(), cl_px4_mr::CbSpiralPattern::update(), cl_px4_mr::CbYawRotate::update(), and cl_px4_mr::CbYawScan::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 145 of file cb_px4_client_behavior_base.hpp.

145{false};

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

◆ goalChecker_

◆ localPosition_

◆ offboardKeepAlive_

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

◆ timeoutMs_

std::atomic<int64_t> cl_px4_mr::CbPx4ClientBehaviorBase::timeoutMs_ {0}
private

Definition at line 146 of file cb_px4_client_behavior_base.hpp.

146{0}; // 0 = watchdog disabled

Referenced by hasTimeout(), setTimeout(), and update().

◆ trajectorySetpoint_

◆ vehicleCommand_

◆ vehicleStatus_

◆ watchdogStart_

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

Definition at line 147 of file cb_px4_client_behavior_base.hpp.

Referenced by update().


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