Commit Graph

11905 Commits

Author SHA1 Message Date
Lucas De Marchi de5025a46f AP_Airspeed: I2C: fix after conversion to I2CDevice
- Allow to fail init
2016-07-14 17:32:32 -03:00
Luiz Ywata 6c87b2aa7c AP_Airspeed: AP_Airspeed_I2C: use I2CDevice interface 2016-07-14 17:32:32 -03:00
Lucas De Marchi 5ef1568137 AP_HAL_Empty: fix sitl
Sitl or anyone using AP_HAL_Empty implementation doesn't have any
I2CDevice, so it's pointless to return an empty one.
2016-07-14 17:32:32 -03:00
Andrew Tridgell 7d48b25207 AP_Module: use ifdef in function, not caller
suggestion by Lucas
2016-07-14 13:39:48 +10:00
Andrew Tridgell eee9fc88a1 AP_InertialSensor: avoid ifdef for AP_MODULE_SUPPORTED 2016-07-14 13:39:47 +10:00
Andrew Tridgell e82468a529 AP_AHRS: avoid ifdef for AP_MODULE_SUPPORTED 2016-07-14 13:39:47 +10:00
Andrew Tridgell 5ce472ab8a AP_Module: changed hook prefix to ap_hook_ 2016-07-14 13:39:47 +10:00
Andrew Tridgell e8d8ca5eef AP_Module: updated example module 2016-07-14 13:39:47 +10:00
Andrew Tridgell 847bfda48a HAL_Linux: adjust include ordering 2016-07-14 13:39:47 +10:00
Andrew Tridgell dd5d0ffbad HAL_Linux: use default module directory 2016-07-14 13:39:47 +10:00
Andrew Tridgell f29323871f AP_Module: added default module directory 2016-07-14 13:39:47 +10:00
Andrew Tridgell 33ce1213a2 AP_InertialSensor: call gyro_sample and accel_sample AP_Module hooks 2016-07-14 13:39:47 +10:00
Andrew Tridgell 6b6a02e67e AP_Module: also allow export of raw gyro and accel samples
allows for oversampling in image correction
2016-07-14 13:39:46 +10:00
Andrew Tridgell 36181b78de AP_AHRS: fixed build for px4 2016-07-14 13:39:46 +10:00
Andrew Tridgell 7a2d67bde9 AP_Module: added AP_MODULE_SUPPORTED define 2016-07-14 13:39:46 +10:00
Andrew Tridgell 107f76828d HAL_Linux: added AP_Module support 2016-07-14 13:39:46 +10:00
Andrew Tridgell 15a01eefb1 AP_AHRS: added AHRS_update hook 2016-07-14 13:39:46 +10:00
Andrew Tridgell bd00beaf99 AP_Module: added external module hook library
this allows for external modules to be called at defined hook
locations in ArduPilot. The initial example is a module that consumes
the AHRS state, but this can be generalised to a wide variety of hooks
2016-07-14 13:39:46 +10:00
Andrew Tridgell f3f34be9c4 SITL: added comment on heli interlock 2016-07-12 20:50:22 +10:00
Jonathan Challinger 630e5378da AC_PosControl: add get_horizontal_error 2016-07-12 18:40:25 +09:00
Jonathan Challinger 8fe0c1b05b AC_PrecLand: don't run if not enabled 2016-07-12 18:40:25 +09:00
Jonathan Challinger e84d1581ab AC_PrecLand: use new irlock interface, refactor backend interface 2016-07-12 18:40:25 +09:00
Jonathan Challinger 6254608c45 AP_IRLock: refactor interface 2016-07-12 18:40:25 +09:00
Andrew Tridgell 4f17093add SITL: give a bit more pitch on tail in XPlane heli 2016-07-12 19:08:50 +10:00
Andrew Tridgell fdd20830d6 SITL: use flaps for collective on helis in X-Plane 10
works for more helis
2016-07-12 19:08:50 +10:00
Randy Mackay 6e224158f1 AP_GPS_MAV: use GPS_INPUT_IGNORE_FLAGS 2016-07-12 15:44:46 +09:00
Randy Mackay e34aa0bc72 AP_GPS_MAV: minor formatting fixes
No functional change
2016-07-12 15:44:19 +09:00
Allan Matthew 4249f7dbe6 AP_GPS: Add GPS_MAV type and accept GPS_INPUT message 2016-07-12 15:34:27 +09:00
Tom Pittenger 84ce499a0d AP_Baro: remove zero-init in constructor 2016-07-11 22:11:34 -07:00
Tom Pittenger 1d81df8144 Revert "AP_Baro: coverity scan - variables not initialized in constructor"
This reverts commit 8d2872d3ab.
2016-07-11 22:02:41 -07:00
Tom Pittenger 9fb4a928e5 Revert "AP_Airspeed: coverity scan - variables not initialized in constructor"
This reverts commit 93462d0fe3.
2016-07-11 22:02:22 -07:00
Tom Pittenger fc02908c0d Revert "GCS_MAVLink: coverity scan - variables not initialized in constructor"
This reverts commit bd8debdf8b.
2016-07-11 22:01:50 -07:00
Tom Pittenger 773372d2f3 Revert "AP_TECS: coverity scan - variables not initialized in constructor"
This reverts commit 753c0d47f0.
2016-07-11 22:01:26 -07:00
Tom Pittenger c38c3ae7fe Revert "AP_TECS: coverity scan: init variable struct"
This reverts commit 19713200e5.
2016-07-11 22:01:02 -07:00
Tom Pittenger be752164f4 Revert "AP_L1_Control: coverity scan - variables not initialized in constructor"
This reverts commit d558f32142.
2016-07-11 21:59:12 -07:00
Andrew Tridgell 871219d199 SITL: support helicopters with X-Plane 10
we get collective from "throttle2" and get interlock from generator1 on/off
2016-07-12 14:40:08 +10:00
priseborough 8793c75da0 AP_NavEKF2: clean up mag field learned logic 2016-07-11 00:44:33 +10:00
priseborough e6592186fc AP_NavEKF2: Tuning update
Slow down magnetic field learning
2016-07-10 08:21:18 +10:00
priseborough 10470b2dc1 AP_NavEKF2: fix bug in initialisation of declination co-variances
Co-variances were being re-zeroed after being set. This meant that the initial declination learning was sensitive to measurement errors which could result in poor initial yaw accuracy.
2016-07-10 08:21:18 +10:00
priseborough 6b04a81b8d AP_NavEKF2: Fix plane in-flight yaw reset bug
Fixes bugs that prevented planes being able to reset yaw to GPS to recovery from takeoff with a bad magnetoemter.

