SMACC2
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
smacc2::client_bases::SmaccActionClientBase< ActionType > Class Template Reference

#include <smacc_action_client_base.hpp>

Inheritance diagram for smacc2::client_bases::SmaccActionClientBase< ActionType >:
Inheritance graph
Collaboration diagram for smacc2::client_bases::SmaccActionClientBase< ActionType >:
Collaboration graph

Public Types

typedef rclcpp_action::Client< ActionType > ActionClient
 
using Goal = typename ActionClient::Goal
 
using Feedback = typename ActionClient::Feedback
 
using GoalHandle = rclcpp_action::ClientGoalHandle< ActionType >
 
typedef GoalHandle::WrappedResult WrappedResult
 
using SendGoalOptions = typename ActionClient::SendGoalOptions
 
using GoalResponseCallback = std::function< void(std::shared_future< typename GoalHandle::SharedPtr >)>
 
using FeedbackCallback = typename GoalHandle::FeedbackCallback
 
using ResultCallback = typename GoalHandle::ResultCallback
 
using CancelRequest = typename ActionType::Impl::CancelGoalService::Request
 
using CancelResponse = typename ActionType::Impl::CancelGoalService::Response
 
using CancelCallback = std::function< void(typename CancelResponse::SharedPtr)>
 

Public Member Functions

 SmaccActionClientBase (std::string actionServerName)
 
 SmaccActionClientBase ()
 
virtual ~SmaccActionClientBase ()
 
virtual std::shared_ptr< rclcpp_action::ClientBase > getClientBase () override
 
void onInitialize () override
 
template<typename EvType >
void postResultEvent (WrappedResult &)
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename T >
boost::signals2::connection onSucceeded (void(T::*callback)(WrappedResult &), T *object)
 
template<typename T >
boost::signals2::connection onSucceeded (std::function< void(WrappedResult &)> callback)
 
template<typename T >
boost::signals2::connection onAborted (void(T::*callback)(WrappedResult &), T *object)
 
template<typename T >
boost::signals2::connection onAborted (std::function< void(WrappedResult &)> callback)
 
template<typename T >
boost::signals2::connection onCancelled (void(T::*callback)(WrappedResult &), T *object)
 
template<typename T >
boost::signals2::connection onCancelled (std::function< void(WrappedResult &)> callback)
 
virtual bool cancelGoal () override
 
std::shared_future< typename GoalHandle::SharedPtr > sendGoal (Goal &goal)
 
- Public Member Functions inherited from smacc2::client_bases::ISmaccActionClient
 ISmaccActionClient ()
 
virtual ~ISmaccActionClient ()
 
std::string getNamespace () const
 
virtual bool cancelGoal ()=0
 
virtual std::shared_ptr< rclcpp_action::ClientBase > getClientBase ()=0
 
virtual std::string getName () const
 
- 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 ()
 

Static Public Member Functions

static std::string getEventLabel ()
 

Public Attributes

std::string action_endpoint_
 
std::optional< std::shared_future< typename GoalHandle::SharedPtr > > lastRequest_
 
GoalHandle::SharedPtr goalHandle_
 
smacc2::SmaccSignal< void(const WrappedResult &)> onSucceeded_
 
smacc2::SmaccSignal< void(const WrappedResult &)> onAborted_
 
smacc2::SmaccSignal< void(const WrappedResult &)> onCancelled_
 
std::function< void(WrappedResult)> postSuccessEvent
 
std::function< void(WrappedResult)> postAbortedEvent
 
std::function< void(WrappedResult)> postCancelledEvent
 
std::function< void(const Feedback &)> postFeedbackEvent
 
ResultCallback done_cb
 
FeedbackCallback feedback_cb
 

Protected Member Functions

void onFeedback (typename GoalHandle::SharedPtr, const std::shared_ptr< const Feedback > feedback_msg)
 
void onResult (const WrappedResult &result_msg)
 
- 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

ActionClient::SharedPtr client_
 
- Protected Attributes inherited from smacc2::client_bases::ISmaccActionClient
std::string name_
 
- Protected Attributes inherited from smacc2::ISmaccClient
std::map< ComponentKey, std::shared_ptr< smacc2::ISmaccComponent > > components_
 

Detailed Description

template<typename ActionType>
class smacc2::client_bases::SmaccActionClientBase< ActionType >

Definition at line 37 of file smacc_action_client_base.hpp.

Member Typedef Documentation

