Firmware
|
Multi-rotor mixer for pre-defined vehicle geometries. More...
#include <mixer.h>
Classes | |
struct | Rotor |
Precalculated rotor mix. More... | |
union | saturation_status |
Public Member Functions | |
MultirotorMixer (ControlCallback control_cb, uintptr_t cb_handle, MultirotorGeometry geometry, float roll_scale, float pitch_scale, float yaw_scale, float idle_speed) | |
Constructor. More... | |
MultirotorMixer (ControlCallback control_cb, uintptr_t cb_handle, Rotor *rotors, unsigned rotor_count) | |
Constructor (for testing). More... | |
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 | set_max_delta_out_once (float delta_out_max) override |
Update slew rate parameter. More... | |
unsigned | set_trim (float trim) override |
Set trim offset for this mixer. More... | |
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... | |
![]() | |
Mixer (ControlCallback control_cb, uintptr_t cb_handle) | |
Constructor. More... | |
Static Public Member Functions | |
static MultirotorMixer * | from_text (Mixer::ControlCallback control_cb, uintptr_t cb_handle, const char *buf, unsigned &buflen) |
Factory method. More... | |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
Mixer * | _next |
next mixer in a list | |
![]() | |
float | get_control (uint8_t group, uint8_t index) |
Invoke the client callback to fetch a control value. More... | |
![]() | |
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. | |
![]() | |
ControlCallback | _control_cb |
client-supplied callback used when fetching control values | |
uintptr_t | _cb_handle |
Multi-rotor mixer for pre-defined vehicle geometries.
Collects four inputs (roll, pitch, yaw, thrust) and mixes them to a set of outputs based on the configured geometry.
MultirotorMixer::MultirotorMixer | ( | ControlCallback | control_cb, |
uintptr_t | cb_handle, | ||
MultirotorGeometry | geometry, | ||
float | roll_scale, | ||
float | pitch_scale, | ||
float | yaw_scale, | ||
float | idle_speed | ||
) |
Constructor.
control_cb | Callback invoked to read inputs. |
cb_handle | Passed to control_cb. |
geometry | The selected geometry. |
roll_scale | Scaling factor applied to roll inputs compared to thrust. |
pitch_scale | Scaling factor applied to pitch inputs compared to thrust. |
yaw_wcale | Scaling factor applied to yaw inputs compared to thrust. |
idle_speed | Minimum rotor control output value; usually tuned to ensure that rotors never stall at the low end of their control range. |
MultirotorMixer::MultirotorMixer | ( | ControlCallback | control_cb, |
uintptr_t | cb_handle, | ||
Rotor * | rotors, | ||
unsigned | rotor_count | ||
) |
Constructor (for testing).
control_cb | Callback invoked to read inputs. |
cb_handle | Passed to control_cb. |
rotors | control allocation matrix |
rotor_count | length of rotors array (= number of motors) |
|
static |
Factory method.
Given a pointer to a buffer containing a text description of the mixer, returns a pointer to a new instance of the mixer.
control_cb | The callback to invoke when fetching a control value. |
cb_handle | Handle passed to the control callback. |
buf | Buffer containing a text description of the mixer. |
buflen | Length of the buffer in bytes, adjusted to reflect the bytes consumed. |
|
overridevirtual |
Get the saturation status.
Implements Mixer.
|
inlineoverridevirtual |
|
overridevirtual |
Analyses the mix configuration and updates a bitmask of groups that are required.
groups | A bitmask of groups (0-31) that the mixer requires. |
Implements Mixer.
|
overridevirtual |
Perform the mixing function.
outputs | Array into which mixed output(s) should be placed. |
space | The number of available entries in the output array; |
Implements Mixer.
|
overridevirtual |
Set airmode.
Airmode allows the mixer to increase the total thrust in order to unsaturate the motors.
[in] | airmode | Select airmode type (0 = disabled, 1 = roll/pitch, 2 = roll/pitch/yaw) |
Reimplemented from Mixer.
|
inlineoverridevirtual |
Update slew rate parameter.
This tells the multicopter mixer 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().
[in] | delta_out_max | Maximum delta output. |
Reimplemented from Mixer.
|
inlineoverridevirtual |
Sets the thrust factor used to calculate mapping from desired thrust to pwm.
[in] | val | The value |
Reimplemented from Mixer.
|
inlineoverridevirtual |