-
Notifications
You must be signed in to change notification settings - Fork 367
Full functionality of chainable controllers #667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d19c724
03ae2b2
c5d7383
862987e
0b7bd7f
2a4af6b
44b17e0
b0cc0a7
f883120
0a46e6c
1b16a1b
50fee31
a3f928d
a0b64da
1b05bf2
5d7b040
fac6a89
a2be1d1
0348e8d
ed0d8d6
648d039
65bcd7c
cad977b
1cb9154
b0ff012
d652a34
8ead608
4b81f80
fe20955
702f69f
e6d2f23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,11 @@ | |
#ifndef CONTROLLER_MANAGER__CONTROLLER_MANAGER_HPP_ | ||
#define CONTROLLER_MANAGER__CONTROLLER_MANAGER_HPP_ | ||
|
||
#include <map> | ||
#include <memory> | ||
#include <string> | ||
#include <tuple> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
#include "controller_interface/chainable_controller_interface.hpp" | ||
|
@@ -40,15 +42,21 @@ | |
#include "controller_manager_msgs/srv/switch_controller.hpp" | ||
#include "controller_manager_msgs/srv/unload_controller.hpp" | ||
|
||
#include "hardware_interface/handle.hpp" | ||
#include "hardware_interface/resource_manager.hpp" | ||
|
||
#include "pluginlib/class_loader.hpp" | ||
|
||
#include "rclcpp/executor.hpp" | ||
#include "rclcpp/node.hpp" | ||
#include "rclcpp/node_interfaces/node_logging_interface.hpp" | ||
#include "rclcpp/node_interfaces/node_parameters_interface.hpp" | ||
#include "rclcpp/parameter.hpp" | ||
|
||
namespace controller_manager | ||
{ | ||
using ControllersListIterator = std::vector<controller_manager::ControllerSpec>::const_iterator; | ||
bmagyar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
class ControllerManager : public rclcpp::Node | ||
{ | ||
public: | ||
|
@@ -169,6 +177,18 @@ class ControllerManager : public rclcpp::Node | |
CONTROLLER_MANAGER_PUBLIC | ||
void stop_controllers(); | ||
|
||
/** | ||
* Switch chained mode for all the controllers with respect to the following cases: | ||
* - a preceding controller is getting activated --> switch controller to chained mode; | ||
* - all preceding controllers are deactivated --> switch controller from chained mode. | ||
* | ||
* \param[in] chained_mode_switch_list list of controller to switch chained mode. | ||
* \param[in] to_chained_mode flag if controller should be switched *to* or *from* chained mode. | ||
*/ | ||
CONTROLLER_MANAGER_PUBLIC | ||
void switch_chained_mode( | ||
const std::vector<std::string> & chained_mode_switch_list, bool to_chained_mode); | ||
|
||
CONTROLLER_MANAGER_PUBLIC | ||
void start_controllers(); | ||
|
||
|
@@ -243,11 +263,78 @@ class ControllerManager : public rclcpp::Node | |
// Per controller update rate support | ||
unsigned int update_loop_counter_ = 0; | ||
unsigned int update_rate_ = 100; | ||
std::vector<std::vector<std::string>> chained_controllers_configuration_; | ||
|
||
std::unique_ptr<hardware_interface::ResourceManager> resource_manager_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. umm... were moved here for testability? can we have them in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is why we moved things to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again: those members are |
||
|
||
private: | ||
std::vector<std::string> get_controller_names(); | ||
|
||
std::unique_ptr<hardware_interface::ResourceManager> resource_manager_; | ||
/** | ||
* Clear request lists used when switching controllers. The lists are shared between "callback" and | ||
* "control loop" threads. | ||
*/ | ||
void clear_requests(); | ||
|
||
/** | ||
* If a controller is deactivated all following controllers (if any exist) should be switched | ||
* 'from' the chained mode. | ||
* | ||
* \param[in] controllers list with controllers. | ||
*/ | ||
void propagate_deactivation_of_chained_mode(const std::vector<ControllerSpec> & controllers); | ||
|
||
/// Check if all the following controllers will be in active state and in the chained mode | ||
/// after controllers' switch. | ||
/** | ||
* Check recursively that all following controllers of the @controller_it | ||
* - are already active, | ||
* - will not be deactivated, | ||
* - or will be activated. | ||
* The following controllers are added to the request to switch in the chained mode or removed | ||
* from the request to switch from the chained mode. | ||
* | ||
* For each controller the whole chain of following controllers is checked. | ||
* | ||
* NOTE: The automatically adding of following controller into starting list is not implemented | ||
* yet. | ||
* | ||
* \param[in] controllers list with controllers. | ||
* \param[in] strictness if value is equal "MANIPULATE_CONTROLLERS_CHAIN" then all following | ||
* controllers will be automatically added to the activate request list if they are not in the | ||
* deactivate request. | ||
* \param[in] controller_it iterator to the controller for which the following controllers are | ||
* checked. | ||
* | ||
* \returns return_type::OK if all following controllers pass the checks, otherwise | ||
* return_type::ERROR. | ||
*/ | ||
controller_interface::return_type check_following_controllers_for_activate( | ||
const std::vector<ControllerSpec> & controllers, int strictness, | ||
const ControllersListIterator controller_it); | ||
|
||
/// Check if all the preceding controllers will be in inactive state after controllers' switch. | ||
/** | ||
* Check that all preceding controllers of the @controller_it | ||
* - are inactive, | ||
* - will be deactivated, | ||
* - and will not be activated. | ||
* | ||
* NOTE: The automatically adding of preceding controllers into stopping list is not implemented | ||
* yet. | ||
* | ||
* \param[in] controllers list with controllers. | ||
* \param[in] strictness if value is equal "MANIPULATE_CONTROLLERS_CHAIN" then all preceding | ||
* controllers will be automatically added to the deactivate request list. | ||
* \param[in] controller_it iterator to the controller for which the preceding controllers are | ||
* checked. | ||
* | ||
* \returns return_type::OK if all preceding controllers pass the checks, otherwise | ||
* return_type::ERROR. | ||
*/ | ||
controller_interface::return_type check_preceeding_controllers_for_deactivate( | ||
const std::vector<ControllerSpec> & controllers, int strictness, | ||
const ControllersListIterator controller_it); | ||
|
||
std::shared_ptr<rclcpp::Executor> executor_; | ||
|
||
|
@@ -366,6 +453,7 @@ class ControllerManager : public rclcpp::Node | |
set_hardware_component_state_service_; | ||
|
||
std::vector<std::string> start_request_, stop_request_; | ||
std::vector<std::string> to_chained_mode_request_, from_chained_mode_request_; | ||
std::vector<std::string> start_command_interface_request_, stop_command_interface_request_; | ||
|
||
struct SwitchParams | ||
|
Uh oh!
There was an error while loading. Please reload this page.