◆ ActionClient

template<typename ActionType >
typedef rclcpp_action::Client<ActionType> smacc2::client_bases::SmaccActionClientBase< ActionType >::ActionClient

Definition at line 42 of file smacc_action_client_base.hpp.

◆ CancelCallback

template<typename ActionType >
using smacc2::client_bases::SmaccActionClientBase< ActionType >::CancelCallback = std::function<void(typename CancelResponse::SharedPtr)>

Definition at line 61 of file smacc_action_client_base.hpp.

◆ CancelRequest

template<typename ActionType >
using smacc2::client_bases::SmaccActionClientBase< ActionType >::CancelRequest = typename ActionType::Impl::CancelGoalService::Request

Definition at line 59 of file smacc_action_client_base.hpp.

◆ CancelResponse

template<typename ActionType >
using smacc2::client_bases::SmaccActionClientBase< ActionType >::CancelResponse = typename ActionType::Impl::CancelGoalService::Response

Definition at line 60 of file smacc_action_client_base.hpp.

◆ Feedback

template<typename ActionType >
using smacc2::client_bases::SmaccActionClientBase< ActionType >::Feedback = typename ActionClient::Feedback

Definition at line 50 of file smacc_action_client_base.hpp.

◆ FeedbackCallback

template<typename ActionType >
using smacc2::client_bases::SmaccActionClientBase< ActionType >::FeedbackCallback = typename GoalHandle::FeedbackCallback

Definition at line 57 of file smacc_action_client_base.hpp.

◆ Goal

template<typename ActionType >
using smacc2::client_bases::SmaccActionClientBase< ActionType >::Goal = typename ActionClient::Goal

Definition at line 49 of file smacc_action_client_base.hpp.

◆ GoalHandle

template<typename ActionType >
using smacc2::client_bases::SmaccActionClientBase< ActionType >::GoalHandle = rclcpp_action::ClientGoalHandle<ActionType>

Definition at line 51 of file smacc_action_client_base.hpp.

◆ GoalResponseCallback

template<typename ActionType >
using smacc2::client_bases::SmaccActionClientBase< ActionType >::GoalResponseCallback = std::function<void(std::shared_future<typename GoalHandle::SharedPtr>)>

Definition at line 55 of file smacc_action_client_base.hpp.

◆ ResultCallback

template<typename ActionType >
using smacc2::client_bases::SmaccActionClientBase< ActionType >::ResultCallback = typename GoalHandle::ResultCallback

Definition at line 58 of file smacc_action_client_base.hpp.

◆ SendGoalOptions

template<typename ActionType >
using smacc2::client_bases::SmaccActionClientBase< ActionType >::SendGoalOptions = typename ActionClient::SendGoalOptions

Definition at line 54 of file smacc_action_client_base.hpp.

◆ WrappedResult

template<typename ActionType >
typedef GoalHandle::WrappedResult smacc2::client_bases::SmaccActionClientBase< ActionType >::WrappedResult

Definition at line 52 of file smacc_action_client_base.hpp.

Constructor & Destructor Documentation

◆ SmaccActionClientBase() [1/2]

template<typename ActionType >
smacc2::client_bases::SmaccActionClientBase< ActionType >::SmaccActionClientBase ( std::string  actionServerName)
inline

◆ SmaccActionClientBase() [2/2]

template<typename ActionType >
smacc2::client_bases::SmaccActionClientBase< ActionType >::SmaccActionClientBase ( )
inline

◆ ~SmaccActionClientBase()

template<typename ActionType >
virtual smacc2::client_bases::SmaccActionClientBase< ActionType >::~SmaccActionClientBase ( )
inlinevirtual

Definition at line 71 of file smacc_action_client_base.hpp.

71{}

Member Function Documentation

◆ cancelGoal()

template<typename ActionType >
virtual bool smacc2::client_bases::SmaccActionClientBase< ActionType >::cancelGoal ( )
inlineoverridevirtual

Implements smacc2::client_bases::ISmaccActionClient.

Definition at line 214 of file smacc_action_client_base.hpp.