1) If the velocity innovation check had not failed by the time the in-air transition occurred, then the yaw reset would not be performed
2) The velocity states were not being reset
3) The non fly-forward vehicle (copter) reset could occur first and effectively lock out the fly-forward vehicle (plane) yaw check.
2016-07-10 08:21:18 +10:00
priseborough 51dbed2338 AP_NavEKF2: remember mag field states between flight on same power cycle
Remember the mag bias and earth field states learned during flight when the vehicle  lands.
This improves performance for vehicles that do multiple flight on one power cycle
2016-07-10 08:21:18 +10:00
priseborough 136df7cb5c AP_NavEKF2: reduce declination errors on start of 3-axis fusion
Reset co-variances for NE field states.
2016-07-10 08:21:18 +10:00
priseborough 744f19cd2d AP_NavEKF2: Improve scaling of output predictor I gain
Provide consistent overshoot of 5% across a wider range of time constants and prevent selection of larger time constants causing 'ringing' in the position and velocity outputs.
2016-07-09 15:57:36 +10:00
priseborough a49c16d63c AP_NavEKF2: Update output filter tuning
Updated tuning to take advantage of corrected time delta dtEkfAvg
2016-07-09 15:57:36 +10:00
priseborough 55dee347e0 AP_NavEKF2: Fix bug in averaged filter delta time
Average EKF time delta was not being updated.
2016-07-09 15:57:36 +10:00
priseborough cc7caa27bc DataFlash: Use a unique struct for EKF2 logging 2016-07-09 15:57:35 +10:00
priseborough 772c719df3 DataFlash: log tracking error for active instance of EKF2 2016-07-09 15:57:35 +10:00
priseborough 927186339c AP_NavEKF2: Improved output predictor tracking
Implement a PI feedback controller for velocity and position state tracking
2016-07-09 15:57:35 +10:00
priseborough 00b66ddc07 DataFlash: Log EKF2 output predictor tracking data 2016-07-09 15:57:35 +10:00
priseborough 253f744824 AP_NavEKF2: Collect output predictor tracking data 2016-07-09 15:57:35 +10:00
priseborough 14bb4f4574 AP_NavEKF2: Publish output observer tracking errors 2016-07-09 15:57:35 +10:00
priseborough fa435d0323 AP_NavEKF2: Allow for faster accel bias change in-flight
Fixes a problem observed in a flight log where rapid temperature change caused the accel bias to change faster than the EKF could keep up.
This allows the bias to be learned faster but with acceptable level of noise in the estimate
2016-07-09 15:57:35 +10:00
priseborough 191c34612d AP_NavEKF2: Fix bug in use of corrected IMU data
IMU data was being corrected before being used by the co-variance prediction, whereas the delta angles and velocities in the derivation were supposed to be uncorrected.
This patch creates separate variable for the corrected data
2016-07-09 15:57:35 +10:00
priseborough 118d5b88b2 AP_NavEKF2: Clean up output observer and reduce pos vel time constant
Previous Time constant was too large leading to poor tracking of EKF states in the presence of bad quality IMU data.
2016-07-09 15:57:35 +10:00
Lucas De Marchi b9f65996bc AP_HAL: sparse-endian: unconditionally use byteswap.h
This is either provided by a system header or a minimal header from
'missing' directory.
2016-07-08 19:49:32 -03:00
Lucas De Marchi 471de28967 AP_Common: provide minimal byteswap.h and endian.h 2016-07-08 19:49:32 -03:00
Lucas De Marchi 40338c3272 AP_HAL: sparse-endian: use pragma once 2016-07-08 19:49:32 -03:00
Lucas De Marchi 6a80c3d70d AP_HAL: RingBuffer: remove trailing whitespaces 2016-07-08 16:44:26 -03:00
Lucas De Marchi 24c7f76034 AP_HAL: RingBuffer: remove C++11 initialization
They are already initialized in the constructor.
2016-07-08 16:44:09 -03:00
Murilo Belluzzo 3e1acdcbbf AP_HAL: Use atomic instead volatile on RingBuffer head/tail
Volatile will provide protection to sequence re-ordering and guarantee
the variable is fetched from memory, but it won't provide the memory
barrier needed to ensure that no re-ordering (by either the compiler or
the CPU) will happen among other threads of execution
accessing the same variables.

