Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
actuators_uavcan.c File Reference

UAVCan actuators using RAWCOMMAND message and ESC_STATUS telemetry. More...

#include "actuators_uavcan.h"
#include "modules/energy/electrical.h"
#include "math/pprz_random.h"
#include "modules/core/abi.h"
#include "modules/actuators/actuators.h"
#include "uavcan.equipment.esc.Status.h"
#include "uavcan.equipment.esc.RawCommand.h"
#include "uavcan.equipment.actuator.Status.h"
#include "uavcan.equipment.actuator.ArrayCommand.h"
#include "uavcan.equipment.device.Temperature.h"
#include "modules/datalink/telemetry.h"
+ Include dependency graph for actuators_uavcan.c:

Go to the source code of this file.

Data Structures

struct  actuators_uavcan_telem_t
 

Macros

#define UAVCAN_ACTUATORS_USE_CURRENT   TRUE
 
#define UAVCAN_CMD_UNUSED   (MIN_PPRZ-1)
 

Functions

static struct actuators_uavcan_telem_tactuators_uavcan_next_telem (void)
 
static void actuators_uavcan_send_esc (struct transport_tx *trans, struct link_device *dev)
 
static struct actuators_uavcan_telem_tget_actuator_telem (struct uavcan_iface_t *iface, uint8_t idx)
 
static uint8_t get_actuator_idx (struct uavcan_iface_t *iface, uint8_t idx)
 
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 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 void actuators_uavcan_device_temperature_cb (struct uavcan_iface_t *iface, CanardRxTransfer *transfer)
 Whevener an DEVICE_TEMPERATURE message from the EQUIPMENT group is received.
 
void actuators_uavcan_init (struct uavcan_iface_t *iface)
 Initialize an uavcan interface.
 
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)
 
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)
 

Variables

static bool actuators_uavcan_initialized = false
 
static uavcan_event esc_status_ev
 
static uavcan_event actuator_status_ev
 
static uavcan_event device_temperature_ev
 
static uint8_t old_idx = 0
 
static uint8_t esc_idx = 0
 

Detailed Description

UAVCan actuators using RAWCOMMAND message and ESC_STATUS telemetry.

Definition in file actuators_uavcan.c.


Data Structure Documentation

◆ actuators_uavcan_telem_t

struct actuators_uavcan_telem_t

Definition at line 46 of file actuators_uavcan.c.

Data Fields
float current
uint32_t energy
uint8_t node_id
float position
int32_t rpm
bool set
float temperature
float temperature_dev
float timestamp
float voltage

Macro Definition Documentation

◆ UAVCAN_ACTUATORS_USE_CURRENT

#define UAVCAN_ACTUATORS_USE_CURRENT   TRUE

Definition at line 42 of file actuators_uavcan.c.

◆ UAVCAN_CMD_UNUSED

#define UAVCAN_CMD_UNUSED   (MIN_PPRZ-1)

Definition at line 91 of file actuators_uavcan.c.

Function Documentation

◆ actuators_uavcan_actuator_status_cb()

static void actuators_uavcan_actuator_status_cb ( struct uavcan_iface_t iface,
CanardRxTransfer transfer 
)
static

Whevener an ACTUATOR_STATUS message from the EQUIPMENT group is received.

Definition at line 276 of file actuators_uavcan.c.

References ACT_FEEDBACK_UAVCAN_ID, foo, get_actuator_idx(), get_actuator_telem(), act_feedback_t::idx, msg, act_feedback_t::act_feedback_set_t::position, act_feedback_t::position, act_feedback_t::set, and transfer().

Referenced by actuators_uavcan_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_uavcan_cmd_commit()

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)

Definition at line 389 of file actuators_uavcan.c.

References foo, MAX_PPRZ, MIN_PPRZ, msg, uavcan_broadcast(), and UAVCAN_CMD_UNUSED.

+ Here is the call graph for this function:

◆ actuators_uavcan_commit()

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)

Definition at line 368 of file actuators_uavcan.c.

