SMACC2
Loading...
Searching...
No Matches
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< ActionTypeActionClient
 
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)>
 
typedef smacc2::SmaccSignal< void(const WrappedResult &)> SmaccActionResultSignal
 

Public Member Functions

 SmaccActionClientBase (std::string actionServerName)
 
 SmaccActionClientBase ()
 
virtual ~SmaccActionClientBase ()
 
virtual std::shared_ptr< rclcpp_action::ClientBase > getClientBase () override
 
void onInitialize () override
 
void waitForServer ()
 
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, typename SmaccActionResultSignal::WeakPtr resultCallback=typename SmaccActionResultSignal::WeakPtr())
 
- Public Member Functions inherited from smacc2::client_bases::ISmaccActionClient
 ISmaccActionClient ()
 
virtual ~ISmaccActionClient ()
 
std::string getNamespace () const
 
virtual std::string getName () const
 
- Public Member Functions inherited from smacc2::ISmaccClient
 ISmaccClient ()
 
virtual ~ISmaccClient ()
 
template<typename TComponent >
TComponentgetComponent ()
 
template<typename TComponent >
TComponentgetComponent (std::string name)
 
template<typename TComponent >
TComponentgetComponent (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)
 
const std::vector< std::shared_ptr< ISmaccComponent > > & iterateComponents () const
 
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_
 
std::optional< std::shared_future< typename CancelResponse::SharedPtr > > lastCancelResponse_
 
SmaccActionResultSignal onSucceeded_
 
SmaccActionResultSignal onAborted_
 
SmaccActionResultSignal onCancelled_
 
std::function< void(WrappedResult)> postSuccessEvent
 
std::function< void(WrappedResult)> postAbortedEvent
 
std::function< void(WrappedResult)> postCancelledEvent
 
std::function< void(const Feedback &)> postFeedbackEvent
 
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>
SmaccComponentTypecreateComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentTypecreateNamedComponent (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

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

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.

◆ SmaccActionResultSignal

Definition at line 63 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()

Definition at line 73 of file smacc_action_client_base.hpp.

73{}

Member Function Documentation

◆ cancelGoal()

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

Implements smacc2::client_bases::ISmaccActionClient.

Definition at line 219 of file smacc_action_client_base.hpp.

220 {
221 lastCancelResponse_ = this->client_->async_cancel_all_goals();
222
223 // if (lastRequest_ && lastRequest_->valid())
224 // {
225
226 // // rclcpp::spin_until_future_complete(getNode(), *lastRequest_);
227 // auto req = lastRequest_->get();
228 // RCLCPP_INFO_STREAM(
229 // getLogger(), "[" << getName() << "] Cancelling goal. req id: "
230 // << rclcpp_action::to_string(req->get_goal_id()));
231 // auto cancelresult = client_->async_cancel_goal(req);
232
233 // // wait actively
234 // // rclcpp::spin_until_future_complete(getNode(), cancelresult);
235 // //lastRequest_.reset();
236 // return true;
237 // }
238 // else
239 // {
240 // RCLCPP_ERROR(
241 // getLogger(), "%s [at %s]: not connected with actionserver, skipping cancel goal ...",
242 // getName().c_str(), getNamespace().c_str());
243 // return false;
244 // }
245
246 return true;
247 }
std::optional< std::shared_future< typename CancelResponse::SharedPtr > > lastCancelResponse_

References smacc2::client_bases::SmaccActionClientBase< ActionType >::client_, and smacc2::client_bases::SmaccActionClientBase< ActionType >::lastCancelResponse_.

Referenced by cl_nav2z::CbNav2ZClientBehaviorBase::cancelGoal(), cl_nitrosz::CbNav2ZClientBehaviorBase::cancelGoal(), cl_nav2z::CbAbortNavigation::onEntry(), and cl_nitrosz::CbAbortNavigation::onEntry().

Here is the caller 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 95 of file smacc_action_client_base.hpp.

96 {
97 auto type = TypeInfo::getTypeInfoFromType<ActionType>();
98 return type->getNonTemplatedTypeName();
99 }

◆ 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 176 of file smacc_action_client_base.hpp.

177 {
178 return this->getStateMachine()->createSignalConnection(onAborted_, callback);
179 }
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)

References 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 170 of file smacc_action_client_base.hpp.