For more info about this effect can be found on articles about
std::memory_order.
2016-07-08 16:12:53 -03:00
Murilo Belluzzo b7dd4dad64 AP_HAL: Fix ByteBuffer::reserve() breaking buffer state
When using reserved(), the reserved memory cannot be read before it's
written, therefore we cannot update 'tail' until the caller of
reserved() is done writing.

To solve that, a method called 'commit()' was added so the caller can
inform that is done with the memory usage and is safe to update 'tail'.
The caller also has to inform the length that was actually written.

This solution was developed to work considering the usage context of
this class: 1 reader and 1 writer **only**.
2016-07-08 13:10:16 -03:00
Murilo Belluzzo 43d4012884 AP_HAL: Fix TOCTOU in ByteBuffer::peekiovec() 2016-07-08 13:10:16 -03:00
Murilo Belluzzo 9951b94d40 AP_HAL: Change the return type of 'peekiovec'
Possible values are '0', '1' and '2' so uint8_t is a better fit. Also,
invert 'if' condition so it's clear that is returning 0, 1 or 2.
2016-07-08 13:10:16 -03:00
Murilo Belluzzo 625f47def7 AP_HAL: Improve ByteBuffer::set_size
So it doesn't delete and re-create the buffer if the size
happens to be the same. Still resets the buffer content.
2016-07-08 13:10:16 -03:00
Murilo Belluzzo e9e31172c0 AP_HAL: Simplify ByteBuffer::readptr logic 2016-07-08 13:10:16 -03:00
Leandro Pereira fbefe32017 AP_HAL: Add method to reserve space in the ring buffer
Adds a method called `reserve()`, that will take a ByteBuffer::IoVec
array of at least two elements, and return the number of elements
filled out.  0 will be returned if `len` is over the total space of
the buffer; 1 will be returned if there's enough contiguous bytes in
the buffer; 2 will be returned if there are two non-contiguous blocks
of memory.

