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

213 {
214 if (lastRequest_ && lastRequest_->valid())
215 {
216 rclcpp::spin_until_future_complete(getNode(), *lastRequest_);
217 auto req = lastRequest_->get();
218 RCLCPP_INFO_STREAM(
219 getLogger(), "[" << getName() << "] Cancelling goal. req id: "
220 << rclcpp_action::to_string(req->get_goal_id()));
221 auto cancelresult = client_->async_cancel_goal(req);
222
223 // wait actively
224 rclcpp::spin_until_future_complete(getNode(), cancelresult);
225 //lastRequest_.reset();
226 return true;
227 }
228 else
229 {
230 RCLCPP_ERROR(
231 getLogger(), "%s [at %s]: not connected with actionserver, skipping cancel goal ...",
232 getName().c_str(), getNamespace().c_str());
233 return false;
234 }
235 }
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 }

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

170 {
171 return this->getStateMachine()->createSignalConnection(onAborted_, callback);
172 }
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
smacc2::SmaccSignal< void(const WrappedResult &)> onAborted_

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

164 {
165 return this->getStateMachine()->createSignalConnection(onAborted_, callback, object);
166 }

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

182 {
183 return this->getStateMachine()->createSignalConnection(onCancelled_, callback);
184 }
smacc2::SmaccSignal< void(const WrappedResult &)> onCancelled_

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

176 {
177 return this->getStateMachine()->createSignalConnection(onCancelled_, callback, object);
178 }

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

344 {
345 postFeedbackEvent(*feedback_msg);
346 }
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()

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 postAbortedEvent = [this](auto msg)
131 { this->postResultEvent<EvActionAborted<TSourceObject, TOrthogonal>>(msg); };
132
133 postCancelledEvent = [this](auto msg)
134 { this->postResultEvent<EvActionCancelled<TSourceObject, TOrthogonal>>(msg); };
135 postFeedbackEvent = [this](auto msg)
136 {
137 auto actionFeedbackEvent = new EvActionFeedback<Feedback, TOrthogonal>();
138 actionFeedbackEvent->client = this;
139 actionFeedbackEvent->feedbackMessage = msg;
140 this->postEvent(actionFeedbackEvent);
141 RCLCPP_DEBUG(getLogger(), "[%s] FEEDBACK EVENT", demangleType(typeid(*this)).c_str());
142 };
143
144 done_cb = [this](auto r) { this->onResult(r); };
145 // done_cb = boost::bind(&SmaccActionClientBase<ActionType>::onResult, this, _1, _2);
146 // active_cb;
147 feedback_cb = [this](auto client, auto feedback) { this->onFeedback(client, feedback); };
148 }
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 348 of file smacc_action_client_base.hpp.

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

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

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

152 {
153 return this->getStateMachine()->createSignalConnection(onSucceeded_, callback, object);
154 }

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

Here is the call graph for this function:

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

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

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_.

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

◆ 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: