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

ArmingChecks: disallow arming via parameter #21742

Merged
merged 2 commits into from
Jun 22, 2023
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
37 changes: 20 additions & 17 deletions src/modules/commander/HealthAndArmingChecks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,37 @@
px4_add_library(health_and_arming_checks
Common.cpp
HealthAndArmingChecks.cpp
checks/systemCheck.cpp
checks/magnetometerCheck.cpp

checks/accelerometerCheck.cpp
checks/gyroCheck.cpp
checks/baroCheck.cpp
checks/imuConsistencyCheck.cpp
checks/airspeedCheck.cpp
checks/armPermissionCheck.cpp
checks/baroCheck.cpp
checks/batteryCheck.cpp
checks/cpuResourceCheck.cpp
checks/distanceSensorChecks.cpp
checks/escCheck.cpp
checks/rcCalibrationCheck.cpp
checks/powerCheck.cpp
checks/estimatorCheck.cpp
checks/failureDetectorCheck.cpp
checks/manualControlCheck.cpp
checks/modeCheck.cpp
checks/cpuResourceCheck.cpp
checks/sdcardCheck.cpp
checks/parachuteCheck.cpp
checks/batteryCheck.cpp
checks/windCheck.cpp
checks/flightTimeCheck.cpp
checks/geofenceCheck.cpp
checks/gyroCheck.cpp
checks/homePositionCheck.cpp
checks/flightTimeCheck.cpp
checks/imuConsistencyCheck.cpp
checks/magnetometerCheck.cpp
checks/manualControlCheck.cpp
checks/missionCheck.cpp
checks/rcAndDataLinkCheck.cpp
checks/vtolCheck.cpp
checks/modeCheck.cpp
checks/offboardCheck.cpp
checks/openDroneIDCheck.cpp
checks/parachuteCheck.cpp
checks/powerCheck.cpp
checks/rcAndDataLinkCheck.cpp
checks/rcCalibrationCheck.cpp
checks/sdcardCheck.cpp
checks/systemCheck.cpp
checks/vtolCheck.cpp
checks/windCheck.cpp

)
add_dependencies(health_and_arming_checks mode_util)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#include "checks/accelerometerCheck.hpp"
#include "checks/airspeedCheck.hpp"
#include "checks/armPermissionCheck.hpp"
#include "checks/baroCheck.hpp"
#include "checks/cpuResourceCheck.hpp"
#include "checks/distanceSensorChecks.hpp"
Expand Down Expand Up @@ -115,6 +116,7 @@ class HealthAndArmingChecks : public ModuleParams
// all checks
AccelerometerChecks _accelerometer_checks;
AirspeedChecks _airspeed_checks;
ArmPermissionChecks _arm_permission_checks;
BaroChecks _baro_checks;
CpuResourceChecks _cpu_resource_checks;
DistanceSensorChecks _distance_sensor_checks;
Expand Down Expand Up @@ -145,6 +147,7 @@ class HealthAndArmingChecks : public ModuleParams
HealthAndArmingCheckBase *_checks[31] = {
&_accelerometer_checks,
&_airspeed_checks,
&_arm_permission_checks,
&_baro_checks,
&_cpu_resource_checks,
&_distance_sensor_checks,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/****************************************************************************
*
* 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 "armPermissionCheck.hpp"

void ArmPermissionChecks::checkAndReport(const Context &context, Report &reporter)
{
if (_param_com_armable.get() < 1) {
/* EVENT
* @description
* Vehicle is in safety configuration and denies arming.
*
* <profile name="dev">
* This check can be configured via <param>COM_ARMABLE</param> parameter.
* </profile>
*/
reporter.armingCheckFailure(NavModes::All, health_component_t::system,
events::ID("check_armable_configuration"),
events::Log::Error, "Vehicle is in safety configuration");

if (reporter.mavlink_log_pub()) {
mavlink_log_critical(reporter.mavlink_log_pub(), "Preflight Fail: Vehicle is in safety configuration");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/****************************************************************************
*
* 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.
*
****************************************************************************/

#pragma once

#include "../Common.hpp"

class ArmPermissionChecks : public HealthAndArmingCheckBase
{
public:
ArmPermissionChecks() = default;
~ArmPermissionChecks() = default;

void checkAndReport(const Context &context, Report &reporter) override;

private:
DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase,
(ParamInt<px4::params::COM_ARMABLE>) _param_com_armable
)
};
12 changes: 12 additions & 0 deletions src/modules/commander/commander_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,3 +1104,15 @@ PARAM_DEFINE_FLOAT(COM_WIND_MAX, -1.f);
* @unit m
*/
PARAM_DEFINE_FLOAT(COM_POS_LOW_EPH, -1.0f);

/**
* Flag to allow arming
*
* Set 0 to prevent accidental use of the vehicle e.g. for safety or maintenance reasons.
*
* @boolean
* @value 0 Disallow arming
* @value 1 Allow arming
* @group Commander
*/
PARAM_DEFINE_INT32(COM_ARMABLE, 1);
Loading