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

#include <cb_follow_waypoints.hpp>

Inheritance diagram for cl_px4_mr::CbFollowWaypoints:
Inheritance graph
Collaboration diagram for cl_px4_mr::CbFollowWaypoints:
Collaboration graph

Public Member Functions

 CbFollowWaypoints (std::vector< std::array< float, 4 > > waypoints, float xyTol=0.5f, float zTol=0.3f)
 
void onEntry () override
 
void wireCompletionSignals () override
 
void onExit () override
 
- Public Member Functions inherited from cl_px4_mr::CbPx4ClientBehaviorBase
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)
 
- Public Member Functions inherited from smacc2::ISmaccUpdatable
 ISmaccUpdatable ()
 
 ISmaccUpdatable (rclcpp::Duration duration)
 
void executeUpdate (rclcpp::Node::SharedPtr node)
 
void setUpdatePeriod (rclcpp::Duration duration)
 

Private Member Functions

void onGoalReachedCallback ()
 
void commandCurrentWaypoint ()
 

Private Attributes

std::vector< std::array< float, 4 > > waypoints_
 
float xyTol_
 
float zTol_
 
size_t currentIndex_ = 0
 

Additional Inherited Members

- Protected Member Functions inherited from cl_px4_mr::CbPx4ClientBehaviorBase
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 inherited from cl_px4_mr::CbPx4ClientBehaviorBase
CpVehicleCommandvehicleCommand_ = nullptr
 
CpVehicleStatusvehicleStatus_ = nullptr
 
CpTrajectorySetpointtrajectorySetpoint_ = nullptr
 
CpGoalCheckergoalChecker_ = nullptr
 
CpVehicleLocalPositionlocalPosition_ = nullptr
 
CpOffboardKeepAliveoffboardKeepAlive_ = nullptr
 

Detailed Description

Definition at line 30 of file cb_follow_waypoints.hpp.

Constructor & Destructor Documentation

◆ CbFollowWaypoints()

cl_px4_mr::CbFollowWaypoints::CbFollowWaypoints ( std::vector< std::array< float, 4 > > waypoints,
float xyTol = 0.5f,
float zTol = 0.3f )

Definition at line 22 of file cb_follow_waypoints.cpp.

24: waypoints_(std::move(waypoints)), xyTol_(xyTol), zTol_(zTol)
25{
26}
std::vector< std::array< float, 4 > > waypoints_

Member Function Documentation

◆ commandCurrentWaypoint()

void cl_px4_mr::CbFollowWaypoints::commandCurrentWaypoint ( )
private

Definition at line 45 of file cb_follow_waypoints.cpp.

46{
47 const auto & wp = waypoints_[currentIndex_];
48 float x = wp[0];
49 float y = wp[1];
50 float z = wp[2];
51 float yaw = wp[3];
52
53 RCLCPP_INFO(
54 getLogger(), "CbFollowWaypoints: commanding waypoint %zu/%zu [%.2f, %.2f, %.2f] yaw=%.2f",
55 currentIndex_ + 1, waypoints_.size(), x, y, z, yaw);
56
58 goalChecker_->setGoal(x, y, z, xyTol_, zTol_);
59}
void setGoal(float x, float y, float z, float xy_tolerance=0.5f, float z_tolerance=0.3f)
void setPositionNED(float x, float y, float z, float yaw=std::numeric_limits< float >::quiet_NaN())
virtual rclcpp::Logger getLogger() const

References currentIndex_, smacc2::ISmaccClientBehavior::getLogger(), cl_px4_mr::CbPx4ClientBehaviorBase::goalChecker_, cl_px4_mr::CpGoalChecker::setGoal(), cl_px4_mr::CpTrajectorySetpoint::setPositionNED(), cl_px4_mr::CbPx4ClientBehaviorBase::trajectorySetpoint_, waypoints_, xyTol_, and zTol_.

Referenced by onEntry(), and onGoalReachedCallback().

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

◆ onEntry()

void cl_px4_mr::CbFollowWaypoints::onEntry ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 28 of file cb_follow_waypoints.cpp.

29{
30 if (waypoints_.empty())
31 {
32 RCLCPP_WARN(getLogger(), "CbFollowWaypoints: no waypoints provided - posting success");
33 this->postPx4Success();
34 return;
35 }
36
37 RCLCPP_INFO(getLogger(), "CbFollowWaypoints: following %zu waypoints", waypoints_.size());
38
39 currentIndex_ = 0;
41}

References commandCurrentWaypoint(), currentIndex_, smacc2::ISmaccClientBehavior::getLogger(), cl_px4_mr::CbPx4ClientBehaviorBase::postPx4Success(), and waypoints_.

Here is the call graph for this function:

◆ onExit()

void cl_px4_mr::CbFollowWaypoints::onExit ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 43 of file cb_follow_waypoints.cpp.

References cl_px4_mr::CpGoalChecker::clearGoal(), and cl_px4_mr::CbPx4ClientBehaviorBase::goalChecker_.

Here is the call graph for this function:

◆ onGoalReachedCallback()

void cl_px4_mr::CbFollowWaypoints::onGoalReachedCallback ( )
private

Definition at line 61 of file cb_follow_waypoints.cpp.

62{
64
65 if (currentIndex_ >= waypoints_.size())
66 {
67 RCLCPP_INFO(
68 getLogger(), "CbFollowWaypoints: all %zu waypoints reached - posting success",
69 waypoints_.size());
70 this->postPx4Success();
71 }
72 else
73 {
75 }
76}

References commandCurrentWaypoint(), currentIndex_, smacc2::ISmaccClientBehavior::getLogger(), cl_px4_mr::CbPx4ClientBehaviorBase::postPx4Success(), and waypoints_.

Referenced by wireCompletionSignals().

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

◆ wireCompletionSignals()

void cl_px4_mr::CbFollowWaypoints::wireCompletionSignals ( )
overridevirtual

Reimplemented from cl_px4_mr::CbPx4ClientBehaviorBase.

Definition at line 78 of file cb_follow_waypoints.cpp.

79{
80 if (goalChecker_ != nullptr)
81 {
84 }
85 else
86 {
87 RCLCPP_WARN(
88 getLogger(), "CbFollowWaypoints: completion component missing, no completion signal wired");
89 }
90}
smacc2::SmaccSignal< void()> onGoalReached_
smacc2::SmaccSignalConnection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)

References smacc2::ISmaccStateMachine::createSignalConnection(), smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getStateMachine(), cl_px4_mr::CbPx4ClientBehaviorBase::goalChecker_, cl_px4_mr::CpGoalChecker::onGoalReached_, and onGoalReachedCallback().

Here is the call graph for this function:

Member Data Documentation

◆ currentIndex_

size_t cl_px4_mr::CbFollowWaypoints::currentIndex_ = 0
private

Definition at line 48 of file cb_follow_waypoints.hpp.

Referenced by commandCurrentWaypoint(), onEntry(), and onGoalReachedCallback().

◆ waypoints_

std::vector<std::array<float, 4> > cl_px4_mr::CbFollowWaypoints::waypoints_
private

Definition at line 45 of file cb_follow_waypoints.hpp.

Referenced by commandCurrentWaypoint(), onEntry(), and onGoalReachedCallback().

◆ xyTol_

float cl_px4_mr::CbFollowWaypoints::xyTol_
private

Definition at line 46 of file cb_follow_waypoints.hpp.

Referenced by commandCurrentWaypoint().

◆ zTol_

float cl_px4_mr::CbFollowWaypoints::zTol_
private

Definition at line 47 of file cb_follow_waypoints.hpp.

Referenced by commandCurrentWaypoint().


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