mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
* fix(airspeed_selector): do not invalidate a sensor on the cycle it is detected A sensor that starts publishing after the selector's init (e.g. the SITL airspeed sim, which waits for a global position) was flagged stale on the first cycle after detection: its last-update timestamp was still zero, so the 1 s missing-data timeout fired before a single sample was read. With ASPD_FS_T_START at its default of -1 the validator never recovers, the selected source stays DISABLED and preflight reports "Airspeed invalid". Seed the timestamp when a new sensor index is detected so the timeout counts from detection. Also silence the DISABLED-to-sensor transition message, which otherwise reports a spurious "healthy, start using again". Assisted-by: Claude:claude-fable-5-1 Signed-off-by: Balduin <balduin@auterion.com> * fix(airspeed_selector): only silence reporting when new sensor added * fix(airspeed_selector): remove newly dead line - this time is always set check_for_connected_airspeed_sensors - there it depends on: - primary index set - otherwise nothing really happens - i >= _number_of_airspeed_sensors: always true on init * test(mavsdk_tests): give the VTOL return with approaches 180 s to disarm The flight from the end of the approach check to disarm takes about 155 s of autopilot time, over the 150 s budget. The test only passed because poll_condition_with_timeout checks elapsed time once per 15 s of autopilot time and usually landed a check before the budget ran out; when the lockstep sim ran slightly faster than the speed factor the disarm fell inside a poll sleep and the test timed out at 158 s. Assisted-by: Claude:claude-fable-5-1 Signed-off-by: Balduin <balduin@auterion.com> --------- Signed-off-by: Balduin <balduin@auterion.com>
286 lines
10 KiB
C++
286 lines
10 KiB
C++
/****************************************************************************
|
|
*
|
|
* Copyright (c) 2023 PX4 Development Team. All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
*
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in
|
|
* the documentation and/or other materials provided with the
|
|
* distribution.
|
|
* 3. Neither the name PX4 nor the names of its contributors may be
|
|
* used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
*
|
|
****************************************************************************/
|
|
|
|
#include "autopilot_tester_rtl.h"
|
|
|
|
TEST_CASE("Return direct Home", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.store_home();
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission_with_land_start.plan");
|
|
// fly directly to home position
|
|
tester.set_rtl_type(0);
|
|
tester.set_rtl_appr_force(0);
|
|
tester.arm();
|
|
tester.execute_rtl_when_reaching_mission_sequence(2);
|
|
tester.wait_until_disarmed(std::chrono::seconds(150));
|
|
tester.check_home_within(5.0f);
|
|
}
|
|
|
|
TEST_CASE("Return direct Mission Land", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.store_home();
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission_with_land_start.plan");
|
|
// Do not allow home
|
|
tester.set_rtl_type(1);
|
|
tester.arm();
|
|
tester.execute_rtl_when_reaching_mission_sequence(2);
|
|
tester.wait_until_disarmed(std::chrono::seconds(150));
|
|
tester.check_mission_land_within(5.0f);
|
|
}
|
|
|
|
TEST_CASE("Return direct Mission Land preserves multicopter mode", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.store_home();
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission_with_land_start.plan");
|
|
tester.set_rtl_type(1);
|
|
tester.arm();
|
|
// Start at DO_LAND_START.
|
|
tester.start_mission_raw_and_wait_for_sequence(6);
|
|
tester.transition_to_multicopter();
|
|
tester.wait_until_multicopter(std::chrono::seconds(60));
|
|
tester.execute_rtl();
|
|
tester.wait_until_disarmed_while_in_multicopter_mode(std::chrono::seconds(180));
|
|
tester.check_mission_land_within(5.0f);
|
|
}
|
|
|
|
TEST_CASE("Return with Mission Landing", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission.plan");
|
|
// Vehicle should follow the mission and use the mission landing
|
|
tester.set_rtl_type(2);
|
|
tester.arm();
|
|
tester.execute_rtl_when_reaching_mission_sequence(2);
|
|
tester.check_tracks_mission_raw(40.0f);
|
|
tester.wait_until_disarmed(std::chrono::seconds(150));
|
|
}
|
|
|
|
TEST_CASE("Return with Reverse Mission", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.set_takeoff_land_requirements(0);
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission_without_landing.plan");
|
|
// vehicle should follow the mission in reverse and land at the home position // TODO enable checks again if MAVSDK can handle mission in reverse order
|
|
tester.set_rtl_type(2);
|
|
tester.arm();
|
|
tester.execute_rtl_when_reaching_mission_sequence(6);
|
|
//tester.check_tracks_mission_raw(35.0f);
|
|
tester.wait_until_disarmed(std::chrono::seconds(150));
|
|
}
|
|
|
|
TEST_CASE("Return with Mission Landing preserves multicopter mode", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.store_home();
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission.plan");
|
|
tester.set_rtl_type(2);
|
|
tester.arm();
|
|
// In fixed wing by then, half way round the mission
|
|
tester.start_mission_raw_and_wait_for_sequence(4);
|
|
tester.transition_to_multicopter();
|
|
tester.wait_until_multicopter(std::chrono::seconds(60));
|
|
tester.execute_rtl();
|
|
// The rest of the mission and its landing are flown as a multicopter
|
|
tester.wait_until_disarmed_while_in_multicopter_mode(std::chrono::seconds(300));
|
|
tester.check_mission_land_within(5.0f);
|
|
}
|
|
|
|
TEST_CASE("Return with Reverse Mission preserves multicopter mode", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.store_home();
|
|
tester.set_takeoff_land_requirements(0);
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission_without_landing.plan");
|
|
tester.set_rtl_type(2);
|
|
tester.arm();
|
|
tester.start_mission_raw_and_wait_for_sequence(4);
|
|
tester.transition_to_multicopter();
|
|
tester.wait_until_multicopter(std::chrono::seconds(60));
|
|
tester.execute_rtl();
|
|
// The mission is flown back in reverse as a multicopter down to the home position
|
|
tester.wait_until_disarmed_while_in_multicopter_mode(std::chrono::seconds(300));
|
|
tester.check_home_within(5.0f);
|
|
}
|
|
|
|
TEST_CASE("Return direct home without approaches", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.store_home();
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission_with_land_start.plan");
|
|
// fly directly to home position
|
|
tester.set_rtl_type(0);
|
|
tester.set_rtl_appr_force(0);
|
|
// reupload rally points with approaches
|
|
tester.add_home_to_rally_point();
|
|
tester.upload_rally_points();
|
|
tester.arm();
|
|
tester.execute_rtl_when_reaching_mission_sequence(4);
|
|
tester.wait_until_disarmed(std::chrono::seconds(150));
|
|
tester.check_home_within(5.0f);
|
|
}
|
|
|
|
TEST_CASE("Return direct home without approaches forced", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.store_home();
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission_with_land_start.plan");
|
|
// fly directly to home position
|
|
tester.set_rtl_type(0);
|
|
tester.set_rtl_appr_force(1);
|
|
// reupload rally points with approaches
|
|
tester.add_home_to_rally_point();
|
|
tester.upload_rally_points();
|
|
tester.arm();
|
|
tester.execute_rtl_when_reaching_mission_sequence(4);
|
|
tester.wait_until_disarmed(std::chrono::seconds(150));
|
|
tester.check_mission_land_within(5.f);
|
|
}
|
|
|
|
TEST_CASE("Return direct home with approaches", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.store_home();
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission_with_land_start.plan");
|
|
// fly directly to home position
|
|
tester.set_rtl_type(0);
|
|
// reupload rally points with approaches
|
|
tester.add_home_with_approaches_to_rally_point();
|
|
tester.upload_rally_points();
|
|
tester.arm();
|
|
tester.execute_rtl_when_reaching_mission_sequence(4);
|
|
tester.check_rtl_approaches(5., std::chrono::seconds(60));
|
|
tester.wait_until_disarmed(std::chrono::seconds(180));
|
|
tester.check_home_within(5.0f);
|
|
}
|
|
|
|
TEST_CASE("Return direct home not as rally point", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.store_home();
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission_with_land_start.plan");
|
|
// fly directly to home position
|
|
tester.set_rtl_type(1);
|
|
// reupload rally points with approaches
|
|
tester.add_home_with_approaches_to_rally_point();
|
|
tester.upload_rally_points();
|
|
tester.arm();
|
|
tester.execute_rtl_when_reaching_mission_sequence(2);
|
|
tester.wait_until_disarmed(std::chrono::seconds(150));
|
|
tester.check_mission_land_within(5.0f);
|
|
}
|
|
|
|
TEST_CASE("Return direct rally without approaches", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.store_home();
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission_with_land_start.plan");
|
|
// Do not allow home position
|
|
tester.set_rtl_type(1);
|
|
tester.set_rtl_appr_force(0);
|
|
// reupload rally points with approaches
|
|
tester.add_local_rally_point({100., -200.});
|
|
tester.upload_rally_points();
|
|
tester.arm();
|
|
tester.execute_rtl_when_reaching_mission_sequence(3);
|
|
tester.wait_until_disarmed(std::chrono::seconds(150));
|
|
tester.check_rally_point_within(5.0f);
|
|
tester.check_home_not_within(20.);
|
|
}
|
|
|
|
TEST_CASE("Return direct rally without approaches forced", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.store_home();
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission_with_land_start.plan");
|
|
// Do not allow home position
|
|
tester.set_rtl_type(1);
|
|
tester.set_rtl_appr_force(1);
|
|
// reupload rally points with approaches
|
|
tester.add_local_rally_point({100., -2000.});
|
|
tester.upload_rally_points();
|
|
tester.arm();
|
|
tester.execute_rtl_when_reaching_mission_sequence(3);
|
|
tester.wait_until_disarmed(std::chrono::seconds(150));
|
|
tester.check_mission_land_within(5.f);
|
|
}
|
|
|
|
TEST_CASE("Return direct rally with approaches", "[vtol]")
|
|
{
|
|
AutopilotTesterRtl tester;
|
|
tester.connect(connection_url);
|
|
tester.wait_until_ready();
|
|
tester.store_home();
|
|
tester.load_qgc_mission_raw_and_move_here("test/mavsdk_tests/vtol_mission_with_land_start.plan");
|
|
// Do not allow home position
|
|
tester.set_rtl_type(1);
|
|
tester.set_rtl_appr_force(0);
|
|
// reupload rally points with approaches
|
|
tester.add_local_rally_with_approaches_point({100., -200.});
|
|
tester.upload_rally_points();
|
|
tester.arm();
|
|
tester.execute_rtl_when_reaching_mission_sequence(3);
|
|
tester.check_rtl_approaches(5., std::chrono::seconds(60));
|
|
tester.wait_until_disarmed(std::chrono::seconds(150));
|
|
tester.check_rally_point_within(5.0f);
|
|
tester.check_home_not_within(20.);
|
|
}
|