diff --git a/test/compile_tests.sh b/test/compile_tests.sh index efbc058..a93d8bf 100755 --- a/test/compile_tests.sh +++ b/test/compile_tests.sh @@ -6,5 +6,5 @@ trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR # build the package -catkin build --this # it has to be fully built normally before building with --catkin-make-args tests +catkin build --this -DMRS_ENABLE_TESTING=1 --no-deps # it has to be fully built normally before building with --catkin-make-args tests catkin build --this -DMRS_ENABLE_TESTING=1 --no-deps --catkin-make-args tests diff --git a/test/gps_baro/gps_baro_basic/test.cpp b/test/gps_baro/gps_baro_basic/test.cpp index 50e094f..cf025d4 100644 --- a/test/gps_baro/gps_baro_basic/test.cpp +++ b/test/gps_baro/gps_baro_basic/test.cpp @@ -10,8 +10,21 @@ class Tester : public mrs_uav_testing::TestGeneric { 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] = activateMidAir(); + 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()); @@ -19,13 +32,13 @@ bool Tester::test() { } } - if (getActiveEstimator() != "gps_baro") { + if (uh->getActiveEstimator() != "gps_baro") { ROS_ERROR("[%s]: gps_baro estimator not active", ros::this_node::getName().c_str()); return false; } { - auto [success, message] = this->gotoRel(10, 2, 1.5, 1.5); + auto [success, message] = uh->gotoRel(10, 2, 1.5, 1.5); if (!success) { ROS_ERROR("[%s]: goto failed with message: '%s'", ros::this_node::getName().c_str(), message.c_str()); @@ -35,7 +48,7 @@ bool Tester::test() { this->sleep(5.0); - if (this->isFlyingNormally()) { + if (uh->isFlyingNormally()) { return true; } else { ROS_ERROR("[%s]: not flying normally", ros::this_node::getName().c_str()); diff --git a/test/gps_garmin/gps_garmin_basic/test.cpp b/test/gps_garmin/gps_garmin_basic/test.cpp index bba13fa..a160309 100644 --- a/test/gps_garmin/gps_garmin_basic/test.cpp +++ b/test/gps_garmin/gps_garmin_basic/test.cpp @@ -10,8 +10,21 @@ class Tester : public mrs_uav_testing::TestGeneric { 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] = activateMidAir(); + 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()); @@ -19,13 +32,13 @@ bool Tester::test() { } } - if (getActiveEstimator() != "gps_garmin") { + if (uh->getActiveEstimator() != "gps_garmin") { ROS_ERROR("[%s]: gps_garmin estimator not active", ros::this_node::getName().c_str()); return false; } { - auto [success, message] = this->gotoRel(10, 2, 1.5, 1.5); + auto [success, message] = uh->gotoRel(10, 2, 1.5, 1.5); if (!success) { ROS_ERROR("[%s]: goto failed with message: '%s'", ros::this_node::getName().c_str(), message.c_str()); @@ -35,7 +48,7 @@ bool Tester::test() { this->sleep(5.0); - if (this->isFlyingNormally()) { + if (uh->isFlyingNormally()) { return true; } else { ROS_ERROR("[%s]: not flying normally", ros::this_node::getName().c_str()); diff --git a/test/rtk/rtk_basic/test.cpp b/test/rtk/rtk_basic/test.cpp index 7785c71..123e8cc 100644 --- a/test/rtk/rtk_basic/test.cpp +++ b/test/rtk/rtk_basic/test.cpp @@ -10,8 +10,21 @@ class Tester : public mrs_uav_testing::TestGeneric { 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] = activateMidAir(); + 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()); @@ -19,13 +32,13 @@ bool Tester::test() { } } - if (getActiveEstimator() != "rtk") { + if (uh->getActiveEstimator() != "rtk") { ROS_ERROR("[%s]: rtk estimator not active", ros::this_node::getName().c_str()); return false; } { - auto [success, message] = this->gotoRel(10, 2, 1.5, 1.5); + auto [success, message] = uh->gotoRel(10, 2, 1.5, 1.5); if (!success) { ROS_ERROR("[%s]: goto failed with message: '%s'", ros::this_node::getName().c_str(), message.c_str()); @@ -35,7 +48,7 @@ bool Tester::test() { this->sleep(5.0); - if (this->isFlyingNormally()) { + if (uh->isFlyingNormally()) { return true; } else { ROS_ERROR("[%s]: not flying normally", ros::this_node::getName().c_str()); diff --git a/test/rtk_garmin/rtk_garmin_basic/test.cpp b/test/rtk_garmin/rtk_garmin_basic/test.cpp index a53b9d9..1f62e73 100644 --- a/test/rtk_garmin/rtk_garmin_basic/test.cpp +++ b/test/rtk_garmin/rtk_garmin_basic/test.cpp @@ -10,8 +10,21 @@ class Tester : public mrs_uav_testing::TestGeneric { 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] = activateMidAir(); + 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()); @@ -19,13 +32,13 @@ bool Tester::test() { } } - if (getActiveEstimator() != "rtk_garmin") { + if (uh->getActiveEstimator() != "rtk_garmin") { ROS_ERROR("[%s]: rtk_garmin estimator not active", ros::this_node::getName().c_str()); return false; } { - auto [success, message] = this->gotoRel(10, 2, 1.5, 1.5); + auto [success, message] = uh->gotoRel(10, 2, 1.5, 1.5); if (!success) { ROS_ERROR("[%s]: goto failed with message: '%s'", ros::this_node::getName().c_str(), message.c_str()); @@ -35,7 +48,7 @@ bool Tester::test() { this->sleep(5.0); - if (this->isFlyingNormally()) { + if (uh->isFlyingNormally()) { return true; } else { ROS_ERROR("[%s]: not flying normally", ros::this_node::getName().c_str());