34#include "uavcan.equipment.esc.Status.h"
35#include "uavcan.equipment.esc.RawCommand.h"
36#include "uavcan.equipment.actuator.Status.h"
37#include "uavcan.equipment.actuator.ArrayCommand.h"
38#include "uavcan.equipment.device.Temperature.h"
41#ifndef UAVCAN_ACTUATORS_USE_CURRENT
42#define UAVCAN_ACTUATORS_USE_CURRENT TRUE
60#ifdef SERVOS_UAVCAN1_NB
63#ifdef SERVOS_UAVCAN2_NB
66#ifdef SERVOS_UAVCAN1CMD_NB
69#ifdef SERVOS_UAVCAN2CMD_NB
74#if SERVOS_UAVCAN1CMD_NB > SERVOS_UAVCAN1_NB
75#define UAVCAN1_TELEM_NB SERVOS_UAVCAN1CMD_NB
77#elif defined(SERVOS_UAVCAN1_NB)
78#define UAVCAN1_TELEM_NB SERVOS_UAVCAN1_NB
82#if SERVOS_UAVCAN2CMD_NB > SERVOS_UAVCAN2_NB
83#define UAVCAN2_TELEM_NB SERVOS_UAVCAN2CMD_NB
85#elif defined(SERVOS_UAVCAN2_NB)
86#define UAVCAN2_TELEM_NB SERVOS_UAVCAN2_NB
91#define UAVCAN_CMD_UNUSED (MIN_PPRZ-1)
113#ifdef UAVCAN1_TELEM_NB
125#ifdef UAVCAN2_TELEM_NB
156 float power =
telem->current *
telem->voltage;
167#ifdef UAVCAN1_TELEM_NB
172#ifdef UAVCAN2_TELEM_NB
184#ifdef UAVCAN1_TELEM_NB
186#ifdef SERVOS_UAVCAN1_NB
190#ifdef SERVOS_UAVCAN1CMD_NB
198#ifdef UAVCAN2_TELEM_NB
200#ifdef SERVOS_UAVCAN2_NB
204#ifdef SERVOS_UAVCAN2CMD_NB
240 telem->temperature =
msg.temperature;
244 if (
telem->temperature > 230.f) {
245 telem->temperature -= 273.15;
257#if UAVCAN_ACTUATORS_USE_CURRENT
260#ifdef UAVCAN1_TELEM_NB
265#ifdef UAVCAN2_TELEM_NB
321 telem->temperature_dev =
msg.temperature - 273.15;
344#if PERIODIC_TELEMETRY
349#ifdef SERVOS_UAVCAN1CMD_NB
353#ifdef SERVOS_UAVCAN2CMD_NB
373 for (
uint8_t i = 0; i < nb; i++) {
374 msg.cmd.data[i] = values[i];
392 msg.commands.len = 0;
395 for (
uint8_t i = 0; i < nb; i++) {
400 msg.commands.data[
msg.commands.len].actuator_id = i;
Main include for ABI (AirBorneInterface).
#define ACT_FEEDBACK_UAVCAN_ID
int16_t actuators_uavcan1_values[SERVOS_UAVCAN1_NB]
Stub file needed per uavcan interface because of generator.
int16_t actuators_uavcan1cmd_values[SERVOS_UAVCAN1CMD_NB]
Stub file needed per uavcan interface because of generator.
int16_t actuators_uavcan2_values[SERVOS_UAVCAN2_NB]
Stub file needed per interface because of generator.
int16_t actuators_uavcan2cmd_values[SERVOS_UAVCAN2CMD_NB]
Stub file needed per uavcan interface because of generator.
static void actuators_uavcan_send_esc(struct transport_tx *trans, struct link_device *dev)
void actuators_uavcan_init(struct uavcan_iface_t *iface)
Initialize an uavcan interface.
static void actuators_uavcan_device_temperature_cb(struct uavcan_iface_t *iface, CanardRxTransfer *transfer)
Whevener an DEVICE_TEMPERATURE message from the EQUIPMENT group is received.
static uavcan_event actuator_status_ev
static struct actuators_uavcan_telem_t * actuators_uavcan_next_telem(void)
void actuators_uavcan_commit(struct uavcan_iface_t *iface, int16_t *values, uint8_t nb)
Commit actuator values to the uavcan interface (EQUIPMENT_ESC_RAWCOMMAND)
static void actuators_uavcan_esc_status_cb(struct uavcan_iface_t *iface, CanardRxTransfer *transfer)
Whevener an ESC_STATUS message from the EQUIPMENT group is received.
static uavcan_event device_temperature_ev
static void actuators_uavcan_actuator_status_cb(struct uavcan_iface_t *iface, CanardRxTransfer *transfer)
Whevener an ACTUATOR_STATUS message from the EQUIPMENT group is received.
static bool actuators_uavcan_initialized
void actuators_uavcan_cmd_commit(struct uavcan_iface_t *iface, int16_t *values, uint8_t nb)
Commit actuator values to the uavcan interface (EQUIPMENT_ACTUATOR_ARRAYCOMMAND)
static struct actuators_uavcan_telem_t * get_actuator_telem(struct uavcan_iface_t *iface, uint8_t idx)
#define UAVCAN_CMD_UNUSED
static uint8_t get_actuator_idx(struct uavcan_iface_t *iface, uint8_t idx)
static uavcan_event esc_status_ev
Main uavcan event structure for registering/calling callbacks.
static const float offset[]
struct Electrical electrical
Interface for electrical status: supply voltage, current, battery status, etc.
float current
current in A
float vsupply
supply voltage in V
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
Hardware independent API for actuators (servos, motor controllers).
bool position
Position is set.
struct act_feedback_t::act_feedback_set_t set
Bitset registering what is set as feedback.
uint8_t idx
General index of the actuators (generated in airframe.h)
float position
In radians.
double rand_uniform(void)
uavcan interface structure
static const struct usb_device_descriptor dev
static float get_sys_time_float(void)
Get the time in seconds since startup.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
void uavcan_broadcast(struct uavcan_iface_t *iface, uint64_t data_type_signature, uint16_t data_type_id, uint8_t priority, const void *payload, uint16_t payload_len)
Broadcast an uavcan message to a specific interface.
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.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
int transfer(const Mat *from, const image_t *to)