Commit Graph

22403 Commits

Author SHA1 Message Date
Tom Pittenger 034cd2413e Plane: re-calc landing glide slope to gracefully handle baro offset during long flights
New param: LAND_SLOPE_RCALC
@Description: This parameter is used when using a rangefinder during landing for altitude correction from baro drift (RNGFND_LANDING=1) and the altitude correction indicates your altitude is lower than the intended slope path. This value is the threshold of the correction to re-calculate the landing approach slope. Set to zero to keep the original slope all the way down and any detected baro drift will be corrected by pitching/throttling up to snap back to resume the original slope path. Otherwise, when a rangefinder altitude correction exceeds this threshold it will trigger a slope re-calculate to give a shallower slope. This also smoothes out the approach when flying over objects such as trees. Recommend a value of 2m.

default value is 2 (so, enabled by default)
2016-05-17 15:39:04 -07:00
Tom Pittenger 4a6dd5a781 Plane: reset baro drift when setting home while disarmed 2016-05-17 15:32:42 -07:00
Gustavo Jose de Sousa 472dae3ed9 waf: don't use hard-coded path for environment cache path
The path for the "non-board" environment cache file was hard-coded, which was
causing the error below when the build was configured with the --out option
value different from the default path.

Traceback (most recent call last):
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Scripting.py", line 161, in waf_entry_point
    run_commands()
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Scripting.py", line 263, in run_commands
    ctx = run_command(cmd_name)
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Scripting.py", line 247, in run_command
    ctx.execute()
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Scripting.py", line 598, in execute
    return execute_method(self)
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Build.py", line 250, in execute
    self.execute_build()
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Build.py", line 263, in execute_build
    self.recurse([self.run_dir])
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Context.py", line 304, in recurse
    user_function(self)
  File "/home/gjsousa/ardupilot/wscript", line 246, in build
    config_header = Utils.h_file(bld.bldnode.make_node('ap_config.h').abspath())
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Utils.py", line 208, in h_file
    f = open(fname, 'rb')
IOError: [Errno 2] No such file or directory: '/tmp/build/ap_config.h'
2016-05-17 15:48:55 -03:00
Glody Guo cda21a3d78 Fix argument 'valgrind' issue about fly.CopterAVC test
Commit 8774f15 causes fly.CopterAVC test failure.
Here is the failure info below:
>>>> FAILED STEP: fly.CopterAVC at Tue May 17 13:21:56 2016 (fly_CopterAVC() got an unexpected keyword argument 'valgrind')
Traceback (most recent call last):
  File "./Tools/autotest/autotest.py", line 406, in run_tests
    if not run_step(step):
  File "./Tools/autotest/autotest.py", line 232, in run_step
    return arducopter.fly_CopterAVC(viewerip=opts.viewerip, map=opts.map, valgrind=opts.valgrind)
TypeError: fly_CopterAVC() got an unexpected keyword argument 'valgrind'
('check step: ', 'fly.CopterAVC')
FAILED 1 tests: ['fly.CopterAVC']

Here is the commit info below:
commit 8774f15b9a
Author: Peter Barker <pbarker@barker.dropbear.id.au>
Date:   Mon Apr 11 18:05:39 2016 +1000

    Tools: add valgrind option to autotest.py

