diff --git a/auv_control_demos/CHANGELOG.md b/auv_control_demos/CHANGELOG.md index 5144491..56a16eb 100644 --- a/auv_control_demos/CHANGELOG.md +++ b/auv_control_demos/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog for package auv_control_demos +## 0.3.0 (2025-06-07) + ## 0.2.1 (2025-06-03) - Updates the individual_controller and chained_controllers demos to use the diff --git a/auv_control_demos/package.xml b/auv_control_demos/package.xml index 4da428e..eec47da 100644 --- a/auv_control_demos/package.xml +++ b/auv_control_demos/package.xml @@ -3,7 +3,7 @@ auv_control_demos - 0.2.1 + 0.3.0 Example package that includes demos for using auv_controllers in individual and chained modes Colin Mitchell diff --git a/auv_control_msgs/CHANGELOG.md b/auv_control_msgs/CHANGELOG.md index bf7ce60..fb72d13 100644 --- a/auv_control_msgs/CHANGELOG.md +++ b/auv_control_msgs/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog for package auv_control_msgs +## 0.3.0 (2025-06-07) + ## 0.2.1 (2025-06-03) ## 0.2.0 (2025-05-03) diff --git a/auv_control_msgs/package.xml b/auv_control_msgs/package.xml index 6ca9806..effa430 100644 --- a/auv_control_msgs/package.xml +++ b/auv_control_msgs/package.xml @@ -1,8 +1,9 @@ + auv_control_msgs - 0.2.1 + 0.3.0 Custom messages for AUV controllers Rakesh Vivekanandan diff --git a/auv_controllers/CHANGELOG.md b/auv_controllers/CHANGELOG.md index c868f9e..3d19326 100644 --- a/auv_controllers/CHANGELOG.md +++ b/auv_controllers/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog for package auv_controllers +## 0.3.0 (2025-06-07) + +- Implements the controller coordinator + ## 0.2.1 (2025-06-03) - Fixes the auv_control_demos configurations diff --git a/auv_controllers/package.xml b/auv_controllers/package.xml index 0bddd3e..7021da3 100644 --- a/auv_controllers/package.xml +++ b/auv_controllers/package.xml @@ -3,7 +3,7 @@ auv_controllers - 0.2.1 + 0.3.0 Meta package for auv_controllers Evan Palmer diff --git a/controller_common/CHANGELOG.md b/controller_common/CHANGELOG.md index 9b65e0f..1811344 100644 --- a/controller_common/CHANGELOG.md +++ b/controller_common/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog for package controller_common +## 0.3.0 (2025-06-07) + ## 0.2.1 (2025-06-03) ## 0.2.0 (2025-05-03) diff --git a/controller_common/package.xml b/controller_common/package.xml index 1ca0cb1..7dfc607 100644 --- a/controller_common/package.xml +++ b/controller_common/package.xml @@ -3,7 +3,7 @@ controller_common - 0.2.1 + 0.3.0 Common interfaces for controllers used in this project Evan Palmer diff --git a/controller_coordinator/CHANGELOG.md b/controller_coordinator/CHANGELOG.md new file mode 100644 index 0000000..93baee0 --- /dev/null +++ b/controller_coordinator/CHANGELOG.md @@ -0,0 +1,6 @@ +# Changelog for package controller_coordinator + +## 0.3.0 (2025-06-07) + +- Implements a simple service endpoint for activating and deactivating a + control system. diff --git a/controller_coordinator/CMakeLists.txt b/controller_coordinator/CMakeLists.txt new file mode 100644 index 0000000..5c4b862 --- /dev/null +++ b/controller_coordinator/CMakeLists.txt @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 3.23) +project(controller_coordinator) + +if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +include(GNUInstallDirs) + +find_package(rclcpp REQUIRED) +find_package(controller_manager_msgs REQUIRED) +find_package(ament_cmake REQUIRED) +find_package(generate_parameter_library REQUIRED) +find_package(std_srvs REQUIRED) + +generate_parameter_library(controller_coordinator_parameters src/coordinator_parameters.yaml) + +add_executable(controller_coordinator) +target_sources(controller_coordinator PRIVATE src/coordinator.cpp) + +target_compile_features(controller_coordinator PUBLIC cxx_std_20) +target_link_libraries( + controller_coordinator + PUBLIC + controller_coordinator_parameters + rclcpp::rclcpp + ${controller_manager_msgs_TARGETS} + ${std_srvs_TARGETS} +) + +install( + TARGETS + controller_coordinator + controller_coordinator_parameters + DESTINATION + lib/controller_coordinator +) + +ament_package() diff --git a/controller_coordinator/LICENSE b/controller_coordinator/LICENSE new file mode 100644 index 0000000..30e8e2e --- /dev/null +++ b/controller_coordinator/LICENSE @@ -0,0 +1,17 @@ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/controller_coordinator/README.md b/controller_coordinator/README.md new file mode 100644 index 0000000..5a9a8f8 --- /dev/null +++ b/controller_coordinator/README.md @@ -0,0 +1,15 @@ +# Controller Coordinator + +The controller coordinator is a high-level interface for activating and +deactivating a control system. This is useful in scenarios where you want to +switch between a custom control framework and a company-provided control +framework. + +## Clients + +- controller_manager/set_hardware_component_state [controller_manager_msgs::srv::SetHardwareComponentState] +- controller_manager/switch_controller [controller_manager_msgs::srv::SwitchController] + +## Services + +- controller_coordinator/activate [std_srvs/srv/SetBool] diff --git a/controller_coordinator/package.xml b/controller_coordinator/package.xml new file mode 100644 index 0000000..8dc4261 --- /dev/null +++ b/controller_coordinator/package.xml @@ -0,0 +1,27 @@ + + + + + controller_coordinator + 0.3.0 + A high-level node used to load and activate/deactivate control systems + + Evan Palmer + MIT + + https://github.com/Robotic-Decision-Making-Lab/auv_controllers.git + https://github.com/Robotic-Decision-Making-Lab/auv_controllers/issues + + Evan Palmer + + ament_cmake + + rclcpp + std_srvs + controller_manager_msgs + generate_parameter_library + + + ament_cmake + + diff --git a/controller_coordinator/src/coordinator.cpp b/controller_coordinator/src/coordinator.cpp new file mode 100644 index 0000000..87bfe27 --- /dev/null +++ b/controller_coordinator/src/coordinator.cpp @@ -0,0 +1,170 @@ +// Copyright 2025, Evan Palmer +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include "coordinator.hpp" + +#include + +#include "lifecycle_msgs/msg/state.hpp" + +namespace coordinator +{ + +ControllerCoordinator::ControllerCoordinator() +: rclcpp::Node("controller_coordinator"), + activate_hardware_request_(std::make_shared()), + deactivate_hardware_request_(std::make_shared()), + activate_controllers_request_(std::make_shared()), + deactivate_controllers_request_(std::make_shared()) +{ + param_listener_ = std::make_shared(this->get_node_parameters_interface()); + params_ = param_listener_->get_params(); + + client_callback_group_ = this->create_callback_group(rclcpp::CallbackGroupType::Reentrant, true); + + // helper function used to wait for services to come up + // this will block indefinitely + auto wait_for_service = [this](const auto & client, const std::string & service_name) { + while (!client->wait_for_service(std::chrono::seconds(1))) { + RCLCPP_INFO(this->get_logger(), "Waiting for %s service to come up", service_name.c_str()); // NOLINT + } + RCLCPP_INFO(this->get_logger(), "%s service available", service_name.c_str()); // NOLINT + }; + + // create clients + const std::string hardware_service = "controller_manager/set_hardware_component_state"; + hardware_client_ = this->create_client( + hardware_service, rclcpp::ServicesQoS(), client_callback_group_); + wait_for_service(hardware_client_, hardware_service); + + const std::string switch_controller_name = "controller_manager/switch_controller"; + switch_controller_client_ = this->create_client( + switch_controller_name, rclcpp::ServicesQoS(), client_callback_group_); + wait_for_service(switch_controller_client_, switch_controller_name); + + // pre-configure the hardware activation/deactivation requests + activate_hardware_request_->name = params_.hardware_interface; + activate_hardware_request_->target_state.id = lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE; + + deactivate_hardware_request_->name = params_.hardware_interface; + deactivate_hardware_request_->target_state.id = lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE; + + // pre-configure the controller activation/deactivation requests + activate_controllers_request_->activate_controllers = params_.controller_sequence; + activate_controllers_request_->strictness = controller_manager_msgs::srv::SwitchController::Request::STRICT; + activate_controllers_request_->activate_asap = true; + activate_controllers_request_->timeout = rclcpp::Duration::from_seconds(params_.timeout); + + deactivate_controllers_request_->deactivate_controllers = params_.controller_sequence; + deactivate_controllers_request_->strictness = controller_manager_msgs::srv::SwitchController::Request::STRICT; + deactivate_controllers_request_->activate_asap = true; + deactivate_controllers_request_->timeout = rclcpp::Duration::from_seconds(params_.timeout); + + // create a service endpoint for users to activate or deactivate their system + service_callback_group_ = this->create_callback_group(rclcpp::CallbackGroupType::Reentrant, true); + activate_system_service_ = this->create_service( + "~/activate", + [this]( + const std::shared_ptr /*request_header*/, + const std::shared_ptr request, + const std::shared_ptr response) { + response->success = true; + if (request->data) { + RCLCPP_INFO(this->get_logger(), "Activating thruster hardware interface and controllers"); // NOLINT + + // activate the hardware interface + hardware_client_->async_send_request( + activate_hardware_request_, + [this, &response]( + rclcpp::Client::SharedFuture result_response) { + const auto & result = result_response.get(); + if (result->ok) { + RCLCPP_INFO(this->get_logger(), "Successfully activated thruster hardware interface"); // NOLINT + } else { + RCLCPP_ERROR(this->get_logger(), "Failed to activate thruster hardware interface"); // NOLINT + response->success = false; + response->message = "Failed to activate thruster hardware interface"; + } + }); + + // activate the controllers + switch_controller_client_->async_send_request( + activate_controllers_request_, + [this, + &response](rclcpp::Client::SharedFuture result_response) { + const auto & result = result_response.get(); + if (result->ok) { + RCLCPP_INFO(this->get_logger(), "Successfully activated controllers"); // NOLINT + } else { + RCLCPP_ERROR(this->get_logger(), "Failed to activate controllers"); // NOLINT + response->success = false; + response->message = "Failed to activate controllers"; + } + }); + } else { + RCLCPP_INFO(this->get_logger(), "Deactivating controllers and thruster hardware interface"); // NOLINT + + // deactivate the hardware interface + hardware_client_->async_send_request( + deactivate_hardware_request_, + [this, &response]( + rclcpp::Client::SharedFuture result_response) { + const auto & result = result_response.get(); + if (result->ok) { + RCLCPP_INFO(this->get_logger(), "Successfully deactivated thruster hardware interface"); // NOLINT + } else { + RCLCPP_ERROR(this->get_logger(), "Failed to deactivate thruster hardware interface"); // NOLINT + response->success = false; + response->message = "Failed to deactivate thruster hardware interface"; + } + }); + + // deactivate the controllers + switch_controller_client_->async_send_request( + deactivate_controllers_request_, + [this, + &response](rclcpp::Client::SharedFuture result_response) { + const auto & result = result_response.get(); + if (result->ok) { + RCLCPP_INFO(this->get_logger(), "Successfully deactivated controllers"); // NOLINT + } else { + RCLCPP_ERROR(this->get_logger(), "Failed to deactivate controllers"); // NOLINT + response->success = false; + response->message = "Failed to deactivate controllers"; + } + }); + } + }, + rclcpp::ServicesQoS(), + service_callback_group_); +} + +} // namespace coordinator + +auto main(int argc, char * argv[]) -> int +{ + rclcpp::init(argc, argv); + rclcpp::executors::MultiThreadedExecutor executor; + auto node = std::make_shared(); + executor.add_node(node->get_node_base_interface()); + executor.spin(); + rclcpp::shutdown(); + return 0; +} diff --git a/controller_coordinator/src/coordinator.hpp b/controller_coordinator/src/coordinator.hpp new file mode 100644 index 0000000..cc37083 --- /dev/null +++ b/controller_coordinator/src/coordinator.hpp @@ -0,0 +1,70 @@ +// Copyright 2025, Evan Palmer +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include "controller_manager_msgs/srv/configure_controller.hpp" +#include "controller_manager_msgs/srv/list_controllers.hpp" +#include "controller_manager_msgs/srv/load_controller.hpp" +#include "controller_manager_msgs/srv/set_hardware_component_state.hpp" +#include "controller_manager_msgs/srv/switch_controller.hpp" +#include "controller_manager_msgs/srv/unload_controller.hpp" +#include "rclcpp/rclcpp.hpp" +#include "std_srvs/srv/set_bool.hpp" + +// auto-generated by generate_parameter_library +#include + +namespace coordinator +{ + +class ControllerCoordinator : public rclcpp::Node +{ +public: + ControllerCoordinator(); + + ~ControllerCoordinator() override = default; + +private: + // we need clients to: + // 1. activate/deactivate the hardware + // 2. activate/deactivate the controllers + std::shared_ptr> hardware_client_; + std::shared_ptr> switch_controller_client_; + + // create a user-facing service that will allow users to activate/deactivate the hardware and all controllers + std::shared_ptr> activate_system_service_; + + // pre-configure the activate/deactivate service messages + // these won't change, so we can set them up once + std::shared_ptr activate_hardware_request_; + std::shared_ptr deactivate_hardware_request_; + std::shared_ptr activate_controllers_request_; + std::shared_ptr deactivate_controllers_request_; + + std::shared_ptr param_listener_; + controller_coordinator::Params params_; + + // we need separate callback groups for the clients and service + std::shared_ptr service_callback_group_; + std::shared_ptr client_callback_group_; +}; + +} // namespace coordinator diff --git a/controller_coordinator/src/coordinator_parameters.yaml b/controller_coordinator/src/coordinator_parameters.yaml new file mode 100644 index 0000000..f932f7e --- /dev/null +++ b/controller_coordinator/src/coordinator_parameters.yaml @@ -0,0 +1,21 @@ +controller_coordinator: + hardware_interface: + type: string + description: The name of the hardware interface to activate/deactivate. + default_value: "" + + controller_sequence: + type: string_array + description: An ordered list of controllers to activate/deactivate. + default_value: [] + + timeout: + type: double + description: The timeout (s) for activating/deactivating controllers. + default_value: 5.0 + + max_attempts: + type: int + description: > + The maximum number of attempts to activate/deactivate the controllers. + default_value: 3 diff --git a/end_effector_trajectory_controller/CHANGELOG.md b/end_effector_trajectory_controller/CHANGELOG.md index a30279d..f17bccc 100644 --- a/end_effector_trajectory_controller/CHANGELOG.md +++ b/end_effector_trajectory_controller/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog for package controller_common +## 0.3.0 (2025-06-07) + ## 0.2.1 (2025-06-03) ## 0.2.0 (2025-05-03) diff --git a/end_effector_trajectory_controller/package.xml b/end_effector_trajectory_controller/package.xml index 3cc36fc..3d28221 100644 --- a/end_effector_trajectory_controller/package.xml +++ b/end_effector_trajectory_controller/package.xml @@ -3,7 +3,7 @@ end_effector_trajectory_controller - 0.2.1 + 0.3.0 End effector trajectory tracking controller for UVMS control Evan Palmer diff --git a/ik_solvers/CHANGELOG.md b/ik_solvers/CHANGELOG.md index b829884..f5c4b1b 100644 --- a/ik_solvers/CHANGELOG.md +++ b/ik_solvers/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog for package ik_solvers +## 0.3.0 (2025-06-07) + ## 0.2.1 (2025-06-03) ## 0.2.0 (2025-05-03) diff --git a/ik_solvers/package.xml b/ik_solvers/package.xml index d788e50..20d6824 100644 --- a/ik_solvers/package.xml +++ b/ik_solvers/package.xml @@ -3,7 +3,7 @@ ik_solvers - 0.2.1 + 0.3.0 Inverse kinematics solvers used for whole-body control Evan Palmer diff --git a/thruster_allocation_matrix_controller/CHANGELOG.md b/thruster_allocation_matrix_controller/CHANGELOG.md index a6f27e5..a12c4c6 100644 --- a/thruster_allocation_matrix_controller/CHANGELOG.md +++ b/thruster_allocation_matrix_controller/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog for package thruster_allocation_matrix_controller +## 0.3.0 (2025-06-07) + ## 0.2.1 (2025-06-03) ## 0.2.0 (2025-05-03) diff --git a/thruster_allocation_matrix_controller/package.xml b/thruster_allocation_matrix_controller/package.xml index 8c02b63..eacf7e8 100644 --- a/thruster_allocation_matrix_controller/package.xml +++ b/thruster_allocation_matrix_controller/package.xml @@ -3,7 +3,7 @@ thruster_allocation_matrix_controller - 0.2.1 + 0.3.0 Thruster allocation matrix controller used to convert wrench commands into thrust commands Evan Palmer diff --git a/thruster_controllers/CHANGELOG.md b/thruster_controllers/CHANGELOG.md index 71b3e38..eac65f5 100644 --- a/thruster_controllers/CHANGELOG.md +++ b/thruster_controllers/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog for package thruster_controllers +## 0.3.0 (2025-06-07) + ## 0.2.1 (2025-06-03) ## 0.2.0 (2025-05-03) diff --git a/thruster_controllers/package.xml b/thruster_controllers/package.xml index 965421d..edfa124 100644 --- a/thruster_controllers/package.xml +++ b/thruster_controllers/package.xml @@ -3,7 +3,7 @@ thruster_controllers - 0.2.1 + 0.3.0 A collection of thruster controllers for AUV control Evan Palmer diff --git a/topic_sensors/CHANGELOG.md b/topic_sensors/CHANGELOG.md index 3b39871..918e00c 100644 --- a/topic_sensors/CHANGELOG.md +++ b/topic_sensors/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog for package topic_sensors +## 0.3.0 (2025-06-07) + ## 0.2.1 (2025-06-03) ## 0.2.0 (2025-05-03) diff --git a/topic_sensors/package.xml b/topic_sensors/package.xml index 19a21c9..707cdb1 100644 --- a/topic_sensors/package.xml +++ b/topic_sensors/package.xml @@ -3,7 +3,7 @@ topic_sensors - 0.2.1 + 0.3.0 Sensor plugins used to write ROS 2 messages to state interfaces Evan Palmer diff --git a/velocity_controllers/CHANGELOG.md b/velocity_controllers/CHANGELOG.md index 16f54a0..5d0da7b 100644 --- a/velocity_controllers/CHANGELOG.md +++ b/velocity_controllers/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog for package velocity_controllers +## 0.3.0 (2025-06-07) + ## 0.2.1 (2025-06-03) ## 0.2.0 (2025-05-03) diff --git a/velocity_controllers/package.xml b/velocity_controllers/package.xml index 09dae57..f4f4947 100644 --- a/velocity_controllers/package.xml +++ b/velocity_controllers/package.xml @@ -3,7 +3,7 @@ velocity_controllers - 0.2.1 + 0.3.0 A collection of velocity controllers for underwater vehicles Evan Palmer diff --git a/whole_body_controllers/CHANGELOG.md b/whole_body_controllers/CHANGELOG.md index 2fdcbb6..8f3fbf6 100644 --- a/whole_body_controllers/CHANGELOG.md +++ b/whole_body_controllers/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog for package whole_body_controllers +## 0.3.0 (2025-06-07) + ## 0.2.1 (2025-06-03) ## 0.2.0 (2025-05-03) diff --git a/whole_body_controllers/package.xml b/whole_body_controllers/package.xml index 6342cea..d5c5866 100644 --- a/whole_body_controllers/package.xml +++ b/whole_body_controllers/package.xml @@ -3,7 +3,7 @@ whole_body_controllers - 0.2.1 + 0.3.0 Whole-body controllers for underwater vehicle manipulator systems Evan Palmer