Firmware
Public Member Functions | List of all members
MixerGroup Class Reference

Group of mixers, built up from single mixers and processed in order when mixing. More...

#include <mixer.h>

Inheritance diagram for MixerGroup:
Mixer

Public Member Functions

 MixerGroup (ControlCallback control_cb, uintptr_t cb_handle)
 
unsigned mix (float *outputs, unsigned space) override
 Perform the mixing function. More...
 
uint16_t get_saturation_status (void) override
 Get the saturation status. More...
 
void groups_required (uint32_t &groups) override
 Analyses the mix configuration and updates a bitmask of groups that are required. More...
 
void add_mixer (Mixer *mixer)
 Add a mixer to the group. More...
 
void reset ()
 Remove all the mixers from the group.
 
unsigned count ()
 Count the mixers in the group.
 
int load_from_buf (const char *buf, unsigned &buflen)
 Adds mixers to the group based on a text description in a buffer. More...
 
void set_max_delta_out_once (float delta_out_max) override
 Update slew rate parameter. More...
 
unsigned set_trims (int16_t *v, unsigned n)
 
unsigned set_trim (float trim) override
 Set trim offset for this mixer. More...
 
unsigned get_trims (int16_t *values)
 
unsigned get_trim (float *trim) override
 Get trim offset for this mixer. More...
 
void set_thrust_factor (float val) override
 Sets the thrust factor used to calculate mapping from desired thrust to pwm. More...
 
void set_airmode (Airmode airmode) override
 Set airmode. More...
 
- Public Member Functions inherited from Mixer
 Mixer (ControlCallback control_cb, uintptr_t cb_handle)
 Constructor. More...
 

Additional Inherited Members

- Public Types inherited from Mixer
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 Attributes inherited from Mixer
Mixer_next
 next mixer in a list
 
- Protected Member Functions inherited from Mixer
float get_control (uint8_t group, uint8_t index)
 Invoke the client callback to fetch a control value. More...
 
- Static Protected Member Functions inherited from Mixer
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 inherited from Mixer
ControlCallback _control_cb
 client-supplied callback used when fetching control values
 
uintptr_t _cb_handle
 

Detailed Description

Group of mixers, built up from single mixers and processed in order when mixing.

Member Function Documentation

§ add_mixer()

void MixerGroup::add_mixer ( Mixer mixer)

Add a mixer to the group.

Parameters
mixerThe mixer to be added.

§ get_saturation_status()

uint16_t MixerGroup::get_saturation_status ( void  )
overridevirtual

Get the saturation status.

Returns
Integer bitmask containing saturation_status from multirotor_motor_limits.msg.

Implements Mixer.

§ get_trim()

unsigned MixerGroup::get_trim ( float *  trim)
inlineoverridevirtual

Get trim offset for this mixer.

Returns
the number of outputs this mixer feeds to

Implements Mixer.

§ groups_required()

void MixerGroup::groups_required ( uint32_t &  groups)
overridevirtual

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

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

Implements Mixer.

§ load_from_buf()

int MixerGroup::load_from_buf ( const char *  buf,
unsigned &  buflen 
)

Adds mixers to the group based on a text description in a buffer.

Mixer definitions begin with a single capital letter and a colon. The actual format of the mixer definition varies with the individual mixers; they are summarised here, but see ROMFS/mixers/README for more details.

Null Mixer ..........

The null mixer definition has the form:

Z:

Simple Mixer ............

A simple mixer definition begins with:

M: <control count>=""> O: <-ve scale> <+ve scale> <offset> <lower limit>=""> <upper limit>="">

The second line O: can be omitted. In that case 'O: 10000 10000 0 -10000 10000' is used. The definition continues with <control count>=""> entries describing the control inputs and their scaling, in the form:

S: <group> <index> <-ve scale> <+ve scale> <offset> <lower limit>=""> <upper limit>="">

Multirotor Mixer ................

The multirotor mixer definition is a single line of the form:

R: <geometry> <roll scale>=""> <pitch scale>=""> <yaw scale>=""> <deadband>

Helicopter Mixer ................

The helicopter mixer includes throttle and pitch curves

H: <swash plate="" servo="" count>=""> T: <0> <2500> <5000> <7500> <10000> P: <-10000> <-5000> <0> <5000> <10000>

The definition continues with <swash plate="" servo="" count>=""> entries describing the position of the servo, in the following form:

S: <angle (deg)> <normalized arm="" length>=""> <scale> <offset> <lower limit>=""> <upper limit>="">

Parameters
bufThe mixer configuration buffer.
buflenThe length of the buffer, updated to reflect bytes as they are consumed.
Returns
Zero on successful load, nonzero otherwise.

§ mix()

unsigned MixerGroup::mix ( float *  outputs,
unsigned  space 
)
overridevirtual

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.

Implements Mixer.

§ set_airmode()

void MixerGroup::set_airmode ( Airmode  airmode)
overridevirtual

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 from Mixer.

§ set_max_delta_out_once()

void MixerGroup::set_max_delta_out_once ( float  delta_out_max)
overridevirtual

Update slew rate parameter.

This tells instances of the class MultirotorMixer the maximum allowed change of the output values per cycle. The value is only valid for one cycle, in order to have continuous slew rate limiting this function needs to be called before every call to mix().

Parameters
[in]delta_out_maxMaximum delta output.

Reimplemented from Mixer.

§ set_thrust_factor()

void MixerGroup::set_thrust_factor ( float  val)
overridevirtual

Sets the thrust factor used to calculate mapping from desired thrust to pwm.

Parameters
[in]valThe value

Reimplemented from Mixer.

§ set_trim()

unsigned MixerGroup::set_trim ( float  trim)
inlineoverridevirtual

Set trim offset for this mixer.

Returns
the number of outputs this mixer feeds to

Implements Mixer.


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