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

Adding Ardupilot SITL to MAVSDK CI #1669

Merged
merged 8 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,3 +630,28 @@ jobs:
- name: look at core files
if: failure()
run: gdb /home/user/Firmware/build/px4_sitl_default/bin/px4 px4.core -ex "thread apply all bt" -ex "quit"

apm-sitl-newer:
name: APM SITL ${{ matrix.apm_version }} (ubuntu-20.04)
runs-on: ubuntu-20.04
container:
image: mavsdk/mavsdk-ubuntu-20.04-apm-sitl-${{ matrix.apm_version }}
options: --privileged
env:
APM_HOME_LAT: 47.397742
APM_HOME_LONG: 8.545594
APM_HOME_ALT: 488.0
APM_HOME_DIR: 180
WORKDIR: "/home/user/MAVSDK"
FIRMWARE_DIR: /home/user/ArduPilot
strategy:
matrix:
apm_version: [copter-4.1.2]
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: test
run: APM_VERSION=${{ matrix.apm_version }} tools/run-sitl-tests.sh /home/user/ArduPilot
timeout-minutes: 45
38 changes: 38 additions & 0 deletions docker/Dockerfile-Ubuntu-20.04-APM-SITL-Copter-4.1.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# APM Copter-4.1.2 SITL testing environment for MAVSDK based on Ubuntu 20.04.
# Author: Yogesh Khedar <yogeshkhedar@gmail.com>
#
FROM mavsdk/mavsdk-ubuntu-20.04
MAINTAINER Yogesh Khedar <yogeshkhedar@gmail.com>

ENV FIRMWARE_DIR ${WORKDIR}../ArduPilot

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get --quiet -y --no-install-recommends install locales \
python3 python3-wheel gnupg gcc lcov rsync screen shellcheck psmisc \
&& apt-get -y autoremove \
&& apt-get clean autoclean \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*

RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV COPTER_VERSION Copter-4.1.2

RUN git clone https://github.com/ArduPilot/ardupilot.git ${FIRMWARE_DIR}
RUN git -C ${FIRMWARE_DIR} checkout ${COPTER_VERSION}
RUN git -C ${FIRMWARE_DIR} submodule update --init --recursive

RUN cd ${FIRMWARE_DIR} && sed -i 's/sudo //' Tools/environment_install/install-prereqs-ubuntu.sh && \
sed -i '6,9d' Tools/environment_install/install-prereqs-ubuntu.sh && \
sed -i '/usermod -a -G dialout/d' Tools/environment_install/install-prereqs-ubuntu.sh && \
sed -i 's/--user//' Tools/environment_install/install-prereqs-ubuntu.sh && \
bash Tools/environment_install/install-prereqs-ubuntu.sh -y

ENV APM_VEHICLE ArduCopter
ENV APM_FRAME quad

RUN cd ${FIRMWARE_DIR} && ./waf distclean && ./waf configure --board sitl && ./waf copter


37 changes: 37 additions & 0 deletions docker/Dockerfile-Ubuntu-20.04-APM-SITL-Rover-4.1.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# APM Rover-4.1.2 SITL testing environment for MAVSDK based on Ubuntu 20.04.
# Author: Yogesh Khedar <yogeshkhedar@gmail.com>
#
FROM mavsdk/mavsdk-ubuntu-20.04
MAINTAINER Yogesh Khedar <yogeshkhedar@gmail.com>

ENV FIRMWARE_DIR ${WORKDIR}../ArduPilot

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get --quiet -y --no-install-recommends install locales \
python3 python3-wheel gnupg gcc lcov rsync screen shellcheck psmisc \
&& apt-get -y autoremove \
&& apt-get clean autoclean \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*

RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV ROVER_VERSION Rover-4.1.2

RUN git clone https://github.com/ArduPilot/ardupilot.git ${FIRMWARE_DIR}
RUN git -C ${FIRMWARE_DIR} checkout ${ROVER_VERSION}
RUN git -C ${FIRMWARE_DIR} submodule update --init --recursive

