SMACC2
Loading...
Searching...
No Matches
cl_nav2z::CbRotateLookAt Class Reference

#include <cb_rotate_look_at.hpp>

Inheritance diagram for cl_nav2z::CbRotateLookAt:
Inheritance graph
Collaboration diagram for cl_nav2z::CbRotateLookAt:
Collaboration graph

Public Member Functions

 CbRotateLookAt ()
 
 CbRotateLookAt (const geometry_msgs::msg::PoseStamped &lookAtPose)
 
void onEntry () override
 
- Public Member Functions inherited from cl_nav2z::CbAbsoluteRotate
 CbAbsoluteRotate ()
 
 CbAbsoluteRotate (float absoluteGoalAngleDegree)
 
- Public Member Functions inherited from cl_nav2z::CbNav2ZClientBehaviorBase
 ~CbNav2ZClientBehaviorBase () override
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
- Public Member Functions inherited from smacc2::client_behavior_bases::CbActionClientBehaviorBase< nav2_msgs::action::NavigateToPose >
void onStateOrthogonalAllocation ()
 
virtual ~CbActionClientBehaviorBase ()
 
void onExit () override
 
- Public Member Functions inherited from smacc2::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
 SmaccAsyncClientBehavior ()=default
 
 ~SmaccAsyncClientBehavior () override
 
 SmaccAsyncClientBehavior (const SmaccAsyncClientBehavior &)=delete
 
SmaccAsyncClientBehavior & operator= (const SmaccAsyncClientBehavior &)=delete
 
 SmaccAsyncClientBehavior (SmaccAsyncClientBehavior &&)=delete
 
SmaccAsyncClientBehavior & operator= (SmaccAsyncClientBehavior &&)=delete
 
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 ()
 
 ISmaccClientBehavior (const ISmaccClientBehavior &)=delete
 
ISmaccClientBehavior & operator= (const ISmaccClientBehavior &)=delete
 
 ISmaccClientBehavior (ISmaccClientBehavior &&)=delete
 
ISmaccClientBehavior & operator= (ISmaccClientBehavior &&)=delete
 
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 (const std::string &name, SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 

Public Attributes

std::optional< geometry_msgs::msg::PoseStamped > lookAtPose_
 
- Public Attributes inherited from cl_nav2z::CbAbsoluteRotate
std::shared_ptr< tf2_ros::Buffer > listener
 
float absoluteGoalAngleDegree = 0
 
std::optional< SpinningPlanner > spinningPlanner
 

Additional Inherited Members

- Public Types inherited from smacc2::client_behavior_bases::CbActionClientBehaviorBase< nav2_msgs::action::NavigateToPose >
using Goal
 
using GoalHandle
 
using WrappedResult
 
using Feedback
 
using ActionClientComponent
 
- Protected Member Functions inherited from cl_nav2z::CbNav2ZClientBehaviorBase
virtual void onNavigationActionSuccess (const components::CpNav2ActionInterface::WrappedResult &)
 
virtual void onNavigationActionAbort (const components::CpNav2ActionInterface::WrappedResult &)
 
void onActionSuccess (const WrappedResult &result) override
 
void onActionAbort (const WrappedResult &result) override
 
- Protected Member Functions inherited from smacc2::client_behavior_bases::CbActionClientBehaviorBase< nav2_msgs::action::NavigateToPose >
bool sendGoal (Goal &goal)
 
bool trackGoal (std::shared_future< typename GoalHandle::SharedPtr > goalHandleFuture)
 
void cancelGoal ()
 
virtual void onActionSuccess (const WrappedResult &result)
 
virtual void onActionAbort (const WrappedResult &result)
 
virtual void onActionFeedback (const Feedback &)
 
void setActionClientName (std::string name)
 
- Protected Member Functions inherited from smacc2::SmaccAsyncClientBehavior
void postSuccessEvent ()
 
void postFailureEvent ()
 
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 ()
 
void postInitializationFailureEvent (const std::string &what)
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 
std::string getTraceStateName () const
 
std::string getTraceOrthogonalName () const
 
- Protected Attributes inherited from cl_nav2z::CbNav2ZClientBehaviorBase
components::CpNav2ActionInterface * nav2ActionInterface_ = nullptr
 
rclcpp_action::ResultCode navigationResult_ = rclcpp_action::ResultCode::UNKNOWN
 
- Protected Attributes inherited from smacc2::client_behavior_bases::CbActionClientBehaviorBase< nav2_msgs::action::NavigateToPose >
ActionClientComponent * actionClient_
 
std::string actionClientName_
 
rclcpp_action::ResultCode actionResult_
 
std::chrono::milliseconds goalResponseTimeout_
 

Detailed Description

Definition at line 30 of file cb_rotate_look_at.hpp.

Constructor & Destructor Documentation

◆ CbRotateLookAt() [1/2]

cl_nav2z::CbRotateLookAt::CbRotateLookAt ( )

Definition at line 32 of file cb_rotate_look_at.cpp.

32{}

◆ CbRotateLookAt() [2/2]

cl_nav2z::CbRotateLookAt::CbRotateLookAt ( const geometry_msgs::msg::PoseStamped & lookAtPose)

Definition at line 34 of file cb_rotate_look_at.cpp.

35: lookAtPose_(lookAtPose)
36{
37}
std::optional< geometry_msgs::msg::PoseStamped > lookAtPose_

Member Function Documentation

◆ onEntry()

void cl_nav2z::CbRotateLookAt::onEntry ( )
overridevirtual

Reimplemented from cl_nav2z::CbAbsoluteRotate.

Definition at line 39 of file cb_rotate_look_at.cpp.

40{
41 cl_nav2z::CpPose * pose = nullptr;
42 this->requiresComponent(pose, ComponentRequirement::HARD);
43
44 if (!pose->waitTransformUpdate(rclcpp::Rate(20), [this] { return this->isShutdownRequested(); }))
45 {
46 return;
47 }
48 auto position = pose->toPoseMsg().position;
49
50 if (lookAtPose_)
51 {
52 auto targetPosition = lookAtPose_->pose.position;
53 double yaw_degrees =
54 atan2(targetPosition.y - position.y, targetPosition.x - position.x) * 180.0 / M_PI;
55 this->absoluteGoalAngleDegree = static_cast<float>(yaw_degrees);
56 }
57
59}
geometry_msgs::msg::Pose toPoseMsg()
Definition cp_pose.hpp:60
bool waitTransformUpdate(rclcpp::Rate r=rclcpp::Rate(20), const std::function< bool()> &cancelled={})
Definition cp_pose.cpp:81
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)

References cl_nav2z::CbAbsoluteRotate::absoluteGoalAngleDegree, lookAtPose_, cl_nav2z::CbAbsoluteRotate::onEntry(), smacc2::ISmaccClientBehavior::requiresComponent(), cl_nav2z::CpPose::toPoseMsg(), and cl_nav2z::CpPose::waitTransformUpdate().

Here is the call graph for this function:

Member Data Documentation

◆ lookAtPose_

std::optional<geometry_msgs::msg::PoseStamped> cl_nav2z::CbRotateLookAt::lookAtPose_

Definition at line 33 of file cb_rotate_look_at.hpp.

Referenced by onEntry().


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