ListControllers Class
Lists controllers from the controller manager with two independent filters. More...
Declaration
Included Headers
Base class
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
Public Constructors Index
| ListControllers (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources) | |
|
Constructor for ListControllers behavior. More... | |
| ListControllers (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< ClientInterfaceBase< controller_manager_msgs::srv::ListControllers > > client_interface) | |
Private Member Functions Index
| tl::expected< std::string, std::string > | getServiceName () override |
|
User-provided function to get the name of the service when initializing the service client. More... | |
| tl::expected< controller_manager_msgs::srv::ListControllers::Request, std::string > | createRequest () override |
|
User-provided function to create the service request. More... | |
| tl::expected< bool, std::string > | processResponse (const controller_manager_msgs::srv::ListControllers::Response &response) override |
|
Optional user-provided function to process the service response after the service has finished. More... | |
| std::shared_future< tl::expected< bool, std::string > > & | getFuture () override |
|
Gets the shared future which is used to monitor the progress of the async process. More... | |
Private Member Attributes Index
| std::shared_future< tl::expected< bool, std::string > > | response_future_ |
|
Holds the result of calling the service asynchronously. More... | |
Public Static Functions Index
| static BT::PortsList | providedPorts () |
|
Defines the input/output ports for this behavior. More... | |
| static BT::KeyValueVector | metadata () |
|
Provides metadata about the behavior for the behavior tree editor. More... | |
Description
Lists controllers from the controller manager with two independent filters.
This behavior queries the controller manager and returns a semicolon-separated list of controller names. Two filters can be combined:
state (by controller state):
- 'all': all controllers regardless of state
- 'active' (default): only active controllers
- 'inactive': only inactive controllers
type (by interface type):
- 'all' (default): all controllers matching the state filter
- 'command': only controllers that claim command interfaces (e.g. joint_trajectory_controller)
- 'state': only controllers with no command interfaces (e.g. joint_state_broadcaster)
This is useful for composing with SwitchController to save/restore controller states.
| Data Port Name | Port Type | Object Type |
|---|---|---|
| service_name | Input | std::string |
| state | Input | std::string |
| type | Input | std::string |
| controller_list | Output | std::vector<std::string> |
Definition at line 42 of file list_controllers.hpp.
Public Constructors
ListControllers()
|
Constructor for ListControllers behavior.
- Parameters
-
name Name of the behavior node.
config BehaviorTree node configuration.
shared_resources Shared resources for the behavior (ROS node, planning scene, etc.).
Declaration at line 51 of file list_controllers.hpp, definition at line 34 of file list_controllers.cpp.
ListControllers()
|
Declaration at line 55 of file list_controllers.hpp, definition at line 40 of file list_controllers.cpp.
Private Member Functions
createRequest()
| virtual |
User-provided function to create the service request.
- Returns
Returns a service request message. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.
Declaration at line 76 of file list_controllers.hpp, definition at line 83 of file list_controllers.cpp.
getFuture()
| inline virtual |
Gets the shared future which is used to monitor the progress of the async process.
Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member.
This exists to prevent destruction of the derived class while the async process is still in-progress. If the derived class is destroyed, the definitions of the functions used within doWork() will be destroyed too, which will result in the virtual functions in the base class being called instead and cause a fault.
This function will force derived classes to add an instance of this type and return a reference to it. The base class can then use this virtual function to access the shared future in functions like onStart.
By adding this virtual function we're properly demonstrating how this future depends on things from the derived class and the natural flow of object lifetimes will do the hard work for us. The std::shared_future destructor will get the value of the future before the derived class is destructed assuming it's the last reference to the shared state. Doing it this way means neither the base nor derived class should need to implement a destructor which is a nice property to have.
- Returns
Returns the shared_future, which should be owned by the child class.
Definition at line 83 of file list_controllers.hpp.
getServiceName()
| virtual |
User-provided function to get the name of the service when initializing the service client.
- Returns
Returns the name of the service. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.
Declaration at line 73 of file list_controllers.hpp, definition at line 67 of file list_controllers.cpp.
processResponse()
|
Optional user-provided function to process the service response after the service has finished.
If no user-defined implementation is provided, then no additional processing will be performed on succeeding service responses and this function will always return void.
- Parameters
-
response Service response message to process.
- Returns
Returns true or false depending on the user's implementation if the service response could be processed successfully. If the service response could not be processed, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.
Declaration at line 80 of file list_controllers.hpp, definition at line 89 of file list_controllers.cpp.
Private Member Attributes
response_future_
|
Holds the result of calling the service asynchronously.
Definition at line 89 of file list_controllers.hpp.
Public Static Functions
metadata()
| static |
Provides metadata about the behavior for the behavior tree editor.
- Returns
Key-value pairs describing subcategory and description.
Declaration at line 69 of file list_controllers.hpp, definition at line 62 of file list_controllers.cpp.
providedPorts()
| static |
Defines the input/output ports for this behavior.
- Returns
List of ports with their types and descriptions.
Declaration at line 63 of file list_controllers.hpp, definition at line 49 of file list_controllers.cpp.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.