mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 14:13:35 +08:00
extend support for Battery status message
Signed-off-by: Claudio Micheli <claudio@auterion.com>
This commit is contained in:
committed by
Beat Küng
parent
bb1177d504
commit
d122513197
@@ -244,6 +244,138 @@
|
||||
"description": "[Unknown]"
|
||||
}
|
||||
}
|
||||
},
|
||||
"battery_fault_reason_t": {
|
||||
"type": "uint8_t",
|
||||
"description": "Reason for battery fault",
|
||||
"entries": {
|
||||
"0": {
|
||||
"name": "deep_discharge",
|
||||
"description": "Battery has deep discharged"
|
||||
},
|
||||
"1": {
|
||||
"name": "voltage_spikes",
|
||||
"description": "Battery detected voltage spikes"
|
||||
},
|
||||
"2": {
|
||||
"name": "cell_fail",
|
||||
"description": "One or more battery cells have failed"
|
||||
},
|
||||
"3": {
|
||||
"name": "over_current",
|
||||
"description": "Battery reported over-current"
|
||||
},
|
||||
"4": {
|
||||
"name": "fault_temperature",
|
||||
"description": "Battery has reached a critical temperature which can result in a critical failure"
|
||||
},
|
||||
"5": {
|
||||
"name": "under_temperature",
|
||||
"description": "Battery temperature is below operating range"
|
||||
},
|
||||
"6": {
|
||||
"name": "incompatible_voltage",
|
||||
"description": "Vehicle voltage is not compatible with battery one"
|
||||
},
|
||||
"7": {
|
||||
"name": "incompatible_firmware",
|
||||
"description": "Battery firmware is not compatible with current autopilot firmware"
|
||||
},
|
||||
"8": {
|
||||
"name": "incompatible_model",
|
||||
"description": "Battery model is not supported by the system"
|
||||
},
|
||||
"9": {
|
||||
"name": "hardware_fault",
|
||||
"description": "Battery reported an hardware problem"
|
||||
},
|
||||
"10": {
|
||||
"name": "over_temperature",
|
||||
"description": "Battery is over-heating"
|
||||
}
|
||||
}
|
||||
},
|
||||
"battery_mode_t": {
|
||||
"type": "uint8_t",
|
||||
"description": "Smart battery modes of operation",
|
||||
"entries": {
|
||||
"0": {
|
||||
"name": "unknown",
|
||||
"description": "unknown"
|
||||
},
|
||||
"1": {
|
||||
"name": "autodischarging",
|
||||
"description": "auto discharging towards storage level"
|
||||
},
|
||||
"2": {
|
||||
"name": "hotswap",
|
||||
"description": "hot-swap"
|
||||
}
|
||||
}
|
||||
},
|
||||
"esc_fault_reason_t": {
|
||||
"type": "uint8_t",
|
||||
"description": "Bitfield for ESC failure reason",
|
||||
"entries": {
|
||||
"0": {
|
||||
"name": "over_current",
|
||||
"description": "detected over current"
|
||||
},
|
||||
"1": {
|
||||
"name": "over_voltage",
|
||||
"description": "detected over voltage"
|
||||
},
|
||||
"2": {
|
||||
"name": "motor_over_temp",
|
||||
"description": "Motor has reached a critical temperature"
|
||||
},
|
||||
"3": {
|
||||
"name": "over_rpm",
|
||||
"description": "Motor RPM is exceeding the limits"
|
||||
},
|
||||
"4": {
|
||||
"name": "inconsistent_cmd",
|
||||
"description": "received an invalid control command"
|
||||
},
|
||||
"5": {
|
||||
"name": "motor_stuck",
|
||||
"description": "Motor stalled"
|
||||
},
|
||||
"6": {
|
||||
"name": "failure_generic",
|
||||
"description": "detected a generic hardware failure"
|
||||
},
|
||||
"7": {
|
||||
"name": "motor_warn_temp",
|
||||
"description": "Motor is over-heating"
|
||||
},
|
||||
"8": {
|
||||
"name": "esc_warn_temp",
|
||||
"description": "is over-heating"
|
||||
},
|
||||
"9": {
|
||||
"name": "esc_over_temp",
|
||||
"description": "reached a critical temperature"
|
||||
}
|
||||
}
|
||||
},
|
||||
"suggested_action_t": {
|
||||
"type": "uint8_t",
|
||||
"description": "Suggested actions for the user in case of a safety critical event is triggered",
|
||||
"entries": {
|
||||
"0": {
|
||||
"name": "none",
|
||||
"description": ""
|
||||
},
|
||||
"1": {
|
||||
"name": "land",
|
||||
"description": "Land now!"
|
||||
},
|
||||
"2": {
|
||||
"name": "reduce_throttle",
|
||||
"description": "Reduce throttle!"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,6 +237,24 @@ constexpr int16_t negate<int16_t>(int16_t value)
|
||||
return -value;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function calculates the Hamming weight, i.e. counts the number of bits that are set
|
||||
* in a given integer.
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
int countSetBits(T n)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
while (n) {
|
||||
count += n & 1;
|
||||
n >>= 1;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
inline bool isFinite(const float &value)
|
||||
{
|
||||
return PX4_ISFINITE(value);
|
||||
|
||||
@@ -212,3 +212,12 @@ TEST(FunctionsTest, lerp)
|
||||
EXPECT_FLOAT_EQ(lerp(.2f, .3f, -.1f), .19f);
|
||||
EXPECT_FLOAT_EQ(lerp(-.4f, .3f, 1.1f), .37f);
|
||||
}
|
||||
|
||||
TEST(FunctionsTest, countSetBits)
|
||||
{
|
||||
EXPECT_EQ(countSetBits(255), 8);
|
||||
EXPECT_EQ(countSetBits(65535), 16);
|
||||
EXPECT_EQ(countSetBits(0), 0);
|
||||
EXPECT_EQ(countSetBits(0xffffffffu), 32);
|
||||
EXPECT_EQ(countSetBits(754323), 9);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user