Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
klaxalk committed Feb 11, 2024
1 parent b67a436 commit 3622064
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/compile_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 17 additions & 4 deletions test/gps_baro/gps_baro_basic/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,35 @@ class Tester : public mrs_uav_testing::TestGeneric {

bool Tester::test() {

std::shared_ptr<mrs_uav_testing::UAVHandler> 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());
return false;
}
}

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());
Expand All @@ -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());
Expand Down
21 changes: 17 additions & 4 deletions test/gps_garmin/gps_garmin_basic/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,35 @@ class Tester : public mrs_uav_testing::TestGeneric {

bool Tester::test() {

std::shared_ptr<mrs_uav_testing::UAVHandler> 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());
return false;
}
}

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());
Expand All @@ -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());
Expand Down
21 changes: 17 additions & 4 deletions test/rtk/rtk_basic/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,35 @@ class Tester : public mrs_uav_testing::TestGeneric {

bool Tester::test() {

std::shared_ptr<mrs_uav_testing::UAVHandler> 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());
return false;
}
}

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());
Expand All @@ -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());
Expand Down
21 changes: 17 additions & 4 deletions test/rtk_garmin/rtk_garmin_basic/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,35 @@ class Tester : public mrs_uav_testing::TestGeneric {

bool Tester::test() {

std::shared_ptr<mrs_uav_testing::UAVHandler> 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());
return false;
}
}

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());
Expand All @@ -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());
Expand Down

0 comments on commit 3622064

Please sign in to comment.