/home/pbarker/rc/ardupilot/libraries/DataFlash/LogFile.cpp:361:25:
error: non-constant-expression cannot be narrowed from type 'enum
Rotation' to 'uint8_t' (aka 'unsigned char') in initializer list
[-Wc++11-narrowing]
orient1 : s0 ? s0->orientation() : ROTATION_NONE,
libraries/AP_Math/tests/test_math.cpp.3.o: In function `MathTest_IsEqual_Test::TestBody()':
test_math.cpp:(.text._ZN21MathTest_IsEqual_Test8TestBodyEv+0x1a0): undefined reference to `std::enable_if<std::is_floating_point<std::common_type<float, double>::type>::value, bool>::type is_equal<float, double>(float, double)'
collect2: error: ld returned 1 exit status
Return type is T which can be an integral type, float or double. By
dividing by 2 we avoid float operation on the first case and do the
right thing on the second and third.
Return type is float, so operate on float types everywhere.
Fixes this warning while building for PX4:
../../libraries/AP_Math/AP_Math.cpp: In instantiation of 'float safe_asin(T) [with T = double]':
../../libraries/AP_Math/AP_Math.cpp:56:48: required from here
../../libraries/AP_Math/AP_Math.cpp:44:11: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
if (v >= 1.0f) {
^
../../libraries/AP_Math/AP_Math.cpp:47:11: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
if (v <= -1.0f) {
^
We are calling fabsf(), which returns a float. We should use the epsilon
from float type, not from the argument type passed to fabsf().
On the other hand when the double version is instantiated we do want to
use the std::numeric_limits<double>::epsilon() value.
This adds a branch to the function, but it's removed when the function
is intantiated by the compiler since the type is known at compile-time.
Fixes this warning when building for PX4:
../../libraries/AP_Math/AP_Math.cpp: In instantiation of 'typename std::enable_if<std::is_floating_point<typename std::common_type<_Tp, _Up>::type>::value, bool>::type is_equal(Arithmetic1, Arithmetic2) [with Arithmetic1 = double; Arithmetic2 = double; typename std::enable_if<std::is_floating_point<typename std::common_type<_Tp, _Up>::type>::value, bool>::type = bool]':
../../libraries/AP_Math/AP_Math.cpp:23:66: required from here
../../libraries/AP_Math/AP_Math.cpp:17:29: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
return fabsf(v_1 - v_2) < std::numeric_limits<decltype(v_1 - v_2)>::epsilon();
^
RC_Channel: To nullptr from NULL.
AC_Fence: To nullptr from NULL.
AC_Avoidance: To nullptr from NULL.
AC_PrecLand: To nullptr from NULL.
DataFlash: To nullptr from NULL.
SITL: To nullptr from NULL.
GCS_MAVLink: To nullptr from NULL.
DataFlash: To nullptr from NULL.
AP_Compass: To nullptr from NULL.
Global: To nullptr from NULL.
Global: To nullptr from NULL.
We currently check examples are buildable with waf which doesn't need
the libraries to be specified in a make.inc file. Having the makefiles
there is misleading since people try to build and realize the build is
broken.
That gives the change of storing that data in flash storage in some
architectures. That doesn't happen yet though, some extra changes are required
for that to happen.
We don't actually need all of them, since the second half is for the opposite
triangles. In that case we just need to negate the resulting vector when
changing basis.
That function was only being used by the unit tests and the benchmark. In order
to remove memory usage, the triangles will be removed, since we don't actually
need to keep them in real situations. Thus, this patch removes that function
and copy those triangles to the test and benchmark.
This is the second optimization. With that we don't have to iterate over the
umbrella's components.
The table below summarizes the mean CPU time in ns from the brenchmark results
on an Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz processor:
| Naive implementation | First Optimization | Second Optimization
------------------------------------------------------------------------
Min. | 26.0 | 28.00 | 26.0
1st Qu.| 78.0 | 48.75 | 39.0
Median | 132.0 | 57.00 | 41.0
Mean | 130.1 | 61.20 | 41.6
3rd Qu.| 182.2 | 76.00 | 47.0
Max. | 234.0 | 98.00 | 54.0
If v is the null vector, then alpha * v is still the null vector for any alpha
as a real number. That means that the null vector doesn't cross any section.
This is a first optimization of the algorithm. The struct for the neighbor
umbrella has only one member, but new members will be added in the next
optimization.
The table below summarizes the mean CPU time in ns from the brenchmark results
on an Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz processor:
Cases | Naive implementation | First Optimization
--------------------------------------------------
Min. | 26.0 | 28.00
1st Qu.| 78.0 | 48.75
Median | 132.0 | 57.00
Mean | 130.1 | 61.20
3rd Qu.| 182.2 | 76.00
Max. | 234.0 | 98.00
This optimization reduces the mean time for the worst case (Max. line) by more
than 50%.
- Change the order of the icosahedron triangles so that there's a uniform way of
finding the opposite triangle. The order visually still makes sense.
- Change test to accommodate the order change.
Avoid warnings like:
[2130/2168] Compiling libraries/AP_Math/tests/test_math.cpp
../../libraries/AP_Math/tests/test_math.cpp: In member function ‘virtual void MathTest_IsZero_Test::TestBody()’:
../../libraries/AP_Math/tests/test_math.cpp:73:196: warning: converting ‘false’ to pointer type for argument 1 of ‘char
testing::internal::IsNullLiteralHelper(testing::internal::Secret*)’ [-Wconversion-null]
../../libraries/AP_Math/tests/test_math.cpp:74:199: warning: converting ‘false’ to pointer type for argument 1 of ‘char
testing::internal::IsNullLiteralHelper(testing::internal::Secret*)’ [-Wconversion-null]
Use EXPECT_TRUE() and EXPECT_FALSE() from gtest instead.
The new function can deal with a variable number of function parameters.
Additionally, I renamed the functions to norm(), because this is the
standard name used in several other projects.
When using wrap_180_cd() we are adding a small float (180 * 100) to a
possibly big number. This may lose float precision as illustrated by the
unit test failing:
OUT: ../../libraries/AP_Math/tests/test_math.cpp:195: Failure
OUT: Value of: wrap_180_cd(-3600000000.f)
OUT: Actual: -80
OUT: Expected: 0.f
OUT: Which is: 0
These functions (or variants thereof) now have unit tests:
- is_zero()
- is_equal()
- sq()
- pythagorous()
- constrain()
- wrap_180()
- wrap_360()
Some tests in wrap_180_cd are failing: -180 should be wrapped to 180,
not -180.