RUN cd ${FIRMWARE_DIR} && sed -i 's/sudo //' Tools/environment_install/install-prereqs-ubuntu.sh && \
sed -i '6,9d' Tools/environment_install/install-prereqs-ubuntu.sh && \
sed -i '/usermod -a -G dialout/d' Tools/environment_install/install-prereqs-ubuntu.sh && \
sed -i 's/--user//' Tools/environment_install/install-prereqs-ubuntu.sh && \
bash Tools/environment_install/install-prereqs-ubuntu.sh -y

ENV APM_VEHICLE Rover
ENV APM_FRAME rover-skid

RUN cd ${FIRMWARE_DIR} && ./waf distclean && ./waf configure --board sitl && ./waf rover

7 changes: 4 additions & 3 deletions docker/build_and_push_docker_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ docker build -f Dockerfile-Ubuntu-20.04-PX4-SITL-v1.12 -t mavsdk/mavsdk-ubuntu-2
docker build -f Dockerfile.dockcross-linux-armv6-custom -t mavsdk/mavsdk-dockcross-linux-armv6-custom .
docker build -f Dockerfile.dockcross-linux-armv7-custom -t mavsdk/mavsdk-dockcross-linux-armv7-custom .
docker build -f Dockerfile.dockcross-linux-arm64-custom -t mavsdk/mavsdk-dockcross-linux-arm64-custom .
docker build -f Dockerfile-Ubuntu-20.04-APM-SITL-Copter-4.1.2 -t mavsdk/mavsdk-ubuntu-20.04-apm-sitl-copter-4.1.2 .
docker build -f Dockerfile-Ubuntu-20.04-APM-SITL-Rover-4.1.2 -t mavsdk/mavsdk-ubuntu-20.04-apm-sitl-rover-4.1.2 .

docker push mavsdk/mavsdk-fedora-34:latest
docker push mavsdk/mavsdk-fedora-35:latest
docker push mavsdk/mavsdk-ubuntu-20.04:latest
docker push mavsdk/mavsdk-ubuntu-20.04-px4-sitl-v1.11:latest
docker push mavsdk/mavsdk-ubuntu-20.04-px4-sitl-v1.12:latest
docker push mavsdk/mavsdk-dockcross-linux-armv6-custom:latest
docker push mavsdk/mavsdk-dockcross-linux-armv7-custom:latest
docker push mavsdk/mavsdk-dockcross-linux-arm64-custom:latest
docker push mavsdk/mavsdk-ubuntu-20.04-apm-sitl-copter-4.1.2
docker push mavsdk/mavsdk-ubuntu-20.04-apm-sitl-rover-4.1.2
2 changes: 1 addition & 1 deletion src/integration_tests/action_goto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using namespace mavsdk;

