diff --git a/src/control_manager/common/common.cpp b/src/control_manager/common/common.cpp index 3f015b9..6ccb525 100644 --- a/src/control_manager/common/common.cpp +++ b/src/control_manager/common/common.cpp @@ -1073,7 +1073,7 @@ Controller::HwApiOutputVariant initializeDefaultOutput(const ControlOutputModali std::visit(HwApiInitializeVisitor(), output, uav_state_var, min_throttle_var, n_motors_var); return output; -} // namespace mrs_uav_managers +} //} diff --git a/test/control_manager/CMakeLists.txt b/test/control_manager/CMakeLists.txt index 9742b50..a720e44 100644 --- a/test/control_manager/CMakeLists.txt +++ b/test/control_manager/CMakeLists.txt @@ -1,5 +1,7 @@ add_subdirectory(goto_service) +add_subdirectory(goto_fcu_service) + add_subdirectory(goto_relative_service) add_subdirectory(eland_control_error) diff --git a/test/control_manager/goto_fcu_service/CMakeLists.txt b/test/control_manager/goto_fcu_service/CMakeLists.txt new file mode 100644 index 0000000..bf8f985 --- /dev/null +++ b/test/control_manager/goto_fcu_service/CMakeLists.txt @@ -0,0 +1,16 @@ +get_filename_component(TEST_NAME "${CMAKE_CURRENT_SOURCE_DIR}" NAME) + +catkin_add_executable_with_gtest(test_${TEST_NAME} + test.cpp + ) + +target_link_libraries(test_${TEST_NAME} + ${catkin_LIBRARIES} + ) + +add_dependencies(test_${TEST_NAME} + ${${PROJECT_NAME}_EXPORTED_TARGETS} + ${catkin_EXPORTED_TARGETS} + ) + +add_rostest(${TEST_NAME}.test) diff --git a/test/control_manager/goto_fcu_service/goto_fcu_service.test b/test/control_manager/goto_fcu_service/goto_fcu_service.test new file mode 100644 index 0000000..604b743 --- /dev/null +++ b/test/control_manager/goto_fcu_service/goto_fcu_service.test @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/control_manager/goto_fcu_service/test.cpp b/test/control_manager/goto_fcu_service/test.cpp new file mode 100644 index 0000000..4566cce --- /dev/null +++ b/test/control_manager/goto_fcu_service/test.cpp @@ -0,0 +1,74 @@ +#include + +#include + +class Tester : public mrs_uav_testing::TestGeneric { + +public: + bool test(); +}; + +bool Tester::test() { + + std::shared_ptr uh; + + { + auto [uhopt, message] = getUAVHandler(_uav_name_); + + if (!uhopt) { + ROS_ERROR("[%s]: Failed obtain handler for '%s': '%s'", ros::this_node::getName().c_str(), _uav_name_.c_str(), message.c_str()); + return false; + } + + uh = uhopt.value(); + } + + { + auto [success, message] = uh->activateMidAir(); + + if (!success) { + ROS_ERROR("[%s]: midair activation failed with message: '%s'", ros::this_node::getName().c_str(), message.c_str()); + return false; + } + } + + { + auto [success, message] = uh->gotoFcu(3, 2, 1, 1); + + if (!success) { + ROS_ERROR("[%s]: goto_fcu failed with message: '%s'", ros::this_node::getName().c_str(), message.c_str()); + return false; + } + } + + this->sleep(5.0); + + if (uh->isFlyingNormally()) { + return true; + } else { + ROS_ERROR("[%s]: not flying normally", ros::this_node::getName().c_str()); + return false; + } +} + +TEST(TESTSuite, test) { + + Tester tester; + + bool result = tester.test(); + + if (result) { + GTEST_SUCCEED(); + } else { + GTEST_FAIL(); + } +} + +int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) { + + ros::init(argc, argv, "test"); + + testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +}