MoveIt Pro API
Core Behaviors for MoveIt Pro
Loading...
Searching...
No Matches
moveit_studio::behaviors::SwitchController Class Referencefinal

A Behavior to call the ros2_control switch_controllers service to activate/deactivate controllers. More...

#include <switch_controller.hpp>

Inheritance diagram for moveit_studio::behaviors::SwitchController:
Collaboration diagram for moveit_studio::behaviors::SwitchController:

Public Member Functions

 SwitchController (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)
 
 SwitchController (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< ClientInterfaceBase< ListControllersSrv > > list_controllers_client_interface)
 
void setSwitchControllerClientInterface (std::unique_ptr< ClientInterfaceBase< SwitchControllerSrv > > switch_controller_client_interface)
 
- Public Member Functions inherited from moveit_studio::behaviors::ServiceClientBehaviorBase< ListControllersSrv >
 ServiceClientBehaviorBase (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)
 Constructs ServiceClientBehaviorBase using the RclcppClientInterface.
 
 ServiceClientBehaviorBase (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< ClientInterfaceBase< ListControllersSrv > > client_interface)
 Constructs ServiceClientBehaviorBase using a user-provided implementation of ClientInterfaceBase.
 
virtual ~ServiceClientBehaviorBase ()=default
 
- Public Member Functions inherited from moveit_studio::behaviors::AsyncBehaviorBase
 AsyncBehaviorBase (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)
 
virtual ~AsyncBehaviorBase ()=default
 
BT::NodeStatus onStart () override
 Required implementation of BT::StatefulActionNode::onStart().
 
BT::NodeStatus onRunning () override
 Required implementation of BT::StatefulActionNode::onRunning().
 
void onHalted () override
 Required implementation of BT::StatefulActionNode::onHalted().
 
void resetStatus ()
 Resets the internal status of this node.
 
- Public Member Functions inherited from moveit_studio::behaviors::SharedResourcesNode< BT::StatefulActionNode >
 SharedResourcesNode (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)
 Constructor for SharedResourcesNode. Called by BT::BehaviorTreeFactory when creating a new behavior tree containing this node.
 

Static Public Member Functions

static BT::PortsList providedPorts ()
 
static BT::KeyValueVector metadata ()
 

Static Public Attributes

static constexpr auto kPortActivateControllers = "activate_controllers"
 
static constexpr auto kPortDeactivateControllers = "deactivate_controllers"
 
static constexpr auto kPortAutomaticDeactivation = "automatic_deactivation"
 
static constexpr auto kPortStrictness = "strictness"
 
static constexpr auto kPortActivateAsap = "activate_asap"
 
static constexpr auto kPortTimeout = "timeout"
 
static constexpr auto kPortListServiceName = "controller_list_action_name"
 
static constexpr auto kPortSwitchServiceName = "controller_switch_action_name"
 
- Static Public Attributes inherited from moveit_studio::behaviors::ServiceClientBehaviorBase< ListControllersSrv >
static constexpr std::chrono::seconds kTimeoutWaitForServiceServer
 

Additional Inherited Members

- Protected Member Functions inherited from moveit_studio::behaviors::ServiceClientBehaviorBase< ListControllersSrv >
virtual tl::expected< std::chrono::duration< double >, std::string > getResponseTimeout ()
 Optional user-provided function to set the timeout used when waiting for the service response.
 
virtual tl::expected< bool, std::string > processResponse (const typename ServiceT::Response &)
 Optional user-provided function to process the service response after the service has finished.
 
- Protected Member Functions inherited from moveit_studio::behaviors::AsyncBehaviorBase
void notifyCanHalt ()
 Called when runAsync() finishes to notify onHalted() that the async process has finished.
 
- Protected Attributes inherited from moveit_studio::behaviors::SharedResourcesNode< BT::StatefulActionNode >
std::shared_ptr< BehaviorContextshared_resources_
 

Detailed Description

A Behavior to call the ros2_control switch_controllers service to activate/deactivate controllers.

This Behavior switches controllers in a ros2_control controller manager. Given a list of controllers to activate/deactivate, a service request is dispatched to switch the active ros2_control controllers accordingly. It can be configured to automatically deactivate controllers that are in conflict with the ones to activate. If any of the controllers fail to start or stop, the Behavior will return failure.

The Behavior will first call the list_controllers service to get the list of controllers and their states. It will then create a request to the switch_controller service with the specified controllers to activate and deactivate. The request will also include the strictness level, whether to activate controllers as soon as their hardware dependencies are ready, and a timeout for the operation.

The Behavior will wait for the service response and return success or failure based on the response.

Data Port Name Port Type Object Type
activate_controllers input std::vector<std::string>
deactivate_controllers input std::vector<std::string>
automatic_deactivation input bool
strictness input int
activate_asap input bool
timeout input std::chrono::duration<double>
controller_list_action_name input std::string
controller_switch_action_name input std::string

Constructor & Destructor Documentation

◆ SwitchController() [1/2]

moveit_studio::behaviors::SwitchController::SwitchController ( const std::string &  name,
const BT::NodeConfiguration &  config,
const std::shared_ptr< BehaviorContext > &  shared_resources 
)
explicit

◆ SwitchController() [2/2]

moveit_studio::behaviors::SwitchController::SwitchController ( const std::string &  name,
const BT::NodeConfiguration &  config,
const std::shared_ptr< BehaviorContext > &  shared_resources,
std::unique_ptr< ClientInterfaceBase< ListControllersSrv > >  list_controllers_client_interface 
)
explicit

Member Function Documentation

◆ metadata()

BT::KeyValueVector moveit_studio::behaviors::SwitchController::metadata ( )
static

◆ providedPorts()

BT::PortsList moveit_studio::behaviors::SwitchController::providedPorts ( )
static

◆ setSwitchControllerClientInterface()

void moveit_studio::behaviors::SwitchController::setSwitchControllerClientInterface ( std::unique_ptr< ClientInterfaceBase< SwitchControllerSrv > >  switch_controller_client_interface)
inline

Member Data Documentation

◆ kPortActivateAsap

constexpr auto moveit_studio::behaviors::SwitchController::kPortActivateAsap = "activate_asap"
staticconstexpr

◆ kPortActivateControllers

constexpr auto moveit_studio::behaviors::SwitchController::kPortActivateControllers = "activate_controllers"
staticconstexpr

◆ kPortAutomaticDeactivation

constexpr auto moveit_studio::behaviors::SwitchController::kPortAutomaticDeactivation = "automatic_deactivation"
staticconstexpr

◆ kPortDeactivateControllers

constexpr auto moveit_studio::behaviors::SwitchController::kPortDeactivateControllers = "deactivate_controllers"
staticconstexpr

◆ kPortListServiceName

constexpr auto moveit_studio::behaviors::SwitchController::kPortListServiceName = "controller_list_action_name"
staticconstexpr

◆ kPortStrictness

constexpr auto moveit_studio::behaviors::SwitchController::kPortStrictness = "strictness"
staticconstexpr

◆ kPortSwitchServiceName

constexpr auto moveit_studio::behaviors::SwitchController::kPortSwitchServiceName = "controller_switch_action_name"
staticconstexpr

◆ kPortTimeout

constexpr auto moveit_studio::behaviors::SwitchController::kPortTimeout = "timeout"
staticconstexpr

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