SMACC2
Loading...
Searching...
No Matches
smacc2::client_behaviors::CbRosLaunch2 Class Reference

#include <cb_ros_launch_2.hpp>

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

Public Member Functions

 CbRosLaunch2 ()
 
 CbRosLaunch2 (std::string package, std::string launchfile, RosLaunchMode)
 
 ~CbRosLaunch2 () override
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
void onEntry () override
 
- Public Member Functions inherited from smacc2::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
 SmaccAsyncClientBehavior ()=default
 
 ~SmaccAsyncClientBehavior () override
 
 SmaccAsyncClientBehavior (const SmaccAsyncClientBehavior &)=delete
 
SmaccAsyncClientBehavior & operator= (const SmaccAsyncClientBehavior &)=delete
 
 SmaccAsyncClientBehavior (SmaccAsyncClientBehavior &&)=delete
 
SmaccAsyncClientBehavior & operator= (SmaccAsyncClientBehavior &&)=delete
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onSuccess (TCallback callback, T *object)
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onFinished (TCallback callback, T *object)
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onFailure (TCallback callback, T *object)
 
void requestForceFinish ()
 
void executeOnEntry () override
 
void executeOnExit () override
 
void waitOnEntryThread (bool requestFinish)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onSuccess (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onFinished (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onFailure (TCallbackMethod callback, T *object)
 
- Public Member Functions inherited from smacc2::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
 ISmaccClientBehavior (const ISmaccClientBehavior &)=delete
 
ISmaccClientBehavior & operator= (const ISmaccClientBehavior &)=delete
 
 ISmaccClientBehavior (ISmaccClientBehavior &&)=delete
 
ISmaccClientBehavior & operator= (ISmaccClientBehavior &&)=delete
 
ISmaccStateMachine * getStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
template<typename SmaccComponentType >
void requiresComponent (const std::string &name, SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
virtual void onExit ()
 

Public Attributes

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

Protected Attributes

std::future< std::string > result_
 
smacc2::client_bases::ClRosLaunch2 * client_
 
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 ()
 
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 ()
 
ISmaccState * getCurrentState ()
 
void postInitializationFailureEvent (const std::string &what)
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 
std::string getTraceStateName () const
 
std::string getTraceOrthogonalName () const
 

Detailed Description

Definition at line 35 of file cb_ros_launch_2.hpp.

Constructor & Destructor Documentation

◆ CbRosLaunch2() [1/2]

smacc2::client_behaviors::CbRosLaunch2::CbRosLaunch2 ( )

Definition at line 28 of file cb_ros_launch_2.cpp.

29: packageName_(std::nullopt),
30 launchFileName_(std::nullopt),
32 client_(nullptr)
33{
34}
std::optional< std::string > launchFileName_
smacc2::client_bases::ClRosLaunch2 * client_
std::optional< std::string > packageName_

◆ CbRosLaunch2() [2/2]

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

Definition at line 36 of file cb_ros_launch_2.cpp.

37: packageName_(package), launchFileName_(launchfile), launchMode_(launchmode), client_(nullptr)
38{
39}

◆ ~CbRosLaunch2()

smacc2::client_behaviors::CbRosLaunch2::~CbRosLaunch2 ( )
override

Definition at line 41 of file cb_ros_launch_2.cpp.

41{}

Member Function Documentation

◆ onEntry()

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

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 43 of file cb_ros_launch_2.cpp.

44{
45 RCLCPP_INFO_STREAM(getLogger(), "[CbRosLaunch2] OnEntry");
46
47 if (
50 {
51 std::function<bool()> breakfunction;
52
53 breakfunction = std::bind(&CbRosLaunch2::isShutdownRequested, this);
54
55 RCLCPP_INFO_STREAM(
56 getLogger(), "[CbRosLaunch2] launching: " << *packageName_ << " , " << *launchFileName_
57 << "LaunchMode: " << (int)launchMode_);
58
59 // LAUNCH_CLIENT_BEHAVIOR_LIFETIME: onEntry returns only when the launch has ended.
61 *packageName_, *launchFileName_, breakfunction);
62 launchFuture.wait();
63 }
65 {
68 {
71 }
72
73 RCLCPP_INFO_STREAM(getLogger(), "[CbRosLaunch2] finding Ros Launch client");
74
75 if (client_ != nullptr)
76 {
77 RCLCPP_INFO_STREAM(
78 getLogger(), "[CbRosLaunch2] launching from client: " << client_->packageName_ << " , "
80
81 client_->launch();
82 }
83 else
84 {
85 RCLCPP_ERROR(
86 getLogger(),
87 "[CbRosLaunch2] Inccorrect ros launch operation. No Ros Launch client specified neither "
88 "package/roslaunch file path.");
89 }
90 }
91 else
92 {
93 RCLCPP_ERROR(
94 getLogger(),
95 "[CbRosLaunch2] Inccorrect ros launch operation. Not supported case. Invalid argument.");
96 }
97}
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(const std::string &packageName, const std::string &launchFileName, std::function< bool()> cancelCondition, ClRosLaunch2 *client=nullptr)

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

Here is the call graph for this function:

◆ onStateOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void smacc2::client_behaviors::CbRosLaunch2::onStateOrthogonalAllocation ( )
inline

Member Data Documentation

◆ client_

smacc2::client_bases::ClRosLaunch2* smacc2::client_behaviors::CbRosLaunch2::client_
protected

Definition at line 63 of file cb_ros_launch_2.hpp.

Referenced by onEntry().

◆ detached_futures_

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

Definition at line 38 of file cb_ros_launch_2.hpp.

◆ future_

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

Definition at line 65 of file cb_ros_launch_2.hpp.

◆ launchFileName_

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

Definition at line 56 of file cb_ros_launch_2.hpp.

Referenced by onEntry().

◆ launchMode_

RosLaunchMode smacc2::client_behaviors::CbRosLaunch2::launchMode_

Definition at line 58 of file cb_ros_launch_2.hpp.

Referenced by onEntry().

◆ packageName_

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

Definition at line 55 of file cb_ros_launch_2.hpp.

Referenced by onEntry().

◆ result_

std::future<std::string> smacc2::client_behaviors::CbRosLaunch2::result_
protected

Definition at line 61 of file cb_ros_launch_2.hpp.


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