-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from husarion/ros2-manager-plugins
ROS 2 manager plugins
- Loading branch information
Showing
32 changed files
with
2,744 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(panther_manager) | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
set(PACKAGE_INCLUDE_DEPENDS | ||
ament_cmake | ||
rclcpp | ||
rclcpp_action | ||
ament_index_cpp | ||
behaviortree_cpp | ||
std_srvs | ||
panther_msgs | ||
libssh | ||
yaml-cpp | ||
behaviortree_ros2 | ||
panther_utils) | ||
|
||
foreach(Dependency IN ITEMS ${PACKAGE_INCLUDE_DEPENDS}) | ||
find_package(${Dependency} REQUIRED) | ||
endforeach() | ||
|
||
include_directories(include) | ||
|
||
add_library(call_set_bool_service_node SHARED | ||
plugins/action/call_set_bool_service_node.cpp) | ||
list(APPEND plugin_libs call_set_bool_service_node) | ||
|
||
add_library(call_trigger_service_node SHARED | ||
plugins/action/call_trigger_service_node.cpp) | ||
list(APPEND plugin_libs call_trigger_service_node) | ||
|
||
add_library(call_set_led_animation_service_node SHARED | ||
plugins/action/call_set_led_animation_service_node.cpp) | ||
list(APPEND plugin_libs call_set_led_animation_service_node) | ||
|
||
add_library(signal_shutdown_node SHARED plugins/action/signal_shutdown_node.cpp) | ||
list(APPEND plugin_libs signal_shutdown_node) | ||
|
||
add_library(shutdown_single_host_node SHARED | ||
plugins/action/shutdown_single_host_node.cpp) | ||
target_link_libraries(shutdown_single_host_node ssh) | ||
list(APPEND plugin_libs shutdown_single_host_node) | ||
|
||
add_library(shutdown_hosts_from_file_node SHARED | ||
plugins/action/shutdown_hosts_from_file_node.cpp) | ||
target_link_libraries(shutdown_hosts_from_file_node ssh yaml-cpp) | ||
list(APPEND plugin_libs shutdown_hosts_from_file_node) | ||
|
||
add_library(tick_after_timeout_node SHARED | ||
plugins/decorator/tick_after_timeout_node.cpp) | ||
list(APPEND plugin_libs tick_after_timeout_node) | ||
|
||
foreach(bt_node ${plugin_libs}) | ||
target_compile_definitions(${bt_node} PRIVATE BT_PLUGIN_EXPORT) | ||
ament_target_dependencies(${bt_node} ${PACKAGE_INCLUDE_DEPENDS}) | ||
endforeach() | ||
|
||
if(BUILD_TESTING) | ||
find_package(ament_cmake_gtest REQUIRED) | ||
|
||
add_library(${PROJECT_NAME}_test_plugin_utils | ||
test/plugins/src/plugin_test_utils.cpp) | ||
target_include_directories(${PROJECT_NAME}_test_plugin_utils | ||
PUBLIC test/plugins/include) | ||
|
||
target_link_libraries( | ||
${PROJECT_NAME}_test_plugin_utils | ||
call_set_bool_service_node | ||
call_trigger_service_node | ||
call_set_led_animation_service_node | ||
signal_shutdown_node | ||
shutdown_single_host_node | ||
shutdown_hosts_from_file_node | ||
tick_after_timeout_node) | ||
|
||
ament_target_dependencies(${PROJECT_NAME}_test_plugin_utils | ||
${PACKAGE_INCLUDE_DEPENDS}) | ||
|
||
ament_add_gtest(${PROJECT_NAME}_test_call_set_bool_service_node | ||
test/plugins/test_call_set_bool_service_node.cpp) | ||
list(APPEND plugin_tests ${PROJECT_NAME}_test_call_set_bool_service_node) | ||
|
||
ament_add_gtest(${PROJECT_NAME}_test_call_trigger_service_node | ||
test/plugins/test_call_trigger_service_node.cpp) | ||
list(APPEND plugin_tests ${PROJECT_NAME}_test_call_trigger_service_node) | ||
|
||
ament_add_gtest(${PROJECT_NAME}_test_call_set_led_animation_service_node | ||
test/plugins/test_call_set_led_animation_service_node.cpp) | ||
list(APPEND plugin_tests | ||
${PROJECT_NAME}_test_call_set_led_animation_service_node) | ||
|
||
ament_add_gtest(${PROJECT_NAME}_test_signal_shutdown_node | ||
test/plugins/test_signal_shutdown_node.cpp) | ||
list(APPEND plugin_tests ${PROJECT_NAME}_test_signal_shutdown_node) | ||
|
||
ament_add_gtest(${PROJECT_NAME}_test_shutdown_single_host_node | ||
test/plugins/test_shutdown_single_host_node.cpp) | ||
list(APPEND plugin_tests ${PROJECT_NAME}_test_shutdown_single_host_node) | ||
|
||
ament_add_gtest(${PROJECT_NAME}_test_shutdown_hosts_from_file_node | ||
test/plugins/test_shutdown_hosts_from_file_node.cpp) | ||
list(APPEND plugin_tests ${PROJECT_NAME}_test_shutdown_hosts_from_file_node) | ||
|
||
ament_add_gtest(${PROJECT_NAME}_test_tick_after_timeout_node | ||
test/plugins/test_tick_after_timeout_node.cpp) | ||
list(APPEND plugin_tests ${PROJECT_NAME}_test_tick_after_timeout_node) | ||
|
||
ament_add_gtest(${PROJECT_NAME}_test_shutdown_host | ||
test/plugins/test_shutdown_host.cpp) | ||
list(APPEND plugin_tests ${PROJECT_NAME}_test_shutdown_host) | ||
|
||
ament_add_gtest(${PROJECT_NAME}_test_shutdown_hosts_node | ||
test/plugins/test_shutdown_hosts_node.cpp) | ||
list(APPEND plugin_tests ${PROJECT_NAME}_test_shutdown_hosts_node) | ||
|
||
foreach(bt_node_test ${plugin_tests}) | ||
target_link_libraries(${bt_node_test} ${PROJECT_NAME}_test_plugin_utils) | ||
ament_target_dependencies(${bt_node_test} ${PACKAGE_INCLUDE_DEPENDS}) | ||
endforeach() | ||
endif() | ||
|
||
install(TARGETS DESTINATION lib/${PROJECT_NAME}) | ||
|
||
ament_export_include_directories(include) | ||
ament_export_dependencies(${PACKAGE_INCLUDE_DEPENDS}) | ||
|
||
ament_package() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Testing | ||
|
||
For testing you have to copy authenticate ssh key on the localhost: | ||
|
||
```bash | ||
ssh-copy-id -f husarion@localhost | ||
``` |
48 changes: 48 additions & 0 deletions
48
panther_manager/include/panther_manager/plugins/action/call_set_bool_service_node.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2024 Husarion sp. z o.o. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef PANTHER_MANAGER_CALL_SET_BOOL_SERVICE_NODE_HPP_ | ||
#define PANTHER_MANAGER_CALL_SET_BOOL_SERVICE_NODE_HPP_ | ||
|
||
#include <string> | ||
|
||
#include <behaviortree_ros2/bt_service_node.hpp> | ||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <std_srvs/srv/set_bool.hpp> | ||
|
||
namespace panther_manager | ||
{ | ||
|
||
class CallSetBoolService : public BT::RosServiceNode<std_srvs::srv::SetBool> | ||
{ | ||
public: | ||
CallSetBoolService( | ||
const std::string & name, const BT::NodeConfig & conf, const BT::RosNodeParams & params) | ||
: BT::RosServiceNode<std_srvs::srv::SetBool>(name, conf, params) | ||
{ | ||
} | ||
|
||
static BT::PortsList providedPorts() | ||
{ | ||
return providedBasicPorts({BT::InputPort<bool>("data", "true / false value")}); | ||
} | ||
|
||
virtual bool setRequest(typename Request::SharedPtr & request) override; | ||
virtual BT::NodeStatus onResponseReceived(const typename Response::SharedPtr & response) override; | ||
}; | ||
|
||
} // namespace panther_manager | ||
|
||
#endif // PANTHER_MANAGER_CALL_SET_BOOL_SERVICE_NODE_HPP_ |
52 changes: 52 additions & 0 deletions
52
...er_manager/include/panther_manager/plugins/action/call_set_led_animation_service_node.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2024 Husarion sp. z o.o. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef PANTHER_MANAGER_CALL_SET_LED_ANIMATION_SERVICE_NODE_HPP_ | ||
#define PANTHER_MANAGER_CALL_SET_LED_ANIMATION_SERVICE_NODE_HPP_ | ||
|
||
#include <string> | ||
|
||
#include <behaviortree_ros2/bt_service_node.hpp> | ||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <panther_msgs/srv/set_led_animation.hpp> | ||
|
||
namespace panther_manager | ||
{ | ||
|
||
class CallSetLedAnimationService : public BT::RosServiceNode<panther_msgs::srv::SetLEDAnimation> | ||
{ | ||
public: | ||
CallSetLedAnimationService( | ||
const std::string & name, const BT::NodeConfig & conf, const BT::RosNodeParams & params) | ||
: BT::RosServiceNode<panther_msgs::srv::SetLEDAnimation>(name, conf, params) | ||
{ | ||
} | ||
|
||
static BT::PortsList providedPorts() | ||
{ | ||
return providedBasicPorts({ | ||
BT::InputPort<unsigned>("id", "animation ID"), | ||
BT::InputPort<std::string>("param", "optional parameter"), | ||
BT::InputPort<bool>("repeating", "indicates if animation should repeat"), | ||
}); | ||
} | ||
|
||
virtual bool setRequest(typename Request::SharedPtr & request) override; | ||
virtual BT::NodeStatus onResponseReceived(const typename Response::SharedPtr & response) override; | ||
}; | ||
|
||
} // namespace panther_manager | ||
|
||
#endif // PANTHER_MANAGER_CALL_SET_LED_ANIMATION_SERVICE_NODE_HPP_ |
45 changes: 45 additions & 0 deletions
45
panther_manager/include/panther_manager/plugins/action/call_trigger_service_node.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2024 Husarion sp. z o.o. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef PANTHER_MANAGER_CALL_TRIGGER_SERVICE_NODE_HPP_ | ||
#define PANTHER_MANAGER_CALL_TRIGGER_SERVICE_NODE_HPP_ | ||
|
||
#include <string> | ||
|
||
#include <behaviortree_ros2/bt_service_node.hpp> | ||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <std_srvs/srv/trigger.hpp> | ||
|
||
namespace panther_manager | ||
{ | ||
|
||
class CallTriggerService : public BT::RosServiceNode<std_srvs::srv::Trigger> | ||
{ | ||
public: | ||
CallTriggerService( | ||
const std::string & name, const BT::NodeConfig & conf, const BT::RosNodeParams & params) | ||
: BT::RosServiceNode<std_srvs::srv::Trigger>(name, conf, params) | ||
{ | ||
} | ||
|
||
static BT::PortsList providedPorts() { return providedBasicPorts({}); } | ||
|
||
virtual bool setRequest(typename Request::SharedPtr & /*request*/) override; | ||
virtual BT::NodeStatus onResponseReceived(const typename Response::SharedPtr & response) override; | ||
}; | ||
|
||
} // namespace panther_manager | ||
|
||
#endif // PANTHER_MANAGER_CALL_SET_BOOL_SERVICE_NODE_HPP_ |
54 changes: 54 additions & 0 deletions
54
panther_manager/include/panther_manager/plugins/action/shutdown_hosts_from_file_node.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2024 Husarion sp. z o.o. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef PANTHER_MANAGER_SHUTDOWN_HOST_FROM_FILE_NODE_HPP_ | ||
#define PANTHER_MANAGER_SHUTDOWN_HOST_FROM_FILE_NODE_HPP_ | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include <behaviortree_cpp/basic_types.h> | ||
#include <yaml-cpp/yaml.h> | ||
|
||
#include <panther_manager/plugins/shutdown_host.hpp> | ||
#include <panther_manager/plugins/shutdown_hosts_node.hpp> | ||
#include <panther_utils/yaml_utils.hpp> | ||
|
||
namespace panther_manager | ||
{ | ||
|
||
class ShutdownHostsFromFile : public ShutdownHosts | ||
{ | ||
public: | ||
ShutdownHostsFromFile(const std::string & name, const BT::NodeConfig & conf) | ||
: ShutdownHosts(name, conf) | ||
{ | ||
} | ||
|
||
static BT::PortsList providedPorts() | ||
{ | ||
return { | ||
BT::InputPort<std::string>( | ||
"shutdown_hosts_file", "global path to YAML file with hosts to shutdown"), | ||
}; | ||
} | ||
|
||
private: | ||
bool UpdateHosts(std::vector<std::shared_ptr<ShutdownHost>> & hosts) override; | ||
}; | ||
|
||
} // namespace panther_manager | ||
|
||
#endif // PANTHER_MANAGER_SHUTDOWN_HOST_FROM_FILE_NODE_HPP_ |
Oops, something went wrong.