27 #include "uavcan/uavcan.h"
31 #define UAVCAN_EQUIPMENT_POWER_BATTERYINFO_ID 1092
32 #define UAVCAN_EQUIPMENT_POWER_BATTERYINFO_SIGNATURE (0x249C26548A711966ULL)
33 #define UAVCAN_EQUIPMENT_POWER_BATTERYINFO_MAX_SIZE 55
36 #define UAVCAN_EQUIPMENT_POWER_CIRCUITSTATUS_ID 1091
37 #define UAVCAN_EQUIPMENT_POWER_CIRCUITSTATUS_SIGNATURE (0x8313D33D0DDDA115ULL)
38 #define UAVCAN_EQUIPMENT_POWER_CIRCUITSTATUS_MAX_SIZE 7
41 #ifndef POWER_UAVCAN_BATTERIES_MAX
42 #define POWER_UAVCAN_BATTERIES_MAX 3
46 #ifndef POWER_UAVCAN_CIRCUITS_MAX
47 #define POWER_UAVCAN_CIRCUITS_MAX 15
51 #ifndef POWER_UAVCAN_BATTERY_CIRCUITS
52 #define POWER_UAVCAN_BATTERY_CIRCUITS {}
108 float temperature = canardConvertFloat16ToNativeFloat(tmp_float);
110 float voltage = canardConvertFloat16ToNativeFloat(tmp_float);
112 float current = canardConvertFloat16ToNativeFloat(tmp_float);
114 float average_power_10sec = canardConvertFloat16ToNativeFloat(tmp_float);
116 float remaining_capacity_wh = canardConvertFloat16ToNativeFloat(tmp_float);
118 float full_charge_capacity_wh = canardConvertFloat16ToNativeFloat(tmp_float);
120 float hours_to_full_charge = canardConvertFloat16ToNativeFloat(tmp_float);
122 canardDecodeScalar(
transfer, (
uint32_t)112, 11,
false, (
void *)&status_flags);
123 uint8_t state_of_health_pct = 0;
124 canardDecodeScalar(
transfer, (
uint32_t)123, 7,
false, (
void *)&state_of_health_pct);
125 uint8_t state_of_charge_pct = 0;
126 canardDecodeScalar(
transfer, (
uint32_t)130, 7,
false, (
void *)&state_of_charge_pct);
127 uint8_t state_of_charge_pct_stdev = 0;
128 canardDecodeScalar(
transfer, (
uint32_t)137, 7,
false, (
void *)&state_of_charge_pct_stdev);
132 canardDecodeScalar(
transfer, (
uint32_t)152, 32,
false, (
void *)&model_instance_id);
171 float current_sum = 0;
191 float voltage = canardConvertFloat16ToNativeFloat(tmp_float);
193 float current = canardConvertFloat16ToNativeFloat(tmp_float);
224 float current_sum = 0;
231 if (voltage > 0 &&
circuits[circuit_idx].is_battery) {
Main uavcan event structure for registering/calling callbacks.
struct Electrical electrical
Interface for electrical status: supply voltage, current, battery status, etc.
float current
current in A
float vsupply
supply voltage in V
static struct uavcan_circuit_battery_t battery_circuits[]
float average_power_10sec
static void power_uavcan_battery_cb(struct uavcan_iface_t *iface, CanardRxTransfer *transfer)
#define POWER_UAVCAN_BATTERY_CIRCUITS
static void power_uavcan_circuit_cb(struct uavcan_iface_t *iface, CanardRxTransfer *transfer)
uint32_t model_instance_id
#define UAVCAN_EQUIPMENT_POWER_CIRCUITSTATUS_SIGNATURE
float remaining_capacity_wh
uint8_t state_of_charge_pct
#define UAVCAN_EQUIPMENT_POWER_BATTERYINFO_SIGNATURE
float full_charge_capacity_wh
static uavcan_event circuit_uavcan_ev
#define POWER_UAVCAN_CIRCUITS_MAX
uint8_t state_of_charge_pct_stdev
static struct uavcan_equipment_power_BatteryInfo batteries[POWER_UAVCAN_BATTERIES_MAX]
void power_uavcan_init(void)
#define UAVCAN_EQUIPMENT_POWER_CIRCUITSTATUS_ID
static uavcan_event power_uavcan_ev
#define POWER_UAVCAN_BATTERIES_MAX
uint8_t state_of_health_pct
static struct uavcan_equipment_power_CircuitStatus circuits[POWER_UAVCAN_CIRCUITS_MAX]
float hours_to_full_charge
#define UAVCAN_EQUIPMENT_POWER_BATTERYINFO_ID
Power sensors on the uavcan bus.
uavcan interface structure
void uavcan_bind(uint16_t data_type_id, uint64_t data_type_signature, uavcan_event *ev, uavcan_callback cb)
Bind to a receiving message from uavcan.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
int transfer(const Mat *from, const image_t *to)