58 PX4_ERR(
"failed to start uavcan sub: %d", res);
71 battery.voltage_v = msg.voltage;
72 battery.voltage_filtered_v = battery.voltage_v;
73 battery.current_a = msg.current;
74 battery.current_filtered_a = battery.current_a;
79 if (msg.full_charge_capacity_wh > 0) {
80 battery.remaining = msg.remaining_capacity_wh / msg.full_charge_capacity_wh;
83 battery.remaining = 0;
88 battery.temperature = msg.temperature;
92 battery.capacity = msg.full_charge_capacity_wh;
96 battery.serial_number = msg.model_instance_id;
97 battery.connected =
true;
98 battery.system_source = msg.status_flags & uavcan::equipment::power::BatteryInfo::STATUS_FLAG_IN_USE;
103 publish(msg.getSrcNodeID().get(), &battery);
int init() override
Starts the bridge.
uavcan::MethodBinder< UavcanBatteryBridge *, void(UavcanBatteryBridge::*)(const uavcan::ReceivedDataStructure< uavcan::equipment::power::BatteryInfo > &) > BatteryInfoCbBinder
uavcan::Subscriber< uavcan::equipment::power::BatteryInfo, BatteryInfoCbBinder > _sub_battery
static const char *const NAME
void battery_sub_cb(const uavcan::ReceivedDataStructure< uavcan::equipment::power::BatteryInfo > &msg)
High-resolution timer with callouts and timekeeping.
static char msg[NUM_MSG][CONFIG_USART1_TXBUFSIZE]
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
This is the base class for redundant sensors with an independent ORB topic per each redundancy channe...
UavcanBatteryBridge(uavcan::INode &node)
void publish(const int node_id, const void *report)
Sends one measurement into appropriate ORB topic.
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).