SMACC2
Public Member Functions | Public Attributes | List of all members
sm_autoware_avp::clients::ClAutoware Class Reference

#include <cl_autoware.hpp>

Inheritance diagram for sm_autoware_avp::clients::ClAutoware:
Inheritance graph
Collaboration diagram for sm_autoware_avp::clients::ClAutoware:
Collaboration graph

Public Member Functions

template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
void onInitialize () override
 
bool checkGoalReached ()
 
void onNdtPoseReceived (const geometry_msgs::msg::PoseWithCovarianceStamped &msg)
 
void publishGoalPose (const geometry_msgs::msg::PoseStamped &msg)
 
void publishInitialPoseEstimation (const geometry_msgs::msg::PoseWithCovarianceStamped &msg)
 
- Public Member Functions inherited from smacc2::ISmaccClient
 ISmaccClient ()
 
virtual ~ISmaccClient ()
 
virtual void onInitialize ()
 
virtual std::string getName () const
 
template<typename TComponent >
TComponent * getComponent ()
 
template<typename TComponent >
TComponent * getComponent (std::string name)
 
template<typename TComponent >
TComponent * getComponent (int index)
 
virtual smacc2::introspection::TypeInfo::Ptr getType ()
 
ISmaccStateMachinegetStateMachine ()
 
template<typename TSmaccSignal , typename T >
void connectSignal (TSmaccSignal &signal, void(T::*callback)(), T *object)
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
void getComponents (std::vector< std::shared_ptr< ISmaccComponent > > &components)
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 

Public Attributes

smacc2::components::CpTopicPublisher< geometry_msgs::msg::PoseWithCovarianceStamped > * cppubLocation_
 
smacc2::components::CpTopicPublisher< geometry_msgs::msg::PoseStamped > * cpppubGoalPose_
 
std::optional< geometry_msgs::msg::PoseWithCovarianceStamped > lastPose_
 
std::optional< geometry_msgs::msg::PoseStamped > lastGoal_
 
double goalToleranceMeters_ = 3.5
 
std::function< void(const geometry_msgs::msg::PoseWithCovarianceStamped &)> postEvAutoLocalized_
 
std::function< void()> postEvGoalReached_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccClient
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createNamedComponent (std::string name, TArgs... targs)
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger ()
 
- Protected Attributes inherited from smacc2::ISmaccClient
std::map< ComponentKey, std::shared_ptr< smacc2::ISmaccComponent > > components_
 

Detailed Description

Definition at line 49 of file cl_autoware.hpp.

Member Function Documentation

◆ checkGoalReached()

bool sm_autoware_avp::clients::ClAutoware::checkGoalReached ( )
inline

Definition at line 111 of file cl_autoware.hpp.

112 {
113 if (lastGoal_ && lastPose_)
114 {
115 auto & pos = this->lastPose_->pose.pose.position;
116 auto & goalpos = this->lastGoal_->pose.position;
117
118 double dx = pos.x - goalpos.x;
119 double dy = pos.y - goalpos.y;
120 double dz = pos.z - goalpos.z;
121
122 double dist = sqrt(dx * dx + dy * dy + dz * dz);
123
124 RCLCPP_INFO_STREAM_THROTTLE(getLogger(), *(getNode()->get_clock()),2000, "[" << getName() << "] goal linear error: " << dist);
125
126 if (dist < goalToleranceMeters_)
127 {
128 return true;
129 }
130 }
131
132 return false;
133 }
std::optional< geometry_msgs::msg::PoseStamped > lastGoal_
Definition: cl_autoware.hpp:57
std::optional< geometry_msgs::msg::PoseWithCovarianceStamped > lastPose_
Definition: cl_autoware.hpp:56
rclcpp::Node::SharedPtr getNode()
Definition: client.cpp:60
virtual std::string getName() const
Definition: client.cpp:42
rclcpp::Logger getLogger()

References smacc2::ISmaccClient::getLogger(), smacc2::ISmaccClient::getName(), smacc2::ISmaccClient::getNode(), goalToleranceMeters_, lastGoal_, and lastPose_.

Referenced by onNdtPoseReceived().

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

◆ onInitialize()

void sm_autoware_avp::clients::ClAutoware::onInitialize ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClient.

Definition at line 80 of file cl_autoware.hpp.

81 {
82 /*
83 auto cppubLocation = client->createNamedComponent<
84 smacc2::components::CpTopicPublisher<geometry_msgs::msg::PoseStamped>>(
85 "initialPoseEstimation", "/localization/initialpose");
86
87 auto cpppubGoalPose = client->createNamedComponent<
88 smacc2::components::CpTopicPublisher<geometry_msgs::msg::PoseStamped>>(
89 "goalPose", "planning/goal_pose");
90 */
91
93 this->getComponent<smacc2::components::CpTopicPublisher<geometry_msgs::msg::PoseWithCovarianceStamped>>(
94 "initialPoseEstimation");
95
97 this->getComponent<smacc2::components::CpTopicPublisher<geometry_msgs::msg::PoseStamped>>(
98 "goalPose");
99
100 // auto subscriberNdtPose = client->createNamedComponent<
101 // smacc2::components::CpTopicSubscriber<geometry_msgs::msg::PoseWithCovarianceStamped>>(
102 // "ndtPose", "/localization/ndt_pose");
103
104 auto subscriberNdtPose = this->getComponent<
106 "ndtPose");
107
108 subscriberNdtPose->onMessageReceived(&ClAutoware::onNdtPoseReceived, this);
109 }
smacc2::components::CpTopicPublisher< geometry_msgs::msg::PoseWithCovarianceStamped > * cppubLocation_
Definition: cl_autoware.hpp:52
smacc2::components::CpTopicPublisher< geometry_msgs::msg::PoseStamped > * cpppubGoalPose_
Definition: cl_autoware.hpp:54
void onNdtPoseReceived(const geometry_msgs::msg::PoseWithCovarianceStamped &msg)
TComponent * getComponent()
boost::signals2::connection onMessageReceived(void(T::*callback)(const MessageType &), T *object)

