From dc29a994b7afb75f3043b441ce8aa79886052289 Mon Sep 17 00:00:00 2001 From: Claudio Micheli Date: Thu, 2 Apr 2020 14:46:55 +0200 Subject: [PATCH] msg: extend field definition in msg/esc_report (arming & failure states) Signed-off-by: Claudio Micheli --- msg/esc_report.msg | 12 ++++++++++++ msg/esc_status.msg | 2 ++ src/drivers/dshot/dshot.cpp | 1 + src/drivers/mkblctrl/mkblctrl.cpp | 2 ++ src/drivers/tap_esc/tap_esc.cpp | 2 ++ src/drivers/uavcan/actuators/esc.cpp | 1 + 6 files changed, 20 insertions(+) diff --git a/msg/esc_report.msg b/msg/esc_report.msg index a31230586d..508a8b9ebd 100644 --- a/msg/esc_report.msg +++ b/msg/esc_report.msg @@ -5,4 +5,16 @@ float32 esc_voltage # Voltage measured from current ESC [V] - if supported float32 esc_current # Current measured from current ESC [A] - if supported uint8 esc_temperature # Temperature measured from current ESC [degC] - if supported uint8 esc_address # Address of current ESC (in most cases 1-8 / must be set by driver) + uint8 esc_state # State of ESC - depend on Vendor + +uint8 failures # Bitmask to indicate the internal ESC faults + +uint8 FAILURE_NONE = 0 +uint8 FAILURE_OVER_CURRENT_MASK = 1 # (1 << 0) +uint8 FAILURE_OVER_VOLTAGE_MASK = 2 # (1 << 1) +uint8 FAILURE_OVER_TEMPERATURE_MASK = 4 # (1 << 2) +uint8 FAILURE_OVER_RPM_MASK = 8 # (1 << 3) +uint8 FAILURE_INCONSISTENT_CMD_MASK = 16 # (1 << 4) Set if ESC received an inconsistent command (i.e out of boundaries) +uint8 FAILURE_MOTOR_STUCK_MASK = 32 # (1 << 5) +uint8 FAILURE_GENERIC_MASK = 64 # (1 << 6) diff --git a/msg/esc_status.msg b/msg/esc_status.msg index a12b890fb8..f786f6d351 100644 --- a/msg/esc_status.msg +++ b/msg/esc_status.msg @@ -23,4 +23,6 @@ uint8 esc_online_flags # Bitmask indicating which ESC is online/offline # esc_online_flags bit 6 : Set to 1 if ESC6 is online # esc_online_flags bit 7 : Set to 1 if ESC7 is online +uint8 esc_armed_flags # Bitmask indicating which ESC is armed. For ESC's where the arming state is not known (returned by the ESC), the arming bits should always be set. + esc_report[8] esc diff --git a/src/drivers/dshot/dshot.cpp b/src/drivers/dshot/dshot.cpp index cc6654a6f7..3875dfbd39 100644 --- a/src/drivers/dshot/dshot.cpp +++ b/src/drivers/dshot/dshot.cpp @@ -604,6 +604,7 @@ void DShotOutput::handleNewTelemetryData(int motor_index, const DShotTelemetry:: ++esc_status.counter; // FIXME: mark all ESC's as online, otherwise commander complains even for a single dropout esc_status.esc_online_flags = (1 << esc_status.esc_count) - 1; + esc_status.esc_armed_flags = (1 << esc_status.esc_count) - 1; _telemetry->esc_status_pub.update(); diff --git a/src/drivers/mkblctrl/mkblctrl.cpp b/src/drivers/mkblctrl/mkblctrl.cpp index d2da4376e7..9ac128cc74 100644 --- a/src/drivers/mkblctrl/mkblctrl.cpp +++ b/src/drivers/mkblctrl/mkblctrl.cpp @@ -611,6 +611,8 @@ MK::task_main() esc.timestamp = hrt_absolute_time(); esc.esc_count = (uint8_t) _num_outputs; esc.esc_connectiontype = esc_status_s::ESC_CONNECTION_TYPE_I2C; + esc.esc_online_flags = (1 << esc.esc_count) - 1; + esc.esc_armed_flags = (1 << esc.esc_count) - 1; for (unsigned int i = 0; i < _num_outputs; i++) { esc.esc[i].esc_address = (uint8_t) BLCTRL_BASE_ADDR + i; diff --git a/src/drivers/tap_esc/tap_esc.cpp b/src/drivers/tap_esc/tap_esc.cpp index 7e8abfc7ee..51b1a06cc0 100644 --- a/src/drivers/tap_esc/tap_esc.cpp +++ b/src/drivers/tap_esc/tap_esc.cpp @@ -573,6 +573,8 @@ void TAP_ESC::cycle() _esc_feedback.esc_connectiontype = esc_status_s::ESC_CONNECTION_TYPE_SERIAL; _esc_feedback.counter++; _esc_feedback.esc_count = num_outputs; + _esc_feedback.esc_online_flags = (1 << num_outputs) - 1; + _esc_feedback.esc_armed_flags = (1 << num_outputs) - 1; _esc_feedback.timestamp = hrt_absolute_time(); diff --git a/src/drivers/uavcan/actuators/esc.cpp b/src/drivers/uavcan/actuators/esc.cpp index b5d35d394f..541d2a4fc7 100644 --- a/src/drivers/uavcan/actuators/esc.cpp +++ b/src/drivers/uavcan/actuators/esc.cpp @@ -163,6 +163,7 @@ UavcanEscController::orb_pub_timer_cb(const uavcan::TimerEvent &) _esc_status.counter += 1; _esc_status.esc_connectiontype = esc_status_s::ESC_CONNECTION_TYPE_CAN; _esc_status.esc_online_flags = check_escs_status(); + _esc_status.esc_armed_flags = (1 << _rotor_count) - 1; _esc_status_pub.publish(_esc_status); }