diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2015-01-06 15:55:28 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-01-06 15:55:28 +0100 |
commit | d5906b1658c697020f31f49df9acbc6d6d721385 (patch) | |
tree | 6df255f9e5fe2768cfb5bac112821dc4abe551e2 /src/modules/systemlib/mixer/mixer_multirotor.cpp | |
parent | 6a2c0e83d51d98e9484e25bd7ecf24fd451bcf9e (diff) | |
parent | c1161d4e89eb7922b64578826de4b7a3a84ef362 (diff) | |
download | px4-firmware-d5906b1658c697020f31f49df9acbc6d6d721385.tar.gz px4-firmware-d5906b1658c697020f31f49df9acbc6d6d721385.tar.bz2 px4-firmware-d5906b1658c697020f31f49df9acbc6d6d721385.zip |
Merge branch 'master' of github.com:PX4/Firmware into nuttx_bringup
Diffstat (limited to 'src/modules/systemlib/mixer/mixer_multirotor.cpp')
-rw-r--r-- | src/modules/systemlib/mixer/mixer_multirotor.cpp | 147 |
1 files changed, 18 insertions, 129 deletions
diff --git a/src/modules/systemlib/mixer/mixer_multirotor.cpp b/src/modules/systemlib/mixer/mixer_multirotor.cpp index eb1aef6c1..5cfbe47f0 100644 --- a/src/modules/systemlib/mixer/mixer_multirotor.cpp +++ b/src/modules/systemlib/mixer/mixer_multirotor.cpp @@ -55,6 +55,9 @@ #include "mixer.h" +// This file is generated by the multi_tables script which is invoked during the build process +#include "mixer_multirotor.generated.h" + #define debug(fmt, args...) do { } while(0) //#define debug(fmt, args...) do { printf("[mixer] " fmt "\n", ##args); } while(0) //#include <debug.h> @@ -72,125 +75,11 @@ float constrain(float val, float min, float max) { return (val < min) ? min : ((val > max) ? max : val); } - -/* - * These tables automatically generated by multi_tables - do not edit. - */ - -const MultirotorMixer::Rotor _config_quad_x[] = { - { -0.707107, 0.707107, 1.000000 }, - { 0.707107, -0.707107, 1.000000 }, - { 0.707107, 0.707107, -1.000000 }, - { -0.707107, -0.707107, -1.000000 }, -}; -const MultirotorMixer::Rotor _config_quad_plus[] = { - { -1.000000, 0.000000, 1.000000 }, - { 1.000000, 0.000000, 1.000000 }, - { 0.000000, 1.000000, -1.000000 }, - { -0.000000, -1.000000, -1.000000 }, -}; -const MultirotorMixer::Rotor _config_quad_v[] = { - { -0.322266, 0.946649, 0.424200 }, - { 0.322266, 0.946649, 1.000000 }, - { 0.322266, 0.946649, -0.424200 }, - { -0.322266, 0.946649, -1.000000 }, -}; -const MultirotorMixer::Rotor _config_quad_wide[] = { - { -0.927184, 0.374607, 1.000000 }, - { 0.777146, -0.629320, 1.000000 }, - { 0.927184, 0.374607, -1.000000 }, - { -0.777146, -0.629320, -1.000000 }, -}; -const MultirotorMixer::Rotor _config_hex_x[] = { - { -1.000000, 0.000000, -1.000000 }, - { 1.000000, 0.000000, 1.000000 }, - { 0.500000, 0.866025, -1.000000 }, - { -0.500000, -0.866025, 1.000000 }, - { -0.500000, 0.866025, 1.000000 }, - { 0.500000, -0.866025, -1.000000 }, -}; -const MultirotorMixer::Rotor _config_hex_plus[] = { - { 0.000000, 1.000000, -1.000000 }, - { -0.000000, -1.000000, 1.000000 }, - { 0.866025, -0.500000, -1.000000 }, - { -0.866025, 0.500000, 1.000000 }, - { 0.866025, 0.500000, 1.000000 }, - { -0.866025, -0.500000, -1.000000 }, -}; -const MultirotorMixer::Rotor _config_hex_cox[] = { - { -0.866025, 0.500000, -1.000000 }, - { -0.866025, 0.500000, 1.000000 }, - { -0.000000, -1.000000, -1.000000 }, - { -0.000000, -1.000000, 1.000000 }, - { 0.866025, 0.500000, -1.000000 }, - { 0.866025, 0.500000, 1.000000 }, -}; -const MultirotorMixer::Rotor _config_octa_x[] = { - { -0.382683, 0.923880, -1.000000 }, - { 0.382683, -0.923880, -1.000000 }, - { -0.923880, 0.382683, 1.000000 }, - { -0.382683, -0.923880, 1.000000 }, - { 0.382683, 0.923880, 1.000000 }, - { 0.923880, -0.382683, 1.000000 }, - { 0.923880, 0.382683, -1.000000 }, - { -0.923880, -0.382683, -1.000000 }, -}; -const MultirotorMixer::Rotor _config_octa_plus[] = { - { 0.000000, 1.000000, -1.000000 }, - { -0.000000, -1.000000, -1.000000 }, - { -0.707107, 0.707107, 1.000000 }, - { -0.707107, -0.707107, 1.000000 }, - { 0.707107, 0.707107, 1.000000 }, - { 0.707107, -0.707107, 1.000000 }, - { 1.000000, 0.000000, -1.000000 }, - { -1.000000, 0.000000, -1.000000 }, -}; -const MultirotorMixer::Rotor _config_octa_cox[] = { - { -0.707107, 0.707107, 1.000000 }, - { 0.707107, 0.707107, -1.000000 }, - { 0.707107, -0.707107, 1.000000 }, - { -0.707107, -0.707107, -1.000000 }, - { 0.707107, 0.707107, 1.000000 }, - { -0.707107, 0.707107, -1.000000 }, - { -0.707107, -0.707107, 1.000000 }, - { 0.707107, -0.707107, -1.000000 }, -}; -const MultirotorMixer::Rotor _config_twin_engine[] = { - { -1.000000, 0.000000, 0.000000 }, - { 1.000000, 0.000000, 0.000000 }, -}; -const MultirotorMixer::Rotor *_config_index[MultirotorMixer::MAX_GEOMETRY] = { - &_config_quad_x[0], - &_config_quad_plus[0], - &_config_quad_v[0], - &_config_quad_wide[0], - &_config_hex_x[0], - &_config_hex_plus[0], - &_config_hex_cox[0], - &_config_octa_x[0], - &_config_octa_plus[0], - &_config_octa_cox[0], - &_config_twin_engine[0], -}; -const unsigned _config_rotor_count[MultirotorMixer::MAX_GEOMETRY] = { - 4, /* quad_x */ - 4, /* quad_plus */ - 4, /* quad_v */ - 4, /* quad_wide */ - 6, /* hex_x */ - 6, /* hex_plus */ - 6, /* hex_cox */ - 8, /* octa_x */ - 8, /* octa_plus */ - 8, /* octa_cox */ - 2, /* twin_engine */ -}; - } MultirotorMixer::MultirotorMixer(ControlCallback control_cb, uintptr_t cb_handle, - Geometry geometry, + MultirotorGeometry geometry, float roll_scale, float pitch_scale, float yaw_scale, @@ -200,8 +89,8 @@ MultirotorMixer::MultirotorMixer(ControlCallback control_cb, _pitch_scale(pitch_scale), _yaw_scale(yaw_scale), _idle_speed(-1.0f + idle_speed * 2.0f), /* shift to output range here to avoid runtime calculation */ - _rotor_count(_config_rotor_count[geometry]), - _rotors(_config_index[geometry]) + _rotor_count(_config_rotor_count[(MultirotorGeometryUnderlyingType)geometry]), + _rotors(_config_index[(MultirotorGeometryUnderlyingType)geometry]) { } @@ -212,7 +101,7 @@ MultirotorMixer::~MultirotorMixer() MultirotorMixer * MultirotorMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handle, const char *buf, unsigned &buflen) { - MultirotorMixer::Geometry geometry; + MultirotorGeometry geometry; char geomname[8]; int s[4]; int used; @@ -252,37 +141,37 @@ MultirotorMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handl debug("remaining in buf: %d, first char: %c", buflen, buf[0]); if (!strcmp(geomname, "4+")) { - geometry = MultirotorMixer::QUAD_PLUS; + geometry = MultirotorGeometry::QUAD_PLUS; } else if (!strcmp(geomname, "4x")) { - geometry = MultirotorMixer::QUAD_X; + geometry = MultirotorGeometry::QUAD_X; } else if (!strcmp(geomname, "4v")) { - geometry = MultirotorMixer::QUAD_V; + geometry = MultirotorGeometry::QUAD_V; } else if (!strcmp(geomname, "4w")) { - geometry = MultirotorMixer::QUAD_WIDE; + geometry = MultirotorGeometry::QUAD_WIDE; } else if (!strcmp(geomname, "6+")) { - geometry = MultirotorMixer::HEX_PLUS; + geometry = MultirotorGeometry::HEX_PLUS; } else if (!strcmp(geomname, "6x")) { - geometry = MultirotorMixer::HEX_X; + geometry = MultirotorGeometry::HEX_X; } else if (!strcmp(geomname, "6c")) { - geometry = MultirotorMixer::HEX_COX; + geometry = MultirotorGeometry::HEX_COX; } else if (!strcmp(geomname, "8+")) { - geometry = MultirotorMixer::OCTA_PLUS; + geometry = MultirotorGeometry::OCTA_PLUS; } else if (!strcmp(geomname, "8x")) { - geometry = MultirotorMixer::OCTA_X; + geometry = MultirotorGeometry::OCTA_X; } else if (!strcmp(geomname, "8c")) { - geometry = MultirotorMixer::OCTA_COX; + geometry = MultirotorGeometry::OCTA_COX; } else if (!strcmp(geomname, "2-")) { - geometry = MultirotorMixer::TWIN_ENGINE; + geometry = MultirotorGeometry::TWIN_ENGINE; } else { debug("unrecognised geometry '%s'", geomname); return nullptr; |