Commit Graph

76 Commits

Author SHA1 Message Date
Andrew Tridgell eb35e0e8ac DCM: fixed the sense of the compass GPS test in initial yaw
we were only disabling null offsets when we didn't have a compass,
which doesn't make much sense!
2012-02-26 22:24:45 +11:00
Andrew Tridgell 900388a85a DCM: disable compass null offsets when setting initial yaw
we need to ensure the compass null offsets code doesn't see a sudden
yaw change, or it will change the offsets by a large amount very
suddenly
2012-02-25 16:02:24 +11:00
Andrew Tridgell eb71b26d3f DCM: use the new use_for_yaw() compass method 2012-02-25 14:51:09 +11:00
Andrew Tridgell 5e2fbdb6cf DCM: don't reset _have_initial_yaw for GPS heading unless very slow
wait till we reach 1m/s before we reset _have_initial_yaw. This
prevents us continually resetting the DCM matrix if our ground speed
is close to 3m/s.
2012-02-25 11:37:20 +11:00
Andrew Tridgell 55e33c3359 DCM: tidy up use of error_course and in_motion
in_motion is not a good name now it is also used for the compass

The error_course and heading component values don't need to be part of
the DCM object, they can be on the stack to reduce the memory usage a bit
2012-02-25 11:37:20 +11:00
Andrew Tridgell ab8cc3d478 DCM: use rotation_matrix_from_euler() to calculate initial yaw
When we first get a compass reading or we first start motion we need
to setup the DCM matrix with the right yaw. This uses
rotation_matrix_from_euler() to get a DCM matrix corresponding to our
current roll/pitch, but with the correct yaw
2012-02-25 11:37:20 +11:00
Andrew Tridgell ddeda1c367 DCM: use rotation_matrix_from_euler() in matrix reset
this makes the code a bit easier to read
2012-02-24 11:54:11 +11:00
Andrew Tridgell 06f37aad75 DCM: use calculate_euler_angles() to get eulers from DCM
this makes the code a bit easier to understand
2012-02-24 11:52:55 +11:00
Andrew Tridgell bad653f230 DCM: tidy up the nan checking in DCM
use is_nan() on the matrix rather than just on c.x, and add
safe_asin() to the (unused) OUTPUTMODE==2 code.
2012-02-24 11:52:55 +11:00
Andrew Tridgell c8e6d03c67 DCM: added matrix recovery on reset
when we get a bad DCM error we can recover a matrix corresponding to
the current attitude, making it more likely that the aircraft will be
able to recover
2012-02-24 11:52:55 +11:00
Andrew Tridgell ef90f336d3 DCM: changed the sense of floating point range comparison
This allows us to detect NaN, otherwise NaN values were considered 
'in range'
2012-02-23 11:41:26 +11:00
Andrew Tridgell 57ffd00b69 DCM: range check the matrix before calculating pitch
The asin() in the pitch calculation can only take values between -1
and 1. This change ensures that the value is in range, and if it isn't
then we force a normalization. If that fails we reset the matrix
2012-02-23 08:16:08 +11:00
Andrew Tridgell 2bb58db3f7 DCM: reset more values on renorm blowup
when DCM blows up, we need to reset a lot more variables to ensure
that any NaN values don't persist
2012-02-23 08:16:08 +11:00
Andrew Tridgell 156d98cb9f DCM: remove the taylor expansion optimisation for renormalisation
The sqrt() costs about 44usec on a 2560, which is small enough for us
not to worry about the speed.

This also changes the range of values where we declare a blowup to
much less likely, which means we can cope with larger delta_t glitches
2012-02-23 08:16:08 +11:00
Andrew Tridgell d52cb7e574 DCM: only add in centripetal accel if we have GPS lock
if we don't have a GPS or the GPS doesn't have a good lock then we
can't rely on the ground speed for adjusting the acceleration vector
2012-02-18 19:27:15 +11:00
Andrew Tridgell 245d265c6a DCM: added a SITL_debug() for DCM normalisation errors
I have seen normalisation errors during simulation runs, but have not
yet tracked down the cause. This log message may help track things
down.
2012-02-15 08:50:45 +11:00
Randy Mackay ed19c25a97 Arduino 1.0 - changed all #includes of "WProgram.h", "wiring.h" and "WConstants.h to "Arduino.h".
Modified FastSerial's write function to return size_t (number of bytes written).
2012-01-28 12:25:47 +09:00
Andrew Tridgell 0dc0d9ddf0 added a simple DCM library example 2012-01-18 21:25:19 +11:00
Andrew Tridgell 15d446bde2 DCM: prevent a segmentation fault when compass is not enabled
when compass is disabled _compass is NULL
2012-01-13 15:48:07 +11:00
Doug Weibel 9846822748 Bug fix for compass.
This is a fix for an interesting bug when a DCM matrix reset was added to the ground start.  This bug only showed up if (A) a ground start were performed after an air start or due to use of the "Calibrate Gryo" action, (B) if the current orientation were sufficiently different from 0/0/0, and (C.) if the particular magnetometer had sufficiently large offsets.  Why did resetting the DCM matrix to 0/0/0 pitch/roll/yaw at ground start cause a bug?  The magnetometer offset nulling determines the proper offsets for the magnetometer by comparing the observed change in the magnetic field vector with the expected change due to rotation as calculated from the rotation in the DCM matrix.  This comparison is made at 10Hz, and then filtered with a weight based on the amount of rotation to estimate the offsets. Normally it would take considerable time at normal in-flight rotation rates for the offset estimate to converge. 

If a DCM matrix reset occurs when the offset nulling algorithm is up and running, the algorithm sees the DCM reset as a instantaneous rotation, however the magnetic field vector did not change at all.  Under certain conditions the algorithm would interpret this as indicating that the offset(s) should be very large.  Since the "rotation" could also have been large the filter weighting would be large and it was possible for a large erroneous estimate of the offset(s) to be made based on this single (bad) data point.

