mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
feat(commander)!: Replace CBRK_IO_SAFETY with COM_SAFETY_MODE for more options (#28744)
* feat(commander): only report safety button as available when it is available and configured to be used via COM_PREARM_MODE * feat(commander): add a new option to COM_PREARM_MODE to explicitly and exclusively allow prearming via VEHICLE_CMD_DO_SET_SAFETY_SWITCH_STATE * feat(commander): explicit dedicated safety-button-only and mavlink-only prearm modes * fix(commander): also accept VEHICLE_CMD_DO_SET_SAFETY_SWITCH_STATE on Always and Disarmed pre-arm profiles to match documentation * docs(prearm): update docs with new prearm mode behaviour * fix(commander): fix syntax for bool * docs(prearm): revert last param table, as COM_FORCE_SAFETY is already mentioned in a table above. * docs(prearm): fix MAVLink spelling, grammar and parameter table Make the pre-arm docs consistent with the COM_PREARM_MODE parameter and the docs style guide: MAVLink is spelled consistently (page and option labels), selectable option names are shown in code style, the parameter table lists all five COM_PREARM_MODE options with the correct default, and sentences are fixed and put one per line. Question for the author: the COM_PREARM_MODE option labels say "Safety button", while the docs say "safety switch". Are these synonyms? If so, which term should we use in both places? If not, what is the difference? Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Hamish Willee <hamishwillee@gmail.com> * fix(commander): clean up _button_disabled logic: button still needs to be enabled in Disabled and Always prearmed modes to switch safety off. * docs(prearm): adjust COM_PREARM_MODE description and clarify/fix/improve prearm docs * chore(VehicleCommand.msg): improved comments * chore(msg): v0->v1 translation for VehicleCommand.msg * Revert "chore(msg): v0->v1 translation for VehicleCommand.msg" This reverts commit 50ea14fc76310ba7b53ebcd1c6ee8cf4e1c0776b. * feat(commander): deny VEHICLE_CMD_DO_SET_SAFETY_SWITCH_STATE when not accepted * feat(commander): COM_SAFETY_MODE replaces CBRK_IO_SAFETY * docs(prearm): update docs with new COM_SAFETY_MODE behaviour * docs(prearm): minor cleanup * fix(commander): migrate CBRK_IO_SAFETY and correct safety ACKs A stored CBRK_IO_SAFETY=0 was dropped on import, so upgraded vehicles booted with COM_SAFETY_MODE=0 and safety off. The CAN GPS nodes have no commander, so setting COM_SAFETY_MODE there only logged an error at boot. A SAFETY_SAFE command in mode 0 and ESC calibration with safety on were ACKed ACCEPTED while doing nothing. Assisted-by: Claude:claude-opus-5-5 --------- Signed-off-by: Hamish Willee <hamishwillee@gmail.com> Co-authored-by: Hamish Willee <hamishwillee@gmail.com> Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
This commit is contained in:
19 files changed
+166
-129
No files matched your search
@@ -3,7 +3,6 @@
|
||||
# board specific defaults
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
param set-default CBRK_IO_SAFETY 0
|
||||
param set-default MBE_ENABLE 0
|
||||
param set-default SENS_IMU_CLPNOTI 0
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# board specific defaults
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
param set-default CBRK_IO_SAFETY 0
|
||||
param set-default CANNODE_SUB_MBD 1
|
||||
param set-default CANNODE_SUB_RTCM 1
|
||||
param set-default GPS_1_GNSS 63
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# board specific defaults
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
param set-default CBRK_IO_SAFETY 0
|
||||
param set-default CANNODE_SUB_MBD 1
|
||||
param set-default CANNODE_SUB_RTCM 1
|
||||
param set-default GPS_1_GNSS 63
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# board specific defaults
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
param set-default CBRK_IO_SAFETY 0
|
||||
param set-default CANNODE_SUB_MBD 1
|
||||
param set-default CANNODE_SUB_RTCM 1
|
||||
param set-default MBE_ENABLE 0
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# board specific defaults
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
param set-default CBRK_IO_SAFETY 0
|
||||
param set-default CANNODE_SUB_MBD 1
|
||||
param set-default CANNODE_SUB_RTCM 1
|
||||
param set-default MBE_ENABLE 0
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# board specific defaults
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
param set-default CBRK_IO_SAFETY 0
|
||||
param set-default CANNODE_SUB_MBD 1
|
||||
param set-default CANNODE_SUB_RTCM 1
|
||||
param set-default GPS_1_GNSS 47
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
# board specific defaults
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
param set-default CBRK_IO_SAFETY 0
|
||||
|
||||
neopixel start
|
||||
safety_button start
|
||||
tone_alarm start
|
||||
@@ -15,7 +15,7 @@ While not technically correct for pre-armed vehicles, it is "safe".
|
||||
|
||||
Users can control progression though these states using a [safety switch](../getting_started/px4_basic_concepts.md#safety-switch) on the vehicle (optional) _and_ an [arming switch/button](#arm_disarm_switch), [arming gesture](#arm_disarm_gestures), or _MAVLink command_ on the ground controller:
|
||||
|
||||
- A _safety switch_ is a control _on the vehicle_ that must be engaged before the vehicle can be armed, and which may also prevent prearming (depending on the configuration).
|
||||
- A _safety switch_ is a control _on the vehicle_ that must be engaged before the vehicle can be armed, and which may also prevent pre-arming (depending on the configuration).
|
||||
Commonly the safety switch is integrated into a GPS unit, but it may also be a separate physical component.
|
||||
|
||||
:::warning
|
||||
@@ -25,7 +25,7 @@ Users can control progression though these states using a [safety switch](../get
|
||||
|
||||
- An _arming switch_ is a switch or button _on an RC controller_ that can be used to arm the vehicle and start motors (provided arming is not prevented by a safety switch).
|
||||
- An _arming gesture_ is a stick movement _on an RC controller_ that can be used as an alternative to an arming switch.
|
||||
- MAVLink commands can also be sent by a ground control station to arm/disarm a vehicle.
|
||||
- MAVLink commands can also be sent by a ground control station to pre-arm, arm, or disarm a vehicle.
|
||||
|
||||
PX4 will also automatically disarm the vehicle if it does not takeoff within a certain amount of time after arming, and if it is not manually disarmed after landing.
|
||||
This reduces the amount of time where an armed (and therefore dangerous) vehicle is on the ground.
|
||||
@@ -91,6 +91,15 @@ The feature is configured using the following timeouts.
|
||||
| <a id="COM_DISARM_LAND"></a>[COM_DISARM_LAND](../advanced_config/parameter_reference.md#COM_DISARM_LAND) | Time-out for auto disarm after landing. Default: 2s (-1 to disable). |
|
||||
| <a id="COM_DISARM_PRFLT"></a>[COM_DISARM_PRFLT](../advanced_config/parameter_reference.md#COM_DISARM_PRFLT) | Time-out for auto disarm if too slow to takeoff. Default: 10s (-1 to disable). |
|
||||
|
||||
By default, the vehicle keeps safety off after disarming.
|
||||
If [COM_FORCE_SAFETY](#COM_FORCE_SAFETY) is set to `1`, safety is re-enabled on disarm, so it must be turned off again (by switch or MAVLink command, depending on [COM_SAFETY_MODE](#COM_SAFETY_MODE)) before the next arming.
|
||||
In modes that pre-arm when safety is turned off, this also exits the pre-armed state.
|
||||
This parameter has no effect when `COM_SAFETY_MODE` is set to `0`.
|
||||
|
||||
| Parameter | Description |
|
||||
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
|
||||
| <a id="COM_FORCE_SAFETY"></a>[COM_FORCE_SAFETY](../advanced_config/parameter_reference.md#COM_FORCE_SAFETY) | Re-enable safety when the vehicle disarms. Default: `0` (Disabled). |
|
||||
|
||||
## Auto-Arming on Boot
|
||||
|
||||
The vehicle can be configured to arm automatically on boot once all preflight checks pass,
|
||||
@@ -113,14 +122,14 @@ Ensure the vehicle is in a safe state before powering on.
|
||||
| -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
||||
| <a id="COM_ARM_ON_BOOT"></a>[COM_ARM_ON_BOOT](../advanced_config/parameter_reference.md#COM_ARM_ON_BOOT) | Arm automatically once preflight checks pass after boot. Default: `0` (Disabled). |
|
||||
|
||||
## Pre-Arm Checks
|
||||
## Pre-Arm Checks {#prearm_checks}
|
||||
|
||||
To reduce accidents, vehicles are only allowed to arm certain conditions are met (some of which are configurable).
|
||||
Arming is prevented if:
|
||||
|
||||
- The vehicle is not in a "healthy" state.
|
||||
For example it is not calibrated, or is reporting sensor errors.
|
||||
- The vehicle has a [safety switch](../getting_started/px4_basic_concepts.md#safety-switch) that has not been engaged.
|
||||
- The vehicle still has its [safety state](#safety_state) set to _ON_. This could for instance be a [safety switch](../getting_started/px4_basic_concepts.md#safety-switch) that has not been engaged.
|
||||
- The vehicle has a [remote ID](../peripherals/remote_id.md) that is unhealthy or otherwise not ready
|
||||
- A VTOL vehicle is in fixed-wing mode ([by default](../advanced_config/parameter_reference.md#CBRK_VTOLARMING)).
|
||||
- The current mode requires an adequate global position estimate but the vehicle does not have GPS lock.
|
||||
@@ -131,7 +140,7 @@ The current failed checks can be viewed in QGroundControl (v4.2.0 and later) [Ar
|
||||
Note that internally PX4 runs arming checks at 10Hz.
|
||||
A list of the failed checks is kept, and if the list changes PX4 emits the current list using the [Events interface](../concept/events_interface.md).
|
||||
The list is also sent out when the GCS connects.
|
||||
Effectively the GCS knows the status of prearm checks immediately, both when disarmed and armed.
|
||||
Effectively the GCS knows the status of pre-arm checks immediately, both when disarmed and armed.
|
||||
|
||||
:::details Implementation notes for developers
|
||||
The client implementation is in [libevents](https://github.com/mavlink/libevents):
|
||||
@@ -144,44 +153,53 @@ QGC implementation: [HealthAndArmingCheckReport.cc](https://github.com/mavlink/q
|
||||
|
||||
PX4 also emits a subset of the arming check information in the [SYS_STATUS](https://mavlink.io/en/messages/common.html#SYS_STATUS) message (see [MAV_SYS_STATUS_SENSOR](https://mavlink.io/en/messages/common.html#MAV_SYS_STATUS_SENSOR)).
|
||||
|
||||
## Arming Sequence: Pre Arm Mode & Safety Button
|
||||
## Arming Sequence: Safety State {#safety_state}
|
||||
|
||||
The arming sequence depends on whether or not there is a _safety switch_, and is controlled by the parameters [COM_PREARM_MODE](#COM_PREARM_MODE) (Prearm mode) and [CBRK_IO_SAFETY](#CBRK_IO_SAFETY) (I/O safety circuit breaker).
|
||||
The arming sequence depends on whether or not there is a _safety switch_, and is controlled by the parameter [COM_SAFETY_MODE](#COM_SAFETY_MODE). Changes to the parameter only take effect after a reboot.
|
||||
|
||||
The [COM_PREARM_MODE](#COM_PREARM_MODE) parameter defines when/if pre-arm mode is enabled ("safe"/non-throttling actuators are able to move):
|
||||
When disarmed (or pre-armed), the safety state can either be _ON_ (a.k.a. _SAFE_), or _OFF_ (a.k.a. _DANGEROUS_). When it is _ON_, arming will always be prevented. When it is _OFF_, the vehicle can be armed for as long as the [pre-arm checks](#prearm_checks) have passed.
|
||||
|
||||
- _Disabled_: Pre-arm mode disabled (there is no stage where only "safe"/non-throttling actuators are enabled).
|
||||
- _Safety Switch_ (Default): The pre-arm mode is enabled by the safety switch.
|
||||
If there is no safety switch then pre-arm mode will not be enabled.
|
||||
- _Always_: Prearm mode is enabled from power up.
|
||||
Additionally, the [COM_PREARM_MODE](#COM_PREARM_MODE) parameter defines when/if pre-arm mode is enabled ("safe"/non-throttling actuators are able to move):
|
||||
|
||||
If there is a safety switch then this will be a precondition for arming.
|
||||
If there is no safety switch the I/O safety circuit breaker must be engaged ([CBRK_IO_SAFETY](#CBRK_IO_SAFETY)), and arming will depend only on the arm command.
|
||||
- `Disabled` (Default): Pre-arm mode disabled (there is no stage where only non-throttling actuators are enabled).
|
||||
- `When safety off`: Pre-arm mode is enabled when safety is turned off.
|
||||
- `Always`: Pre-arm mode is enabled from power up.
|
||||
|
||||
The sections below detail the startup sequences for the different configurations
|
||||
The sections below detail the startup sequences for the different configurations of [COM_SAFETY_MODE](#COM_SAFETY_MODE) and [COM_PREARM_MODE](#COM_PREARM_MODE).
|
||||
|
||||
### Default: COM_PREARM_MODE=Safety and Safety Switch
|
||||
### COM_SAFETY_MODE=Always off (Default) and COM_PREARM_MODE=Disabled (Default)
|
||||
|
||||
The default configuration uses safety switch to prearm.
|
||||
From prearm you can then arm to engage all motors/actuators.
|
||||
It corresponds to: [COM_PREARM_MODE=1](#COM_PREARM_MODE) (safety switch) and [CBRK_IO_SAFETY=0](#CBRK_IO_SAFETY) (I/O safety circuit breaker disabled).
|
||||
The default configuration does not impose any additional safety measures. Arming is possible as soon as the rest of the system is ready.
|
||||
|
||||
The default startup sequence is:
|
||||
The startup sequence is:
|
||||
|
||||
1. Power-up.
|
||||
- All actuators locked into disarmed position
|
||||
- Not possible to arm.
|
||||
1. Safety switch is pressed.
|
||||
- System now prearmed: non-throttling actuators can move (e.g. ailerons).
|
||||
- System safety is off: Arming possible.
|
||||
- System safety is off: Arming possible once the other pre-arm checks pass.
|
||||
1. Arm command is issued.
|
||||
- The system is armed.
|
||||
- All motors and actuators can move.
|
||||
|
||||
### COM_PREARM_MODE=Disabled and Safety Switch
|
||||
### COM_SAFETY_MODE=Safety switch (physical or virtual via MAVLink) and COM_PREARM_MODE=When safety off
|
||||
|
||||
When prearm mode is _Disabled_, engaging the safety switch does not unlock the "safe" actuators, though it does allow you to then arm the vehicle.
|
||||
This corresponds to [COM_PREARM_MODE=0](#COM_PREARM_MODE) (Disabled) and [CBRK_IO_SAFETY=0](#CBRK_IO_SAFETY) (I/O safety circuit breaker disabled).
|
||||
This configuration lets you use either the safety switch or a MAVLink command [MAV_CMD_DO_SET_SAFETY_SWITCH_STATE](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_SET_SAFETY_SWITCH_STATE) to turn safety off. Note that sending the corresponding MAVLink command with SAFETY_SWITCH_STATE_SAFE also lets you turn safety back on, but the physical switch does *not* allow to go back to a safe state.
|
||||
|
||||
The startup sequence is:
|
||||
|
||||
1. Power-up.
|
||||
- All actuators locked into disarmed position
|
||||
- Not possible to arm.
|
||||
1. Safety switch is pressed or a MAVLink command is received.
|
||||
- System now pre-armed: non-throttling actuators can move (e.g. ailerons).
|
||||
- System safety is off: Arming possible once the other pre-arm checks pass.
|
||||
1. Arm command is issued.
|
||||
- The system is armed.
|
||||
- All motors and actuators can move.
|
||||
|
||||
### COM_SAFETY_MODE=Physical safety switch only and COM_PREARM_MODE=When safety off
|
||||
|
||||
When safety mode is `Physical safety switch only`, you must press the safety switch to turn safety off. Note that pressing the safety switch again does *not* allow to go back to a safe state.
|
||||
The MAVLink command is rejected.
|
||||
|
||||
The startup sequence is:
|
||||
|
||||
@@ -189,63 +207,35 @@ The startup sequence is:
|
||||
- All actuators locked into disarmed position
|
||||
- Not possible to arm.
|
||||
1. Safety switch is pressed.
|
||||
- _All actuators stay locked into disarmed position (same as disarmed)._
|
||||
- System safety is off: Arming possible.
|
||||
- System now pre-armed: non-throttling actuators can move (e.g. ailerons).
|
||||
- System safety is off: Arming possible once the other pre-arm checks pass.
|
||||
1. Arm command is issued.
|
||||
- The system is armed.
|
||||
- All motors and actuators can move.
|
||||
|
||||
### COM_PREARM_MODE=Always and Safety Switch
|
||||
### COM_SAFETY_MODE=MAVLink only and COM_PREARM_MODE=When safety off
|
||||
|
||||
When prearm mode is _Always_, prearm mode is enabled from power up.
|
||||
To arm, you still need the safety switch.
|
||||
This corresponds to [COM_PREARM_MODE=2](#COM_PREARM_MODE) (Always) and [CBRK_IO_SAFETY=0](#CBRK_IO_SAFETY) (I/O safety circuit breaker disabled).
|
||||
|
||||
The startup sequence is:
|
||||
|
||||
1. Power-up.
|
||||
- System now prearmed: non-throttling actuators can move (e.g. ailerons).
|
||||
- Not possible to arm.
|
||||
1. Safety switch is pressed.
|
||||
- System safety is off: Arming possible.
|
||||
1. Arm command is issued.
|
||||
- The system is armed.
|
||||
- All motors and actuators can move.
|
||||
|
||||
### COM_PREARM_MODE=Safety or Disabled and No Safety Switch
|
||||
|
||||
With no safety switch, when `COM_PREARM_MODE` is set to _Safety_ or _Disabled_ prearm mode cannot be enabled (same as disarmed).
|
||||
This corresponds to [COM_PREARM_MODE=0 or 1](#COM_PREARM_MODE) (Disabled/Safety Switch) and [CBRK_IO_SAFETY=22027](#CBRK_IO_SAFETY) (I/O safety circuit breaker engaged).
|
||||
When safety mode is `MAVLink only`, you must send a MAVLink command [MAV_CMD_DO_SET_SAFETY_SWITCH_STATE](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_SET_SAFETY_SWITCH_STATE) to turn safety off. Note that sending the corresponding MAVLink command with SAFETY_SWITCH_STATE_SAFE also lets you turn safety back on.
|
||||
Any physical safety switch is ignored.
|
||||
|
||||
The startup sequence is:
|
||||
|
||||
1. Power-up.
|
||||
- All actuators locked into disarmed position
|
||||
- System safety is off: Arming possible.
|
||||
1. Arm command is issued.
|
||||
- The system is armed.
|
||||
- All motors and actuators can move.
|
||||
|
||||
### COM_PREARM_MODE=Always and No Safety Switch
|
||||
|
||||
When prearm mode is _Always_, prearm mode is enabled from power up.
|
||||
This corresponds to [COM_PREARM_MODE=2](#COM_PREARM_MODE) (Always) and [CBRK_IO_SAFETY=22027](#CBRK_IO_SAFETY) (I/O safety circuit breaker engaged).
|
||||
|
||||
The startup sequence is:
|
||||
|
||||
1. Power-up.
|
||||
- System now prearmed: non-throttling actuators can move (e.g. ailerons).
|
||||
- System safety is off: Arming possible.
|
||||
- Not possible to arm.
|
||||
1. A MAVLink command is received.
|
||||
- System now pre-armed: non-throttling actuators can move (e.g. ailerons).
|
||||
- System safety is off: Arming possible once the other pre-arm checks pass.
|
||||
1. Arm command is issued.
|
||||
- The system is armed.
|
||||
- All motors and actuators can move.
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Description |
|
||||
| -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| <a id="COM_PREARM_MODE"></a>[COM_PREARM_MODE](../advanced_config/parameter_reference.md#COM_PREARM_MODE) | Condition to enter prearmed mode. `0`: Disabled, `1`: Safety switch (prearm mode enabled by safety switch; if no switch present cannot be enabled), `2`: Always (prearm mode enabled from power up). Default: `1` (safety button). |
|
||||
| <a id="CBRK_IO_SAFETY"></a>[CBRK_IO_SAFETY](../advanced_config/parameter_reference.md#CBRK_IO_SAFETY) | Circuit breaker for IO safety. |
|
||||
| Parameter | Description |
|
||||
| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
||||
| <a id="COM_SAFETY_MODE"></a>[COM_SAFETY_MODE](../advanced_config/parameter_reference.md#COM_SAFETY_MODE) | Condition to turn safety off. Vehicle arming is prevented for as long as safety is on. |
|
||||
| <a id="COM_PREARM_MODE"></a>[COM_PREARM_MODE](../advanced_config/parameter_reference.md#COM_PREARM_MODE) | Condition to enter the prearmed state. |
|
||||
|
||||
<!-- Discussion:
|
||||
https://github.com/PX4/PX4-Autopilot/pull/12806#discussion_r318337567
|
||||
|
||||
@@ -206,7 +206,7 @@ Vehicles may include a _safety switch_ that must be engaged before the vehicle c
|
||||
This switch is almost always integrated into the [GPS](../gps_compass/index.md) module that is connected to the Pixhawk `GPS1` port — along with the [buzzer](#buzzer) and [UI LED](#leds).
|
||||
|
||||
The switch may be disabled by default, though this depends on the particular flight controller and airframe configuration.
|
||||
You can disable/enable use of the switch with the [CBRK_IO_SAFETY](../advanced_config/parameter_reference.md#CBRK_IO_SAFETY) parameter.
|
||||
You can disable/enable use of the switch with the [COM_SAFETY_MODE](../advanced_config/parameter_reference.md#COM_SAFETY_MODE) parameter.
|
||||
|
||||
::: info
|
||||
Safety switches are optional.
|
||||
|
||||
@@ -103,7 +103,7 @@ uint16 VEHICLE_CMD_LOGGING_START = 2510 # Start streaming ULog data.
|
||||
uint16 VEHICLE_CMD_LOGGING_STOP = 2511 # Stop streaming ULog data.
|
||||
uint16 VEHICLE_CMD_CONTROL_HIGH_LATENCY = 2600 # Control starting/stopping transmitting data over the high latency link.
|
||||
uint16 VEHICLE_CMD_DO_VTOL_TRANSITION = 3000 # Command VTOL transition.
|
||||
uint16 VEHICLE_CMD_DO_SET_SAFETY_SWITCH_STATE = 5300 # Command safety on/off. |SAFETY_SAFE (0) to activate safety, SAFETY_DANGEROUS (1) to deactivate safety and allow non-throttling actuator movement|Unused|Unused|Unused|Unused|Unused|Unused|uint16 VEHICLE_CMD_ARM_AUTHORIZATION_REQUEST = 3001 # Request arm authorization.
|
||||
uint16 VEHICLE_CMD_DO_SET_SAFETY_SWITCH_STATE = 5300 # Command safety on/off. |SAFETY_SAFE (0) to activate safety, SAFETY_DANGEROUS (1) to deactivate safety and allow non-throttling actuator movement|Unused|Unused|Unused|Unused|Unused|Unused|
|
||||
uint16 VEHICLE_CMD_ARM_AUTHORIZATION_REQUEST = 3001 # Request arm authorization.
|
||||
uint16 VEHICLE_CMD_PAYLOAD_PREPARE_DEPLOY = 30001 # Prepare a payload deployment in the flight plan.
|
||||
uint16 VEHICLE_CMD_PAYLOAD_CONTROL_DEPLOY = 30002 # Control a pre-programmed payload deployment.
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
|
||||
#define CBRK_BUZZER_KEY 782097
|
||||
#define CBRK_SUPPLY_CHK_KEY 894281
|
||||
#define CBRK_IO_SAFETY_KEY 22027
|
||||
#define CBRK_FLIGHTTERM_KEY 121212
|
||||
#define CBRK_USB_CHK_KEY 197848
|
||||
#define CBRK_VTOLARMING_KEY 159753
|
||||
|
||||
@@ -14,17 +14,6 @@ parameters:
|
||||
default: 0
|
||||
min: 0
|
||||
max: 894281
|
||||
CBRK_IO_SAFETY:
|
||||
description:
|
||||
short: Circuit breaker for IO safety
|
||||
long: |-
|
||||
Setting this parameter to 22027 will disable IO safety.
|
||||
WARNING: ENABLING THIS CIRCUIT BREAKER IS AT OWN RISK
|
||||
category: Developer
|
||||
type: int32
|
||||
default: 22027
|
||||
min: 0
|
||||
max: 22027
|
||||
CBRK_FLIGHTTERM:
|
||||
description:
|
||||
short: Circuit breaker for flight termination
|
||||
|
||||
@@ -424,5 +424,16 @@ param_modify_on_import_ret param_modify_on_import(bson_node_t node)
|
||||
}
|
||||
}
|
||||
|
||||
// 2026-10-06: translate CBRK_IO_SAFETY -> COM_SAFETY_MODE. Any value but the breaker key had safety enabled, with
|
||||
// both the switch and the MAVLink command able to turn it off.
|
||||
{
|
||||
if ((node->type == bson_type_t::BSON_INT32) && (strcmp("CBRK_IO_SAFETY", node->name) == 0)) {
|
||||
node->i32 = (node->i32 == 22027) ? 0 : 1;
|
||||
strcpy(node->name, "COM_SAFETY_MODE");
|
||||
PX4_INFO("migrating %s -> %s", "CBRK_IO_SAFETY", "COM_SAFETY_MODE");
|
||||
return param_modify_on_import_ret::PARAM_MODIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
return param_modify_on_import_ret::PARAM_NOT_MODIFIED;
|
||||
}
|
||||
@@ -1525,14 +1525,15 @@ Commander::handle_command(const vehicle_command_s &cmd)
|
||||
} else if ((int)(cmd.param7) == 1) {
|
||||
/* do esc calibration */
|
||||
if (check_battery_disconnected(&_mavlink_log_pub)) {
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED);
|
||||
|
||||
if (_safety.isButtonAvailable() && !_safety.isSafetyOff()) {
|
||||
mavlink_log_critical(&_mavlink_log_pub, "ESC calibration denied! Press safety button first\t");
|
||||
if (!_safety.isSafetyOff()) {
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_DENIED);
|
||||
const char *safety_message = _safety.isButtonAvailable() ? "Press safety button" : "Turn safety off";
|
||||
mavlink_log_critical(&_mavlink_log_pub, "ESC calibration denied! %s first\t", safety_message);
|
||||
events::send(events::ID("commander_esc_calibration_denied"), events::Log::Critical,
|
||||
"ESCs calibration denied");
|
||||
|
||||
} else {
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED);
|
||||
_vehicle_status.calibration_enabled = true;
|
||||
_actuator_armed.in_esc_calibration_mode = true;
|
||||
_worker_thread.startTask(WorkerThread::Request::ESCCalibration);
|
||||
@@ -1673,9 +1674,13 @@ Commander::handle_command(const vehicle_command_s &cmd)
|
||||
|
||||
case vehicle_command_s::VEHICLE_CMD_DO_SET_SAFETY_SWITCH_STATE: {
|
||||
// reject if armed, only allow pre or post flight for safety
|
||||
// or if COM_SAFETY_MODE is not set to accept mavlink commands
|
||||
if (isArmed()) {
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED);
|
||||
|
||||
} else if ((SafetyMode)_param_com_safety_mode.get() == SafetyMode::BUTTON_ONLY) {
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_DENIED);
|
||||
|
||||
} else {
|
||||
int commanded_state = (int)cmd.param1;
|
||||
|
||||
@@ -1684,8 +1689,14 @@ Commander::handle_command(const vehicle_command_s &cmd)
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED);
|
||||
|
||||
} else if (commanded_state == vehicle_command_s::SAFETY_SAFE) {
|
||||
_safety.activateSafety();
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED);
|
||||
if (_safety.isSafetyDisabled()) {
|
||||
// COM_SAFETY_MODE 0 keeps safety off, so turning it on would be a no-op
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_DENIED);
|
||||
|
||||
} else {
|
||||
_safety.activateSafety();
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED);
|
||||
}
|
||||
|
||||
} else {
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_FAILED);
|
||||
@@ -1797,7 +1808,7 @@ void Commander::handleCommandsFromModeExecutors()
|
||||
|
||||
unsigned Commander::handleCommandActuatorTest(const vehicle_command_s &cmd)
|
||||
{
|
||||
if (isArmed() || (_safety.isButtonAvailable() && !_safety.isSafetyOff())) {
|
||||
if (isArmed() || !_safety.isSafetyOff()) {
|
||||
return vehicle_command_ack_s::VEHICLE_CMD_RESULT_DENIED;
|
||||
}
|
||||
|
||||
@@ -2257,20 +2268,15 @@ bool Commander::getPrearmState() const
|
||||
return false;
|
||||
|
||||
case PrearmedMode::ALWAYS:
|
||||
/* safety is not present, go into prearmed
|
||||
/* Always go into prearmed state
|
||||
* (all output drivers should be started / unlocked last in the boot process
|
||||
* when the rest of the system is fully initialized)
|
||||
*/
|
||||
return hrt_elapsed_time(&_boot_timestamp) > 5_s;
|
||||
|
||||
case PrearmedMode::SAFETY_BUTTON:
|
||||
if (_safety.isButtonAvailable()) {
|
||||
/* safety button is present, go into prearmed if safety is off */
|
||||
return _safety.isSafetyOff();
|
||||
}
|
||||
|
||||
/* safety button is not present, do not go into prearmed */
|
||||
return false;
|
||||
case PrearmedMode::WHEN_SAFETY_OFF:
|
||||
/* prearmed state matches safety_off state */
|
||||
return _safety.isSafetyOff();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -215,7 +215,7 @@ private:
|
||||
|
||||
enum class PrearmedMode {
|
||||
DISABLED = 0,
|
||||
SAFETY_BUTTON = 1,
|
||||
WHEN_SAFETY_OFF = 1,
|
||||
ALWAYS = 2
|
||||
};
|
||||
|
||||
@@ -346,6 +346,7 @@ private:
|
||||
(ParamBool<px4::params::COM_HOME_IN_AIR>) _param_com_home_in_air,
|
||||
(ParamBool<px4::params::COM_FORCE_SAFETY>) _param_com_force_safety,
|
||||
(ParamInt<px4::params::COM_PREARM_MODE>) _param_com_prearm_mode,
|
||||
(ParamInt<px4::params::COM_SAFETY_MODE>) _param_com_safety_mode,
|
||||
(ParamFloat<px4::params::COM_SPOOLUP_TIME>) _param_com_spoolup_time,
|
||||
(ParamInt<px4::params::COM_FLIGHT_UUID>) _param_com_flight_uuid,
|
||||
(ParamFloat<px4::params::COM_CPU_MAX>) _param_com_cpu_max,
|
||||
|
||||
@@ -106,18 +106,34 @@ void SystemChecks::checkAndReport(const Context &context, Report &reporter)
|
||||
}
|
||||
|
||||
// safety button
|
||||
if (context.status().safety_button_available && !context.status().safety_off && !context.isArmed()) {
|
||||
/* EVENT
|
||||
* @description
|
||||
* <profile name="dev">
|
||||
* This check can be configured via <param>CBRK_IO_SAFETY</param> parameter.
|
||||
* </profile>
|
||||
*/
|
||||
reporter.armingCheckFailure(NavModes::All, health_component_t::system, events::ID("check_system_safety_button"),
|
||||
events::Log::Info, "Press safety button first");
|
||||
if (!context.status().safety_off && !context.isArmed()) {
|
||||
if (context.status().safety_button_available) {
|
||||
/* EVENT
|
||||
* @description
|
||||
* <profile name="dev">
|
||||
* This check can be configured via <param>COM_SAFETY_MODE</param> parameter.
|
||||
* </profile>
|
||||
*/
|
||||
reporter.armingCheckFailure(NavModes::All, health_component_t::system, events::ID("check_system_safety_button"),
|
||||
events::Log::Info, "Press safety button first");
|
||||
|
||||
if (reporter.mavlink_log_pub()) {
|
||||
mavlink_log_critical(reporter.mavlink_log_pub(), "Preflight Fail: Press safety button first");
|
||||
if (reporter.mavlink_log_pub()) {
|
||||
mavlink_log_critical(reporter.mavlink_log_pub(), "Preflight Fail: Press safety button first");
|
||||
}
|
||||
|
||||
} else {
|
||||
/* EVENT
|
||||
* @description
|
||||
* <profile name="dev">
|
||||
* This check can be configured via <param>COM_SAFETY_MODE</param> parameter.
|
||||
* </profile>
|
||||
*/
|
||||
reporter.armingCheckFailure(NavModes::All, health_component_t::system, events::ID("check_system_safety"),
|
||||
events::Log::Info, "Turn safety off first");
|
||||
|
||||
if (reporter.mavlink_log_pub()) {
|
||||
mavlink_log_critical(reporter.mavlink_log_pub(), "Preflight Fail: Turn safety off first");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,28 +36,33 @@
|
||||
*/
|
||||
|
||||
#include "Safety.hpp"
|
||||
#include <circuit_breaker/circuit_breaker.h>
|
||||
#include <lib/parameters/param.h>
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
Safety::Safety()
|
||||
{
|
||||
// Safety can be turned off with the CBRK_IO_SAFETY parameter.
|
||||
_safety_disabled = circuit_breaker_enabled("CBRK_IO_SAFETY", CBRK_IO_SAFETY_KEY);
|
||||
// Safety can be turned off with the COM_SAFETY_MODE parameter.
|
||||
int32_t com_safety_mode = 0;
|
||||
param_get(param_find("COM_SAFETY_MODE"), &com_safety_mode);
|
||||
|
||||
_safety_disabled = (SafetyMode)com_safety_mode == SafetyMode::ALWAYS_OFF;
|
||||
|
||||
if (_safety_disabled) {
|
||||
_button_available = true;
|
||||
_safety_off = true;
|
||||
}
|
||||
|
||||
// the button has no effect in SafetyMode::MAVLINK_ONLY, so don't announce it as available.
|
||||
_button_disabled = (SafetyMode)com_safety_mode == SafetyMode::MAVLINK_ONLY;
|
||||
}
|
||||
|
||||
bool Safety::safetyButtonHandler()
|
||||
{
|
||||
if (!_safety_disabled) {
|
||||
if (!_button_available && _safety_button_sub.advertised()) {
|
||||
_button_available = true;
|
||||
}
|
||||
if (!_button_disabled && !_button_available && _safety_button_sub.advertised()) {
|
||||
_button_available = true;
|
||||
}
|
||||
|
||||
if (!_safety_disabled && !_button_disabled) {
|
||||
button_event_s button_event;
|
||||
|
||||
while (_safety_button_sub.update(&button_event)) {
|
||||
|
||||
@@ -41,6 +41,12 @@
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/topics/button_event.h>
|
||||
|
||||
enum class SafetyMode {
|
||||
ALWAYS_OFF = 0,
|
||||
BUTTON_OR_MAVLINK = 1,
|
||||
BUTTON_ONLY = 2,
|
||||
MAVLINK_ONLY = 3
|
||||
};
|
||||
class Safety
|
||||
{
|
||||
public:
|
||||
@@ -58,6 +64,7 @@ private:
|
||||
uORB::Subscription _safety_button_sub{ORB_ID::safety_button};
|
||||
|
||||
bool _button_available{false};///< Set to true if a safety button is connected
|
||||
bool _button_disabled{false};///< Set to true if the safety button should be ignored
|
||||
bool _safety_off{false}; ///< Set to true if safety is off
|
||||
bool _previous_safety_off{false}; ///< Previous safety value
|
||||
bool _safety_disabled{false}; ///< Set to true if safety is disabled
|
||||
|
||||
@@ -507,16 +507,37 @@ parameters:
|
||||
long: |-
|
||||
Condition to enter the prearmed state, an intermediate state between disarmed and armed
|
||||
in which non-throttling actuators are active.
|
||||
|
||||
0: Never prearmed.
|
||||
1: Prearmed when safety is off (COM_SAFETY_MODE)
|
||||
2: Always prearmed.
|
||||
type: enum
|
||||
values:
|
||||
0: Disabled
|
||||
1: Safety button
|
||||
1: When safety off
|
||||
2: Always
|
||||
default: 0
|
||||
COM_SAFETY_MODE:
|
||||
description:
|
||||
short: Condition to turn safety off
|
||||
long: |-
|
||||
Condition to turn safety off. Vehicle arming is prevented for as long as safety is on.
|
||||
|
||||
0: Always off.
|
||||
1: Safety can be turned off either by pressing a physical safety switch, or by sending a MAV_CMD_DO_SET_SAFETY_SWITCH_STATE command.
|
||||
2: Safety can only be turned off by pressing a physical safety switch. MAV_CMD_DO_SET_SAFETY_SWITCH_STATE commands are rejected.
|
||||
3: Safety can only be turned off by sending a MAV_CMD_DO_SET_SAFETY_SWITCH_STATE command. Any physical switch is ignored.
|
||||
type: enum
|
||||
values:
|
||||
0: Always off
|
||||
1: Safety switch (physical or virtual via MAVLink)
|
||||
2: Physical safety switch only
|
||||
3: MAVLink only
|
||||
default: 0
|
||||
reboot_required: true
|
||||
COM_FORCE_SAFETY:
|
||||
description:
|
||||
short: Enable force safety
|
||||
long: Force safety when the vehicle disarms
|
||||
short: Re-enable safety when the vehicle disarms
|
||||
type: boolean
|
||||
default: 0
|
||||
COM_CPU_MAX:
|
||||
|
||||
Reference in new issue
Block a user