From eda1ea1c452bcae03a675524854fbe66b49dafda Mon Sep 17 00:00:00 2001 From: Jakub Delicat Date: Fri, 20 Dec 2024 03:06:39 +0000 Subject: [PATCH] Remove accident panther_manager Signed-off-by: Jakub Delicat --- .../plugins/condition/test_check_bool_msg.cpp | 102 ---------- .../plugins/condition/test_check_joy_msg.cpp | 186 ------------------ 2 files changed, 288 deletions(-) delete mode 100644 panther_manager/test/plugins/condition/test_check_bool_msg.cpp delete mode 100644 panther_manager/test/plugins/condition/test_check_joy_msg.cpp diff --git a/panther_manager/test/plugins/condition/test_check_bool_msg.cpp b/panther_manager/test/plugins/condition/test_check_bool_msg.cpp deleted file mode 100644 index c4cfc7cd3..000000000 --- a/panther_manager/test/plugins/condition/test_check_bool_msg.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// 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. - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include "panther_manager/plugins/condition/check_bool_msg.hpp" -#include "utils/plugin_test_utils.hpp" - -using BoolMsg = std_msgs::msg::Bool; -using bt_ports = std::map; - -struct TestCase -{ - BT::NodeStatus result; - bt_ports input; - BoolMsg msg; -}; - -constexpr auto TOPIC = "bool"; -constexpr auto PLUGIN = "CheckBoolMsg"; - -class TestCheckBoolMsg : public panther_manager::plugin_test_utils::PluginTestUtils -{ -public: - TestCheckBoolMsg(); - BoolMsg CreateMsg(bool data); - void PublishMsg(BoolMsg msg) { publisher_->publish(msg); } - -protected: - rclcpp::Publisher::SharedPtr publisher_; -}; - -TestCheckBoolMsg::TestCheckBoolMsg() -{ - RegisterNodeWithParams(PLUGIN); - publisher_ = bt_node_->create_publisher(TOPIC, 10); -} - -BoolMsg TestCheckBoolMsg::CreateMsg(bool data) -{ - BoolMsg msg; - msg.data = data; - return msg; -} - -TEST_F(TestCheckBoolMsg, NoMessageArrived) -{ - bt_ports input = {{"topic_name", TOPIC}, {"data", "true"}}; - ASSERT_NO_THROW({ CreateTree(PLUGIN, input); }); - - auto & tree = GetTree(); - auto status = tree.tickWhileRunning(); - EXPECT_EQ(status, BT::NodeStatus::FAILURE); -} - -TEST_F(TestCheckBoolMsg, OnTickBehavior) -{ - std::vector test_cases = { - {BT::NodeStatus::SUCCESS, {{"topic_name", TOPIC}, {"data", "true"}}, CreateMsg(true)}, - {BT::NodeStatus::SUCCESS, {{"topic_name", TOPIC}, {"data", "false"}}, CreateMsg(false)}, - {BT::NodeStatus::FAILURE, {{"topic_name", TOPIC}, {"data", "true"}}, CreateMsg(false)}, - {BT::NodeStatus::FAILURE, {{"topic_name", TOPIC}, {"data", "false"}}, CreateMsg(true)}}; - - for (auto & test_case : test_cases) { - CreateTree(PLUGIN, test_case.input); - PublishMsg(test_case.msg); - - auto & tree = GetTree(); - auto status = tree.tickWhileRunning(); - - EXPECT_EQ(status, test_case.result); - } -} - -int main(int argc, char ** argv) -{ - testing::InitGoogleTest(&argc, argv); - auto result = RUN_ALL_TESTS(); - return result; -} diff --git a/panther_manager/test/plugins/condition/test_check_joy_msg.cpp b/panther_manager/test/plugins/condition/test_check_joy_msg.cpp deleted file mode 100644 index fe12ecece..000000000 --- a/panther_manager/test/plugins/condition/test_check_joy_msg.cpp +++ /dev/null @@ -1,186 +0,0 @@ -// 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. - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include "panther_manager/plugins/condition/check_joy_msg.hpp" -#include "utils/plugin_test_utils.hpp" - -using JoyMsg = sensor_msgs::msg::Joy; -using HeaderMsg = std_msgs::msg::Header; -using bt_ports = std::map; - -struct TestCase -{ - BT::NodeStatus result; - bt_ports input; - JoyMsg msg; -}; - -constexpr auto TOPIC = "joy"; -constexpr auto PLUGIN = "CheckJoyMsg"; - -class TestCheckJoyMsg : public panther_manager::plugin_test_utils::PluginTestUtils -{ -public: - TestCheckJoyMsg(); - void PublishMsg(JoyMsg msg) { joy_publisher_->publish(msg); }; - JoyMsg CreateMsg( - const std::vector & axes = {}, const std::vector & buttons = {}, - const HeaderMsg & header = HeaderMsg()); - void SetCurrentMsgTime(JoyMsg & header); - -protected: - rclcpp::Publisher::SharedPtr joy_publisher_; -}; - -TestCheckJoyMsg::TestCheckJoyMsg() -{ - RegisterNodeWithParams(PLUGIN); - joy_publisher_ = bt_node_->create_publisher(TOPIC, 10); -} - -JoyMsg TestCheckJoyMsg::CreateMsg( - const std::vector & axes, const std::vector & buttons, const HeaderMsg & header) -{ - JoyMsg msg; - msg.header = header; - msg.axes = axes; - msg.buttons = buttons; - return msg; -} - -void TestCheckJoyMsg::SetCurrentMsgTime(JoyMsg & msg) { msg.header.stamp = bt_node_->now(); } - -TEST_F(TestCheckJoyMsg, NoMessageArrived) -{ - bt_ports input = {{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}}; - ASSERT_NO_THROW({ CreateTree(PLUGIN, input); }); - - auto & tree = GetTree(); - auto status = tree.tickWhileRunning(); - EXPECT_EQ(status, BT::NodeStatus::FAILURE); -} - -TEST_F(TestCheckJoyMsg, TimeoutTests) -{ - std::vector test_cases = { - {BT::NodeStatus::SUCCESS, - {{"topic_name", TOPIC}, {"axes", ""}, {"buttons", ""}, {"timeout", "0.5"}}, - CreateMsg()}, - {BT::NodeStatus::SUCCESS, - {{"topic_name", TOPIC}, {"axes", ""}, {"buttons", ""}, {"timeout", "0.0"}}, - CreateMsg()}, - {BT::NodeStatus::SUCCESS, - {{"topic_name", TOPIC}, {"axes", ""}, {"buttons", ""}, {"timeout", "-0.5"}}, - CreateMsg()}, - {BT::NodeStatus::FAILURE, - {{"topic_name", TOPIC}, {"axes", ""}, {"buttons", ""}, {"timeout", "0.001"}}, - CreateMsg()}}; - - for (auto & test_case : test_cases) { - CreateTree(PLUGIN, test_case.input); - SetCurrentMsgTime(test_case.msg); - std::this_thread::sleep_for(std::chrono::milliseconds(2)); - PublishMsg(test_case.msg); - - auto & tree = GetTree(); - auto status = tree.tickWhileRunning(); - - EXPECT_EQ(status, test_case.result); - } -} - -TEST_F(TestCheckJoyMsg, OnTickBehavior) -{ - std::vector test_cases = { - {BT::NodeStatus::SUCCESS, - {{"topic_name", TOPIC}, {"axes", ""}, {"buttons", ""}, {"timeout", "1.0"}}, - CreateMsg()}, - {BT::NodeStatus::SUCCESS, - {{"topic_name", TOPIC}, {"axes", "1"}, {"buttons", ""}, {"timeout", "1.0"}}, - CreateMsg({1})}, - {BT::NodeStatus::SUCCESS, - {{"topic_name", TOPIC}, {"axes", ""}, {"buttons", "1"}, {"timeout", "1.0"}}, - CreateMsg({}, {1})}, - {BT::NodeStatus::SUCCESS, - {{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}}, - CreateMsg({0, 0}, {0, 0})}, - {BT::NodeStatus::SUCCESS, - {{"topic_name", TOPIC}, {"axes", "0.1;-0.2;1.0"}, {"buttons", "0;0;10;0"}, {"timeout", "1.0"}}, - CreateMsg({0.1, -0.2, 1.0}, {0, 0, 10, 0})}, - {BT::NodeStatus::SUCCESS, - {{"topic_name", TOPIC}, {"axes", "0.1;-0.2;1.0"}, {"buttons", ""}, {"timeout", "1.0"}}, - CreateMsg({0.1, -0.2, 1.0}, {0, 0, 10, 0})}, - {BT::NodeStatus::SUCCESS, - {{"topic_name", TOPIC}, {"axes", ""}, {"buttons", "0;0;10;0"}, {"timeout", "1.0"}}, - CreateMsg({0.1, -0.2, 1.0}, {0, 0, 10, 0})}, - {BT::NodeStatus::FAILURE, - {{"topic_name", TOPIC}, {"axes", "0.1;-0.2;1.0"}, {"buttons", "0;0;10;0"}, {"timeout", "1.0"}}, - CreateMsg({0.2, -0.2, 1.0}, {0, 0, 10, 0})}, - {BT::NodeStatus::FAILURE, - {{"topic_name", TOPIC}, {"axes", "0;0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}}, - CreateMsg({0, 0}, {0, 0})}, - {BT::NodeStatus::FAILURE, - {{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0;0"}, {"timeout", "1.0"}}, - CreateMsg({0, 0}, {0, 0})}, - {BT::NodeStatus::FAILURE, - {{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}}, - CreateMsg({0, 0, 0}, {0, 0})}, - {BT::NodeStatus::FAILURE, - {{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}}, - CreateMsg({0, 0}, {0, 0, 0})}, - {BT::NodeStatus::FAILURE, - {{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}}, - CreateMsg({0, 1}, {0, 0})}, - {BT::NodeStatus::FAILURE, - {{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}}, - CreateMsg({0, 0}, {0, 1})}, - {BT::NodeStatus::FAILURE, - {{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}}, - CreateMsg({1, 1}, {1, 1})}, - {BT::NodeStatus::FAILURE, - {{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0;0"}, {"timeout", "1.0"}}, - CreateMsg({1, 1}, {1, 1, 1})}}; - - for (auto & test_case : test_cases) { - CreateTree(PLUGIN, test_case.input); - SetCurrentMsgTime(test_case.msg); - PublishMsg(test_case.msg); - - auto & tree = GetTree(); - auto status = tree.tickWhileRunning(); - - EXPECT_EQ(status, test_case.result); - } -} - -int main(int argc, char ** argv) -{ - testing::InitGoogleTest(&argc, argv); - auto result = RUN_ALL_TESTS(); - return result; -}