References cpppubGoalPose_, cppubLocation_, smacc2::ISmaccClient::getComponent(), smacc2::components::CpTopicSubscriber< MessageType >::onMessageReceived(), and onNdtPoseReceived().

Here is the call graph for this function:

◆ onNdtPoseReceived()

void sm_autoware_avp::clients::ClAutoware::onNdtPoseReceived ( const geometry_msgs::msg::PoseWithCovarianceStamped &  msg)
inline

Definition at line 135 of file cl_autoware.hpp.

136 {
137 lastPose_ = msg;
138 this->postEvAutoLocalized_(msg);
139
140 if(checkGoalReached())
141 {
142 this->postEvGoalReached_();
143 }
144 }
std::function< void(const geometry_msgs::msg::PoseWithCovarianceStamped &)> postEvAutoLocalized_
Definition: cl_autoware.hpp:61
std::function< void()> postEvGoalReached_
Definition: cl_autoware.hpp:62

References checkGoalReached(), lastPose_, postEvAutoLocalized_, and postEvGoalReached_.

Referenced by onInitialize().

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

◆ onOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void sm_autoware_avp::clients::ClAutoware::onOrthogonalAllocation ( )
inline

Definition at line 65 of file cl_autoware.hpp.

66 {
67 this->postEvAutoLocalized_ = [this](const geometry_msgs::msg::PoseWithCovarianceStamped & msg)
68 {
69 auto ev = new EvAutoLocalized<TSourceObject, TOrthogonal>();
70 ev->location = msg;
71 this->postEvent(ev);
72 };
73
74 this->postEvGoalReached_ = [this]()
75 {
76 this->postEvent<EvGoalReached<TSourceObject, TOrthogonal>>();
77 };
78 }

References smacc2::ISmaccClient::postEvent().

Here is the call graph for this function:

◆ publishGoalPose()

void sm_autoware_avp::clients::ClAutoware::publishGoalPose ( const geometry_msgs::msg::PoseStamped &  msg)
inline

Definition at line 146 of file cl_autoware.hpp.

147 {
148 lastGoal_ = msg;
149 this->cpppubGoalPose_->publish(msg);
150 }
void publish(const MessageType &msg)

References lastGoal_, and smacc2::components::CpTopicPublisher< MessageType >::publish().

Referenced by sm_autoware_avp::clients::autoware_client::CbNavigateGlobalPosition::onEntry().

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

◆ publishInitialPoseEstimation()

void sm_autoware_avp::clients::ClAutoware::publishInitialPoseEstimation ( const geometry_msgs::msg::PoseWithCovarianceStamped &  msg)
inline

Definition at line 152 of file cl_autoware.hpp.

153 {
154 this->cppubLocation_->publish(msg);
155 }

References smacc2::components::CpTopicPublisher< MessageType >::publish().

Referenced by sm_autoware_avp::clients::autoware_client::CbSetupInitialPoseEstimation::onEntry().

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

Member Data Documentation

◆ cpppubGoalPose_

smacc2::components::CpTopicPublisher<geometry_msgs::msg::PoseStamped>* sm_autoware_avp::clients::ClAutoware::cpppubGoalPose_

Definition at line 54 of file cl_autoware.hpp.

Referenced by onInitialize().

◆ cppubLocation_

smacc2::components::CpTopicPublisher<geometry_msgs::msg::PoseWithCovarianceStamped>* sm_autoware_avp::clients::ClAutoware::cppubLocation_

Definition at line 52 of file cl_autoware.hpp.

Referenced by onInitialize().

◆ goalToleranceMeters_

double sm_autoware_avp::clients::ClAutoware::goalToleranceMeters_ = 3.5

Definition at line 59 of file cl_autoware.hpp.

Referenced by checkGoalReached().

◆ lastGoal_

std::optional<geometry_msgs::msg::PoseStamped> sm_autoware_avp::clients::ClAutoware::lastGoal_

Definition at line 57 of file cl_autoware.hpp.

Referenced by checkGoalReached(), and publishGoalPose().

◆ lastPose_

std::optional<geometry_msgs::msg::PoseWithCovarianceStamped> sm_autoware_avp::clients::ClAutoware::lastPose_

Definition at line 56 of file cl_autoware.hpp.

Referenced by checkGoalReached(), and onNdtPoseReceived().

◆ postEvAutoLocalized_

std::function<void(const geometry_msgs::msg::PoseWithCovarianceStamped &)> sm_autoware_avp::clients::ClAutoware::postEvAutoLocalized_

Definition at line 61 of file cl_autoware.hpp.

Referenced by onNdtPoseReceived().

◆ postEvGoalReached_

std::function<void()> sm_autoware_avp::clients::ClAutoware::postEvGoalReached_

Definition at line 62 of file cl_autoware.hpp.

Referenced by onNdtPoseReceived().


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