171 {
172 return this->getStateMachine()->createSignalConnection(onAborted_, callback, object);
173 }

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

Here is the call 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 188 of file smacc_action_client_base.hpp.

189 {
190 return this->getStateMachine()->createSignalConnection(onCancelled_, callback);
191 }

References 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 182 of file smacc_action_client_base.hpp.

183 {
184 return this->getStateMachine()->createSignalConnection(onCancelled_, callback, object);
185 }

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

Here is the call 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 382 of file smacc_action_client_base.hpp.

385 {
386 postFeedbackEvent(*feedback_msg);
387 }
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 77 of file smacc_action_client_base.hpp.

78 {
79 if (name_ == "") name_ = smacc2::demangleSymbol(typeid(*this).name());
80 this->client_ = rclcpp_action::create_client<ActionType>(getNode(), action_endpoint_);
81 // RCLCPP_INFO_STREAM(
82 // this->getLogger(),
83 // "Waiting for action server '" << name_ << "' of type: " << demangledTypeName<ActionType>());
84 //client_->wait_for_action_server();
85 }
rclcpp::Node::SharedPtr getNode()
Definition client.cpp:60
std::string demangleSymbol()

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

Definition at line 134 of file smacc_action_client_base.hpp.

135 {
136 // we create here all the event factory functions capturing the TOrthogonal
137 postSuccessEvent = [this](auto msg)
138 { this->postResultEvent<EvActionSucceeded<TSourceObject, TOrthogonal>>(msg); };
139 postAbortedEvent = [this](auto msg)
140 { this->postResultEvent<EvActionAborted<TSourceObject, TOrthogonal>>(msg); };
141
142 postCancelledEvent = [this](auto msg)
143 { this->postResultEvent<EvActionCancelled<TSourceObject, TOrthogonal>>(msg); };
144
145 postFeedbackEvent = [this](auto msg)
146 {
147 auto actionFeedbackEvent = new EvActionFeedback<Feedback, TOrthogonal>();
148 actionFeedbackEvent->client = this;
149 actionFeedbackEvent->feedbackMessage = msg;
150 this->postEvent(actionFeedbackEvent);
151 RCLCPP_DEBUG(getLogger(), "[%s] FEEDBACK EVENT", demangleType(typeid(*this)).c_str());
152 };
153
154 feedback_cb = [this](auto client, auto feedback) { this->onFeedback(client, feedback); };
155 }
rclcpp::Logger getLogger()
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
std::string demangleType(const std::type_info *tinfo)

References smacc2::introspection::demangleType(), smacc2::client_bases::SmaccActionClientBase< ActionType >::feedback_cb, smacc2::ISmaccClient::getLogger(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onFeedback(), 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 389 of file smacc_action_client_base.hpp.

390 {
391 // auto *actionResultEvent = new EvActionResult<TDerived>();
392 // actionResultEvent->client = this;
393 // actionResultEvent->resultMessage = *result_msg;
394
395 // const auto &resultType = this->getState();
396 const auto & resultType = result_msg.code;
397
398 RCLCPP_INFO_STREAM(
399 getLogger(), "[" << this->getName() << "] response result ["
400 << rclcpp_action::to_string(result_msg.goal_id) << "]: " << (int)resultType);
401
402 if (resultType == rclcpp_action::ResultCode::SUCCEEDED)
403 {
404 RCLCPP_INFO(getLogger(), "[%s] request result: Success", this->getName().c_str());
405 onSucceeded_(result_msg);
406 postSuccessEvent(result_msg);
407 }
408 else if (resultType == rclcpp_action::ResultCode::ABORTED)
409 {
410 RCLCPP_INFO(getLogger(), "[%s] request result: Aborted", this->getName().c_str());
411 onAborted_(result_msg);
412 postAbortedEvent(result_msg);
413 }
414 else if (resultType == rclcpp_action::ResultCode::CANCELED)
415 {
416 RCLCPP_INFO(getLogger(), "[%s] request result: Cancelled", this->getName().c_str());
417 onCancelled_(result_msg);
418 postCancelledEvent(result_msg);
419 }
420 /*
421 else if (resultType == actionlib::SimpleClientGoalState::REJECTED)
422 {
423 RCLCPP_INFO(getLogger(),"[%s] request result: Rejected", this->getName().c_str());
424 onRejected_(result_msg);
425 postRejectedEvent(result_msg);
426 }
427 else if (resultType == actionlib::SimpleClientGoalState::PREEMPTED)
428 {
429 RCLCPP_INFO(getLogger(),"[%s] request result: Preempted", this->getName().c_str());
430 onPreempted_(result_msg);
431 postPreemptedEvent(result_msg);
432 }*/
433 else
434 {
435 RCLCPP_INFO(
436 getLogger(), "[%s] request result: NOT HANDLED TYPE: %d", this->getName().c_str(),
437 (int)resultType);
438 }
439 }

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 >::sendGoal().

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 164 of file smacc_action_client_base.hpp.

165 {
166 return this->getStateMachine()->createSignalConnection(onSucceeded_, callback);
167 }

References 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

Definition at line 158 of file smacc_action_client_base.hpp.

159 {
160 return this->getStateMachine()->createSignalConnection(onSucceeded_, callback, object);
161 }

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

Here is the call graph for this function:

◆ postResultEvent()

Definition at line 123 of file smacc_action_client_base.hpp.

124 {
125 auto * ev = new EvType();
126 // ev->client = this;
127 // ev->resultMessage = *result;
128 RCLCPP_INFO(
129 getLogger(), "Action client Posting EVENT %s", demangleSymbol(typeid(ev).name()).c_str());
130 this->postEvent(ev);
131 }

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,
typename SmaccActionResultSignal::WeakPtr  resultCallback = typename SmaccActionResultSignal::WeakPtr() 
)
inline

