SMACC
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Attributes | List of all members
smacc::components::CpRosControlInterface Class Reference

#include <cp_ros_control_interface.h>

Inheritance diagram for smacc::components::CpRosControlInterface:
Inheritance graph
Collaboration diagram for smacc::components::CpRosControlInterface:
Collaboration graph

Public Member Functions

 CpRosControlInterface ()
 
virtual ~CpRosControlInterface ()
 
virtual void onInitialize () override
 
std::vector< ControllerTypeInfolistControllerTypes ()
 
std::vector< controller_manager_msgs::ControllerState > listControllers ()
 
bool loadController (std::string name)
 
bool unloadController (std::string name)
 
bool reloadControllerLibraries (bool forceKill)
 
bool switchControllers (std::vector< std::string > start_controllers, std::vector< std::string > stop_controllers, Strictness strictness)
 
- Public Member Functions inherited from smacc::ISmaccComponent
 ISmaccComponent ()
 
virtual ~ISmaccComponent ()
 
virtual std::string getName () const
 

Public Attributes

boost::optional< std::string > serviceName_
 

Private Attributes

ros::NodeHandle nh_
 
ros::ServiceClient srvListControllers
 
ros::ServiceClient srvListControllersTypes
 
ros::ServiceClient srvLoadController
 
ros::ServiceClient srvReloadControllerLibraries
 
ros::ServiceClient srvSwitchControllers
 
ros::ServiceClient srvUnloadController
 

Additional Inherited Members

- Protected Member Functions inherited from smacc::ISmaccComponent
virtual void initialize (ISmaccClient *owner)
 
void setStateMachine (ISmaccStateMachine *stateMachine)
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename TComponent >
void requiresComponent (TComponent *&requiredComponentStorage)
 
template<typename TClient >
void requiresClient (TClient *&requiredClientStorage)
 
virtual void onInitialize ()
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingNamedComponent (std::string name, TArgs... targs)
 
- Protected Attributes inherited from smacc::ISmaccComponent
ISmaccStateMachinestateMachine_
 
ISmaccClientowner_
 

Detailed Description

Definition at line 21 of file cp_ros_control_interface.h.

Constructor & Destructor Documentation

◆ CpRosControlInterface()

smacc::components::CpRosControlInterface::CpRosControlInterface ( )

Definition at line 16 of file cp_ros_control_interface.cpp.

17{
18}

◆ ~CpRosControlInterface()

smacc::components::CpRosControlInterface::~CpRosControlInterface ( )
virtual

Definition at line 20 of file cp_ros_control_interface.cpp.

21{
22}

Member Function Documentation

◆ listControllers()

std::vector< controller_manager_msgs::ControllerState > smacc::components::CpRosControlInterface::listControllers ( )

Definition at line 35 of file cp_ros_control_interface.cpp.

36{
37 ListControllers::Request req;
38 ListControllers::Response res;
39
40 srvListControllers.call(req, res);
41 return res.controller;
42}

References srvListControllers.

◆ listControllerTypes()

std::vector< ControllerTypeInfo > smacc::components::CpRosControlInterface::listControllerTypes ( )

Definition at line 44 of file cp_ros_control_interface.cpp.

45{
46 ListControllerTypes::Request req;
47 ListControllerTypes::Response res;
48 srvListControllersTypes.call(req, res);
49
50 std::vector<ControllerTypeInfo> ret;
51 for (int i = 0; i < res.types.size(); i++)
52 {
53 ControllerTypeInfo entry;
54 entry.type = res.types[i];
55 entry.baseClass = res.base_classes[i];
56
57 ret.push_back(entry);
58 }
59
60 return ret;
61}

References smacc::components::ControllerTypeInfo::baseClass, srvListControllersTypes, and smacc::components::ControllerTypeInfo::type.

◆ loadController()

bool smacc::components::CpRosControlInterface::loadController ( std::string  name)

Definition at line 63 of file cp_ros_control_interface.cpp.

64{
65 LoadController::Request req;
66 LoadController::Response res;
67 req.name = name;
68
69 srvLoadController.call(req, res);
70 return res.ok;
71}

References srvLoadController.

◆ onInitialize()