This method is suitable to be used with POSIX system calls such as
readv(), and is an optimization to not require temporary memory copies
while reading from a file descriptor.

Also modify the write() method to use reserve(), so that similar checks
are performed only in one place.
2016-07-08 13:10:16 -03:00
Leandro Pereira e3b676ba89 AP_HAL: Add method to peek non-contiguous parts of a ByteBuffer
Modify ByteBuffer class to have a `peekiovec()` method, that takes in a
`struct IoVec` array (similar to `struct iovec` from POSIX), and a
number of bytes, and returns the number of elements from this array
that have been filled out.  It is either 0 (buffer is empty), 1
(there's enough contiguous bytes to read that amount) or 2 (ring buffer
is wrapping around).

This enables using scatter-gather I/O (i.e. writev()), removing calls
to memcpy().  That's one call when no wrap-around is happening, and
two calls if it is.

Also, rewrite `ByteBuffer::peekbytes()` to use `peekiovec()`, so that
some of the checks performed by the former are not replicated in the
latter.
2016-07-08 13:10:16 -03:00
Lucas De Marchi efb6b4c57e DataFlash: ifdef both __APPLE__ and __MACH__
This is how we do in other places and should mean that we are targetting
MacOS, not other apple products or other OSes using a mach kernel.
2016-07-07 12:41:51 -03:00
Siddharth Bharat Purohit d65f453da1 AP_HAL_SITL:use common fenv function 2016-07-07 11:35:18 -03:00
Lucas De Marchi c728b6c164 AP_Common: missing/fenv: fix coding style 2016-07-07 11:35:18 -03:00
Siddharth Bharat Purohit 484db9ff82 AP_Common: add replacements for fe control functions systems without them 2016-07-07 11:35:18 -03:00
Siddharth Bharat Purohit 8903bc9eab AP_HAL: add support for get realtime on Darwin systems 2016-07-07 11:35:17 -03:00
Andrew Tridgell f090e9b27c HAL_Linux: fixed makefile build with PRIu64 2016-07-07 15:10:59 +10:00
Lucas De Marchi 3ba27df405 AP_Compass: BMM150: minor refactors
- Correctly sort includes and add missing AP_Math.h
  - Use anonymous struct for trim_registers in _load_trim_values,
    renaming its members so they don't start with underscore
  - Don't change _dig* values when we failed to read from sensor
  - Add some blank lines
  - Make _dig_* members be inside a _dig struct
  - Use constrain_int32 instead of if/else chain
  - s/time_us/time_usec/
  - Construct raw_field with a single constructor in _update()
  - Add missing copyright notice
  - Group methods together in declaration
