mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-07-27 00:48:23 +08:00
feat(commander): add companion computer temperature warning check (#27637)
* feat(commander) add companion computer temperature warning check * refactor(commander): improve wording * Apply suggestions from code review Co-authored-by: Silvan Fuhrer <silvan@auterion.com> --------- Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
@@ -40,6 +40,7 @@ px4_add_library(health_and_arming_checks
|
||||
checks/armPermissionCheck.cpp
|
||||
checks/baroCheck.cpp
|
||||
checks/batteryCheck.cpp
|
||||
checks/companionComputerCheck.cpp
|
||||
checks/cpuResourceCheck.cpp
|
||||
checks/distanceSensorChecks.cpp
|
||||
checks/opticalFlowCheck.cpp
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "checks/airspeedCheck.hpp"
|
||||
#include "checks/armPermissionCheck.hpp"
|
||||
#include "checks/baroCheck.hpp"
|
||||
#include "checks/companionComputerCheck.hpp"
|
||||
#include "checks/cpuResourceCheck.hpp"
|
||||
#include "checks/distanceSensorChecks.hpp"
|
||||
#include "checks/opticalFlowCheck.hpp"
|
||||
@@ -135,6 +136,7 @@ private:
|
||||
AirspeedChecks _airspeed_checks;
|
||||
ArmPermissionChecks _arm_permission_checks;
|
||||
BaroChecks _baro_checks;
|
||||
CompanionComputerChecks _companion_computer_checks;
|
||||
CpuResourceChecks _cpu_resource_checks;
|
||||
DistanceSensorChecks _distance_sensor_checks;
|
||||
OpticalFlowCheck _optical_flow_check;
|
||||
@@ -170,7 +172,7 @@ private:
|
||||
ExternalChecks _external_checks;
|
||||
#endif
|
||||
|
||||
HealthAndArmingCheckBase *_checks[41] = {
|
||||
HealthAndArmingCheckBase *_checks[42] = {
|
||||
#ifndef CONSTRAINED_FLASH
|
||||
&_external_checks,
|
||||
#endif
|
||||
@@ -178,6 +180,7 @@ private:
|
||||
&_airspeed_checks,
|
||||
&_arm_permission_checks,
|
||||
&_baro_checks,
|
||||
&_companion_computer_checks,
|
||||
&_cpu_resource_checks,
|
||||
&_distance_sensor_checks,
|
||||
&_optical_flow_check,
|
||||
|
||||
@@ -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 "companionComputerCheck.hpp"
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
void CompanionComputerChecks::checkAndReport(const Context &context, Report &reporter)
|
||||
{
|
||||
const float temperature_warn_threshold = _param_com_cc_temp_warn.get();
|
||||
|
||||
if (temperature_warn_threshold < FLT_EPSILON) {
|
||||
return;
|
||||
}
|
||||
|
||||
onboard_computer_status_s onboard_computer_status;
|
||||
|
||||
// Skip if no companion computer is connected or reporting.
|
||||
if (!_onboard_computer_status_sub.copy(&onboard_computer_status)
|
||||
|| hrt_elapsed_time(&onboard_computer_status.timestamp) > 5_s
|
||||
|| onboard_computer_status.temperature_board == INT8_MAX) {
|
||||
return;
|
||||
}
|
||||
|
||||
const float temperature_board = (float)onboard_computer_status.temperature_board;
|
||||
|
||||
if (temperature_board >= temperature_warn_threshold) {
|
||||
/* EVENT
|
||||
* @description
|
||||
* The companion computer temperature is above the warning threshold.
|
||||
*
|
||||
* <profile name="dev">
|
||||
* The threshold can be adjusted via <param>COM_CC_TEMP_WARN</param> parameter.
|
||||
* </profile>
|
||||
*/
|
||||
reporter.healthFailure<int8_t>(NavModes::None, health_component_t::system,
|
||||
events::ID("check_companion_computer_temperature_high"),
|
||||
events::Log::Warning, "Companion computer temperature warning, {1} C",
|
||||
onboard_computer_status.temperature_board);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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"
|
||||
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/onboard_computer_status.h>
|
||||
|
||||
class CompanionComputerChecks : public HealthAndArmingCheckBase
|
||||
{
|
||||
public:
|
||||
CompanionComputerChecks() = default;
|
||||
~CompanionComputerChecks() = default;
|
||||
|
||||
void checkAndReport(const Context &context, Report &reporter) override;
|
||||
|
||||
private:
|
||||
uORB::Subscription _onboard_computer_status_sub{ORB_ID(onboard_computer_status)};
|
||||
|
||||
DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase,
|
||||
(ParamFloat<px4::params::COM_CC_TEMP_WARN>) _param_com_cc_temp_warn
|
||||
)
|
||||
};
|
||||
@@ -595,6 +595,22 @@ parameters:
|
||||
decimal: 1
|
||||
increment: 0.1
|
||||
unit: s
|
||||
COM_CC_TEMP_WARN:
|
||||
description:
|
||||
short: Companion computer high-temperature warning threshold
|
||||
long: |-
|
||||
|
||||
|
||||
Arming is not prevented as the temperature typically drops in flight.
|
||||
|
||||
Set to -1 to disable.
|
||||
type: float
|
||||
default: 80.0
|
||||
min: -1
|
||||
max: 127
|
||||
decimal: 0
|
||||
increment: 1
|
||||
unit: celcius
|
||||
COM_WIND_WARN:
|
||||
description:
|
||||
short: Wind speed warning threshold
|
||||
|
||||
Reference in New Issue
Block a user