Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAVSDK testing improvements #14296

Merged
merged 51 commits into from Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
89e9ce6
mavsdk_tests: MAVSDK is required
julianoes Mar 2, 2020
7453599
mavsdk_tests: PEP8 fixes
julianoes Mar 2, 2020
c6c259a
simulator: remove redundant semicolon
julianoes Mar 2, 2020
d0eac74
mavsdk_tests: add max speed factor
julianoes Mar 4, 2020
42bc412
mavsdk_tests: remove opt_flow test
julianoes Mar 5, 2020
2a5093b
mavsdk_tests: use the min of the speed factors
julianoes Mar 5, 2020
7a80308
mavsdk_tests: remove plane tests
julianoes Mar 5, 2020
c1bc9ee
mavsdk_tests: move config into json file
julianoes Mar 5, 2020
44f761a
mavsdk_tests: without speedup the VTOL takes time
julianoes Mar 5, 2020
a289b25
mavsdk_tests: add more config into JSON
julianoes Mar 5, 2020
80fcfc7
mavsdk_tests: improve naming of argument
julianoes Mar 5, 2020
eae94d6
workflows: adapt to mavsdk_tests cli changes
julianoes Mar 5, 2020
6fccbad
mavsdk_tests: consolidate level of abstraction
julianoes Mar 6, 2020
062c3c2
mavsdk_tests: add missing unit
julianoes Mar 6, 2020
c1afdf4
mavsdk_tests: remove unused/not working test
julianoes Mar 6, 2020
205c836
mavsdk_tests: use CHECK if we don't need to abort
julianoes Mar 6, 2020
3d3fd8b
mavsdk_tests: try using tags as intended
julianoes Mar 6, 2020
19f0cfd
mavsdk_tests: write output to logs folder
julianoes Mar 6, 2020
39284ad
Tools: exit as straightaway with DONT_RUN set
julianoes Mar 6, 2020
48f62ca
mavsdk_tests: output less verbose unless needed
julianoes Mar 6, 2020
92da35d
mavsdk_tests: only print error on failure
julianoes Mar 10, 2020
d83218e
mavsdk_tests: improve test output readability
julianoes Mar 10, 2020
b70575b
mavsdk_tests: improve test name/description
julianoes Mar 10, 2020
2cf483e
mavsdk_tests: improve output, allow log and stdout
julianoes Mar 11, 2020
c55c394
mavsdk_tests: properly exit on Ctrl+C
julianoes Mar 11, 2020
184734c
mavsdk_tests: initialize Tester class in ctor
julianoes Mar 11, 2020
07c30cc
mavsdk_tests: split up Python script
julianoes Mar 11, 2020
48f0339
mavsdk_tests: import naming, easier coloring
julianoes Mar 12, 2020
10d0b6c
mavsdk_tests: further argument cleanup, some types
julianoes Mar 13, 2020
0a444af
mavsdk_tests: satisfy mypy type checks
julianoes Mar 13, 2020
7f8dac5
mavsdk_tests: print overall results
julianoes Mar 13, 2020
d439552
mavsdk_tests: improve log file folder structure
julianoes Mar 16, 2020
47ad85c
mavsdk_tests: add combined log
julianoes Mar 16, 2020
8307d4b
mavsdk_tests: improve and fix colors/result
julianoes Mar 17, 2020
8f0aca4
mavsdk_tests: print error on failure
julianoes Mar 17, 2020
3859746
mavsdk_tests: print where to find logfiles
julianoes Mar 17, 2020
a011996
mavsdk_tests: fix missing space after number
julianoes Mar 17, 2020
d892d70
mavsdk_tests: add filter for cases
julianoes Mar 17, 2020
0f3454b
Tools: check style of mavsdk_tests files
julianoes Mar 17, 2020
e817992
mavsdk_tests: add header and fix style
julianoes Mar 17, 2020
92374b4
mavsdk_tests: name files consistently
julianoes Mar 17, 2020
355f15a
mavsdk_tests: fix error for Python < 3.8
julianoes Mar 17, 2020
92beffa
mavsdk_tests: remove unused import
julianoes Mar 17, 2020
3093a22
github: new check for MAVSDK tester Python scripts
julianoes Mar 17, 2020
f8a7f84
github: try to get latest tools using pip
julianoes Mar 17, 2020
44cc8f6
mavsdk_tests: a timeout of 5min should be enough
julianoes Mar 18, 2020
b1db077
mavsdk_tests: remove commented out code
julianoes Mar 18, 2020
4aaaa47
mavsdk_tests: pass PX4_HOME_ env variables on
julianoes Mar 18, 2020
d123a42
workflows: add more tests outside of Europe
julianoes Mar 18, 2020
e9708b4
mavsdk_tests: only env vars that are set
julianoes Mar 18, 2020
3aaa432
mavsdk_tests: c++ test_runner is now mavsdk_tests
julianoes Mar 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/python_checks.yml
@@ -0,0 +1,25 @@
name: Python CI checks

