aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modules/systemlib/mixer/mixer.h18
-rw-r--r--src/modules/systemlib/mixer/mixer_multirotor.cpp30
-rwxr-xr-xsrc/modules/systemlib/mixer/multi_tables39
-rw-r--r--src/modules/systemlib/mixer/multi_tables.mk6
4 files changed, 65 insertions, 28 deletions
diff --git a/src/modules/systemlib/mixer/mixer.h b/src/modules/systemlib/mixer/mixer.h
index a0197df48..864ce21a5 100644
--- a/src/modules/systemlib/mixer/mixer.h
+++ b/src/modules/systemlib/mixer/mixer.h
@@ -441,6 +441,15 @@ private:
SimpleMixer operator=(const SimpleMixer&);
};
+
+/**
+ * Supported multirotor geometries.
+ *
+ * Values are generated by the multi_tables script and placed to mixer_multirotor.generated.h
+ */
+typedef unsigned int MultirotorGeometryUnderlyingType;
+enum class MultirotorGeometry : MultirotorGeometryUnderlyingType;
+
/**
* Multi-rotor mixer for pre-defined vehicle geometries.
*
@@ -451,13 +460,6 @@ class __EXPORT MultirotorMixer : public Mixer
{
public:
/**
- * Supported multirotor geometries.
- *
- * Values are generated by the multi_tables script and placed to mixer_multirotor.generated.h
- */
- enum Geometry : unsigned int;
-
- /**
* Precalculated rotor mix.
*/
struct Rotor {
@@ -484,7 +486,7 @@ public:
*/
MultirotorMixer(ControlCallback control_cb,
uintptr_t cb_handle,
- Geometry geometry,
+ MultirotorGeometry geometry,
float roll_scale,
float pitch_scale,
float yaw_scale,
diff --git a/src/modules/systemlib/mixer/mixer_multirotor.cpp b/src/modules/systemlib/mixer/mixer_multirotor.cpp
index 42e3513f4..5cfbe47f0 100644
--- a/src/modules/systemlib/mixer/mixer_multirotor.cpp
+++ b/src/modules/systemlib/mixer/mixer_multirotor.cpp
@@ -79,7 +79,7 @@ float constrain(float val, float min, float max)
MultirotorMixer::MultirotorMixer(ControlCallback control_cb,
uintptr_t cb_handle,
- Geometry geometry,
+ MultirotorGeometry geometry,
float roll_scale,
float pitch_scale,
float yaw_scale,
@@ -89,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])
{
}
@@ -101,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;
@@ -141,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;
diff --git a/src/modules/systemlib/mixer/multi_tables b/src/modules/systemlib/mixer/multi_tables
index 46dfc5bff..a9edb357b 100755
--- a/src/modules/systemlib/mixer/multi_tables
+++ b/src/modules/systemlib/mixer/multi_tables
@@ -1,4 +1,37 @@
#!/usr/bin/env python
+############################################################################
+#
+# Copyright (c) 2013, 2014 PX4 Development Team. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name PX4 nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
#
# Generate multirotor mixer scale tables compatible with the ArduCopter layout
#
@@ -6,7 +39,7 @@
import math
print "/*"
-print "* This file is automatically generated by multi_tables.py - do not edit."
+print "* This file is automatically generated by multi_tables - do not edit."
print "*/"
print ""
print "#ifndef _MIXER_MULTI_TABLES"
@@ -121,12 +154,12 @@ tables = [quad_x, quad_plus, quad_v, quad_wide, hex_x, hex_plus, hex_cox, octa_x
def printEnum():
- print "enum MultirotorMixer::Geometry : unsigned int {"
+ print "enum class MultirotorGeometry : MultirotorGeometryUnderlyingType {"
for table in tables:
print "\t{},".format(variableName(table).upper())
print "\n\tMAX_GEOMETRY"
- print "}; // enum MultirotorMixer::Geometry\n"
+ print "}; // enum class MultirotorGeometry\n"
def printScaleTables():
for table in tables:
diff --git a/src/modules/systemlib/mixer/multi_tables.mk b/src/modules/systemlib/mixer/multi_tables.mk
index 02216c3d4..6429961cc 100644
--- a/src/modules/systemlib/mixer/multi_tables.mk
+++ b/src/modules/systemlib/mixer/multi_tables.mk
@@ -1,6 +1,6 @@
############################################################################
#
-# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved.
+# Copyright (c) 2014 Anton Matosov <anton.matosov@gmail.com>. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -38,4 +38,6 @@ SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
$(SELF_DIR)mixer_multirotor.cpp : $(SELF_DIR)mixer_multirotor.generated.h
$(SELF_DIR)mixer_multirotor.generated.h : $(SELF_DIR)multi_tables
- $(SELF_DIR)multi_tables> $(SELF_DIR)mixer_multirotor.generated.h \ No newline at end of file
+ $(SELF_DIR)multi_tables > $(SELF_DIR)mixer_multirotor.generated.h
+ $(SELF_DIR)multi_tables
+ \ No newline at end of file