To fix this bug methods were added to the compass object to start and stop the offset nulling algorithm.  Further, when the algorithm is started, it is set up to get fresh samples.  The DCM matrix reset method now calls these new methods to stop the offset nulling before resetting the matrix, and resume after the matrix has been reset.
2012-01-12 14:44:24 -07:00
Andrew Tridgell 8f74631882 DCM: don't use compass unless its healthy 2011-12-28 20:41:54 +11:00
Andrew Tridgell 0147c7b6c6 DCM: added matrix_reset() method 2011-12-13 21:32:50 +11:00
Andrew Tridgell 14866927e1 dcm: fixed an uninitialised variable
if no compass and not in motion the DCM we would multiply by an
uninitialised number
2011-12-11 15:21:10 -08:00
Wenyao Xie 2432ae130d Fixed baro. 2011-12-06 18:56:16 -05:00
Jason Short fa7f39ba20 Access to _clamp val. May want to make a private member and write accessor. 2011-12-03 17:57:12 -08:00
Jason Short e37dffadf3 Added faster conversion from and to degrees*100 / rads 2011-12-03 17:56:41 -08:00
Doug Weibel e3ab1b0353 Add an accessor for the DCM drift correction integrator to monitor performance
Also made the get_health accessor an inline function.
2011-11-05 09:02:23 -06:00
Doug Weibel 947950398c Changed the DCM drift correction integrator limit to a vector magnitude of 30 degrees/second.
The drift correction integrator limit previously was near/at the gyro saturation limit.  If we have that much drift there is a serious hardware problem.  30 degrees/second is arbitrary but should handle all temperature variation, etc.
2011-11-05 09:01:20 -06:00
Doug Weibel c7077fa9e8 In case of DCM renorm "blow-up" reset the drift correction integrators
This should aid in recovery if we loose the AHRS solution and have to force to initial orientation.  Also removed some old commented out code moved to the IMU object
2011-11-05 08:59:16 -06:00
Michael Oborne 6818794bb4 Fix HIL DCM to match actual 2011-10-28 17:40:18 +08:00
James Goppert 0c7c508541 Optional recursion added. 2011-09-30 17:17:51 -04:00
James Goppert 5489b84f8e Improvements to cmake. 2011-09-29 21:23:26 -04:00
James Goppert d887a28b91 Added ArduBoat/ ArduRover/ and APO library. 2011-09-29 14:12:15 -04:00
Andrew Tridgell 8b90ad84f6 fixed ArduCopter HIL build 2011-09-17 14:58:02 +10:00
Andrew Tridgell 9314dcaa89 DCM: re-work the DCM to use the new IMU/ADC features
this gives us higher resolution DCM calculations, with much more
accurate timing of the update delta time.
2011-09-17 14:58:02 +10:00
unknown a4e001bbcf Adding CMake support 2011-09-14 15:44:55 +02:00
Amilcar Lucas f08cea8044 These changes were meant to be inside commit a14c06adc06b. I'm sorry but reverting stuff is not that easy 2011-09-13 01:54:47 +02:00
Amilcar Lucas 5406991831 Added support for routing any function to any of the aux. servos.
This is a manual merge from the APM_Camera branch.
It reverts the stuff that Oliver did not menat to do with his commit 6dcbc7f44bc0
2011-09-13 01:24:06 +02:00
Olivier ADLER 1ee65e3ef2 Merge branch 'APM_Camera' of https://code.google.com/p/ardupilot-mega/
Conflicts:
	ArduPlane/ArduPlane.pde
	libraries/AP_Camera/AP_Camera.h
	libraries/AP_Mount/AP_Mount.cpp
	libraries/AP_Mount/AP_Mount.h
2011-09-12 00:31:18 +02:00
Amilcar Lucas 77c798abd5 Use G_RC_AUX macro to simplify accessing the auxiliary servos 2011-09-12 00:02:47 +02:00
Jason Short d50ed35077 Added a state machine intended to run at 250hz to the DCM. Spread load of DCM out to lower CPU. 2011-09-11 11:03:55 -07:00
jasonshort 61dc79f65b Added some missing functions needed to get HIL to compile
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2964 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-07-30 20:34:23 +00:00
jasonshort 5e163c6052 added ki_Yaw private variable and accessors.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2778 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-07-08 03:57:12 +00:00
jasonshort 418a4b3903 removed redundant FP calcs for speed up.
added ability to alternate normalization and drift correction. Not fully implemented, needs further testing.


git-svn-id: https://arducopter.googlecode.com/svn/trunk@2691 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-06-26 22:54:08 +00:00
tridge60@gmail.com cb492ac00e fixed warnings in AP_DCM
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2559 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-06-15 12:24:51 +00:00
jasonshort edaf2b9641 Based on Doug's recommendation - increased Accel weighting to .66 – 1.33 Gs
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2557 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-06-14 23:37:43 +00:00
jasonshort 595266152b Added dynamic setting of kp_rollpitch, ki_rollpitch, kp_yaw.
Added three constants for kp_rollpitch, (high, med -default, low)
Functionally equivalent to prior version.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@2550 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-06-12 23:49:01 +00:00
DrZiplok 71604405f4 Re-order initialisers to suppress warnings
git-svn-id: https://arducopter.googlecode.com/svn/trunk@2072 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-05-02 05:55:59 +00:00
james.goppert aa598b575a APO merge.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1935 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-05-01 02:05:17 +00:00
deweibel@gmail.com 92bf4c4e0a Add method definition for set_centripetal()
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1756 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-03-08 01:47:43 +00:00