on:
push:
branches:
- 'master'
pull_request:
branches:
- '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
token: ${{ secrets.ACCESS_TOKEN }}
- name: Install Python3
run: sudo apt-get install python3 python3-setuptools python3-pip -y
- name: Install tools
run: pip3 install --user mypy flake8
- name: Check MAVSDK test scripts with mypy
run: $HOME/.local/bin/mypy --strict test/mavsdk_tests/*.py
- name: Check MAVSDK test scripts with flake8
run: $HOME/.local/bin/flake8 test/mavsdk_tests/*.py
18 changes: 8 additions & 10 deletions .github/workflows/sitl_tests.yml
Expand Up @@ -33,16 +33,14 @@ jobs:
run: DONT_RUN=1 make px4_sitl PX4_CMAKE_BUILD_TYPE=Coverage gazebo mavsdk_tests
- name: ccache post-run
run: ccache -s && ccache -z

# Run mavsdk tests
- name: Run multicopter simulation test
run: test/mavsdk_tests/mavsdk_test_runner.py --model iris --speed-factor 20 --iterations 1 --fail-early
- name: Run multicopter with optical flow simulation test
run: test/mavsdk_tests/mavsdk_test_runner.py --model iris_opt_flow_mockup --speed-factor 1 --iterations 1 --fail-early
- name: Run multicopter with VIO sensor simulation test
run: test/mavsdk_tests/mavsdk_test_runner.py --model iris_vision --speed-factor 1 --iterations 1 --fail-early
- name: Run VTOL simulation test #
run: test/mavsdk_tests/mavsdk_test_runner.py --model standard_vtol --speed-factor 20 --iterations 1 --fail-early
- name: Run SITL tests
run: test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 20 --abort-early test/mavsdk_tests/configs/sitl.json
- name: Run SITL tests in Southern hemisphere
run: PX4_HOME_LAT=-37.8134048 PX4_HOME_LON=175.304109 PX4_HOME_ALT=32 |
test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 20 --abort-early test/mavsdk_tests/configs/sitl.json
- name: Run SITL tests far in the West
run: PX4_HOME_LAT=59.6176928 PX4_HOME_LON=-151.1453163 PX4_HOME_ALT=48 |
test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 20 --abort-early test/mavsdk_tests/configs/sitl.json

# Report test coverage
- name: disable the keychain credential helper
Expand Down
3 changes: 2 additions & 1 deletion Tools/astyle/files_to_check_code_style.sh
Expand Up @@ -7,7 +7,7 @@ if [ $# -gt 0 ]; then
PATTERN="$1"
fi

exec find boards msg src platforms \
exec find boards msg src platforms test \
-path msg/templates/urtps -prune -o \
-path platforms/nuttx/NuttX -prune -o \
-path platforms/qurt/dspal -prune -o \
Expand All @@ -18,4 +18,5 @@ exec find boards msg src platforms \
-path src/lib/systemlib/uthash -prune -o \
-path src/modules/micrortps_bridge/micro-CDR -prune -o \
-path src/modules/micrortps_bridge/microRTPS_client -prune -o \
-path test/mavsdk_tests/catch2 -prune -o \
-type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) | grep $PATTERN
58 changes: 28 additions & 30 deletions Tools/sitl_run.sh
Expand Up @@ -2,6 +2,16 @@

set -e

if [ "$#" -lt 6 ]; then
echo usage: sitl_run.sh sitl_bin debugger program model src_path build_path
exit 1
fi

if [[ -n "$DONT_RUN" ]]; then
echo "Not running simulation (DONT_RUN is set)."
exit 0
julianoes marked this conversation as resolved.
Show resolved Hide resolved
fi

sitl_bin="$1"
debugger="$2"
program="$3"
Expand Down Expand Up @@ -41,12 +51,6 @@ if [ "$model" == "" ] || [ "$model" == "none" ]; then
model="iris"
fi

if [ "$#" -lt 6 ]; then
echo usage: sitl_run.sh sitl_bin debugger program model src_path build_path
echo ""
exit 1
fi

# kill process names that might stil
# be running from last time
pkill -x gazebo || true
Expand All @@ -73,22 +77,20 @@ if [ "$program" == "jmavsim" ] && [ ! -n "$no_sim" ]; then
SIM_PID=`echo $!`
elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]; then
if [ -x "$(command -v gazebo)" ]; then
if [[ -z "$DONT_RUN" ]]; then
# Set the plugin path so Gazebo finds our model and sim
source "$src_path/Tools/setup_gazebo.bash" "${src_path}" "${build_path}"
# Set the plugin path so Gazebo finds our model and sim
source "$src_path/Tools/setup_gazebo.bash" "${src_path}" "${build_path}"

gzserver "${src_path}/Tools/sitl_gazebo/worlds/${model}.world" &
SIM_PID=`echo $!`

if [[ -n "$HEADLESS" ]]; then
echo "not running gazebo gui"
else
# gzserver needs to be running to avoid a race. Since the launch
# is putting it into the background we need to avoid it by backing off
sleep 3
nice -n 20 gzclient --verbose &
GUI_PID=`echo $!`
fi
if [[ -n "$HEADLESS" ]]; then
echo "not running gazebo gui"
else
# gzserver needs to be running to avoid a race. Since the launch
# is putting it into the background we need to avoid it by backing off
sleep 3
nice -n 20 gzclient --verbose &
GUI_PID=`echo $!`
fi
else
echo "You need to have gazebo simulator installed!"
Expand All @@ -112,9 +114,7 @@ echo SITL COMMAND: $sitl_command
export PX4_SIM_MODEL=${model}


if [[ -n "$DONT_RUN" ]]; then
echo "Not running simulation (\$DONT_RUN is set)."
elif [ "$debugger" == "lldb" ]; then
if [ "$debugger" == "lldb" ]; then
eval lldb -- $sitl_command
elif [ "$debugger" == "gdb" ]; then
eval gdb --args $sitl_command
Expand All @@ -138,14 +138,12 @@ fi

popd >/dev/null

if [[ -z "$DONT_RUN" ]]; then
if [ "$program" == "jmavsim" ]; then
pkill -9 -P $SIM_PID
kill -9 $SIM_PID
elif [ "$program" == "gazebo" ]; then
kill -9 $SIM_PID
if [[ ! -n "$HEADLESS" ]]; then
kill -9 $GUI_PID
fi
if [ "$program" == "jmavsim" ]; then
pkill -9 -P $SIM_PID
kill -9 $SIM_PID
elif [ "$program" == "gazebo" ]; then
kill -9 $SIM_PID
if [[ ! -n "$HEADLESS" ]]; then
kill -9 $GUI_PID
fi
fi
2 changes: 1 addition & 1 deletion src/modules/simulator/simulator_mavlink.cpp
Expand Up @@ -963,7 +963,7 @@ int Simulator::publish_flow_topic(const mavlink_hil_optical_flow_t *flow_mavlink
{
optical_flow_s flow = {};
flow.sensor_id = flow_mavlink->sensor_id;
flow.timestamp = hrt_absolute_time();;
flow.timestamp = hrt_absolute_time();
flow.time_since_last_sonar_update = 0;
flow.frame_count_since_last_readout = 0; // ?
flow.integration_timespan = flow_mavlink->integration_time_us;
Expand Down
7 changes: 3 additions & 4 deletions test/mavsdk_tests/CMakeLists.txt
Expand Up @@ -6,16 +6,15 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(MAVSDK QUIET)
find_package(MAVSDK REQUIRED)

if(MAVSDK_FOUND)
add_executable(mavsdk_tests
test_main.cpp
autopilot_tester.cpp
test_multicopter_offboard.cpp
test_mission_multicopter.cpp
test_mission_plane.cpp
test_mission_vtol.cpp
test_multicopter_mission.cpp
test_vtol_mission.cpp
)

target_link_libraries(mavsdk_tests
Expand Down