2016-07-06 10:04:05 -03:00
José Roberto de Souza 6e53854122 AP_Compass: Add BMM150 backend 2016-07-06 10:03:30 -03:00
Fernandes Pinheiro, Daker 51bf638ad3 PID: Remove unused method get_pid_4500 2016-07-06 08:45:01 +09:00
Tom Pittenger 19713200e5 AP_TECS: coverity scan: init variable struct 2016-07-05 14:09:40 -07:00
Tom Pittenger 6d0cf22358 AP_TECS: spelling 2016-07-05 14:09:39 -07:00
Tom Pittenger 753c0d47f0 AP_TECS: coverity scan - variables not initialized in constructor 2016-07-05 13:53:26 -07:00
Tom Pittenger 5f16d873b8 AP_L1_Control: coverity scan - ignoring get_position() result
- if no GPS location is available, do not continue computing navigation values. Hold old nav/target bearings and allow GPS failsafe to switch modes
2016-07-05 13:32:34 -07:00
Tom Pittenger a74e86c234 GCS_MAVLink: coverity scan - computed value overwritten without use for SITL
- when building for SITL we should just skip the num_sends work instead of overwriting the value
2016-07-05 13:32:29 -07:00
Tom Pittenger bd8debdf8b GCS_MAVLink: coverity scan - variables not initialized in constructor 2016-07-05 13:32:24 -07:00
Tom Pittenger 8d2872d3ab AP_Baro: coverity scan - variables not initialized in constructor 2016-07-05 13:32:06 -07:00
Tom Pittenger 93462d0fe3 AP_Airspeed: coverity scan - variables not initialized in constructor 2016-07-05 13:32:00 -07:00
Tom Pittenger d558f32142 AP_L1_Control: coverity scan - variables not initialized in constructor 2016-07-05 13:28:52 -07:00
Andrew Tridgell 0be442d34b SITL: improved throttle input in XPlane
reduce chance that throttle output will be interpreted as input
2016-07-05 09:48:40 +10:00
Andrew Tridgell f387f248d3 SITL: added support for servo slew rates and retract servos
this is for tiltrotors with retract servos
2016-07-05 09:40:37 +10:00
Luis Vale Gonçalves 334233d48f AP_BoardConfig: fix spelling in parameter description
witch ->no
switch->yes
2016-07-04 21:59:30 +09:00
Randy Mackay e820506c5a AC_Fence: add polygon fence check to check_destination_within_fence 2016-07-04 18:25:03 +09:00
Randy Mackay a9d1dcd6ac AC_Fence: trigger reloading of polygon fence if update from GCS
The GCS can either modify a point with a mavlink message or directly change the FENCE_TOTAL parameter value
2016-07-04 18:25:03 +09:00
Jonathan Challinger 0eac5a5c8f AC_PrecLand: remove zero terms from math 2016-07-04 16:57:06 +09:00
Jonathan Challinger b5e80148c6 AC_WPNav: remove shift_loiter_target 2016-07-04 16:57:06 +09:00
Jonathan Challinger f74e162451 AC_PrecLand: redo math, simplify interface 2016-07-04 16:57:06 +09:00
Randy Mackay 4bedc57cbe DataFlash: rename SBFE's Long field to Lng
This naming is consistent with the other GPS messages
2016-07-04 11:17:14 +09:00
Randy Mackay 032e834849 Dataflash: log rally points 2016-07-04 11:17:09 +09:00
Andrew Tridgell 11975223dd AP_Motors: added H_RSC_POWER_NEGC and H_RSC_SLEWRATE
this gives more control over throttle for petrol
helis. H_RSC_POWER_NEGC allows for a asymmetric V-curve, which allows
for less power being put into the head when landing or when sitting on
the ground. That can lead to significantly less vibration and chance
of ground oscillation. A heli not being flown with aerobatics does not
need to use high throttle at negative collective pitch.

The H_RSC_SLEWRATE allows for a maximum throttle slew rate to be
set. Some petrol motors can cut if the throttle is moved too
quickly. We had this happen at a height of 6m when switching from
ALT_HOLD to STABILIZE mode. It also lowers the chance of the blades
skewing in their holders with the sudden change of power when the heli
is disarmed. In general it is a bad idea to do instantaneous large
movements of a IC engine throttle.
2016-07-03 18:29:05 +10:00
Andrew Tridgell 918c41b1e4 AP_BoardConfig: fixed IMU_TARGTEMP index 2016-07-03 12:54:27 +10:00
Andrew Tridgell 3377714300 RC_Channel: fixed typo 2016-07-01 15:35:55 +10:00
Andrew Tridgell a331542958 GCS_MAVLink: fixed typo 2016-07-01 15:35:49 +10:00
Andrew Tridgell 4dcff15603 DataFlash: fixed typo 2016-07-01 15:35:45 +10:00