215 {
216 if (lastRequest_ && lastRequest_->valid())
217 {
218 rclcpp::spin_until_future_complete(getNode(), *lastRequest_);
219 auto req = lastRequest_->get();
220 RCLCPP_INFO_STREAM(
221 getLogger(), "[" << getName() << "] Cancelling goal. req id: "
222 << rclcpp_action::to_string(req->get_goal_id()));
223 auto cancelresult = client_->async_cancel_goal(req);
224
225 // wait actively
226 rclcpp::spin_until_future_complete(getNode(), cancelresult);
227 //lastRequest_.reset();
228 return true;
229 }
230 else
231 {
232 RCLCPP_ERROR(
233 getLogger(), "%s [at %s]: not connected with actionserver, skipping cancel goal ...",
234 getName().c_str(), getNamespace().c_str());
235 return false;
236 }
237 }
rclcpp::Node::SharedPtr getNode()
Definition: client.cpp:60
rclcpp::Logger getLogger()
std::optional< std::shared_future< typename GoalHandle::SharedPtr > > lastRequest_

References smacc2::client_bases::SmaccActionClientBase< ActionType >::client_, smacc2::ISmaccClient::getLogger(), smacc2::client_bases::ISmaccActionClient::getName(), smacc2::client_bases::ISmaccActionClient::getNamespace(), smacc2::ISmaccClient::getNode(), and smacc2::client_bases::SmaccActionClientBase< ActionType >::lastRequest_.

Here is the call graph for this function:

◆ getClientBase()

template<typename ActionType >
virtual std::shared_ptr< rclcpp_action::ClientBase > smacc2::client_bases::SmaccActionClientBase< ActionType >::getClientBase ( )
inlineoverridevirtual

◆ getEventLabel()

template<typename ActionType >
static std::string smacc2::client_bases::SmaccActionClientBase< ActionType >::getEventLabel ( )
inlinestatic

Definition at line 85 of file smacc_action_client_base.hpp.

86 {
87 auto type = TypeInfo::getTypeInfoFromType<ActionType>();
88 return type->getNonTemplatedTypeName();
89 }

References generate_debs::type.

◆ onAborted() [1/2]

template<typename ActionType >
template<typename T >
boost::signals2::connection smacc2::client_bases::SmaccActionClientBase< ActionType >::onAborted ( std::function< void(WrappedResult &)>  callback)
inline

Definition at line 171 of file smacc_action_client_base.hpp.

172 {
174 }
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
smacc2::SmaccSignal< void(const WrappedResult &)> onAborted_
void callback(const image_tools::ROSCvMatContainer &img)

References callback(), smacc2::ISmaccStateMachine::createSignalConnection(), and smacc2::ISmaccClient::getStateMachine().

Here is the call graph for this function:

◆ onAborted() [2/2]

template<typename ActionType >
template<typename T >
boost::signals2::connection smacc2::client_bases::SmaccActionClientBase< ActionType >::onAborted ( void(T::*)(WrappedResult &)  callback,
T object 
)
inline

Definition at line 165 of file smacc_action_client_base.hpp.

166 {
168 }

References callback(), smacc2::ISmaccStateMachine::createSignalConnection(), and smacc2::ISmaccClient::getStateMachine().

Referenced by cl_nav2z::CbNav2ZClientBehaviorBase::onOrthogonalAllocation(), and cl_nav2z::WaypointNavigator::sendNextGoal().

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

◆ onCancelled() [1/2]

template<typename ActionType >
template<typename T >
boost::signals2::connection smacc2::client_bases::SmaccActionClientBase< ActionType >::onCancelled ( std::function< void(WrappedResult &)>  callback)
inline

Definition at line 183 of file smacc_action_client_base.hpp.

184 {
186 }
smacc2::SmaccSignal< void(const WrappedResult &)> onCancelled_

References callback(), smacc2::ISmaccStateMachine::createSignalConnection(), and smacc2::ISmaccClient::getStateMachine().

Here is the call graph for this function:

◆ onCancelled() [2/2]

template<typename ActionType >
template<typename T >
boost::signals2::connection smacc2::client_bases::SmaccActionClientBase< ActionType >::onCancelled ( void(T::*)(WrappedResult &)  callback,
T object 
)
inline

Definition at line 177 of file smacc_action_client_base.hpp.

178 {
180 }

References callback(), smacc2::ISmaccStateMachine::createSignalConnection(), and smacc2::ISmaccClient::getStateMachine().

Referenced by cl_nav2z::CbNav2ZClientBehaviorBase::onOrthogonalAllocation(), and cl_nav2z::WaypointNavigator::sendNextGoal().

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

◆ onFeedback()

