Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
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 <math.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 UNITLESS   UAVCAN_EQUIPMENT_ACTUATOR_COMMAND_COMMAND_TYPE_UNITLESS
#define POSITION   UAVCAN_EQUIPMENT_ACTUATOR_COMMAND_COMMAND_TYPE_POSITION
#define FORCE   UAVCAN_EQUIPMENT_ACTUATOR_COMMAND_COMMAND_TYPE_FORCE
#define SPEED   UAVCAN_EQUIPMENT_ACTUATOR_COMMAND_COMMAND_TYPE_SPEED
#define PWM   UAVCAN_EQUIPMENT_ACTUATOR_COMMAND_COMMAND_TYPE_PWM
#define UAVCAN_CMD_UNUSED   (MIN_PPRZ-1)

Functions

static struct actuators_uavcan_telem_t * actuators_uavcan_next_telem (void)
static void actuators_uavcan_send_esc (struct transport_tx *trans, struct link_device *dev)
static struct actuators_uavcan_telem_t * get_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 53 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

◆ FORCE

#define FORCE   UAVCAN_EQUIPMENT_ACTUATOR_COMMAND_COMMAND_TYPE_FORCE

Definition at line 48 of file actuators_uavcan.c.

◆ POSITION

#define POSITION   UAVCAN_EQUIPMENT_ACTUATOR_COMMAND_COMMAND_TYPE_POSITION

Definition at line 47 of file actuators_uavcan.c.

◆ PWM

#define PWM   UAVCAN_EQUIPMENT_ACTUATOR_COMMAND_COMMAND_TYPE_PWM

Definition at line 50 of file actuators_uavcan.c.

◆ SPEED

#define SPEED   UAVCAN_EQUIPMENT_ACTUATOR_COMMAND_COMMAND_TYPE_SPEED

Definition at line 49 of file actuators_uavcan.c.

◆ UAVCAN_ACTUATORS_USE_CURRENT

#define UAVCAN_ACTUATORS_USE_CURRENT   TRUE

Definition at line 43 of file actuators_uavcan.c.

◆ UAVCAN_CMD_UNUSED

#define UAVCAN_CMD_UNUSED   (MIN_PPRZ-1)

Definition at line 144 of file actuators_uavcan.c.

Referenced by actuators_uavcan_cmd_commit(), and actuators_uavcan_init().

◆ UNITLESS

#define UNITLESS   UAVCAN_EQUIPMENT_ACTUATOR_COMMAND_COMMAND_TYPE_UNITLESS

Definition at line 46 of file actuators_uavcan.c.

Function Documentation

◆ actuators_uavcan_actuator_status_cb()

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

◆ 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 492 of file actuators_uavcan.c.

References MAX_PPRZ, MIN_PPRZ, 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 471 of file actuators_uavcan.c.

References uavcan_broadcast().

Here is the call graph for this function:

◆ actuators_uavcan_device_temperature_cb()

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 409 of file actuators_uavcan.c.

References get_actuator_telem(), actuators_uavcan_telem_t::set, actuators_uavcan_telem_t::temperature_dev, 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()

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

◆ actuators_uavcan_init()

◆ actuators_uavcan_next_telem()

struct actuators_uavcan_telem_t * actuators_uavcan_next_telem ( void )
static

Definition at line 157 of file actuators_uavcan.c.

References esc_idx, idx, 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()

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

◆ get_actuator_idx()

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

Definition at line 269 of file actuators_uavcan.c.

References actuators_uavcan1cmd_set(), actuators_uavcan2cmd_set(), idx, and actuators_uavcan_telem_t::set.

Referenced by actuators_uavcan_actuator_status_cb(), and actuators_uavcan_esc_status_cb().

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

◆ get_actuator_telem()

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

Definition at line 252 of file actuators_uavcan.c.

References 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 149 of file actuators_uavcan.c.

Referenced by actuators_uavcan_init().

◆ actuators_uavcan_initialized

bool actuators_uavcan_initialized = false
static

Definition at line 147 of file actuators_uavcan.c.

Referenced by actuators_uavcan_init().

◆ device_temperature_ev

uavcan_event device_temperature_ev
static

Definition at line 150 of file actuators_uavcan.c.

Referenced by actuators_uavcan_init().

◆ esc_idx

uint8_t esc_idx = 0
static

Definition at line 156 of file actuators_uavcan.c.

Referenced by actuators_uavcan_next_telem().

◆ esc_status_ev

uavcan_event esc_status_ev
static

Definition at line 148 of file actuators_uavcan.c.

Referenced by actuators_uavcan_init().

◆ old_idx

uint8_t old_idx = 0
static

Definition at line 155 of file actuators_uavcan.c.

Referenced by actuators_uavcan_next_telem(), and actuators_uavcan_send_esc().