PX4 Firmware
PX4 Autopilot Software http://px4.io
Mixer Class Referenceabstract

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

#include <Mixer.hpp>

Inheritance diagram for Mixer:
Collaboration diagram for Mixer:

Public Types

enum  Airmode : int32_t { Airmode::disabled = 0, Airmode::roll_pitch = 1, Airmode::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 ~Mixer ()=default
 
 Mixer (const Mixer &)=delete
 
Mixeroperator= (const Mixer &)=delete
 
 Mixer (Mixer &&)=delete
 
Mixeroperator= (Mixer &&)=delete
 
virtual unsigned mix (float *outputs, unsigned space)=0
 Perform the mixing function. More...
 
virtual uint16_t get_saturation_status ()
 Get the saturation status. More...
 
virtual void groups_required (uint32_t &groups)
 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)
 Set trim offset for this mixer. More...
 
virtual unsigned get_trim (float *trim)
 Get trim offset for this mixer. More...
 
virtual void set_thrust_factor (float val)
 
virtual void set_airmode (Airmode airmode)
 Set airmode. More...
 
virtual unsigned get_multirotor_count ()
 
- Public Member Functions inherited from ListNode< Mixer *>
void setSibling (Mixer * sibling)
 
const MixergetSibling () const
 

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 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. More...
 

Protected Attributes

ControlCallback _control_cb
 client-supplied callback used when fetching control values More...
 
uintptr_t _cb_handle
 
- Protected Attributes inherited from ListNode< Mixer *>
Mixer_list_node_sibling
 

Detailed Description

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

Definition at line 136 of file Mixer.hpp.

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.

Definition at line 154 of file Mixer.hpp.

Member Enumeration Documentation

◆ Airmode

enum Mixer::Airmode : int32_t
strong
Enumerator
disabled 
roll_pitch 
roll_pitch_yaw 

Definition at line 139 of file Mixer.hpp.

Constructor & Destructor Documentation

◆ Mixer() [1/3]

Mixer::Mixer ( ControlCallback  control_cb,
uintptr_t  cb_handle 
)
inline

Constructor.

Parameters
control_cbCallback invoked when reading controls.

Definition at line 161 of file Mixer.hpp.

References mix(), operator=(), and ~Mixer().

Here is the call graph for this function:

◆ ~Mixer()

virtual Mixer::~Mixer ( )
virtualdefault

Referenced by Mixer().

Here is the caller graph for this function:

◆ Mixer() [2/3]

Mixer::Mixer ( const Mixer )
delete

◆ Mixer() [3/3]

Mixer::Mixer ( Mixer &&  )
delete

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.

Definition at line 75 of file Mixer.cpp.

Referenced by SimpleMixer::from_text().

Here is the caller graph for this function:

◆ 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.

Definition at line 60 of file Mixer.cpp.

Referenced by HelicopterMixer::from_text(), SimpleMixer::parse_control_scaler(), and SimpleMixer::parse_output_scaler().

Here is the caller graph for this function:

◆ 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.

Definition at line 50 of file Mixer.cpp.

References _cb_handle, and _control_cb.

Referenced by HelicopterMixer::mix(), and MultirotorMixer::mix().

Here is the caller graph for this function:

◆ get_multirotor_count()

virtual unsigned Mixer::get_multirotor_count ( )
inlinevirtual

Reimplemented in MultirotorMixer.

Definition at line 230 of file Mixer.hpp.

◆ get_saturation_status()

virtual uint16_t Mixer::get_saturation_status ( )
inlinevirtual

Get the saturation status.

Returns
Integer bitmask containing saturation_status from multirotor_motor_limits.msg.

Reimplemented in MultirotorMixer.

Definition at line 184 of file Mixer.hpp.

◆ get_trim()

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

Get trim offset for this mixer.

Returns
the number of outputs this mixer feeds to

Reimplemented in MultirotorMixer, SimpleMixer, HelicopterMixer, and NullMixer.

Definition at line 214 of file Mixer.hpp.

◆ groups_required()

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

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

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

Reimplemented in MultirotorMixer, SimpleMixer, and HelicopterMixer.

Definition at line 192 of file Mixer.hpp.

◆ 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 MultirotorMixer, SimpleMixer, HelicopterMixer, and NullMixer.

Referenced by Mixer().

Here is the caller graph for this function:

◆ operator=() [1/2]

Mixer& Mixer::operator= ( const Mixer )
delete

Referenced by Mixer().

Here is the caller graph for this function:

◆ operator=() [2/2]

Mixer& Mixer::operator= ( Mixer &&  )
delete

◆ 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.

Definition at line 228 of file Mixer.hpp.

◆ 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.

Definition at line 200 of file Mixer.hpp.

◆ set_thrust_factor()

virtual void Mixer::set_thrust_factor ( float  val)
inlinevirtual

Reimplemented in MultirotorMixer.

Definition at line 221 of file Mixer.hpp.

◆ set_trim()

virtual unsigned Mixer::set_trim ( float  trim)
inlinevirtual

Set trim offset for this mixer.

Returns
the number of outputs this mixer feeds to

Reimplemented in MultirotorMixer, SimpleMixer, HelicopterMixer, and NullMixer.

Definition at line 207 of file Mixer.hpp.

◆ 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

Definition at line 90 of file Mixer.cpp.

Referenced by HelicopterMixer::from_text(), SimpleMixer::from_text(), MultirotorMixer::from_text(), SimpleMixer::parse_control_scaler(), and SimpleMixer::parse_output_scaler().

Here is the caller graph for this function:

◆ string_well_formed()

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

Check wether the string is well formed and suitable for parsing.

Definition at line 105 of file Mixer.cpp.

References debug.

Referenced by NullMixer::from_text(), HelicopterMixer::from_text(), SimpleMixer::from_text(), and MultirotorMixer::from_text().

Here is the caller graph for this function:

Member Data Documentation

◆ _cb_handle

uintptr_t Mixer::_cb_handle
protected

Definition at line 236 of file Mixer.hpp.

Referenced by SimpleMixer::check(), get_control(), and SimpleMixer::mix().

◆ _control_cb

ControlCallback Mixer::_control_cb
protected

client-supplied callback used when fetching control values

Definition at line 235 of file Mixer.hpp.

Referenced by SimpleMixer::check(), get_control(), and SimpleMixer::mix().


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