:040000 040000 a111bc5b18 609503f3b1 M      Tools
2016-05-17 21:36:57 +10:00
Andrew Tridgell 7b47d54d6b AP_Common: workaround for SITL on windows 2016-05-17 20:55:57 +10:00
Andrew Tridgell e3b2e90a27 Plane: cleanup unnecessarily complex gcs[] usage 2016-05-17 08:27:39 +10:00
Andrew Tridgell e4948544e7 Copter: cleanup unnecessarily complex gcs[] usage 2016-05-17 08:27:35 +10:00
Andrew Tridgell 7957f25f32 Rover: cleanup unnecessarily complex gcs[] usage 2016-05-17 08:27:28 +10:00
Andrew Tridgell 23197b0689 AntennaTracker: cleanup unnecessarily complex gcs[] usage 2016-05-17 08:27:01 +10:00
Lucas De Marchi fa6f2c6b67 AP_Math: fix some coding style mistakes
- fix alignement of &
    - remove const from bool arguments
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa 0c31354539 AP_Compass: implement completion mask
Fill the completion mask and send that through MAVLink while calibrating the
compass.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa 390b196eda AP_Math: AP_GeodesicGrid: add notice for auto generated code 2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa b3068baa11 AP_Math: add geodesic_grid toolset
That was used to aid development AP_GeodesicGrid and understanding its
concepts.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa 9d34b3b996 AP_Math: AP_GeodesicGrid: make all methods static
Since all members are.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa 3b05ec1157 AP_Math: make vectors and matrix constructors constexpr
That allows some object to be constructed at compile time.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa 77223a7fcb AP_Math: AP_GeodesicGrid: make data static
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.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa fd2428db34 AP_Math: AP_GeodesicGrid: reduce number of _neighbor_umbrellas items
Only the first half is necessary. The values for the other half can be derived.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa 43d9e00ab7 AP_Math: AP_GeodesicGrid: use uint8_t for _neighbor_umbrellas
All integers there are limited to the range [0,20), so uint8_t is enough.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa 54889e4175 AP_Math: AP_GeodesicGrid: reduce number of inverses by half
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.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa f31161ecb6 AP_Math: AP_GeodesicGrid: remove triangles
There's no need to keep those triangles, since we just need the inverses.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa b34c04a4f9 AP_Math: test_geodesic_grid: test also non-centroid vectors 2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa 8e8ab3af96 AP_Math: AP_GeodesicGrid: remove section_triangle() function
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.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa c7eb46fae2 AP_Math: AP_GeodesicGrid: optimize _from_neighbor_umbrella()
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
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa eb90ef23a1 AP_Math: AP_GeodesicGrid: fix algorithm for null vector
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.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa c28c3265c8 AP_Math: AP_GeodesicGrid: optimize with neighbor umbrellas
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%.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa 0ff05b7af3 AP_Math: test_geodesic_grid: test triangles indexes
That helps figuring out which intermediate step failed the high level call.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa 4398e1e49b AP_Math: AP_GeodesicGrid: change order of triangles
- 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.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa ea412ad629 AP_Math: benchmark_geodesic_grid: add benchmark
That will help to benchmark improvements on the section search algorithm.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa 797a2da031 AP_Math: test_geodesic_grid: test when inclusive=true 2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa b299261ad4 AP_Math: AP_GeodesicGrid: add first implementation
The search for the geodesic section is still naive in this version.
Additionally, add unit tests.
2016-05-16 19:08:35 -03:00
Gustavo Jose de Sousa 3f2ad764ca AP_Math: Matrix3: add inverse() and invert() functions
Additionally, add unit tests.
2016-05-16 19:08:35 -03:00
Gustavo Jose de Sousa 06eea2838f AP_Math: Matrix3: add det() function
Function to calculate determinant. Additionally, add unit tests.
2016-05-16 19:08:35 -03:00
Gustavo Jose de Sousa fe4aaaac95 tests: add macro for printing test parameter
Google Test allows to instantiate tests for a list of different values, which
are called parameters. A common use of that feature in Ardupilot will be that a
parameter will be represented by an object that will have the value to be
tested and information about that value. That information will basically map
the expected behavior of tests on the value stored by the parameter.

The macro added in this patch allows to easily print the value of a failed
test's parameter.
2016-05-16 19:08:35 -03:00
Gustavo Jose de Sousa 26959f1448 AP_Math: define golden ratio constant 2016-05-16 19:08:35 -03:00
dgrat 48c243bed0 ArduPlane: Do not use is_zero() for non-float types 2016-05-16 19:08:35 -03:00
dgrat 3bc97ae356 ArduCopter: Do not use is_zero() for non-float types
This function makes only sense for floating point types. However this
function was also used for ints.
2016-05-16 19:08:35 -03:00
dgrat f8540f1a80 AP_Compass: Do not use is_zero() for non-float types 2016-05-16 19:08:35 -03:00
dgrat 7ff8004f8f AP_Math: Replace is_zero() with a template function
This function only makes sense for floating point types. However this
function was also used for ints.
2016-05-16 19:08:35 -03:00
Tom Pittenger ebd993dabb AP_Arming: updated z-axis accel threshold comment 2016-05-16 13:46:17 -07:00
Lucas De Marchi 368a72044c APMrover2: fix indentation leading to compiler warning
GCC 6 has a new warning about misleading indentation:

../../APMrover2/system.cpp: In member function ‘void Rover::set_mode(mode)’:
../../APMrover2/system.cpp:272:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
     if (control_mode == AUTO)
     ^~
../../APMrover2/system.cpp:275:2: note: ...this statement, but the^Bn latter is misleadingly indented as if it is guarded by the ‘if’
  control_mode = mode;
  ^~~~~~~~~~~~

