-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
find_package(rostest REQUIRED) | ||
|
||
add_subdirectory(takeoff) | ||
|
||
add_subdirectory(uav_models) |
33 changes: 33 additions & 0 deletions
33
ros_packages/mrs_uav_gazebo_simulation/test/uav_models/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
get_filename_component(TEST_NAME "${CMAKE_CURRENT_SOURCE_DIR}" NAME) | ||
|
||
set(MODELS | ||
x500 | ||
f330 | ||
f450 | ||
f550 | ||
t650 | ||
m690 | ||
naki | ||
) | ||
|
||
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} | ||
) | ||
|
||
foreach(MODEL ${MODELS}) | ||
|
||
add_rostest(${TEST_NAME}.test | ||
ARGS | ||
UAV_TYPE:=${MODEL} | ||
) | ||
|
||
endforeach() |
16 changes: 16 additions & 0 deletions
16
ros_packages/mrs_uav_gazebo_simulation/test/uav_models/config/custom_config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# GET ALL PARAMETERS USABLE FOR CUSTOM CONFIG BY RUNNING: | ||
## -------------------------------------------------------------- | ||
## | rosrun mrs_uav_core get_public_params.py # | ||
## -------------------------------------------------------------- | ||
|
||
mrs_uav_managers: | ||
|
||
estimation_manager: | ||
|
||
# loaded state estimator plugins | ||
state_estimators: [ | ||
"gps_garmin", | ||
] | ||
|
||
initial_state_estimator: "gps_garmin" # will be used as the first state estimator | ||
agl_height_estimator: "garmin_agl" # only slightly filtered height for checking min height (not used in control feedback) |
62 changes: 62 additions & 0 deletions
62
ros_packages/mrs_uav_gazebo_simulation/test/uav_models/test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include <mrs_uav_testing/test_generic.h> | ||
|
||
class Tester : public mrs_uav_testing::TestGeneric { | ||
|
||
public: | ||
bool test(); | ||
}; | ||
|
||
bool Tester::test() { | ||
|
||
{ | ||
auto [success, message] = spawnGazeboUav(); | ||
|
||
if (!success) { | ||
ROS_ERROR("[%s]: gazebo UAV spawning failed with message: '%s'", ros::this_node::getName().c_str(), message.c_str()); | ||
return false; | ||
} | ||
} | ||
|
||
{ | ||
auto [success, message] = takeoff(); | ||
|
||
if (!success) { | ||
ROS_ERROR("[%s]: takeoff failed with message: '%s'", ros::this_node::getName().c_str(), message.c_str()); | ||
return false; | ||
} | ||
} | ||
|
||
this->sleep(5.0); | ||
|
||
if (this->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(); | ||
} |
36 changes: 36 additions & 0 deletions
36
ros_packages/mrs_uav_gazebo_simulation/test/uav_models/uav_models.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<launch> | ||
|
||
<arg name="this_path" default="$(dirname)" /> | ||
|
||
<arg name="UAV_NAME" default="uav1" /> | ||
<arg name="UAV_TYPE" default="x500" /> | ||
|
||
<!-- automatically deduce the test name --> | ||
<arg name="test_name" default="$(eval arg('this_path').split('/')[-1])" /> | ||
|
||
<!-- automatically deduce the package name --> | ||
<arg name="import_eval" default="eval('_' + '_import_' + '_')"/> | ||
<arg name="package_eval" default="eval(arg('import_eval') + '(\'rospkg\')').get_package_name(arg('this_path'))" /> | ||
<arg name="package" default="$(eval eval(arg('package_eval')))" /> | ||
|
||
<include file="$(find mrs_uav_testing)/launch/gazebo_simulator.launch" /> | ||
|
||
<include file="$(find mrs_uav_px4_api)/launch/api.launch"> | ||
<arg name="UAV_NAME" default="$(arg UAV_NAME)" /> | ||
<arg name="RUN_TYPE" default="simulation" /> | ||
</include> | ||
|
||
<include file="$(find mrs_uav_testing)/launch/mrs_uav_system.launch"> | ||
<arg name="automatic_start" default="true" /> | ||
<arg name="platform_config" default="$(find mrs_uav_gazebo_simulation)/config/mrs_uav_system/$(arg UAV_TYPE).yaml" /> | ||
<arg name="custom_config" default="$(dirname)/config/custom_config.yaml" /> | ||
<arg name="UAV_NAME" default="$(arg UAV_NAME)" /> | ||
</include> | ||
|
||
<test pkg="$(arg package)" type="test_$(arg test_name)" test-name="$(arg test_name)" time-limit="120.0"> | ||
<param name="test_name" value="$(arg test_name)" /> | ||
<param name="uav_name" value="$(arg UAV_NAME)" /> | ||
<param name="gazebo_spawner_params" value="1 --$(arg UAV_TYPE) --enable-rangefinder" /> | ||
</test> | ||
|
||
</launch> |