Commit Graph

258 Commits

Author SHA1 Message Date
Carlo Wood baf89f4398 Clean up of px4_defines.h (remove math.h)
This patch reorders px4_defines.h to make it more readable (I think)
but more importantly, cleans up the #include <math.h>/<cmath>
and [std::]isfinite stuff.

My main goal was to completely get rid of including math.h/cmath,
because that doesn't really belong in a header that is supposed to
define macro's and is included in almost every source file (if not
all).

I'm not sure what it did before ;) (pun intended), but now it does
the following:

PX4_ISFINITE is only used in C++ code (that was already the case,
but hereby is official; for C code just use 'isfinite()') and is
defined to be std::isfinite, except on __PX4_QURT because that uses
the HEXAGON toolset which (erroneously) defines isfinite as macro.

I would have liked to remove PX4_ISFINITE completely from the code
and just use std::isfinite whereever that is needed, but that would
have required changing the libecl submodule, and at the moment I'm
getting tired of changing submodules... so maybe something for the
future.

Also, all includes of <math.h> or <cmath> have been removed except
for __PX4_NUTTX. Like the HEXAGON toolset NuttX currently defines
isfinite as macro for C++. So, we could have solved this in the
same was as __P4_QURT; but since we can fix NuttX ourselves I chose
to add a kludge to px4_defines.h instead that fixes this problem,
until the time that NuttX can be fixed (again postponing changing
a submodule). The kludge still demands including <cmath>, thus.

After removal of the math header file, it needed to be included
in source files that actually need it, of course.

Finally, I had a look at the math macro's (like M_PI, M_PI_F,
M_DEG_TO_RAD etc). These are sometimes (erroneously) defined in
certain math.h header files (like both, hexagon and nuttx).
This is incorrect: neither the C nor the C++ standard defines
math constants (neither as macro nor otherwise). The "problem"
here was that px4_defines.h defined some of the M_*_F float
constants in terms of the M_* double constant, which are
sometimes not defined either thus. So, I cleaned this up by
defining the M_*_F math constants as float literals in px4_defines.h,
except when they are defined in math.h for that platform.
This means that math.h has to be always included when using those
constants, but well; not much difference there as those files
usually also need/use the macro NAN (which *is* a standard macro
defined by math.h).

Finally finally, DEFAULT_PARAM_FILE was removed as it isn't
used anymore.

All in all I think the resulting px4_defines.h is nice, giving me
much less the feeling of a nearly unmaintainable and over time
slowly growing collection of kludges and hacks.
2016-10-28 08:41:30 +02:00
Roman a978d61d9a attitude message cleanup: more cleanup
Signed-off-by: Roman <bapstroman@gmail.com>
2016-10-18 20:46:08 +02:00
Roman 3faaeb06d1 attitude setpoint topic: cleanup of matrix class usage
Signed-off-by: Roman <bapstroman@gmail.com>
2016-10-18 20:46:08 +02:00
Lorenz Meier 526fb8f515 Remove q_valid flag from attitude topic 2016-10-18 20:46:08 +02:00
Roman b8a219d351 removed comments and fixed some euler bugs 2016-10-18 20:46:08 +02:00
tumbili 5e0e522903 adapted to new vehicle attitude message 2016-10-18 20:46:08 +02:00
Julian Oes 8ff237c69f Remove size optimization for individual modules
It makes more sense to set the optimization flags on a platform basis
instead of individually for each module. This allows for different
optimization options for SITL, NuttX, Snapdragon, etc.
2016-09-30 08:11:51 +02:00
Daniel Agar cff9e90bec position_estimator_inav fix and enforce code style 2016-08-07 10:40:17 +02:00
Lorenz Meier 7601788c43 INAV: clean up vision timestamps 2016-07-10 12:44:00 +02:00
Beat Küng 9c73eae941 sensor_combined: replace accel & gyro integral with value, use float for dt
Reason: the value is easier to read & handle (for example plotting). In
most places the value is needed, not the integral.

Note that this breaks the replay format for sdlog2 replay
2016-07-07 11:35:50 +02:00
Beat Küng 8e136779ec stack sizes: reduce stack sizes for modules that use sensor_combined
The sensor_combined topic got reduced from ~780 bytes to 72 bytes.
2016-07-07 11:35:50 +02:00
Beat Küng c5ea4b43be sensor_combined.msg: make timestamps relative
This is needed for the new logger & saves some space as well.
2016-07-07 11:35:50 +02:00
Beat Küng d846ad5dac sensors: move voting into sensors module
- voting is now at a central place instead of duplicated within the
  estimators
  -> this also means that estimators that did not do voting so far,
     now have voting, like ekf2
- estimators requiring more than that can still subscribe to the raw
  sensors
- allows sensors_combined to be 3 times smaller
  - reduces logger, memcpy (cache) & RAM overhead
- all modules requiring only 1 or 2 sensor values now automatically get
  the voted result
- this also adds voting to baro
2016-07-07 11:35:50 +02:00
Beat Küng b4ecc5a8d9 sensor_combined cleanup: remove many unneeded fields
Decreases the message size from 780 to 280 bytes.
In particular, all modules using sensor_combined must use the integral now.
The sensor value can easily be reconstructed by dividing with dt.

Voters now need to be moved into sensors module, because error count and
priority is removed from the topic.