void smacc::components::CpRosControlInterface::onInitialize ( )
overridevirtual

Reimplemented from smacc::ISmaccComponent.

Definition at line 24 of file cp_ros_control_interface.cpp.

25{
26 srvListControllers = nh_.serviceClient<ListControllers>(*serviceName_);
27 srvListControllersTypes = nh_.serviceClient<ListControllerTypes>(*serviceName_);
28
29 srvLoadController = nh_.serviceClient<LoadController>(*serviceName_);
30 srvUnloadController = nh_.serviceClient<UnloadController>(*serviceName_);
31 srvReloadControllerLibraries = nh_.serviceClient<ReloadControllerLibraries>(*serviceName_);
32 srvSwitchControllers = nh_.serviceClient<SwitchController>(*serviceName_);
33}

References nh_, srvListControllers, srvListControllersTypes, srvLoadController, srvReloadControllerLibraries, srvSwitchControllers, and srvUnloadController.

◆ reloadControllerLibraries()

bool smacc::components::CpRosControlInterface::reloadControllerLibraries ( bool  forceKill)

Definition at line 83 of file cp_ros_control_interface.cpp.

84{
85 ReloadControllerLibraries::Request req;
86 ReloadControllerLibraries::Response res;
87 req.force_kill = forceKill;
88
89 srvReloadControllerLibraries.call(req, res);
90
91 return res.ok;
92 //srvReloadControllerLibraries
93}

References srvReloadControllerLibraries.

◆ switchControllers()

bool smacc::components::CpRosControlInterface::switchControllers ( std::vector< std::string >  start_controllers,
std::vector< std::string >  stop_controllers,
Strictness  strictness 
)

Definition at line 95 of file cp_ros_control_interface.cpp.

98{
99 SwitchController::Request req;
100 SwitchController::Response res;
101
102 req.start_controllers = start_controllers;
103 req.stop_controllers = stop_controllers;
104 req.strictness = strictness;
105
106 srvSwitchControllers.call(req, res);
107
108 return res.ok;
109}

References srvSwitchControllers.

◆ unloadController()

bool smacc::components::CpRosControlInterface::unloadController ( std::string  name)

Definition at line 73 of file cp_ros_control_interface.cpp.

74{
75 UnloadController::Request req;
76 UnloadController::Response res;
77
78 req.name = name;
79 srvUnloadController.call(req, res);
80 return res.ok;
81}

References srvUnloadController.

Member Data Documentation

◆ nh_

ros::NodeHandle smacc::components::CpRosControlInterface::nh_
private

Definition at line 50 of file cp_ros_control_interface.h.

Referenced by onInitialize().

◆ serviceName_

boost::optional<std::string> smacc::components::CpRosControlInterface::serviceName_

Definition at line 47 of file cp_ros_control_interface.h.

◆ srvListControllers

ros::ServiceClient smacc::components::CpRosControlInterface::srvListControllers
private

Definition at line 52 of file cp_ros_control_interface.h.

Referenced by listControllers(), and onInitialize().

◆ srvListControllersTypes

ros::ServiceClient smacc::components::CpRosControlInterface::srvListControllersTypes
private

Definition at line 53 of file cp_ros_control_interface.h.

Referenced by listControllerTypes(), and onInitialize().

◆ srvLoadController

ros::ServiceClient smacc::components::CpRosControlInterface::srvLoadController
private

Definition at line 54 of file cp_ros_control_interface.h.

Referenced by loadController(), and onInitialize().

◆ srvReloadControllerLibraries

ros::ServiceClient smacc::components::CpRosControlInterface::srvReloadControllerLibraries
private

Definition at line 55 of file cp_ros_control_interface.h.

Referenced by onInitialize(), and reloadControllerLibraries().

◆ srvSwitchControllers

ros::ServiceClient smacc::components::CpRosControlInterface::srvSwitchControllers
private

Definition at line 56 of file cp_ros_control_interface.h.

Referenced by onInitialize(), and switchControllers().

◆ srvUnloadController

ros::ServiceClient smacc::components::CpRosControlInterface::srvUnloadController
private

Definition at line 57 of file cp_ros_control_interface.h.

Referenced by onInitialize(), and unloadController().


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