TEST_F(SitlTest, ActionGoto)
TEST_F(SitlTest, PX4ActionGoto)
{
Mavsdk mavsdk;

Expand Down
2 changes: 1 addition & 1 deletion src/integration_tests/action_hold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using namespace mavsdk;

TEST_F(SitlTest, ActionHold)
TEST_F(SitlTest, PX4ActionHold)
{
Mavsdk mavsdk;

Expand Down
2 changes: 1 addition & 1 deletion src/integration_tests/action_hover_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using namespace mavsdk;

TEST_F(SitlTest, ActionHoverAsync)
TEST_F(SitlTest, PX4ActionHoverAsync)
{
Mavsdk mavsdk;

Expand Down
12 changes: 8 additions & 4 deletions src/integration_tests/action_hover_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ using namespace mavsdk;

static void takeoff_and_hover_at_altitude(float altitude_m);

TEST_F(SitlTest, ActionHoverSyncDefault)
TEST_F(SitlTest, PX4ActionHoverSyncDefault)
{
takeoff_and_hover_at_altitude(2.5);
}

TEST_F(SitlTest, ActionHoverSyncHigher)
TEST_F(SitlTest, PX4ActionHoverSyncHigher)
{
takeoff_and_hover_at_altitude(5.0f);
}

TEST_F(SitlTest, ActionHoverSyncLower)
TEST_F(SitlTest, PX4ActionHoverSyncLower)
{
// TODO: less than 1.0 is currently failing due to a Firmware bug.
// https://github.com/PX4/Firmware/issues/12471
Expand Down Expand Up @@ -59,7 +59,11 @@ void takeoff_and_hover_at_altitude(float altitude_m)

LogInfo() << "Waiting for system to be ready";
ASSERT_TRUE(poll_condition_with_timeout(
[telemetry]() { return telemetry->health_all_ok(); }, std::chrono::seconds(10)));
[telemetry]() {
LogInfo() << "Waiting for system to be ready";
return telemetry->health_all_ok();
},
std::chrono::seconds(10)));

auto action = std::make_shared<Action>(*system);

Expand Down
2 changes: 1 addition & 1 deletion src/integration_tests/action_takeoff_and_kill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

using namespace mavsdk;

TEST_F(SitlTest, ActionTakeoffAndKill)
TEST_F(SitlTest, PX4ActionTakeoffAndKill)
{
Mavsdk mavsdk;
ASSERT_EQ(mavsdk.add_udp_connection(), ConnectionResult::Success);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using namespace mavsdk;

TEST_F(SitlTest, ActionTransitionSync_standard_vtol)
TEST_F(SitlTest, PX4ActionTransitionSync_standard_vtol)
{
// Init & connect
Mavsdk mavsdk;
Expand All @@ -34,10 +34,13 @@ TEST_F(SitlTest, ActionTransitionSync_standard_vtol)
auto action = std::make_shared<Action>(system);
auto telemetry = std::make_shared<Telemetry>(system);

while (!telemetry->health_all_ok()) {
std::cout << "waiting for system to be ready" << '\n';
std::this_thread::sleep_for(std::chrono::seconds(1));
}
LogInfo() << "Waiting for system to be ready";
ASSERT_TRUE(poll_condition_with_timeout(
[telemetry]() {
LogInfo() << "Waiting for system to be ready";
return telemetry->health_all_ok();
},
std::chrono::seconds(10)));

// We need to takeoff first, otherwise we can't actually transition
float altitude_m = 10.0f;
Expand Down
26 changes: 16 additions & 10 deletions src/integration_tests/follow_me.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void send_location_updates(

const size_t N_LOCATIONS = 100ul;

TEST_F(SitlTest, FollowMeOneLocation)
TEST_F(SitlTest, PX4FollowMeOneLocation)
{
Mavsdk mavsdk;

Expand All @@ -35,10 +35,13 @@ TEST_F(SitlTest, FollowMeOneLocation)
auto follow_me = std::make_shared<FollowMe>(system);
auto action = std::make_shared<Action>(system);

while (!telemetry->health_all_ok()) {
std::cout << "waiting for system to be ready" << '\n';
sleep_for(seconds(1));
}
LogInfo() << "Waiting for system to be ready";
ASSERT_TRUE(poll_condition_with_timeout(
[telemetry]() {
LogInfo() << "Waiting for system to be ready";
return telemetry->health_all_ok();
},
std::chrono::seconds(10)));

Action::Result action_ret = action->arm();
ASSERT_EQ(Action::Result::Success, action_ret);
Expand Down Expand Up @@ -95,7 +98,7 @@ TEST_F(SitlTest, FollowMeOneLocation)
telemetry->subscribe_flight_mode(nullptr);
}

TEST_F(SitlTest, FollowMeMultiLocationWithConfig)
TEST_F(SitlTest, PX4FollowMeMultiLocationWithConfig)
{
Mavsdk mavsdk;

Expand All @@ -122,10 +125,13 @@ TEST_F(SitlTest, FollowMeMultiLocationWithConfig)
auto follow_me = std::make_shared<FollowMe>(system);
auto action = std::make_shared<Action>(system);

while (!telemetry->health_all_ok()) {
std::cout << "Waiting for system to be ready" << '\n';
sleep_for(seconds(1));
}
LogInfo() << "Waiting for system to be ready";
ASSERT_TRUE(poll_condition_with_timeout(
[telemetry]() {
LogInfo() << "Waiting for system to be ready";
return telemetry->health_all_ok();
},
std::chrono::seconds(10)));

Action::Result action_ret = action->arm();
ASSERT_EQ(Action::Result::Success, action_ret);
Expand Down
13 changes: 8 additions & 5 deletions src/integration_tests/geofence_inclusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace mavsdk;

static Geofence::Point add_point(double latitude_deg, double longitude_deg);

TEST_F(SitlTest, GeofenceInclusion)
TEST_F(SitlTest, PX4GeofenceInclusion)
{
Mavsdk mavsdk;

Expand All @@ -24,10 +24,13 @@ TEST_F(SitlTest, GeofenceInclusion)
auto telemetry = std::make_shared<Telemetry>(system);
auto geofence = std::make_shared<Geofence>(system);

while (!telemetry->health_all_ok()) {
LogInfo() << "waiting for system to be ready";
std::this_thread::sleep_for(std::chrono::seconds(1));
}
LogInfo() << "Waiting for system to be ready";
ASSERT_TRUE(poll_condition_with_timeout(
[telemetry]() {
LogInfo() << "Waiting for system to be ready";
return telemetry->health_all_ok();
},
std::chrono::seconds(10)));

LogInfo() << "System ready, let's start";

Expand Down
22 changes: 14 additions & 8 deletions src/integration_tests/gimbal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,13 @@ TEST(SitlTestGimbal, GimbalTakeoffAndMove)
auto action = std::make_shared<Action>(system);
auto offboard = std::make_shared<Offboard>(system);

while (!telemetry->health_all_ok()) {
LogInfo() << "waiting for system to be ready";
std::this_thread::sleep_for(std::chrono::seconds(1));
}
LogInfo() << "Waiting for system to be ready";
ASSERT_TRUE(poll_condition_with_timeout(
[telemetry]() {
LogInfo() << "Waiting for system to be ready";
return telemetry->health_all_ok();
},
std::chrono::seconds(10)));

Action::Result action_result = action->arm();
EXPECT_EQ(action_result, Action::Result::Success);
Expand Down Expand Up @@ -257,10 +260,13 @@ TEST(SitlTestGimbal, GimbalROIOffboard)
auto action = std::make_shared<Action>(system);
auto offboard = std::make_shared<Offboard>(system);

while (!telemetry->health_all_ok()) {
LogInfo() << "waiting for system to be ready";
std::this_thread::sleep_for(std::chrono::seconds(1));
}
LogInfo() << "Waiting for system to be ready";
ASSERT_TRUE(poll_condition_with_timeout(
[telemetry]() {
LogInfo() << "Waiting for system to be ready";
return telemetry->health_all_ok();
},
std::chrono::seconds(10)));

const Telemetry::Position& position = telemetry->position();

Expand Down
2 changes: 1 addition & 1 deletion src/integration_tests/info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

using namespace mavsdk;

TEST_F(SitlTest, Info)
TEST_F(SitlTest, PX4Info)
{
Mavsdk mavsdk;

Expand Down
2 changes: 1 addition & 1 deletion src/integration_tests/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

using namespace mavsdk;

TEST_F(SitlTest, Logging)
TEST_F(SitlTest, PX4Logging)
{
Mavsdk mavsdk;

Expand Down
2 changes: 1 addition & 1 deletion src/integration_tests/mavlink_passthrough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using namespace mavsdk;

TEST_F(SitlTest, MavlinkPassthrough)
TEST_F(SitlTest, PX4MavlinkPassthrough)
{
Mavsdk mavsdk;
ASSERT_EQ(mavsdk.add_udp_connection(), ConnectionResult::Success);
Expand Down
14 changes: 8 additions & 6 deletions src/integration_tests/mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static constexpr int NUM_MISSION_ITEMS = 6;

static std::atomic<bool> pause_already_done{false};

TEST_F(SitlTest, MissionAddWaypointsAndFly)
TEST_F(SitlTest, PX4MissionAddWaypointsAndFly)
{
Mavsdk mavsdk;

Expand Down Expand Up @@ -81,11 +81,13 @@ void test_mission(
std::shared_ptr<Mission> mission,
std::shared_ptr<Action> action)
{
while (!telemetry->health_all_ok()) {
LogInfo() << "Waiting for system to be ready";
LogDebug() << "Health: " << telemetry->health();
std::this_thread::sleep_for(std::chrono::seconds(30));
}
LogInfo() << "Waiting for system to be ready";
ASSERT_TRUE(poll_condition_with_timeout(
[telemetry]() {
LogInfo() << "Waiting for system to be ready";
return telemetry->health_all_ok();
},
std::chrono::seconds(10)));

LogInfo() << "System ready";
LogInfo() << "Creating and uploading mission";
Expand Down
Loading