mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 21:23:35 +08:00
Add Traffic Avoidance System (ADSB/FLARM) Arming Check (#26390)
* Add traffic avoidance system checks * Update msg/px4_msgs_old/msg/VehicleStatusV1.msg Co-authored-by: Hamish Willee <hamishwillee@gmail.com> * docs: add arming check for traffic avoidance systems in ADS-B/FLARM documentation * fix formating * trafficAvoidanceCheck: switch case for configuration options --------- Co-authored-by: Hamish Willee <hamishwillee@gmail.com> Co-authored-by: Matthias Grob <maetugr@gmail.com>
This commit is contained in:
committed by
Matthias Grob
co-authored by
Hamish Willee
Matthias Grob
parent
adc9a6d35d
commit
05de941399
@@ -276,6 +276,10 @@
|
||||
"1073741824": {
|
||||
"name": "open_drone_id",
|
||||
"description": "Open Drone ID system"
|
||||
},
|
||||
"2147483648": {
|
||||
"name": "traffic_avoidance",
|
||||
"description": "Traffic Avoidance (ADSB/FLARM)"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2880,6 +2880,22 @@ void Commander::dataLinkCheck()
|
||||
_vehicle_status.open_drone_id_system_present = true;
|
||||
_vehicle_status.open_drone_id_system_healthy = healthy;
|
||||
}
|
||||
|
||||
// Traffic avoidance system (ADSB or FLARM)
|
||||
if (telemetry.heartbeat_type_adsb || telemetry.heartbeat_type_flarm) {
|
||||
if (_traffic_avoidance_system_lost) { // recovered
|
||||
_traffic_avoidance_system_lost = false;
|
||||
|
||||
if (_datalink_last_heartbeat_traffic_avoidance_system != 0) {
|
||||
mavlink_log_info(&_mavlink_log_pub, "Traffic avoidance system regained\t");
|
||||
events::send(events::ID("commander_traffic_avoidance_regained"), events::Log::Info,
|
||||
"Traffic avoidance system regained");
|
||||
}
|
||||
}
|
||||
|
||||
_datalink_last_heartbeat_traffic_avoidance_system = telemetry.timestamp;
|
||||
_vehicle_status.traffic_avoidance_system_present = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2931,6 +2947,16 @@ void Commander::dataLinkCheck()
|
||||
_open_drone_id_system_lost = true;
|
||||
_status_changed = true;
|
||||
}
|
||||
|
||||
// Traffic avoidance system (ADSB/FLARM)
|
||||
if ((hrt_elapsed_time(&_datalink_last_heartbeat_traffic_avoidance_system) > 3_s)
|
||||
&& !_traffic_avoidance_system_lost) {
|
||||
mavlink_log_critical(&_mavlink_log_pub, "Traffic avoidance system lost");
|
||||
events::send(events::ID("commander_traffic_avoidance_lost"), events::Log::Critical, "Traffic avoidance system lost");
|
||||
_vehicle_status.traffic_avoidance_system_present = false;
|
||||
_traffic_avoidance_system_lost = true;
|
||||
_status_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Commander::battery_status_check()
|
||||
|
||||
@@ -243,6 +243,7 @@ private:
|
||||
hrt_abstime _datalink_last_heartbeat_gcs{0};
|
||||
hrt_abstime _datalink_last_heartbeat_onboard_controller{0};
|
||||
hrt_abstime _datalink_last_heartbeat_parachute_system{0};
|
||||
hrt_abstime _datalink_last_heartbeat_traffic_avoidance_system{0};
|
||||
|
||||
hrt_abstime _last_print_mode_reject_time{0}; ///< To remember when last notification was sent
|
||||
|
||||
@@ -268,6 +269,7 @@ private:
|
||||
bool _open_drone_id_system_lost{true};
|
||||
bool _onboard_controller_lost{false};
|
||||
bool _parachute_system_lost{true};
|
||||
bool _traffic_avoidance_system_lost{true};
|
||||
|
||||
bool _last_overload{false};
|
||||
bool _mode_switch_mapped{false};
|
||||
|
||||
@@ -65,6 +65,7 @@ px4_add_library(health_and_arming_checks
|
||||
checks/rcCalibrationCheck.cpp
|
||||
checks/sdcardCheck.cpp
|
||||
checks/systemCheck.cpp
|
||||
checks/trafficAvoidanceCheck.cpp
|
||||
checks/vtolCheck.cpp
|
||||
checks/windCheck.cpp
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
#include "checks/vtolCheck.hpp"
|
||||
#include "checks/offboardCheck.hpp"
|
||||
#include "checks/openDroneIDCheck.hpp"
|
||||
#include "checks/trafficAvoidanceCheck.hpp"
|
||||
#include "checks/externalChecks.hpp"
|
||||
|
||||
class HealthAndArmingChecks : public ModuleParams
|
||||
@@ -157,6 +158,7 @@ private:
|
||||
RcAndDataLinkChecks _rc_and_data_link_checks;
|
||||
VtolChecks _vtol_checks;
|
||||
OffboardChecks _offboard_checks;
|
||||
TrafficAvoidanceChecks _traffic_avoidance_checks;
|
||||
#ifndef CONSTRAINED_FLASH
|
||||
ExternalChecks _external_checks;
|
||||
#endif
|
||||
@@ -197,5 +199,6 @@ private:
|
||||
&_flight_time_checks,
|
||||
&_rc_and_data_link_checks,
|
||||
&_vtol_checks,
|
||||
&_traffic_avoidance_checks,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2026 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 "trafficAvoidanceCheck.hpp"
|
||||
|
||||
|
||||
void TrafficAvoidanceChecks::checkAndReport(const Context &context, Report &reporter)
|
||||
{
|
||||
NavModes affected_modes{NavModes::None}; // COM_ARM_TRAFF 1 - warning only, arming allowed, affected_modes stays None
|
||||
|
||||
switch (_param_com_arm_traff.get()) {
|
||||
case 0:
|
||||
return; // Check disabled
|
||||
|
||||
case 2:
|
||||
affected_modes = NavModes::All; // Disallow arming for all modes
|
||||
break;
|
||||
|
||||
case 3:
|
||||
affected_modes = NavModes::Mission; // Disallow arming for mission
|
||||
break;
|
||||
}
|
||||
|
||||
if (!context.status().traffic_avoidance_system_present) {
|
||||
/* EVENT
|
||||
* @description
|
||||
* Traffic avoidance system (ADSB/FLARM) failed to report. Make sure it is setup and connected properly.
|
||||
*
|
||||
* <profile name="dev">
|
||||
* This check can be configured via <param>COM_ARM_TRAFF</param> parameter.
|
||||
* </profile>
|
||||
*/
|
||||
reporter.armingCheckFailure(affected_modes, health_component_t::traffic_avoidance,
|
||||
events::ID("check_traffic_avoidance_missing"),
|
||||
events::Log::Error, "Traffic avoidance system missing");
|
||||
|
||||
if (reporter.mavlink_log_pub()) {
|
||||
mavlink_log_critical(reporter.mavlink_log_pub(), "Preflight Fail: Traffic avoidance system missing");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2026 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Common.hpp"
|
||||
|
||||
class TrafficAvoidanceChecks : public HealthAndArmingCheckBase
|
||||
{
|
||||
public:
|
||||
TrafficAvoidanceChecks() = default;
|
||||
~TrafficAvoidanceChecks() = default;
|
||||
|
||||
void checkAndReport(const Context &context, Report &reporter) override;
|
||||
|
||||
private:
|
||||
DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase,
|
||||
(ParamInt<px4::params::COM_ARM_TRAFF>) _param_com_arm_traff
|
||||
)
|
||||
};
|
||||
@@ -836,6 +836,21 @@ PARAM_DEFINE_INT32(COM_ARM_HFLT_CHK, 1);
|
||||
*/
|
||||
PARAM_DEFINE_INT32(COM_ARM_ODID, 0);
|
||||
|
||||
/**
|
||||
* Enable Traffic Avoidance system detection check
|
||||
*
|
||||
* This check detects if a traffic avoidance system (ADSB/FLARM transponder)
|
||||
* is missing. Depending on the value of the parameter, the check can be
|
||||
* disabled, warn only, or deny arming.
|
||||
*
|
||||
* @group Commander
|
||||
* @value 0 Disabled
|
||||
* @value 1 Warning only
|
||||
* @value 2 Enforce for all modes
|
||||
* @value 3 Enforce for mission modes only
|
||||
*/
|
||||
PARAM_DEFINE_INT32(COM_ARM_TRAFF, 0);
|
||||
|
||||
/**
|
||||
* Enforced delay between arming and further navigation
|
||||
*
|
||||
|
||||
@@ -2177,6 +2177,10 @@ MavlinkReceiver::handle_message_heartbeat(mavlink_message_t *msg)
|
||||
_heartbeat_type_adsb = now;
|
||||
break;
|
||||
|
||||
case MAV_TYPE_FLARM:
|
||||
_heartbeat_type_flarm = now;
|
||||
break;
|
||||
|
||||
case MAV_TYPE_CAMERA:
|
||||
_heartbeat_type_camera = now;
|
||||
camera_status.timestamp = now;
|
||||
@@ -2925,6 +2929,7 @@ void MavlinkReceiver::CheckHeartbeats(const hrt_abstime &t, bool force)
|
||||
tstatus.heartbeat_type_onboard_controller = (t <= TIMEOUT + _heartbeat_type_onboard_controller);
|
||||
tstatus.heartbeat_type_gimbal = (t <= TIMEOUT + _heartbeat_type_gimbal);
|
||||
tstatus.heartbeat_type_adsb = (t <= TIMEOUT + _heartbeat_type_adsb);
|
||||
tstatus.heartbeat_type_flarm = (t <= TIMEOUT + _heartbeat_type_flarm);
|
||||
tstatus.heartbeat_type_camera = (t <= TIMEOUT + _heartbeat_type_camera);
|
||||
tstatus.heartbeat_type_parachute = (t <= TIMEOUT + _heartbeat_type_parachute);
|
||||
tstatus.heartbeat_type_open_drone_id = (t <= TIMEOUT + _heartbeat_type_open_drone_id);
|
||||
|
||||
@@ -391,6 +391,7 @@ private:
|
||||
hrt_abstime _heartbeat_type_onboard_controller{0};
|
||||
hrt_abstime _heartbeat_type_gimbal{0};
|
||||
hrt_abstime _heartbeat_type_adsb{0};
|
||||
hrt_abstime _heartbeat_type_flarm{0};
|
||||
hrt_abstime _heartbeat_type_camera{0};
|
||||
hrt_abstime _heartbeat_type_parachute{0};
|
||||
hrt_abstime _heartbeat_type_open_drone_id{0};
|
||||
|
||||
Reference in New Issue
Block a user