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
68#ifdef SERVOS_UAVCAN2_NB
76#ifdef SERVOS_UAVCAN1CMD_NB
84#ifdef SERVOS_UAVCAN2CMD_NB
94#if SERVOS_UAVCAN1CMD_NB > SERVOS_UAVCAN1_NB
95#define UAVCAN1_TELEM_NB SERVOS_UAVCAN1CMD_NB
97#elif defined(SERVOS_UAVCAN1_NB)
98#define UAVCAN1_TELEM_NB SERVOS_UAVCAN1_NB
102#if SERVOS_UAVCAN2CMD_NB > SERVOS_UAVCAN2_NB
103#define UAVCAN2_TELEM_NB SERVOS_UAVCAN2CMD_NB
105#elif defined(SERVOS_UAVCAN2_NB)
106#define UAVCAN2_TELEM_NB SERVOS_UAVCAN2_NB
111#define UAVCAN_CMD_UNUSED (MIN_PPRZ-1)
119#if PERIODIC_TELEMETRY
133#ifdef UAVCAN1_TELEM_NB
145#ifdef UAVCAN2_TELEM_NB
176 float power =
telem->current *
telem->voltage;
187#ifdef UAVCAN1_TELEM_NB
192#ifdef UAVCAN2_TELEM_NB
204#ifdef UAVCAN1_TELEM_NB
206#ifdef SERVOS_UAVCAN1_NB
210#ifdef SERVOS_UAVCAN1CMD_NB
218#ifdef UAVCAN2_TELEM_NB
220#ifdef SERVOS_UAVCAN2_NB
224#ifdef SERVOS_UAVCAN2CMD_NB
260 telem->temperature =
msg.temperature;
264 if (
telem->temperature > 230.f) {
265 telem->temperature -= 273.15;
277#if UAVCAN_ACTUATORS_USE_CURRENT
280#ifdef UAVCAN1_TELEM_NB
285#ifdef UAVCAN2_TELEM_NB
341 telem->temperature_dev =
msg.temperature - 273.15;
364#if PERIODIC_TELEMETRY
369#ifdef SERVOS_UAVCAN1CMD_NB
373#ifdef SERVOS_UAVCAN2CMD_NB
393 for (
uint8_t i = 0; i < nb; i++) {
394 msg.cmd.data[i] = values[i];
412 msg.commands.len = 0;
415 for (
uint8_t i = 0; i < nb; i++) {
420 msg.commands.data[
msg.commands.len].actuator_id = i;
Main include for ABI (AirBorneInterface).
#define ACT_FEEDBACK_UAVCAN_ID
void actuators_uavcan1_set(uint8_t idx, int16_t value)
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.
void actuators_uavcan1cmd_set(uint8_t idx, int16_t value)
void actuators_uavcan2_set(uint8_t idx, int16_t value)
int16_t actuators_uavcan2_values[SERVOS_UAVCAN2_NB]
Stub file needed per interface because of generator.
void actuators_uavcan2cmd_set(uint8_t idx, int16_t value)
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.
int16_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint16_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)