-
Notifications
You must be signed in to change notification settings - Fork 347
[CM] Add controller_manager activity topic #2006
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
29c81a8
76976bf
d6c8cf8
df01691
ed19d63
65faf4f
6768145
e975db7
8c23873
c6ee487
934e4fd
61ee0c4
7952d89
27af6fe
73aac52
d76302f
a2b07d9
0aa3494
c81ea41
5641d8d
30e8c2c
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 |
---|---|---|
|
@@ -373,6 +373,14 @@ bool ControllerManager::shutdown_controllers() | |
|
||
void ControllerManager::init_controller_manager() | ||
{ | ||
controller_manager_activity_publisher_ = | ||
create_publisher<controller_manager_msgs::msg::ControllerManagerActivity>( | ||
"~/activity", rclcpp::QoS(1).reliable().transient_local()); | ||
rt_controllers_wrapper_.set_on_switch_callback( | ||
std::bind(&ControllerManager::publish_activity, this)); | ||
resource_manager_->set_on_component_state_switch_callback( | ||
std::bind(&ControllerManager::publish_activity, this)); | ||
Comment on lines
+381
to
+382
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. I understand that this is easier to integrate now but shouldn't we simply make these part of the constructors? 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. Sure, when we branch off, we will certainly do that :) |
||
|
||
// Get parameters needed for RT "update" loop to work | ||
if (is_resource_manager_initialized()) | ||
{ | ||
|
@@ -2695,6 +2703,8 @@ controller_interface::return_type ControllerManager::update( | |
{ | ||
activate_controllers(rt_controller_list, rt_buffer_.fallback_controllers_list); | ||
} | ||
// To publish the activity of the failing controllers and the fallback controllers | ||
publish_activity(); | ||
} | ||
|
||
// there are controllers to (de)activate | ||
|
@@ -2784,6 +2794,17 @@ void ControllerManager::RTControllerListWrapper::switch_updated_list( | |
int former_current_controllers_list_ = updated_controllers_index_; | ||
updated_controllers_index_ = get_other_list(former_current_controllers_list_); | ||
wait_until_rt_not_using(former_current_controllers_list_); | ||
if (on_switch_callback_) | ||
{ | ||
on_switch_callback_(); | ||
} | ||
} | ||
|
||
void ControllerManager::RTControllerListWrapper::set_on_switch_callback( | ||
std::function<void()> callback) | ||
{ | ||
std::lock_guard<std::recursive_mutex> guard(controllers_lock_); | ||
on_switch_callback_ = callback; | ||
} | ||
|
||
int ControllerManager::RTControllerListWrapper::get_other_list(int index) const | ||
|
@@ -3231,6 +3252,38 @@ ControllerManager::check_fallback_controllers_state_pre_activation( | |
return controller_interface::return_type::OK; | ||
} | ||
|
||
void ControllerManager::publish_activity() | ||
{ | ||
controller_manager_msgs::msg::ControllerManagerActivity status_msg; | ||
status_msg.header.stamp = get_clock()->now(); | ||
{ | ||
// lock controllers | ||
std::lock_guard<std::recursive_mutex> guard(rt_controllers_wrapper_.controllers_lock_); | ||
const std::vector<ControllerSpec> & controllers = | ||
rt_controllers_wrapper_.get_updated_list(guard); | ||
for (const auto & controller : controllers) | ||
{ | ||
controller_manager_msgs::msg::NamedLifecycleState lifecycle_info; | ||
lifecycle_info.name = controller.info.name; | ||
lifecycle_info.state.id = controller.c->get_lifecycle_state().id(); | ||
lifecycle_info.state.label = controller.c->get_lifecycle_state().label(); | ||
status_msg.controllers.push_back(lifecycle_info); | ||
} | ||
} | ||
{ | ||
const auto hw_components_info = resource_manager_->get_components_status(); | ||
for (const auto & [component_name, component_info] : hw_components_info) | ||
{ | ||
controller_manager_msgs::msg::NamedLifecycleState lifecycle_info; | ||
lifecycle_info.name = component_name; | ||
lifecycle_info.state.id = component_info.state.id(); | ||
lifecycle_info.state.label = component_info.state.label(); | ||
status_msg.hardware_components.push_back(lifecycle_info); | ||
} | ||
} | ||
controller_manager_activity_publisher_->publish(status_msg); | ||
} | ||
|
||
void ControllerManager::controller_activity_diagnostic_callback( | ||
diagnostic_updater::DiagnosticStatusWrapper & stat) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This message is used to provide the activity within the controller manager regarding the change in state of controllers and hardware interfaces | ||
|
||
# The header is used to provide timestamp information | ||
std_msgs/Header header | ||
|
||
# The current state of the controllers | ||
NamedLifecycleState[] controllers | ||
|
||
# The current state of the hardware components | ||
NamedLifecycleState[] hardware_components |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This message is used to provide information about the lifecycle state of the controller or the hardware components | ||
|
||
# The name of the controller or hardware interface | ||
string name | ||
|
||
# The current lifecycle state of the controller or hardware components | ||
lifecycle_msgs/State state |
Uh oh!
There was an error while loading. Please reload this page.