template<typename ActionType >
void smacc2::client_bases::SmaccActionClientBase< ActionType >::onFeedback ( typename GoalHandle::SharedPtr  ,
const std::shared_ptr< const Feedback feedback_msg 
)
inlineprotected

Definition at line 342 of file smacc_action_client_base.hpp.

345 {
346 postFeedbackEvent(*feedback_msg);
347 }
std::function< void(const Feedback &)> postFeedbackEvent

References smacc2::client_bases::SmaccActionClientBase< ActionType >::postFeedbackEvent.

Referenced by smacc2::client_bases::SmaccActionClientBase< ActionType >::onOrthogonalAllocation().

Here is the caller graph for this function:

◆ onInitialize()

template<typename ActionType >
void smacc2::client_bases::SmaccActionClientBase< ActionType >::onInitialize ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClient.

Definition at line 75 of file smacc_action_client_base.hpp.

76 {
77 if (name_ == "") name_ = smacc2::demangleSymbol(typeid(*this).name());
78 this->client_ = rclcpp_action::create_client<ActionType>(getNode(), action_endpoint_);
79 // RCLCPP_INFO_STREAM(
80 // this->getLogger(),
81 // "Waiting for action server '" << name_ << "' of type: " << demangledTypeName<ActionType>());
82 //client_->wait_for_action_server();
83 }
std::string demangleSymbol(const std::string &name)

References smacc2::client_bases::SmaccActionClientBase< ActionType >::action_endpoint_, smacc2::client_bases::SmaccActionClientBase< ActionType >::client_, smacc2::introspection::demangleSymbol(), smacc2::ISmaccClient::getNode(), and smacc2::client_bases::ISmaccActionClient::name_.

Here is the call graph for this function:

◆ onOrthogonalAllocation()

template<typename ActionType >
template<typename TOrthogonal , typename TSourceObject >
void smacc2::client_bases::SmaccActionClientBase< ActionType >::onOrthogonalAllocation ( )
inline

Definition at line 125 of file smacc_action_client_base.hpp.

126 {
127 // we create here all the event factory functions capturing the TOrthogonal
128 postSuccessEvent = [this](auto msg) {
129 this->postResultEvent<EvActionSucceeded<TSourceObject, TOrthogonal>>(msg);
130 };
131 postAbortedEvent = [this](auto msg) {
132 this->postResultEvent<EvActionAborted<TSourceObject, TOrthogonal>>(msg);
133 };
134
135 postCancelledEvent = [this](auto msg) {
136 this->postResultEvent<EvActionCancelled<TSourceObject, TOrthogonal>>(msg);
137 };
138 postFeedbackEvent = [this](auto msg) {
139 auto actionFeedbackEvent = new EvActionFeedback<Feedback, TOrthogonal>();
140 actionFeedbackEvent->client = this;
141 actionFeedbackEvent->feedbackMessage = msg;
142 this->postEvent(actionFeedbackEvent);
143 RCLCPP_DEBUG(getLogger(), "[%s] FEEDBACK EVENT", demangleType(typeid(*this)).c_str());
144 };
145
146 done_cb = [this](auto r) { this->onResult(r); };
147 // done_cb = boost::bind(&SmaccActionClientBase<ActionType>::onResult, this, _1, _2);
148 // active_cb;
149 feedback_cb = [this](auto client, auto feedback) { this->onFeedback(client, feedback); };
150 }
void onFeedback(typename GoalHandle::SharedPtr, const std::shared_ptr< const Feedback > feedback_msg)
std::function< void(WrappedResult)> postCancelledEvent
std::function< void(WrappedResult)> postSuccessEvent
std::function< void(WrappedResult)> postAbortedEvent
void onResult(const WrappedResult &result_msg)
std::string demangleType(const std::type_info *tinfo)