The issue here is that we are mixing tabs and spaces. Remove tabs and re-indent
the code.
2016-05-16 17:35:58 -03:00
Tom Pittenger 7af888633d Plane: 3of3 add loiter_xtrack option flag for post-loiter navigation
0 to crosstrack from center of waypoint, 1 to crosstrack from tangent exit location
2016-05-16 11:50:54 -07:00
Tom Pittenger 9073ac91ff AP_Mission: 2of3 add loiter_xtrack option flag for post-loiter navigation via param4
0 to crosstrack from center of waypoint, 1 to crosstrack from tangent exit location
2016-05-16 11:50:54 -07:00
Tom Pittenger 02eeb2d4f0 AP_Common: 1of3 add loiter_xtrack option flag for post-loiter navigation
0 to crosstrack from center of waypoint, 1 to crosstrack from tangent exit location
2016-05-16 11:50:53 -07:00
Gustavo Jose de Sousa 2246343ec7 AP_HAL_SITL: pass signed value to abs()
Passing an unsigned value to abs() causes compilation error in gcc 6.1.1
(and doing that doesn't make sense too).

As a bonus, this patch fixes the code, since, for two unsigned integers
a and b, such that a > b, (a - b) without the casting to a signed
integer would produce garbage in the context of this patch. The type
int32_t is enough for the cases covered by this patch.
2016-05-16 15:04:22 -03:00
Lucas De Marchi 421b9ef54a AP_Mount do not use flexible array in union
We actually don't want a flexible array in this union, but rather a way
to access it byte by byte. This fixes the build for gcc >= 6

In file included from ../../libraries/AP_GPS/AP_GPS_UBLOX.cpp:23:0:
../../libraries/AP_GPS/AP_GPS_UBLOX.h:387:23: error: flexible array member in union
         uint8_t bytes[];
                       ^
compilation terminated due to -Wfatal-errors.

In file included from ../../libraries/AP_Mount/AP_Mount.cpp:9:0:
../../libraries/AP_Mount/AP_Mount_Alexmos.h:291:23: error: flexible array member in union
         uint8_t bytes[];
                       ^
compilation terminated due to -Wfatal-errors.
2016-05-16 13:50:56 -03:00
Lucas De Marchi 39bd196481 AP_GPS: do not use flexible array in union
We actually don't want a flexible array in this union, but rather a way
to access it byte by byte. This fixes the build for gcc >= 6

In file included from ../../libraries/AP_GPS/AP_GPS.cpp:24:0:
../../libraries/AP_GPS/AP_GPS_ERB.h:93:23: error: flexible array member in union
         uint8_t bytes[];
                       ^
compilation terminated due to -Wfatal-errors.

In file included from ../../libraries/AP_GPS/AP_GPS_ERB.cpp:22:0:
../../libraries/AP_GPS/AP_GPS_ERB.h:93:23: error: flexible array member in union
         uint8_t bytes[];
                       ^
compilation terminated due to -Wfatal-errors.

In file included from ../../libraries/AP_GPS/AP_GPS_MTK.cpp:25:0:
../../libraries/AP_GPS/AP_GPS_MTK.h:75:23: error: flexible array member in union
         uint8_t bytes[];
                       ^
compilation terminated due to -Wfatal-errors.

In file included from ../../libraries/AP_GPS/AP_GPS_MTK19.cpp:26:0:
../../libraries/AP_GPS/AP_GPS_MTK.h:75:23: error: flexible array member in union
         uint8_t bytes[];
                       ^
compilation terminated due to -Wfatal-errors.

In file included from ../../libraries/AP_GPS/AP_GPS_SIRF.cpp:22:0:
../../libraries/AP_GPS/AP_GPS_SIRF.h:101:23: error: flexible array member in union
         uint8_t bytes[];
                       ^
compilation terminated due to -Wfatal-errors.

In file included from ../../libraries/AP_GPS/AP_GPS_UBLOX.cpp:23:0:
../../libraries/AP_GPS/AP_GPS_UBLOX.h:387:23: error: flexible array member in union
         uint8_t bytes[];
                       ^
compilation terminated due to -Wfatal-errors.
2016-05-16 13:50:39 -03:00
Gustavo Jose de Sousa d615628367 AP_HAL_Linux: I2CDevice: add missing stdio.h include
This was probably being included by another header, but it's not on
gcc >= 6.1 and glibc 2.23.
2016-05-16 13:12:53 -03:00
Peter Barker 8d5ceda534 AP_HAL_SITL: ensure specified SITL model is found
Without this check we get a null pointer exception the first time we attempt
to use the model object
2016-05-16 13:04:15 -03:00
Peter Barker 27e7c870ed Tools: remove absolute paths in run_in_terminal_window
Also add quotes to avoid ambiguous redirect issue
2016-05-16 19:39:37 +10:00
Andrew Tridgell 4116f80901 Replay: added --no-params option 2016-05-16 17:22:11 +10:00