Firmware
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Mixer Class Referenceabstract

Abstract class defining a mixer mixing zero or more inputs to one or more outputs. More...

#include <mixer.h>

Inheritance diagram for Mixer:
HelicopterMixer MixerGroup MultirotorMixer NullMixer SimpleMixer

Public Types

enum  Airmode : int32_t { disabled = 0, roll_pitch = 1, roll_pitch_yaw = 2 }
 
typedef int(* ControlCallback) (uintptr_t handle, uint8_t control_group, uint8_t control_index, float &control)
 Fetch a control value. More...
 

Public Member Functions

 Mixer (ControlCallback control_cb, uintptr_t cb_handle)
 Constructor. More...
 
virtual unsigned mix (float *outputs, unsigned space)=0
 Perform the mixing function. More...
 
virtual uint16_t get_saturation_status (void)=0
 Get the saturation status. More...
 
virtual void groups_required (uint32_t &groups)=0
 Analyses the mix configuration and updates a bitmask of groups that are required. More...
 
virtual void set_max_delta_out_once (float delta_out_max)
 Empty method, only implemented for MultirotorMixer and MixerGroup class. More...
 
virtual unsigned set_trim (float trim)=0
 Set trim offset for this mixer. More...
 
virtual unsigned get_trim (float *trim)=0
 Get trim offset for this mixer. More...
 
virtual void set_thrust_factor (float val)
 
virtual void set_airmode (Airmode airmode)
 Set airmode. More...
 

Public Attributes

Mixer_next
 next mixer in a list
 

Protected Member Functions

float get_control (uint8_t group, uint8_t index)
 Invoke the client callback to fetch a control value. More...
 

Static Protected Member Functions

static float scale (const mixer_scaler_s &scaler, float input)
 Perform simpler linear scaling. More...
 
static int scale_check (struct mixer_scaler_s &scaler)
 Validate a scaler. More...
 
static const char * findtag (const char *buf, unsigned &buflen, char tag)
 Find a tag. More...
 
static char findnexttag (const char *buf, unsigned buflen)
 Find next tag and return it (0 is returned if no tag is found) More...
 
static const char * skipline (const char *buf, unsigned &buflen)
 Skip a line. More...
 
static bool string_well_formed (const char *buf, unsigned &buflen)
 Check wether the string is well formed and suitable for parsing.
 

Protected Attributes

ControlCallback _control_cb
 client-supplied callback used when fetching control values
 
uintptr_t _cb_handle
 

Detailed Description

Abstract class defining a mixer mixing zero or more inputs to one or more outputs.

Member Typedef Documentation

§ ControlCallback

typedef int(* Mixer::ControlCallback) (uintptr_t handle, uint8_t control_group, uint8_t control_index, float &control)

Fetch a control value.

Parameters
handleToken passed when the callback is registered.
control_groupThe group to fetch the control from.
control_indexThe group-relative index to fetch the control from.
controlThe returned control
Returns
Zero if the value was fetched, nonzero otherwise.

Constructor & Destructor Documentation

§ Mixer()

Mixer::Mixer ( ControlCallback  control_cb,
uintptr_t  cb_handle 
)

Constructor.

Parameters
control_cbCallback invoked when reading controls.

Member Function Documentation

§ findnexttag()

char Mixer::findnexttag ( const char *  buf,
unsigned  buflen 
)
staticprotected

Find next tag and return it (0 is returned if no tag is found)

Parameters
bufThe buffer to operate on.
buflenlength of the buffer.

§ findtag()

const char * Mixer::findtag ( const char *  buf,
unsigned &  buflen,
char  tag 
)
staticprotected

Find a tag.

Parameters
bufThe buffer to operate on.
buflenlength of the buffer.
tagcharacter to search for.

§ get_control()

float Mixer::get_control ( uint8_t  group,
uint8_t  index 
)
protected

Invoke the client callback to fetch a control value.

Parameters
groupControl group to fetch from.
indexControl index to fetch.
Returns
The control value.

§ get_saturation_status()

virtual uint16_t Mixer::get_saturation_status ( void  )
pure virtual

Get the saturation status.

Returns
Integer bitmask containing saturation_status from multirotor_motor_limits.msg.

Implemented in HelicopterMixer, MultirotorMixer, SimpleMixer, NullMixer, and MixerGroup.

§ get_trim()

virtual unsigned Mixer::get_trim ( float *  trim)
pure virtual

Get trim offset for this mixer.

Returns
the number of outputs this mixer feeds to

Implemented in HelicopterMixer, MultirotorMixer, SimpleMixer, NullMixer, and MixerGroup.

§ groups_required()

virtual void Mixer::groups_required ( uint32_t &  groups)
pure virtual

Analyses the mix configuration and updates a bitmask of groups that are required.

Parameters
groupsA bitmask of groups (0-31) that the mixer requires.

Implemented in HelicopterMixer, MultirotorMixer, SimpleMixer, NullMixer, and MixerGroup.

§ mix()

virtual unsigned Mixer::mix ( float *  outputs,
unsigned  space 
)
pure virtual

Perform the mixing function.

Parameters
outputsArray into which mixed output(s) should be placed.
spaceThe number of available entries in the output array;
Returns
The number of entries in the output array that were populated.

Implemented in HelicopterMixer, MultirotorMixer, SimpleMixer, NullMixer, and MixerGroup.

§ scale()

float Mixer::scale ( const mixer_scaler_s scaler,
float  input 
)
staticprotected

Perform simpler linear scaling.

Parameters
scalerThe scaler configuration.
inputThe value to be scaled.
Returns
The scaled value.

§ scale_check()

int Mixer::scale_check ( struct mixer_scaler_s scaler)
staticprotected

Validate a scaler.

Parameters
scalerThe scaler to be validated.
Returns
Zero if good, nonzero otherwise.

§ set_airmode()

virtual void Mixer::set_airmode ( Airmode  airmode)
inlinevirtual

Set airmode.

Airmode allows the mixer to increase the total thrust in order to unsaturate the motors.

Parameters
[in]airmodeSelect airmode type (0 = disabled, 1 = roll/pitch, 2 = roll/pitch/yaw)

Reimplemented in MultirotorMixer, and MixerGroup.

§ set_max_delta_out_once()

virtual void Mixer::set_max_delta_out_once ( float  delta_out_max)
inlinevirtual

Empty method, only implemented for MultirotorMixer and MixerGroup class.

Parameters
[in]delta_out_maxMaximum delta output.

Reimplemented in MultirotorMixer, and MixerGroup.

§ set_trim()

virtual unsigned Mixer::set_trim ( float  trim)
pure virtual

Set trim offset for this mixer.

Returns
the number of outputs this mixer feeds to

Implemented in HelicopterMixer, MultirotorMixer, SimpleMixer, NullMixer, and MixerGroup.

§ skipline()

const char * Mixer::skipline ( const char *  buf,
unsigned &  buflen 
)
staticprotected

Skip a line.

Parameters
bufThe buffer to operate on.
buflenlength of the buffer.
Returns
0 / OK if a line could be skipped, 1 else

The documentation for this class was generated from the following files: