mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-25 08:40:30 +08:00
fix(uavcan): publish ArmingStatus when ESC output is enabled (#28364)
* fix(uavcan): publish ArmingStatus when ESC output is enabled DroneCAN ESCs such as ARK32 ignore RawCommand unless they receive STATUS_FULLY_ARMED. Requiring UAVCAN_PUB_ARM made QGC actuator tests fail out of the box. Publish ArmingStatus automatically when UAVCAN_ENABLE is 3, and send it at the arming-status rate so actuator tests are reported promptly. Assisted-by: Grok:grok-4.6 Signed-off-by: alexklimaj <alex@arkelectron.com> * Update docs/en/dronecan/escs.md * Update src/drivers/uavcan/uavcan_main.cpp * Update src/drivers/uavcan/uavcan_params.yaml --------- Signed-off-by: alexklimaj <alex@arkelectron.com> Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
This commit is contained in:
1 parent
031606ec02
commit
e5156f77ea
4 files changed
+31
-19
No files matched your search
@@ -32,6 +32,9 @@ In addition to the general setup, such as setting `UAVCAN_ENABLE` to `3`:
|
||||
- Select the specific CAN interface(s) used for ESC data output using the [UAVCAN_ESC_IFACE](../advanced_config/parameter_reference.md#UAVCAN_ESC_IFACE) parameter (all that all interfaces are selected by default).
|
||||
- Configure the [motor order and servo outputs](../config/actuators.md).
|
||||
|
||||
When ESC output is enabled, PX4 publishes [ArmingStatus](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#armingstatus) (`STATUS_FULLY_ARMED` while armed or during QGC actuator tests).
|
||||
ESCs that require that message work for both flight and the Actuators page without setting [UAVCAN_PUB_ARM](../advanced_config/parameter_reference.md#UAVCAN_PUB_ARM).
|
||||
|
||||
## Reversible Motors {#reversible-motors}
|
||||
|
||||
<Badge type="tip" text="main (PX4 v2.0)" />
|
||||
|
||||
@@ -146,6 +146,7 @@ For example, [SENS_FLOW_MINHGT](../advanced_config/parameter_reference.md#SENS_F
|
||||
|
||||
For example, to use a connected DroneCAN smart battery you would enable the [UAVCAN_SUB_BAT](../advanced_config/parameter_reference.md#UAVCAN_SUB_BAT) parameter, which would subscribe PX4 to receive [BatteryInfo](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#batteryinfo) DroneCAN messages.
|
||||
If using a peripheral that needs to know if PX4 is armed, you would need to set the [UAVCAN_PUB_ARM](../advanced_config/parameter_reference.md#UAVCAN_PUB_ARM) parameter so that PX4 starts publishing [ArmingStatus](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#armingstatus) messages.
|
||||
ArmingStatus is published automatically when [UAVCAN_ENABLE](../advanced_config/parameter_reference.md#UAVCAN_ENABLE) is `3` (ESC output).
|
||||
|
||||
The parameter names are prefixed with `UAVCAN_SUB_` and `UAVCAN_PUB_` to indicate whether they enable PX4 subscribing or publishing.
|
||||
The remainder of the name indicates the specific message/feature being set.
|
||||
@@ -275,6 +276,7 @@ If the rangefinder is connected via DroneCAN (whether inbuilt or separate), you
|
||||
PX4 DroneCAN parameters:
|
||||
|
||||
- [UAVCAN_PUB_ARM](../advanced_config/parameter_reference.md#UAVCAN_PUB_ARM) ([Arming Status](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#armingstatus)): Publish when using DroneCAN components that require the PX4 arming status as a precondition for use.
|
||||
Not required for DroneCAN ESCs: ArmingStatus is published automatically when [UAVCAN_ENABLE](../advanced_config/parameter_reference.md#UAVCAN_ENABLE) is `3`.
|
||||
|
||||
#### Grippers
|
||||
|
||||
|
||||
@@ -63,18 +63,20 @@ void UavcanArmingStatus::periodic_update(const uavcan::TimerEvent &)
|
||||
{
|
||||
actuator_armed_s actuator_armed;
|
||||
|
||||
if (_actuator_armed_sub.update(&actuator_armed)) {
|
||||
uavcan::equipment::safety::ArmingStatus cmd;
|
||||
|
||||
bool lockdown_active = actuator_armed.lockdown || actuator_armed.termination || actuator_armed.kill;
|
||||
|
||||
if (!lockdown_active && (actuator_armed.armed || _is_actuator_test_running)) {
|
||||
cmd.status = cmd.STATUS_FULLY_ARMED;
|
||||
|
||||
} else {
|
||||
cmd.status = cmd.STATUS_DISARMED;
|
||||
}
|
||||
|
||||
(void)_arming_status_pub.broadcast(cmd);
|
||||
if (!_actuator_armed_sub.copy(&actuator_armed)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uavcan::equipment::safety::ArmingStatus cmd;
|
||||
|
||||
const bool lockdown_active = actuator_armed.lockdown || actuator_armed.termination || actuator_armed.kill;
|
||||
|
||||
if (!lockdown_active && (actuator_armed.armed || _is_actuator_test_running)) {
|
||||
cmd.status = cmd.STATUS_FULLY_ARMED;
|
||||
|
||||
} else {
|
||||
cmd.status = cmd.STATUS_DISARMED;
|
||||
}
|
||||
|
||||
(void)_arming_status_pub.broadcast(cmd);
|
||||
}
|
||||
@@ -504,12 +504,19 @@ UavcanNode::init(uavcan::NodeID node_id, UAVCAN_DRIVER::BusEvent &bus_events)
|
||||
|
||||
int ret;
|
||||
|
||||
// UAVCAN_PUB_ARM
|
||||
#if defined(CONFIG_UAVCAN_ARMING_CONTROLLER) || defined(CONFIG_UAVCAN_OUTPUTS_CONTROLLER)
|
||||
int32_t uavcan_enable = 0;
|
||||
(void)param_get(param_find("UAVCAN_ENABLE"), &uavcan_enable);
|
||||
#endif
|
||||
|
||||
// Publish ArmingStatus when ESC output is enabled. Many DroneCAN ESCs
|
||||
// ignore RawCommand unless they see STATUS_FULLY_ARMED, including during actuator tests.
|
||||
// UAVCAN_PUB_ARM still enables it for sensor-only buses.
|
||||
#if defined(CONFIG_UAVCAN_ARMING_CONTROLLER)
|
||||
int32_t uavcan_pub_arm = 0;
|
||||
param_get(param_find("UAVCAN_PUB_ARM"), &uavcan_pub_arm);
|
||||
(void)param_get(param_find("UAVCAN_PUB_ARM"), &uavcan_pub_arm);
|
||||
|
||||
if (uavcan_pub_arm == 1) {
|
||||
if (uavcan_pub_arm == 1 || uavcan_enable > 2) {
|
||||
ret = _arming_status_controller.init();
|
||||
|
||||
if (ret < 0) {
|
||||
@@ -530,8 +537,6 @@ UavcanNode::init(uavcan::NodeID node_id, UAVCAN_DRIVER::BusEvent &bus_events)
|
||||
|
||||
// Actuators
|
||||
#if defined(CONFIG_UAVCAN_OUTPUTS_CONTROLLER)
|
||||
int32_t uavcan_enable = -1;
|
||||
(void)param_get(param_find("UAVCAN_ENABLE"), &uavcan_enable);
|
||||
|
||||
if (uavcan_enable > 2) {
|
||||
|
||||
@@ -1002,7 +1007,7 @@ UavcanNode::Run()
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CONFIG_UAVCAN_OUTPUTS_CONTROLLER)
|
||||
#if defined(CONFIG_UAVCAN_OUTPUTS_CONTROLLER) && defined(CONFIG_UAVCAN_ARMING_CONTROLLER)
|
||||
_arming_status_controller.setActuatorTestRunning(_mixing_interface_esc.isActuatorTestRunning());
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user