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 onExit () 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)
 

Private Member Functions

void onGoalReachedCallback ()
 
void commandCurrentWaypoint ()
 

Private Attributes

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

Additional Inherited Members

- 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
 

Detailed Description

Definition at line 28 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 51 of file cb_follow_waypoints.cpp.

52{
53 const auto & wp = waypoints_[currentIndex_];
54 float x = wp[0];
55 float y = wp[1];
56 float z = wp[2];
57 float yaw = wp[3];
58
59 RCLCPP_INFO(
60 getLogger(), "CbFollowWaypoints: commanding waypoint %zu/%zu [%.2f, %.2f, %.2f] yaw=%.2f",
61 currentIndex_ + 1, waypoints_.size(), x, y, z, yaw);
62
64 goalChecker_->setGoal(x, y, z, xyTol_, zTol_);
65}
CpTrajectorySetpoint * trajectorySetpoint_
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(), goalChecker_, cl_px4_mr::CpGoalChecker::setGoal(), cl_px4_mr::CpTrajectorySetpoint::setPositionNED(), 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{
32
35
36 if (waypoints_.empty())
37 {
38 RCLCPP_WARN(getLogger(), "CbFollowWaypoints: no waypoints provided - posting success");
39 this->postSuccessEvent();
40 return;
41 }
42
43 RCLCPP_INFO(getLogger(), "CbFollowWaypoints: following %zu waypoints", waypoints_.size());
44
45 currentIndex_ = 0;
47}
smacc2::SmaccSignal< void()> onGoalReached_
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
smacc2::SmaccSignalConnection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)

References commandCurrentWaypoint(), smacc2::ISmaccStateMachine::createSignalConnection(), currentIndex_, smacc2::ISmaccClientBehavior::getLogger(), smacc2::ISmaccClientBehavior::getStateMachine(), goalChecker_, cl_px4_mr::CpGoalChecker::onGoalReached_, onGoalReachedCallback(), smacc2::SmaccAsyncClientBehavior::postSuccessEvent(), smacc2::ISmaccClientBehavior::requiresComponent(), trajectorySetpoint_, 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 49 of file cb_follow_waypoints.cpp.

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

Here is the call graph for this function:

◆ onGoalReachedCallback()

void cl_px4_mr::CbFollowWaypoints::onGoalReachedCallback ( )
private

Definition at line 67 of file cb_follow_waypoints.cpp.

68{
70
71 if (currentIndex_ >= waypoints_.size())
72 {
73 RCLCPP_INFO(
74 getLogger(), "CbFollowWaypoints: all %zu waypoints reached - posting success",
75 waypoints_.size());
76 this->postSuccessEvent();
77 }
78 else
79 {
81 }
82}

References commandCurrentWaypoint(), currentIndex_, smacc2::ISmaccClientBehavior::getLogger(), smacc2::SmaccAsyncClientBehavior::postSuccessEvent(), and waypoints_.

Referenced by onEntry().

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

Member Data Documentation

◆ currentIndex_

size_t cl_px4_mr::CbFollowWaypoints::currentIndex_ = 0
private

Definition at line 44 of file cb_follow_waypoints.hpp.

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

◆ goalChecker_

CpGoalChecker* cl_px4_mr::CbFollowWaypoints::goalChecker_ = nullptr
private

Definition at line 47 of file cb_follow_waypoints.hpp.

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

◆ trajectorySetpoint_

CpTrajectorySetpoint* cl_px4_mr::CbFollowWaypoints::trajectorySetpoint_ = nullptr
private

Definition at line 46 of file cb_follow_waypoints.hpp.

Referenced by commandCurrentWaypoint(), and onEntry().

◆ waypoints_

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

Definition at line 41 of file cb_follow_waypoints.hpp.

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

◆ xyTol_

float cl_px4_mr::CbFollowWaypoints::xyTol_
private

Definition at line 42 of file cb_follow_waypoints.hpp.

Referenced by commandCurrentWaypoint().

◆ zTol_

float cl_px4_mr::CbFollowWaypoints::zTol_
private

Definition at line 43 of file cb_follow_waypoints.hpp.

Referenced by commandCurrentWaypoint().


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