SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | Static Private Attributes | List of all members
smacc2::client_behaviors::CbRosLaunch Class Reference

#include <cb_ros_launch.hpp>

Inheritance diagram for smacc2::client_behaviors::CbRosLaunch:
Inheritance graph
Collaboration diagram for smacc2::client_behaviors::CbRosLaunch:
Collaboration graph

Public Member Functions

 CbRosLaunch ()
 
 CbRosLaunch (std::string package, std::string launchfile, RosLaunchMode)
 
virtual ~CbRosLaunch ()
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
void onEntry () override
 
- Public Member Functions inherited from smacc2::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
virtual ~SmaccAsyncClientBehavior ()
 
template<typename TCallback , typename T >
boost::signals2::connection onSuccess (TCallback callback, T *object)
 
template<typename TCallback , typename T >
boost::signals2::connection onFinished (TCallback callback, T *object)
 
template<typename TCallback , typename T >
boost::signals2::connection onFailure (TCallback callback, T *object)
 
void requestForceFinish ()
 
void executeOnEntry () override
 
void executeOnExit () override
 
void waitOnEntryThread (bool requestFinish)
 
template<typename TCallbackMethod , typename T >
boost::signals2::connection onSuccess (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
boost::signals2::connection onFinished (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
boost::signals2::connection onFailure (TCallbackMethod callback, T *object)
 
- Public Member Functions inherited from smacc2::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
ISmaccStateMachinegetStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, bool throwExceptionIfNotExist=false)
 
virtual void onExit ()
 

Public Attributes

std::optional< std::string > packageName_
 
std::optional< std::string > launchFileName_
 
RosLaunchMode launchMode_
 

Protected Attributes

std::string result_
 
smacc2::client_bases::ClRosLaunchclient_
 
std::future< std::string > future_
 

Static Private Attributes

static std::vector< std::future< std::string > > detached_futures_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::SmaccAsyncClientBehavior
void postSuccessEvent ()
 
void postFailureEvent ()
 
virtual void dispose () override
 
bool isShutdownRequested ()
 onEntry is executed in a new thread. However the current state cannot be left until the onEntry thread finishes. This flag can be checked from the onEntry thread to force finishing the thread.
 
- Protected Member Functions inherited from smacc2::ISmaccClientBehavior
virtual void runtimeConfigure ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
ISmaccStategetCurrentState ()
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 

Detailed Description

Definition at line 35 of file cb_ros_launch.hpp.

Constructor & Destructor Documentation

◆ CbRosLaunch() [1/2]

smacc2::client_behaviors::CbRosLaunch::CbRosLaunch ( )

Definition at line 28 of file cb_ros_launch.cpp.

◆ CbRosLaunch() [2/2]

smacc2::client_behaviors::CbRosLaunch::CbRosLaunch ( std::string  package,
std::string  launchfile,
RosLaunchMode  launchmode 
)

Definition at line 35 of file cb_ros_launch.cpp.

36: packageName_(package), launchFileName_(launchfile), launchMode_(launchmode)
37{
38}

◆ ~CbRosLaunch()

smacc2::client_behaviors::CbRosLaunch::~CbRosLaunch ( )
virtual

Definition at line 40 of file cb_ros_launch.cpp.

40{}

Member Function Documentation

◆ onEntry()

void smacc2::client_behaviors::CbRosLaunch::onEntry ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 48 of file cb_ros_launch.cpp.

49{
50 RCLCPP_INFO_STREAM(getLogger(), "[CbRosLaunch] OnEntry");
51
52 std::string packageName, launchFileName;
54 {
55 std::function<bool()> breakfunction;
56
58 {
59 breakfunction = [this]() -> bool { return this->isShutdownRequested(); };
60 }
61 else
62 {
63 breakfunction = []() -> bool { return false; };
64 }
65
66 RCLCPP_INFO_STREAM(
67 getLogger(), "[CbRosLaunch] launching: " << *packageName_ << " , " << *launchFileName_
68 << "LaunchMode: " << (int)launchMode_);
69
71 *packageName_, *launchFileName_, breakfunction);
72
74 detached_futures_.push_back(std::move(fut));
75 else
76 future_ = std::move(fut);
77 }
78 else
79 {
80 RCLCPP_INFO_STREAM(getLogger(), "[CbRosLaunch] finding Ros Launch client");
81
83 if (client_ != nullptr)
84 {
85 RCLCPP_INFO_STREAM(
86 getLogger(), "[CbRosLaunch] launching from client: " << client_->packageName_ << " , "
88
89 client_->launch();
90 }
91 else
92 {
93 RCLCPP_ERROR(
94 getLogger(),
95 "[CbRosLaunch] Inccorrect ros launch operation. No Ros Launch client specified neither "
96 "package/roslaunch file path.");
97 }
98 }
99}
virtual rclcpp::Logger getLogger() const
void requiresClient(SmaccClientType *&storage)
bool isShutdownRequested()
onEntry is executed in a new thread. However the current state cannot be left until the onEntry threa...
static std::future< std::string > executeRosLaunch(std::string packageName, std::string launchFilename, std::function< bool()> cancelCondition)
smacc2::client_bases::ClRosLaunch * client_
std::future< std::string > future_
static std::vector< std::future< std::string > > detached_futures_

References client_, detached_futures_, smacc2::client_bases::ClRosLaunch::executeRosLaunch(), future_, smacc2::ISmaccClientBehavior::getLogger(), smacc2::SmaccAsyncClientBehavior::isShutdownRequested(), smacc2::client_bases::ClRosLaunch::launch(), smacc2::client_behaviors::LAUNCH_CLIENT_BEHAVIOR_LIFETIME, smacc2::client_behaviors::LAUNCH_DETTACHED, smacc2::client_bases::ClRosLaunch::launchFileName_, launchFileName_, launchMode_, smacc2::client_bases::ClRosLaunch::packageName_, packageName_, and smacc2::ISmaccClientBehavior::requiresClient().

Here is the call graph for this function:

◆ onOrthogonalAllocation()

void smacc2::client_behaviors::CbRosLaunch::onOrthogonalAllocation ( )
inline

Definition at line 50 of file cb_ros_launch.hpp.

51 {
52 smacc2::SmaccAsyncClientBehavior::onOrthogonalAllocation<TOrthogonal, TSourceObject>();
53 }

Member Data Documentation

◆ client_

smacc2::client_bases::ClRosLaunch* smacc2::client_behaviors::CbRosLaunch::client_
protected

Definition at line 65 of file cb_ros_launch.hpp.

Referenced by onEntry().

◆ detached_futures_

std::vector< std::future< std::string > > smacc2::client_behaviors::CbRosLaunch::detached_futures_
staticprivate

Definition at line 38 of file cb_ros_launch.hpp.

Referenced by onEntry().

◆ future_

std::future<std::string> smacc2::client_behaviors::CbRosLaunch::future_
protected

Definition at line 67 of file cb_ros_launch.hpp.

Referenced by onEntry().

◆ launchFileName_

std::optional<std::string> smacc2::client_behaviors::CbRosLaunch::launchFileName_

Definition at line 58 of file cb_ros_launch.hpp.

Referenced by onEntry().

◆ launchMode_

RosLaunchMode smacc2::client_behaviors::CbRosLaunch::launchMode_

Definition at line 60 of file cb_ros_launch.hpp.

Referenced by onEntry().

◆ packageName_

std::optional<std::string> smacc2::client_behaviors::CbRosLaunch::packageName_

Definition at line 57 of file cb_ros_launch.hpp.

Referenced by onEntry().

◆ result_

std::string smacc2::client_behaviors::CbRosLaunch::result_
protected

Definition at line 63 of file cb_ros_launch.hpp.


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