Any module that requires additional data from a sensor can subscribe to
the raw sensor topics.

At two places, values are set to zero instead of subscribing to the raw
sensors (with the assumption that no one reads them):
- mavlink mavlink_highres_imu_t::abs_pressure
- sdlog2: sensor temperatures
2016-07-07 11:35:50 +02:00
Beat Küng b28bfce186 position_estimator_inav: fix compiler issue for GCC 6.1.1 (#4923)
GCC output:
implicit conversion from ‘float’ to ‘double’ to match other operand of
binary expression [-Werror=double-promotion]

It seems gcc 6.1.1 uses the float variant of fabs, whereas older gcc's
use the double version. This makes it compile for both.
2016-06-28 09:25:36 +02:00
Beat Küng e2a7145379 vehicle_gps_position: remove timestamp_variance & timestamp_velocity (they're not used) 2016-06-24 00:22:01 +02:00
Beat Küng 89f5bd27e8 vehicle_gps_position: use timestamp field instead of timestamp_position
timestamp was unused. This allows to remove timestamp_position.
2016-06-24 00:22:01 +02:00
Lorenz Meier fe69be05ca INAV: Move to -Os 2016-05-29 15:54:04 +02:00
Daniel Agar 76387b1693 uorb autogeneration 2016-05-14 11:27:07 +02:00
Daniel Agar e08e8fa24f position_estimator_inav_params.cpp param metadata 2016-05-13 21:03:40 -04:00
Beat Küng 27d821ac9f fix position_estimator_inav_main: put terrain_estimator on the stack
This fixes a memory leak
2016-05-03 17:34:42 +02:00
James Goppert f73af95b38 Added SYS_MC_EST_GROUP to allow fine grained algorithm selection. 2016-04-14 15:22:25 -04:00
James Goppert 967e4dd127 Modified cmake to use STACK_MAX and STACK_MAIN 2016-04-14 13:36:36 -04:00
Daniel Agar 70a68def83 params correct boolean tag 2016-03-25 20:25:17 -04:00
Julian Oes bba0d0384d drivers/modules: changes after mavlink_log change
The mavlink_log API changes lead to changes in all drivers/modules using
it.
2016-03-24 13:10:02 +01:00
Daniel Agar 7a9427bc34 param remove empty @unit 2016-03-14 09:12:34 +01:00
Daniel Agar c10dbfed7b position_estimator_inav param @unit 2016-03-14 09:12:34 +01:00
Daniel Agar cfac0b0640 position_estimator_inav param @unit 2016-03-14 09:12:34 +01:00
Mark Charlebois 9f3bf8e9f4 Rebase changes on upstream master
This brings in many of the changes from the PX4 fork on ATLFLight.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
2016-02-19 16:59:41 +01:00
Julian Oes 1bbfb02430 position_estimator_inav: fix function declaration 2016-02-18 18:53:00 +01:00
ChristophTobler 19bc39e7ad added a offset parameter for lidar in inav 2016-02-10 09:24:39 +01:00
ChristophTobler 0a76347c9d Changed min/max distance with distance topic params. Added a check for mocap: mocap estimation requires heading from mocap 2016-02-10 09:24:39 +01:00
ChristophTobler c7640723c9 change std::fabs to fabs and rate_threshold to double 2016-02-10 09:24:39 +01:00
ChristophTobler c7ff253a6d change abs to std::fabs 2016-02-10 09:24:39 +01:00
ChristophTobler e7cdb19424 gyro threshold for optical flow and lidar min/max parameter 2016-02-10 09:24:39 +01:00
ChristophTobler a78d732957 change lidar altitude correction threshold 2016-02-10 09:24:39 +01:00
ChristophTobler e2c04b7fa7 replaced lidar min/max distances with parameters 2016-02-10 09:24:39 +01:00
ChristophTobler 1a6c4e123c formatting 2016-02-10 09:24:39 +01:00
ChristophTobler f822b136dc change optical flow weight and scale 2016-02-10 09:24:39 +01:00
ChristophTobler 82be3d09d6 added optical flow scale and removed blanks 2016-02-10 09:24:39 +01:00
ChristophTobler f32021f856 remove lidar filter value from qgc params 2016-02-10 09:24:39 +01:00
ChristophTobler 23f428d639 removed lowpass for lidar correction 2016-02-10 09:24:39 +01:00
ChristophTobler 42131e817d changed value for lidar filter 2016-02-10 09:24:39 +01:00
ChristophTobler b54bc23550 fix in flow yaw compensation 2016-02-10 09:24:39 +01:00
ChristophTobler 6650bca35b decoupled lidar from flow and used it for altitude estimation. qgc params added to enable it. 2016-02-10 09:24:39 +01:00
Andreas Antener 3d971e214a don't update local position reference if home position changes 2015-12-31 13:24:12 +01:00
Andreas Antener bdce1a902f update missin param in inav 2015-12-17 18:25:23 +01:00
Lorenz Meier 4a1dd4f047 Merge pull request #3234 from UAVenture/altitude_message
WIP: Altitude message
2015-12-06 14:10:31 +01:00
Lorenz Meier e1a5efb9a5 INAV: Be less chatty 2015-12-03 13:49:35 +01:00
Lorenz Meier f0a4979da6 Merged master into driver_framework 2015-12-01 12:34:02 +01:00