Function called whenever feedback is received for the goal.

Function called when the result for the goal is received.

Definition at line 249 of file smacc_action_client_base.hpp.

253 {
254 // client_->sendGoal(goal, result_cb, active_cb, feedback_cb);
255 // std::shared_future<typename GoalHandle::SharedPtr>
256
257 SendGoalOptions options;
258
259 // GoalResponseCallback
260 // options.goal_response_callback;
261
263 // FeedbackCallback
264 options.feedback_callback = feedback_cb;
265
267 // ResultCallback result_callback;
268 // options.result_callback = result_cb;
269
270 options.result_callback =
271 [this, resultCallback](
272 const typename rclcpp_action::ClientGoalHandle<ActionType>::WrappedResult & result)
273 {
274 // TODO(#1652): a work around until rcl_action interface is updated
275 // if goal ids are not matched, the older goa call this callback so ignore the result
276 // if matched, it must be processed (including aborted)
277
278 RCLCPP_INFO_STREAM(
279 getLogger(), "[" << getName() << "] Action result callback, getting shared future");
280 // auto goalHandle = result->get();
281 // goalHandle_ = lastRequest_->get();
282 RCLCPP_INFO_STREAM(
283 getLogger(), "[" << getName() << "] Action client Result goal id: "
284 << rclcpp_action::to_string(result.goal_id));
285
286 // if (goalHandle_->get_goal_id() == result.goal_id)
287 // {
288 // // goal_result_available_ = true;
289 // // result_ = result;
290 // RCLCPP_INFO_STREAM(getLogger(), "[" << getName() << "] Result CB Goal id matches with last request");
291
292 auto resultCallbackPtr = resultCallback.lock();
293
294 if (resultCallbackPtr != nullptr)
295 {
296 RCLCPP_INFO_STREAM(
297 getLogger(), "[" << getName() << "] Result CB calling user callback:"
298 << demangleSymbol(typeid(*resultCallbackPtr).name()));
299 (*resultCallbackPtr)(result);
300 }
301 else
302 {
303 RCLCPP_INFO_STREAM(
304 getLogger(), "[" << getName() << "] Result CB calling default callback");
305 this->onResult(result);
306 }
307
308 // }
309 // else
310 // {
311 // RCLCPP_ERROR_STREAM(getLogger(), "[" << getName() << "] Result CB Goal id DOES NOT match with last request. Skipping, incorrect behavior.");
312 // }
313 };
314
315 // if (lastRequest_ && lastRequest_->valid())
316 // {
317 // RCLCPP_INFO_STREAM(getLogger(), getName() << ": checking previous request is really finished.");
318 // auto res = this->lastRequest_->get();
319 // RCLCPP_INFO_STREAM(getLogger(), getName() << ": okay");
320 // }
321 // else
322 // {
323 // RCLCPP_INFO_STREAM(getLogger(), getName() << ": no previous request.");
324 // }
325
326 RCLCPP_INFO_STREAM(
327 getLogger(), "[" << getName() << "] client ready clients: "
328 << this->client_->get_number_of_ready_clients());
329 RCLCPP_INFO_STREAM(
330 getLogger(),
331 "[" << getName() << "] Waiting it is ready? " << client_->action_server_is_ready());
332
333 RCLCPP_INFO_STREAM(getLogger(), getName() << ": async send goal.");
334 auto lastRequest = this->client_->async_send_goal(goal, options);
335 this->lastRequest_ = lastRequest;
336
337 RCLCPP_INFO_STREAM(
338 getLogger(), "[" << getName() << "] Action request "
339 // << rclcpp_action::to_string(this->goalHandle_->get_goal_id()) <<". Goal sent to " << this->action_endpoint_
340 // << "\": " << std::endl
341 // << goal
342 );
343
344 // if (client_->isServerConnected())
345 // {
346 // RCLCPP_INFO_STREAM(getLogger(), getName() << ": Goal sent:" << goal);
347
348 // RCLCPP_INFO_STREAM(getLogger(), getName() << ": Goal Id: " <<
349 // rclcpp_action::to_string(lastRequest_->get()->get_goal_id()));
350
351 // for (auto& gh: this->goal_handles_)
352 // {
353
354 // }
355
356 // RCLCPP_INFO_STREAM(getLogger(), getName() << ": spinning until completed");
357 // if (rclcpp::spin_until_future_complete(this->getNode(), lastRequest_, std::chrono::seconds(2))
358 // !=rclcpp::executor::FutureReturnCode::SUCCESS)
359 // {
360 // throw std::runtime_error("send_goal failed");
361 // }
362
363 // goalHandle_ = lastRequest_->get();
364 // if (!goalHandle_) {
365 // throw std::runtime_error("Goal was rejected by the action server");
366 // }
367
368 // }
369 // else
370 // {
371 // RCLCPP_ERROR(getLogger(),"%s [at %s]: not connected with actionserver, skipping goal request
372 // ...", getName().c_str(), getNamespace().c_str());
373 // //client_->waitForServer();
374 // }
375
376 return lastRequest;
377 }
typename ActionClient::SendGoalOptions SendGoalOptions
void onResult(const WrappedResult &result_msg)
std::optional< std::shared_future< typename GoalHandle::SharedPtr > > lastRequest_