References smacc2::introspection::demangleType(), smacc2::client_bases::SmaccActionClientBase< ActionType >::done_cb, smacc2::client_bases::SmaccActionClientBase< ActionType >::feedback_cb, smacc2::ISmaccClient::getLogger(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onFeedback(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onResult(), smacc2::client_bases::SmaccActionClientBase< ActionType >::postAbortedEvent, smacc2::client_bases::SmaccActionClientBase< ActionType >::postCancelledEvent, smacc2::ISmaccClient::postEvent(), smacc2::client_bases::SmaccActionClientBase< ActionType >::postFeedbackEvent, and smacc2::client_bases::SmaccActionClientBase< ActionType >::postSuccessEvent.

Here is the call graph for this function:

◆ onResult()

template<typename ActionType >
void smacc2::client_bases::SmaccActionClientBase< ActionType >::onResult ( const WrappedResult result_msg)
inlineprotected

Definition at line 349 of file smacc_action_client_base.hpp.

350 {
351 // auto *actionResultEvent = new EvActionResult<TDerived>();
352 // actionResultEvent->client = this;
353 // actionResultEvent->resultMessage = *result_msg;
354
355 // const auto &resultType = this->getState();
356 const auto & resultType = result_msg.code;
357
358 RCLCPP_INFO_STREAM(
359 getLogger(), "[" << this->getName() << "] request result of request ["
360 << rclcpp_action::to_string(result_msg.goal_id) << "]: " << (int)resultType);
361
362 if (resultType == rclcpp_action::ResultCode::SUCCEEDED)
363 {
364 RCLCPP_INFO(getLogger(), "[%s] request result: Success", this->getName().c_str());
365 onSucceeded_(result_msg);
366 postSuccessEvent(result_msg);
367 }
368 else if (resultType == rclcpp_action::ResultCode::ABORTED)
369 {
370 RCLCPP_INFO(getLogger(), "[%s] request result: Aborted", this->getName().c_str());
371 onAborted_(result_msg);
372 postAbortedEvent(result_msg);
373 }
374 else if (resultType == rclcpp_action::ResultCode::CANCELED)
375 {
376 RCLCPP_INFO(getLogger(), "[%s] request result: Cancelled", this->getName().c_str());
377 onCancelled_(result_msg);
378 postCancelledEvent(result_msg);
379 }
380 /*
381 else if (resultType == actionlib::SimpleClientGoalState::REJECTED)
382 {
383 RCLCPP_INFO(getLogger(),"[%s] request result: Rejected", this->getName().c_str());
384 onRejected_(result_msg);
385 postRejectedEvent(result_msg);
386 }
387 else if (resultType == actionlib::SimpleClientGoalState::PREEMPTED)
388 {
389 RCLCPP_INFO(getLogger(),"[%s] request result: Preempted", this->getName().c_str());
390 onPreempted_(result_msg);
391 postPreemptedEvent(result_msg);
392 }*/
393 else
394 {
395 RCLCPP_INFO(
396 getLogger(), "[%s] request result: NOT HANDLED TYPE: %d", this->getName().c_str(),
397 (int)resultType);
398 }
399 }
smacc2::SmaccSignal< void(const WrappedResult &)> onSucceeded_

References smacc2::ISmaccClient::getLogger(), smacc2::client_bases::ISmaccActionClient::getName(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onAborted_, smacc2::client_bases::SmaccActionClientBase< ActionType >::onCancelled_, smacc2::client_bases::SmaccActionClientBase< ActionType >::onSucceeded_, smacc2::client_bases::SmaccActionClientBase< ActionType >::postAbortedEvent, smacc2::client_bases::SmaccActionClientBase< ActionType >::postCancelledEvent, and smacc2::client_bases::SmaccActionClientBase< ActionType >::postSuccessEvent.

Referenced by smacc2::client_bases::SmaccActionClientBase< ActionType >::onOrthogonalAllocation().

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

◆ onSucceeded() [1/2]

template<typename ActionType >
template<typename T >
boost::signals2::connection smacc2::client_bases::SmaccActionClientBase< ActionType >::onSucceeded ( std::function< void(WrappedResult &)>  callback)
inline

Definition at line 159 of file smacc_action_client_base.hpp.

160 {
162 }

References callback(), smacc2::ISmaccStateMachine::createSignalConnection(), and smacc2::ISmaccClient::getStateMachine().

Here is the call graph for this function:

◆ onSucceeded() [2/2]

template<typename ActionType >
template<typename T >
boost::signals2::connection smacc2::client_bases::SmaccActionClientBase< ActionType >::onSucceeded ( void(T::*)(WrappedResult &)  callback,
T object 
)
inline

◆ postResultEvent()

template<typename ActionType >
template<typename EvType >
void smacc2::client_bases::SmaccActionClientBase< ActionType >::postResultEvent ( WrappedResult )
inline

Definition at line 114 of file smacc_action_client_base.hpp.

115 {
116 auto * ev = new EvType();
117 // ev->client = this;
118 // ev->resultMessage = *result;
119 RCLCPP_INFO(
120 getLogger(), "Action client Posting EVENT %s", demangleSymbol(typeid(ev).name()).c_str());
121 this->postEvent(ev);
122 }

References smacc2::introspection::demangleSymbol(), smacc2::ISmaccClient::getLogger(), and smacc2::ISmaccClient::postEvent().

Here is the call graph for this function:

◆ sendGoal()

template<typename ActionType >
std::shared_future< typename GoalHandle::SharedPtr > smacc2::client_bases::SmaccActionClientBase< ActionType >::sendGoal ( Goal goal)
inline

Function called whenever feedback is received for the goal.

Function called when the result for the goal is received.

Definition at line 239 of file smacc_action_client_base.hpp.

240 {
241 // client_->sendGoal(goal, done_cb, active_cb, feedback_cb);
242 // std::shared_future<typename GoalHandle::SharedPtr>
243
244 SendGoalOptions options;
245
246 // GoalResponseCallback
247 // options.goal_response_callback;
248
250 // FeedbackCallback
251 options.feedback_callback = feedback_cb;
252
254 // ResultCallback result_callback;
255 // options.result_callback = done_cb;
256
257 options.result_callback =
258 [this](const typename rclcpp_action::ClientGoalHandle<ActionType>::WrappedResult & result) {
259 // TODO(#1652): a work around until rcl_action interface is updated
260 // if goal ids are not matched, the older goal call this callback so ignore the result
261 // if matched, it must be processed (including aborted)
262 RCLCPP_INFO_STREAM(getLogger(), getName() << ": Result callback, getting shared future");
263 goalHandle_ = lastRequest_->get();
264 RCLCPP_INFO_STREAM(getLogger(), getName() << ": Result CB Check goal id");
265 if (this->goalHandle_->get_goal_id() == result.goal_id)
266 {
267 // goal_result_available_ = true;
268 // result_ = result;
269 RCLCPP_INFO_STREAM(getLogger(), getName() << ": Result CB Goal id matches");
270 done_cb(result);
271 }
272 else
273 {
274 RCLCPP_INFO_STREAM(getLogger(), getName() << ": Result CB Goal id DOES NOT match");
275 }
276 };
277
278 // if (lastRequest_ && lastRequest_->valid())
279 // {
280 // RCLCPP_INFO_STREAM(getLogger(), getName() << ": checking previous request is really finished.");
281 // auto res = this->lastRequest_->get();
282 // RCLCPP_INFO_STREAM(getLogger(), getName() << ": okay");
283 // }
284 // else
285 // {
286 // RCLCPP_INFO_STREAM(getLogger(), getName() << ": no previous request.");
287 // }
288
289 RCLCPP_INFO_STREAM(getLogger(), getName() << ": async send goal.");
290 this->lastRequest_ = this->client_->async_send_goal(goal, options);
291
292 RCLCPP_INFO_STREAM(
293 getLogger(), "[" << getName() << "] Action goal sent to " << this->action_endpoint_
294 << "\": " << std::endl
295 << goal);
296
297 // if (client_->isServerConnected())
298 // {
299 // RCLCPP_INFO_STREAM(getLogger(), getName() << ": Goal sent:" << goal);
300
301 // RCLCPP_INFO_STREAM(getLogger(), getName() << ": Goal Id: " <<
302 // rclcpp_action::to_string(lastRequest_->get()->get_goal_id()));
303
304 RCLCPP_INFO_STREAM(
305 getLogger(), "[" << getName() << "] client ready clients: "
306 << this->client_->get_number_of_ready_clients());
307 RCLCPP_INFO_STREAM(
308 getLogger(),
309 "[" << getName() << "] Waiting it is ready? " << client_->action_server_is_ready());
310
311 // for (auto& gh: this->goal_handles_)
312 // {
313
314 // }
315
316 // RCLCPP_INFO_STREAM(getLogger(), getName() << ": spinning until completed");
317 // if (rclcpp::spin_until_future_complete(this->getNode(), lastRequest_, std::chrono::seconds(2))
318 // !=rclcpp::executor::FutureReturnCode::SUCCESS)
319 // {
320 // throw std::runtime_error("send_goal failed");
321 // }
322
323 // goalHandle_ = lastRequest_->get();
324 // if (!goalHandle_) {
325 // throw std::runtime_error("Goal was rejected by the action server");
326 // }
327
328 // }
329 // else
330 // {
331 // RCLCPP_ERROR(getLogger(),"%s [at %s]: not connected with actionserver, skipping goal request
332 // ...", getName().c_str(), getNamespace().c_str());
333 // //client_->waitForServer();
334 // }
335
336 return *lastRequest_;
337 }
typename ActionClient::SendGoalOptions SendGoalOptions
Base::WrappedResult WrappedResult

References smacc2::client_bases::SmaccActionClientBase< ActionType >::client_, smacc2::client_bases::SmaccActionClientBase< ActionType >::done_cb, smacc2::client_bases::SmaccActionClientBase< ActionType >::feedback_cb, smacc2::ISmaccClient::getLogger(), smacc2::client_bases::ISmaccActionClient::getName(), smacc2::client_bases::SmaccActionClientBase< ActionType >::goalHandle_, and smacc2::client_bases::SmaccActionClientBase< ActionType >::lastRequest_.

Referenced by cl_nav2z::CbNavigateGlobalPosition::execute(), cl_nav2z::CbAbsoluteRotate::onEntry(), cl_nav2z::CbNavigateBackwards::onEntry(), cl_nav2z::CbNavigateForward::onEntry(), cl_nav2z::CbRotate::onEntry(), cl_nav2z::CbUndoPathBackwards::onEntry(), sm_dance_bot::cl_led::CbLEDOff::onEntry(), sm_dance_bot::cl_led::CbLEDOn::onEntry(), sm_dance_bot_strikes_back::cl_led::CbLEDOff::onEntry(), sm_dance_bot_strikes_back::cl_led::CbLEDOn::onEntry(), sm_dance_bot_warehouse::cl_led::CbLEDOff::onEntry(), sm_dance_bot_warehouse::cl_led::CbLEDOn::onEntry(), sm_dance_bot_warehouse_2::cl_led::CbLEDOff::onEntry(), sm_dance_bot_warehouse_2::cl_led::CbLEDOn::onEntry(), sm_dance_bot_warehouse_3::cl_led::CbLEDOff::onEntry(), sm_dance_bot_warehouse_3::cl_led::CbLEDOn::onEntry(), and cl_nav2z::WaypointNavigator::sendNextGoal().

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

Member Data Documentation

◆ action_endpoint_

template<typename ActionType >
std::string smacc2::client_bases::SmaccActionClientBase< ActionType >::action_endpoint_

◆ client_

template<typename ActionType >
ActionClient::SharedPtr smacc2::client_bases::SmaccActionClientBase< ActionType >::client_
protected

◆ done_cb

template<typename ActionType >
ResultCallback smacc2::client_bases::SmaccActionClientBase< ActionType >::done_cb

◆ feedback_cb

template<typename ActionType >
FeedbackCallback smacc2::client_bases::SmaccActionClientBase< ActionType >::feedback_cb

◆ goalHandle_

template<typename ActionType >
GoalHandle::SharedPtr smacc2::client_bases::SmaccActionClientBase< ActionType >::goalHandle_

◆ lastRequest_

template<typename ActionType >
std::optional<std::shared_future<typename GoalHandle::SharedPtr> > smacc2::client_bases::SmaccActionClientBase< ActionType >::lastRequest_

◆ onAborted_

template<typename ActionType >
smacc2::SmaccSignal<void(const WrappedResult &)> smacc2::client_bases::SmaccActionClientBase< ActionType >::onAborted_

◆ onCancelled_

template<typename ActionType >
smacc2::SmaccSignal<void(const WrappedResult &)> smacc2::client_bases::SmaccActionClientBase< ActionType >::onCancelled_

◆ onSucceeded_

template<typename ActionType >
smacc2::SmaccSignal<void(const WrappedResult &)> smacc2::client_bases::SmaccActionClientBase< ActionType >::onSucceeded_

◆ postAbortedEvent

template<typename ActionType >
std::function<void(WrappedResult)> smacc2::client_bases::SmaccActionClientBase< ActionType >::postAbortedEvent

◆ postCancelledEvent

template<typename ActionType >
std::function<void(WrappedResult)> smacc2::client_bases::SmaccActionClientBase< ActionType >::postCancelledEvent

◆ postFeedbackEvent

template<typename ActionType >
std::function<void(const Feedback &)> smacc2::client_bases::SmaccActionClientBase< ActionType >::postFeedbackEvent

◆ postSuccessEvent

template<typename ActionType >
std::function<void(WrappedResult)> smacc2::client_bases::SmaccActionClientBase< ActionType >::postSuccessEvent

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