diff --git a/src/drivers/drv_mixer.h b/src/drivers/drv_mixer.h index 1f61797c82babe681525e8a5c2392993f2c175f5..f2e3701b720ba6258e2983316bac8ff108ee9e46 100644 --- a/src/drivers/drv_mixer.h +++ b/src/drivers/drv_mixer.h @@ -71,31 +71,6 @@ /** reset (clear) the mixer configuration */ #define MIXERIOCRESET _MIXERIOC(1) -/** simple channel scaler */ -struct mixer_scaler_s { - float negative_scale; - float positive_scale; - float offset; - float min_output; - float max_output; -}; - -/** mixer input */ -struct mixer_control_s { - uint8_t control_group; /**< group from which the input reads */ - uint8_t control_index; /**< index within the control group */ - struct mixer_scaler_s scaler; /**< scaling applied to the input before use */ -}; - -/** simple mixer */ -struct mixer_simple_s { - uint8_t control_count; /**< number of inputs */ - struct mixer_scaler_s output_scaler; /**< scaling for the output */ - struct mixer_control_s controls[0]; /**< actual size of the array is set by control_count */ -}; - -#define MIXER_SIMPLE_SIZE(_icount) (sizeof(struct mixer_simple_s) + (_icount) * sizeof(struct mixer_control_s)) - /** * add a simple mixer in (struct mixer_simple_s *)arg */ diff --git a/src/drivers/uavcan/uavcan_main.cpp b/src/drivers/uavcan/uavcan_main.cpp index fbac9c4414edd9f405604c977e5f6d0e0357fe03..ce714d73f074334741c8c234e86d87106bf098e4 100644 --- a/src/drivers/uavcan/uavcan_main.cpp +++ b/src/drivers/uavcan/uavcan_main.cpp @@ -59,6 +59,7 @@ #include <uORB/topics/parameter_update.h> #include <drivers/drv_hrt.h> +#include <drivers/drv_mixer.h> #include <drivers/drv_pwm_output.h> #include "uavcan_module.hpp" diff --git a/src/lib/FlightTasks/tasks/Utility/ManualSmoothingXY.cpp b/src/lib/FlightTasks/tasks/Utility/ManualSmoothingXY.cpp index 6908afeb13502d280ff0ec93831e4d944614449d..755ba5cbcf779ae58720283bd4060b9a4150df9e 100644 --- a/src/lib/FlightTasks/tasks/Utility/ManualSmoothingXY.cpp +++ b/src/lib/FlightTasks/tasks/Utility/ManualSmoothingXY.cpp @@ -38,6 +38,7 @@ #include "ManualSmoothingXY.hpp" #include <mathlib/mathlib.h> #include <float.h> +#include <px4_defines.h> using namespace matrix; diff --git a/src/lib/FlightTasks/tasks/Utility/StraightLine.cpp b/src/lib/FlightTasks/tasks/Utility/StraightLine.cpp index 501bd20ba9f8cfec3f541aa335d274a546af1a87..8fc5df22d25fc824cc34915c2f4d2dcbd5109243 100644 --- a/src/lib/FlightTasks/tasks/Utility/StraightLine.cpp +++ b/src/lib/FlightTasks/tasks/Utility/StraightLine.cpp @@ -38,6 +38,7 @@ #include "StraightLine.hpp" #include <mathlib/mathlib.h> #include <float.h> +#include <px4_defines.h> #define VEL_ZERO_THRESHOLD 0.001f // Threshold to compare if the target velocity is zero #define DECELERATION_MAX 8.0f // The vehicles maximum deceleration TODO check to create param diff --git a/src/lib/FlightTasks/tasks/Utility/VelocitySmoothing.cpp b/src/lib/FlightTasks/tasks/Utility/VelocitySmoothing.cpp index d65ec361532385aa9eb2c19f99e17c682424a9ab..5503d4bbfbdcf18fe6dfb4d6b20c7c43007dc965 100644 --- a/src/lib/FlightTasks/tasks/Utility/VelocitySmoothing.cpp +++ b/src/lib/FlightTasks/tasks/Utility/VelocitySmoothing.cpp @@ -36,6 +36,7 @@ #include <cstdio> #include <float.h> #include <math.h> +#include <px4_defines.h> #include <mathlib/mathlib.h> diff --git a/src/lib/battery/battery.cpp b/src/lib/battery/battery.cpp index c690ad476bf20270924124a7d1ee2d9c90839c09..2b2075e244c0c592e33009d4ce090c1945c9adb3 100644 --- a/src/lib/battery/battery.cpp +++ b/src/lib/battery/battery.cpp @@ -42,6 +42,7 @@ #include "battery.h" #include <mathlib/mathlib.h> #include <cstring> +#include <px4_defines.h> Battery::Battery() : ModuleParams(nullptr), diff --git a/src/lib/conversion/rotation.cpp b/src/lib/conversion/rotation.cpp index 1ffc18150c7d4c3dfc7f29037d66cd7e93fe6c52..0b508c516414c7d02ac01911cf29d97725dfe932 100644 --- a/src/lib/conversion/rotation.cpp +++ b/src/lib/conversion/rotation.cpp @@ -37,6 +37,7 @@ * Vector rotation library */ +#include <px4_defines.h> #include "math.h" #include "rotation.h" diff --git a/src/lib/mathlib/math/Functions.hpp b/src/lib/mathlib/math/Functions.hpp index 59ae0ea21067cfe71fafeb06b61c5319a6e63324..14dcd5f1699e5f0f782edb8e8a93751a57044877 100644 --- a/src/lib/mathlib/math/Functions.hpp +++ b/src/lib/mathlib/math/Functions.hpp @@ -39,7 +39,7 @@ #pragma once -#include <platforms/px4_defines.h> +#include "Limits.hpp" namespace math { diff --git a/src/lib/mathlib/math/Limits.hpp b/src/lib/mathlib/math/Limits.hpp index 4610a01e402eadc2783d9a35f088d74d36fec83f..cab5d9870706eaf50e07ebf7af58e96ad8355016 100644 --- a/src/lib/mathlib/math/Limits.hpp +++ b/src/lib/mathlib/math/Limits.hpp @@ -39,8 +39,13 @@ #pragma once -#include <platforms/px4_defines.h> #include <float.h> +#include <math.h> +#include <stdint.h> + +#ifndef MATH_PI +#define MATH_PI 3.141592653589793238462643383280 +#endif //this should be defined in stdint.h, but seems to be missing in the ARM toolchain (5.2.0) #ifndef UINT64_C @@ -90,13 +95,13 @@ inline constexpr bool isInRange(const _Tp &val, const _Tp &min_val, const _Tp &m template<typename T> constexpr T radians(const T degrees) { - return degrees * (static_cast<T>(M_PI) / static_cast<T>(180)); + return degrees * (static_cast<T>(MATH_PI) / static_cast<T>(180)); } template<typename T> constexpr T degrees(const T radians) { - return radians * (static_cast<T>(180) / static_cast<T>(M_PI)); + return radians * (static_cast<T>(180) / static_cast<T>(MATH_PI)); } /** Save way to check if float is zero */ diff --git a/src/lib/mathlib/math/SearchMin.hpp b/src/lib/mathlib/math/SearchMin.hpp index f265c8ed688a9193f54181e9901ca81e7e5da3a5..668f291f97ded8e7a3f767798d529582d9b54070 100644 --- a/src/lib/mathlib/math/SearchMin.hpp +++ b/src/lib/mathlib/math/SearchMin.hpp @@ -40,8 +40,6 @@ #pragma once -#include <platforms/px4_defines.h> - namespace math { static constexpr double GOLDEN_RATIO = 1.6180339887; //(sqrt(5)+1)/2 diff --git a/src/lib/mixer/mixer.cpp b/src/lib/mixer/mixer.cpp index ed176b6f63d765780d6a90c2e049547f012503b6..2907fa09f960bca74d5ed04c4735d9ceab62fb63 100644 --- a/src/lib/mixer/mixer.cpp +++ b/src/lib/mixer/mixer.cpp @@ -39,6 +39,7 @@ #include "mixer.h" +#include <math.h> #include <cstring> #include <ctype.h> diff --git a/src/lib/mixer/mixer.h b/src/lib/mixer/mixer.h index fcf065a11a36633510d962df2ed74b1c50c89b6d..011db6b98d3716d1a043fa6fabdac7955bc75d66 100644 --- a/src/lib/mixer/mixer.h +++ b/src/lib/mixer/mixer.h @@ -125,19 +125,41 @@ */ -#ifndef _SYSTEMLIB_MIXER_MIXER_H -#define _SYSTEMLIB_MIXER_MIXER_H value +#pragma once -#include <px4_config.h> -#include "drivers/drv_mixer.h" +#include <stdint.h> + +/** simple channel scaler */ +struct mixer_scaler_s { + float negative_scale; + float positive_scale; + float offset; + float min_output; + float max_output; +}; + +/** mixer input */ +struct mixer_control_s { + uint8_t control_group; /**< group from which the input reads */ + uint8_t control_index; /**< index within the control group */ + struct mixer_scaler_s scaler; /**< scaling applied to the input before use */ +}; + +/** simple mixer */ +struct mixer_simple_s { + uint8_t control_count; /**< number of inputs */ + struct mixer_scaler_s output_scaler; /**< scaling for the output */ + struct mixer_control_s controls[0]; /**< actual size of the array is set by control_count */ +}; + +#define MIXER_SIMPLE_SIZE(_icount) (sizeof(struct mixer_simple_s) + (_icount) * sizeof(struct mixer_control_s)) -#include "mixer_load.h" /** * Abstract class defining a mixer mixing zero or more inputs to * one or more outputs. */ -class __EXPORT Mixer +class Mixer { public: enum class Airmode : int32_t { @@ -304,7 +326,7 @@ private: * Group of mixers, built up from single mixers and processed * in order when mixing. */ -class __EXPORT MixerGroup : public Mixer +class MixerGroup : public Mixer { public: MixerGroup(ControlCallback control_cb, uintptr_t cb_handle); @@ -440,7 +462,7 @@ private: * * Used as a placeholder for output channels that are unassigned in groups. */ -class __EXPORT NullMixer : public Mixer +class NullMixer : public Mixer { public: NullMixer(); @@ -481,7 +503,7 @@ public: * * Collects zero or more inputs and mixes them to a single output. */ -class __EXPORT SimpleMixer : public Mixer +class SimpleMixer : public Mixer { public: /** @@ -582,7 +604,7 @@ enum class MultirotorGeometry : MultirotorGeometryUnderlyingType; * Collects four inputs (roll, pitch, yaw, thrust) and mixes them to * a set of outputs based on the configured geometry. */ -class __EXPORT MultirotorMixer : public Mixer +class MultirotorMixer : public Mixer { public: /** @@ -813,7 +835,7 @@ struct mixer_heli_s { * Collects four inputs (roll, pitch, yaw, thrust) and mixes them to servo commands * for swash plate tilting and throttle- and pitch curves. */ -class __EXPORT HelicopterMixer : public Mixer +class HelicopterMixer : public Mixer { public: /** @@ -870,5 +892,3 @@ private: HelicopterMixer(const HelicopterMixer &); HelicopterMixer operator=(const HelicopterMixer &); }; - -#endif diff --git a/src/lib/mixer/mixer_helicopter.cpp b/src/lib/mixer/mixer_helicopter.cpp index df192b8b15491ebb66e2ce9c8a64017a7e43609e..87441ee7bcf096e712fcb07f4f03cf8f705f5816 100644 --- a/src/lib/mixer/mixer_helicopter.cpp +++ b/src/lib/mixer/mixer_helicopter.cpp @@ -40,6 +40,8 @@ #include "mixer.h" #include <mathlib/mathlib.h> +#include <cstdio> +#include <px4_defines.h> #define debug(fmt, args...) do { } while(0) //#define debug(fmt, args...) do { printf("[mixer] " fmt "\n", ##args); } while(0) diff --git a/src/lib/mixer/mixer_multirotor.cpp b/src/lib/mixer/mixer_multirotor.cpp index bd749fdf523b709ceb7189356525a850c6d8a601..069bda4e6b260719d86dbfd6a56865623297ce92 100644 --- a/src/lib/mixer/mixer_multirotor.cpp +++ b/src/lib/mixer/mixer_multirotor.cpp @@ -41,6 +41,7 @@ #include <cfloat> #include <cstring> +#include <cstdio> #include <mathlib/mathlib.h> diff --git a/src/lib/mixer/mixer_simple.cpp b/src/lib/mixer/mixer_simple.cpp index 94cc725713c9f8665a6776dad12eaaf9b40856ba..12a958d7797a84f8b31b2553da0b3961a0363652 100644 --- a/src/lib/mixer/mixer_simple.cpp +++ b/src/lib/mixer/mixer_simple.cpp @@ -38,6 +38,7 @@ */ #include "mixer.h" +#include <stdio.h> #define debug(fmt, args...) do { } while(0) //#define debug(fmt, args...) do { printf("[mixer] " fmt "\n", ##args); } while(0) diff --git a/src/lib/terrain_estimation/terrain_estimator.cpp b/src/lib/terrain_estimation/terrain_estimator.cpp index f007257ebf34073949e2c97835776ee40a662c2c..ed1f46bde5d471d80b764c5576e35ce662526c65 100644 --- a/src/lib/terrain_estimation/terrain_estimator.cpp +++ b/src/lib/terrain_estimation/terrain_estimator.cpp @@ -38,6 +38,7 @@ #include "terrain_estimator.h" #include <lib/ecl/geo/geo.h> +#include <px4_defines.h> #define DISTANCE_TIMEOUT 100000 // time in usec after which laser is considered dead diff --git a/src/modules/mc_pos_control/PositionControl.cpp b/src/modules/mc_pos_control/PositionControl.cpp index d31dd0f3f6bce96905d4b8a0f7f589e194bc902d..bbb99468eb23e07d2d809512efaff96d6ce2cde7 100644 --- a/src/modules/mc_pos_control/PositionControl.cpp +++ b/src/modules/mc_pos_control/PositionControl.cpp @@ -39,6 +39,7 @@ #include <float.h> #include <mathlib/mathlib.h> #include "Utility/ControlMath.hpp" +#include <px4_defines.h> using namespace matrix; diff --git a/src/platforms/posix/drivers/df_bebop_bus_wrapper/df_bebop_bus_wrapper.cpp b/src/platforms/posix/drivers/df_bebop_bus_wrapper/df_bebop_bus_wrapper.cpp index a528552d215074109874a7bec66f7ba34d72f537..4daac7de244220e1fa7e822b136da7c1b90add94 100644 --- a/src/platforms/posix/drivers/df_bebop_bus_wrapper/df_bebop_bus_wrapper.cpp +++ b/src/platforms/posix/drivers/df_bebop_bus_wrapper/df_bebop_bus_wrapper.cpp @@ -54,6 +54,7 @@ #include <uORB/topics/esc_status.h> #include <lib/mixer/mixer.h> +#include <lib/mixer/mixer_load.h> #include <battery/battery.h> #include <bebop_bus/BebopBus.hpp> diff --git a/src/systemcmds/mixer/mixer.cpp b/src/systemcmds/mixer/mixer.cpp index 133a378b9f625973c0c787234090c20ce9e0f671..9bc520777f66e573ca8279ded865dff9b5fe946f 100644 --- a/src/systemcmds/mixer/mixer.cpp +++ b/src/systemcmds/mixer/mixer.cpp @@ -32,7 +32,7 @@ ****************************************************************************/ /** - * @file mixer.c + * @file mixer.cpp * * Mixer utility. */ @@ -48,7 +48,9 @@ #include <errno.h> #include <ctype.h> +#include <drivers/drv_mixer.h> #include <lib/mixer/mixer.h> +#include <lib/mixer/mixer_load.h> #include <uORB/topics/actuator_controls.h> /** diff --git a/src/systemcmds/tests/test_mixer.cpp b/src/systemcmds/tests/test_mixer.cpp index eb7acd6f880cd20db6d4b2cbf5363ea30c1190a4..b06b2d62d225a30f4d850e8640ccb1bc877b4e3f 100644 --- a/src/systemcmds/tests/test_mixer.cpp +++ b/src/systemcmds/tests/test_mixer.cpp @@ -44,6 +44,7 @@ #include <px4_config.h> #include <mixer/mixer.h> +#include <mixer/mixer_load.h> #include <pwm_limit/pwm_limit.h> #include <drivers/drv_hrt.h> #include <drivers/drv_pwm_output.h>