References foo, msg, and uavcan_broadcast().

+ Here is the call graph for this function:

◆ actuators_uavcan_device_temperature_cb()

static void actuators_uavcan_device_temperature_cb ( struct uavcan_iface_t iface,
CanardRxTransfer transfer 
)
static

Whevener an DEVICE_TEMPERATURE message from the EQUIPMENT group is received.

Definition at line 306 of file actuators_uavcan.c.

References foo, get_actuator_telem(), msg, and transfer().

Referenced by actuators_uavcan_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_uavcan_esc_status_cb()

static void actuators_uavcan_esc_status_cb ( struct uavcan_iface_t iface,
CanardRxTransfer transfer 
)
static

Whevener an ESC_STATUS message from the EQUIPMENT group is received.

Definition at line 219 of file actuators_uavcan.c.

References ACT_FEEDBACK_UAVCAN_ID, Electrical::current, electrical, foo, get_actuator_idx(), get_actuator_telem(), get_sys_time_float(), act_feedback_t::idx, msg, act_feedback_t::act_feedback_set_t::rpm, act_feedback_t::rpm, act_feedback_t::set, and transfer().

Referenced by actuators_uavcan_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_uavcan_init()

◆ actuators_uavcan_next_telem()

static struct actuators_uavcan_telem_t * actuators_uavcan_next_telem ( void  )
static

Definition at line 104 of file actuators_uavcan.c.

References esc_idx, foo, offset, old_idx, rand_uniform(), and actuators_uavcan_telem_t::set.

Referenced by actuators_uavcan_send_esc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_uavcan_send_esc()

static void actuators_uavcan_send_esc ( struct transport_tx trans,
struct link_device dev 
)
static

Definition at line 143 of file actuators_uavcan.c.

References actuators_uavcan_next_telem(), dev, electrical, actuators_uavcan_telem_t::energy, foo, old_idx, rpm, and Electrical::vsupply.

Referenced by actuators_uavcan_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_actuator_idx()

static uint8_t get_actuator_idx ( struct uavcan_iface_t iface,
uint8_t  idx 
)
static

Definition at line 181 of file actuators_uavcan.c.

References actuators_uavcan1cmd_values, actuators_uavcan2cmd_values, foo, idx, and UAVCAN_CMD_UNUSED.

Referenced by actuators_uavcan_actuator_status_cb(), and actuators_uavcan_esc_status_cb().

+ Here is the caller graph for this function:

◆ get_actuator_telem()

static struct actuators_uavcan_telem_t * get_actuator_telem ( struct uavcan_iface_t iface,
uint8_t  idx 
)
static

Definition at line 164 of file actuators_uavcan.c.

References foo, and idx.

Referenced by actuators_uavcan_actuator_status_cb(), actuators_uavcan_device_temperature_cb(), and actuators_uavcan_esc_status_cb().

+ Here is the caller graph for this function:

Variable Documentation

◆ actuator_status_ev

uavcan_event actuator_status_ev
static

Definition at line 96 of file actuators_uavcan.c.

Referenced by actuators_uavcan_init().

◆ actuators_uavcan_initialized

bool actuators_uavcan_initialized = false
static

Definition at line 94 of file actuators_uavcan.c.

Referenced by actuators_uavcan_init().

◆ device_temperature_ev

uavcan_event device_temperature_ev
static

Definition at line 97 of file actuators_uavcan.c.

Referenced by actuators_uavcan_init().

◆ esc_idx

uint8_t esc_idx = 0
static

Definition at line 103 of file actuators_uavcan.c.

Referenced by actuators_uavcan_next_telem().

◆ esc_status_ev

uavcan_event esc_status_ev
static

Definition at line 95 of file actuators_uavcan.c.

Referenced by actuators_uavcan_init().

◆ old_idx

uint8_t old_idx = 0
static

Definition at line 102 of file actuators_uavcan.c.

Referenced by actuators_uavcan_next_telem(), and actuators_uavcan_send_esc().