Skip to content
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

Ros2 manager plugins #232

Merged
merged 36 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7561800
added behaviortree_ros2 to the repository because it is not in rosped
delihus Feb 15, 2024
067feb5
added set bool service
delihus Feb 15, 2024
411d328
added set bool service
delihus Feb 15, 2024
da67b2e
Added trigger service call plugin
delihus Feb 15, 2024
85f4d65
Added full call_set_bool plugin test
delihus Feb 19, 2024
bed1fbe
Added trigger tests
delihus Feb 19, 2024
7a5d74c
Added tests for set animation plugin
delihus Feb 19, 2024
f933e45
Added explicite casts
delihus Feb 19, 2024
35ddb1e
Moved pluigns to actions | added shutdown plugins
delihus Feb 20, 2024
d84870b
Removed different types of building behavio tree
delihus Feb 20, 2024
4da02fa
Fixed building trigger
delihus Feb 20, 2024
8512745
Added tests for signal shutdown plugin
delihus Feb 20, 2024
93995d2
added test single plugin
delihus Feb 22, 2024
a4f9051
added test for single host plugin
delihus Feb 26, 2024
450b3bd
Revert "added test for single host plugin"
delihus Feb 26, 2024
bd066b3
Fixed tesT
delihus Feb 26, 2024
5b22b39
tested on the robot
delihus Feb 26, 2024
75337ad
typo
delihus Feb 26, 2024
0e21029
Added TickAfterTimeout
delihus Feb 28, 2024
428d201
reverted panther_gazebo
delihus Mar 6, 2024
32ec819
added tests for tick_after_timeout
delihus Mar 6, 2024
f498161
Merge remote-tracking branch 'origin/ros2-devel' into ros2-manager-pl…
delihus Mar 15, 2024
3f58a58
Added package suggestions without tests
delihus Mar 15, 2024
8295f4c
Changed utils names and moved start stop to constructor and destructor
delihus Mar 15, 2024
ea26a37
applied panther_utils
delihus Mar 15, 2024
d975d61
Made fixed commit for behaviortreee | templated create service funct…
delihus Mar 20, 2024
98d6d69
Added RegisterNode template function
delihus Mar 20, 2024
67c3182
Changed tests' names to PascalCase | added testing::TempDir() | Start…
delihus Mar 20, 2024
f59ab95
fixed tests
delihus Mar 20, 2024
e1b040a
fixed tick after timeout node
delihus Mar 21, 2024
7084b46
fixed user to username | added test_shutdown_host
delihus Mar 22, 2024
40a5d44
Added all suggestions
delihus Mar 22, 2024
ffe5c93
Add suggestions
delihus Mar 25, 2024
4af614e
Added shutdonw hosts node
delihus Mar 25, 2024
e4f9522
Fixed typo | cleaned up the test_shutdown_hosts_node
delihus Mar 25, 2024
115ddb7
fix tests
KmakD Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions panther/panther_hardware.repos
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ repositories:
type: git
url: https://github.com/husarion/husarion_controllers
version: main
behaviortree_ros2:
type: git
url: https://github.com/BehaviorTree/BehaviorTree.ROS2
version: ce923e19c12d28f4734a41b1442c123f2d4a41d2
2 changes: 1 addition & 1 deletion panther_lights/test/test_image_animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TestImageAnimation : public testing::Test
~TestImageAnimation();

protected:
std::string test_image_path = "/tmp/test_image.png";
std::string test_image_path = testing::TempDir() + "/test_image.png";
std::unique_ptr<ImageAnimationWrapper> animation_;
};

Expand Down
122 changes: 122 additions & 0 deletions panther_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
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)

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()
7 changes: 7 additions & 0 deletions panther_manager/README.md
KmakD marked this conversation as resolved.
Show resolved Hide resolved
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
```
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_
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_
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_
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:
void update_hosts(std::vector<std::shared_ptr<ShutdownHost>> & hosts) override;
};

} // namespace panther_manager

#endif // PANTHER_MANAGER_SHUTDOWN_HOST_FROM_FILE_NODE_HPP_
Loading