References smacc2::client_bases::SmaccActionClientBase< ActionType >::client_, smacc2::introspection::demangleSymbol(), smacc2::client_bases::SmaccActionClientBase< ActionType >::feedback_cb, smacc2::ISmaccClient::getLogger(), smacc2::client_bases::ISmaccActionClient::getName(), and smacc2::client_bases::SmaccActionClientBase< ActionType >::onResult().

Referenced by cl_nav2z::CbNav2ZClientBehaviorBase::sendGoal(), cl_nitrosz::CbNav2ZClientBehaviorBase::sendGoal(), cl_nav2z::CpWaypointNavigator::sendNextGoal(), and cl_nitrosz::CpWaypointNavigator::sendNextGoal().

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

◆ waitForServer()

Definition at line 87 of file smacc_action_client_base.hpp.

88 {
89 RCLCPP_INFO_STREAM(
90 this->getLogger(),
91 "Waiting for action server '" << name_ << "' of type: " << demangledTypeName<ActionType>());
92 client_->wait_for_action_server();
93 }

References smacc2::client_bases::SmaccActionClientBase< ActionType >::client_, smacc2::ISmaccClient::getLogger(), and smacc2::client_bases::ISmaccActionClient::name_.

Here is the call 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

◆ feedback_cb

◆ lastCancelResponse_

template<typename ActionType >
std::optional<std::shared_future<typename CancelResponse::SharedPtr> > smacc2::client_bases::SmaccActionClientBase< ActionType >::lastCancelResponse_

◆ lastRequest_

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

Definition at line 101 of file smacc_action_client_base.hpp.

◆ onAborted_

◆ onCancelled_

◆ onSucceeded_

◆ postAbortedEvent

◆ postCancelledEvent

◆ postFeedbackEvent

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

◆ postSuccessEvent


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