Commit Graph

1592 Commits

Author SHA1 Message Date
Amilcar Lucas 6e9ffb4249 correct small typos in comments 2012-03-11 21:30:09 +01:00
Andrew Tridgell b337441ec5 SITL: added pgm_read_byte_far() 2012-03-11 20:59:47 +11:00
Andrew Tridgell c1b945018b AP_Declination: fixed usage of headers 2012-03-11 20:59:47 +11:00
Adam M Rivera b9be6ed290 AP_Declination: Updated comment.
Signed-off-by: Andrew Tridgell <tridge@samba.org>
2012-03-11 20:59:47 +11:00
Adam M Rivera fe8c896d69 AP_Declination: Added method set_initial_location
This will set the declination based on lat/lon if the user has
not yet saved one to the EEPROM, OR if they have specified via the
config parameter that they want it to overwrite the declination every
3D fix.

Signed-off-by: Andrew Tridgell <tridge@samba.org>
2012-03-11 20:59:47 +11:00
Adam M Rivera e08b50ee91 AP_Declination: Increased range of supported latitude coordinates.
Fixed incorrect type usage to save stack space.

Signed-off-by: Andrew Tridgell <tridge@samba.org>
2012-03-11 20:59:47 +11:00
Adam M Rivera e22da153ec Added AP_Declination test sketch. I will be improving the test sketch soon.
Signed-off-by: Andrew Tridgell <tridge@samba.org>
2012-03-11 20:59:47 +11:00
Adam M Rivera d2a07b1603 Added AP_Declination library. It contains the lookup table (lat/lng -> declination) as well as a method that performs the lookup.
Signed-off-by: Andrew Tridgell <tridge@samba.org>
2012-03-11 20:59:47 +11:00
Andrew Tridgell d10c4b76ad Compass: removed an incorrect comment 2012-03-11 20:07:38 +11:00
Andrew Tridgell 0da64e98f8 Compass: don't save the orientation to EEPROM
there is no point in saving this, the value is only configurable at
compile time for now, and is always set
2012-03-11 15:37:07 +11:00
Andrew Tridgell 0ec9857689 Math: any euler angle with pitch > 90 is invalid
both DCM and quaternion always return pitch in the range -90 to 90
2012-03-11 15:37:07 +11:00
Andrew Tridgell 4bf28d499a Quaternion: update for new Quaternion interface 2012-03-11 15:37:07 +11:00
Andrew Tridgell e8f1c5742b DCM: update for new Matrix3f interface 2012-03-11 15:37:07 +11:00
Andrew Tridgell 4d3789d11c AP_Math: update the test suite 2012-03-11 15:37:07 +11:00
Andrew Tridgell 4422486d44 AP_Math: made rotation matrices more C++
thanks to Adam for the suggestion
2012-03-11 15:37:07 +11:00
Andrew Tridgell 5c6368bad3 AP_Math: allow null pointers in Quaternion::to_euler()
this matches the Matrix3f method
2012-03-11 15:37:07 +11:00
Andrew Tridgell 16c95236c0 Quaternion: use the new quaternion API 2012-03-11 15:37:07 +11:00
Andrew Tridgell 9f0cb78f08 AP_Math: re-work quaternion functions to be more C++ like
thanks to Adam for the suggestion!
2012-03-11 15:37:07 +11:00
Andrew Tridgell 9e30b5e4a5 I2C: fixed cr/lf mess 2012-03-11 15:37:07 +11:00
Andrew Tridgell 6021daf423 OpticalFlow: adapt optical flow library to new rotation system 2012-03-11 15:37:07 +11:00
Andrew Tridgell 2ab3d2c080 OpticalFlow: fixed line endings
this library was a mixture of dos and unix line endings, which makes
for very messy editing
2012-03-11 15:37:07 +11:00
Andrew Tridgell cb96dd975f Compass: update the compass driver to use the new vector.rotate() method 2012-03-11 15:37:07 +11:00
Andrew Tridgell 55aa43a70d Math: added a test suite for the new rotation methods 2012-03-11 15:37:07 +11:00
Andrew Tridgell 289c64c0b9 Math: added vector3.rotate() and matrix3.rotation() methods
these operate on a "enum Rotation" which defines a set of standard
rotations. These are much faster than our previous method, plus use
less memory
2012-03-11 15:37:07 +11:00
Andrew Tridgell ba8e764349 SITL: lower the noise and drift levels for general autotest usage 2012-03-10 10:34:34 +11:00
Andrew Tridgell b02ca58901 InertialSensor: fixed HIL build 2012-03-10 10:34:34 +11:00
Andrew Tridgell 44ebb20329 MAVLink: bring the v1.0 MAVLink in sync with 0.9 2012-03-10 10:34:34 +11:00
Andrew Tridgell 87c463bcc7 DCM: after some experimentation, raise the ki values a bit
this tracks the max gyro drift more accurately
2012-03-10 10:34:34 +11:00
Andrew Tridgell eff6778515 Quaternion: use gyro drift value from sensor driver 2012-03-10 10:34:34 +11:00
Andrew Tridgell 3989fe2c2c Quaternion: go back to the full update_MARG()
the separate drift controller is too erratic on yaw hold to be usable
at the moment
2012-03-10 10:34:34 +11:00
Andrew Tridgell c8189c80d4 SITL: cleanup the gyro drift calculations
use units that are more easily understood
2012-03-10 10:34:34 +11:00
Andrew Tridgell b833190abb Quaternion: make the quaternion test more generic
works with DCM too
2012-03-10 10:34:33 +11:00
Andrew Tridgell 2f9af05cfa Quaternion: update to get_gyro_drift() interface 2012-03-10 10:34:33 +11:00
Andrew Tridgell bf16b2926c Quaternion: removed some unused variables 2012-03-10 10:34:33 +11:00
Andrew Tridgell 3b2609c441 DCM: separate out the omega_yaw_P from omega_P
this cleans up the separation of drift rates and proportional
correction from yaw source and accelerometers, allow the yaw
to run at a different rate to the accel correction
2012-03-10 10:34:33 +11:00
Andrew Tridgell bcb7196680 IMU: added get_gyro_drift_rate() interface
this just calls down to the InertialSensor layer
2012-03-10 10:34:33 +11:00
Andrew Tridgell 9296ac494d AP_InertialSensor: added a get_gyro_drift_rate() interface
this returns the expected max drift rate for the particular type of
gyro being used
2012-03-10 10:34:33 +11:00
Andrew Tridgell 882fa1818b DCM: removed the limit on linear acceleration
we get linear accelerations of more than 1g when turning corners
2012-03-10 10:34:33 +11:00
Andrew Tridgell 801a442ffb Quaternion: minor tuning 2012-03-10 10:34:33 +11:00
Andrew Tridgell 3344869285 DCM: minor tuning based on testing my quad 2012-03-10 10:34:33 +11:00
Andrew Tridgell dffb435aac SITL: make the yaw match the APM conventions 2012-03-10 10:34:33 +11:00
Andrew Tridgell 2673614f6d SITL: fixed the pwm output on startup 2012-03-10 10:34:33 +11:00
Andrew Tridgell 982712d58f Quaternion: code cleanups and added comments 2012-03-10 10:34:32 +11:00
Andrew Tridgell f405477875 DCM: code cleanup and added more comments 2012-03-10 10:34:32 +11:00
Andrew Tridgell 9dc08b30cd Quaternion: bumb up gyro drift limit to match DCM 2012-03-10 10:34:32 +11:00
Andrew Tridgell f9394f8068 ADC: removed the ADC level accel smoothing
the quaternion code does a better job of handling this noise than this
filter does
2012-03-10 10:34:32 +11:00
Andrew Tridgell 8b40c44522 Quaternion: separate out drift correction from main updates 2012-03-10 10:34:32 +11:00
Andrew Tridgell 3e960f8ef9 InertionSensor: update for new Ch6() interface 2012-03-10 10:34:32 +11:00
Andrew Tridgell 919874f2a0 IMU: fixed a warning 2012-03-10 10:34:32 +11:00
Andrew Tridgell 4dff78b9c0 GPS: expose last_fix_time 2012-03-10 10:34:32 +11:00
Andrew Tridgell 6eff9107ea Compass: change last_update to be in microseconds 2012-03-10 10:34:32 +11:00
Andrew Tridgell a0a360f955 ADC: use floats for ADC averaging
this costs almost nothing and improved accel/gyro calibration
2012-03-10 10:34:32 +11:00
Andrew Tridgell 045b49c4c4 DCM: removed update_DCM_fast
this combines the functionality of the 'fast' DCM with the normal one,
and also speeds up both the yaw drift correction and the matrix update
code
2012-03-10 10:34:31 +11:00
Andrew Tridgell 321200ebbc AP_IMU: fixed led flashing in gyro cal
thanks Pat!
2012-03-10 10:34:31 +11:00
Andrew Tridgell a92fb67b70 AP_Math: expanded the math test suite 2012-03-10 10:34:31 +11:00
Andrew Tridgell 4d65cda0ea AP_Math: added quaternion->matrix and earth frame routines
this will be used for 3d acceleration
2012-03-10 10:34:31 +11:00
Andrew Tridgell 8abbbe5713 AP_Math: better way of handling safe_sqrt()
better to test the result, than predict it
2012-03-10 10:34:31 +11:00
Andrew Tridgell ccada2e9c2 SITL: avoid parent pid code on cygwin
this causes problems on windows
2012-03-10 10:34:31 +11:00
Andrew Tridgell 3666476bcb SITL: prevent nested timer interrupts 2012-03-10 10:34:31 +11:00
Andrew Tridgell 3b7d78cf02 Quat: test patch for michael 2012-03-10 10:34:31 +11:00
Andrew Tridgell f363f81869 Quaternion: added NaN paranoid checking
this is for Michael to run
2012-03-10 10:34:30 +11:00
Andrew Tridgell 1ec4c0777c Math: added comment on quaternion constructor 2012-03-10 10:34:30 +11:00
Andrew Tridgell f5e6dc0757 Math: added is_inf() on vector3f 2012-03-10 10:34:30 +11:00
Andrew Tridgell 066a513758 Quaternion: added more numerical safety in the quaternion code
prevent infinities from creeping in and prevent large drift changes
2012-03-10 10:34:30 +11:00
Andrew Tridgell c7d5f06b21 AP_Math: added quaternion helper functions and a test suite 2012-03-10 10:34:30 +11:00
Andrew Tridgell f70dfe440d Quaternion: fix the gyro bias in centripetal and remove smoothing
the centripetal code needs to take account of the current gyro
bias.

It turned out that the accel and gyro smoothing was causing
significant control lag, and we're better off just letting the
quaternion code handle it via its own smoothing parameters
2012-03-10 10:34:30 +11:00
Andrew Tridgell 47ddd4dfdd SITL: disable interrupts during register updates
this may prevent bogus mode channel reads
2012-03-10 10:34:30 +11:00
Andrew Tridgell 7256652de5 Quaternion: use GPS to correct for linear acceleration
this gives much better pitch estimates. We should do this with the
airspeed sensor if available.
2012-03-10 10:34:30 +11:00
Andrew Tridgell c7ef72cf28 Quaternion: don't update if we have a very long deltat
this can be caused by stopping the system in a debugger
2012-03-10 10:34:30 +11:00
Andrew Tridgell 6d356b6c6e Compass: fixed last_update time for HIL compass 2012-03-10 10:34:30 +11:00
Andrew Tridgell ebc55bb494 RC: disable interrupts when reading the RC registers
this prevents getting bogus values which could cause a flight mode
change
2012-03-10 10:34:30 +11:00
Andrew Tridgell 57f67ca6e3 GPS: added an acceleration estimate to the GPS driver
This uses the GPS ground speed to estimate acceleration
2012-03-10 10:34:30 +11:00
Andrew Tridgell 7fbfcc2721 GPS: fixed some stdint types 2012-03-10 10:34:29 +11:00
Andrew Tridgell e699e9ace0 Quaternion: added in reporting of gyro drift and rp/yaw errors 2012-03-10 10:34:29 +11:00
Andrew Tridgell 2a8b167d95 fixed comment 2012-03-10 10:34:29 +11:00
Andrew Tridgell c73c55aa90 DCM: fixed an uninitialised variable warning 2012-03-10 10:34:29 +11:00
Andrew Tridgell d8234882d4 Quaternion: tweak the quaternion gains a bit 2012-03-10 10:34:29 +11:00
Andrew Tridgell cc887949c9 AP_IMU: improved the gyro calibration code
this should give a much more accurate result
2012-03-10 10:34:29 +11:00
Andrew Tridgell ffa6786697 Quaternion: drop the gyro drift rates down
this should allow us to cope with noise more readily
2012-03-10 10:34:29 +11:00
Andrew Tridgell bee4bd9474 DCM: fixed bug in accel averaging
sorry Randy!
2012-03-10 10:34:29 +11:00
Andrew Tridgell 25e5ddeaa4 AP_Quaternion: fixed build on Arduino 1.0 2012-03-10 10:34:29 +11:00
Andrew Tridgell c369d9f60a AP_Quaternion: added DCM compatibility interfaces
useful for getting the code going quickly
2012-03-10 10:34:29 +11:00
Andrew Tridgell 6138f31cec AP_IMU: added new_data_available() interface 2012-03-10 10:34:29 +11:00
Andrew Tridgell a9dea35310 AP_InertialSensor: added new_data_available() interface 2012-03-10 10:34:28 +11:00
Andrew Tridgell c80ec9a55c AP_ADC: added new_data_available() interface
returns true if more samples are available
2012-03-10 10:34:28 +11:00
Andrew Tridgell c8a459ab0d fixed deltat in quaternion 2012-03-10 10:34:28 +11:00
Andrew Tridgell a791224d07 SITL: make SITL not depend on DCM 2012-03-10 10:34:28 +11:00
Andrew Tridgell 74eef7018a Quaternion: added an AP_Quaternion library
this is for experimenting with the Madgwick quaternion system, to see
if it is more or less noise sensitive than DCM
2012-03-10 10:34:28 +11:00
Andrew Tridgell fd2a24f8ed SITL: reduce the simulated compass offsets
this was causing us problems in getting DCM right
2012-03-10 10:34:28 +11:00
Andrew Tridgell bddc6ba241 SITL: separate out drift speed and drift level 2012-03-10 10:34:28 +11:00
Andrew Tridgell 25cad09746 SITL: added a drift_level multiplier
this makes it easier to experiment with different gyro drift levels
2012-03-10 10:34:28 +11:00
Andrew Tridgell b11b571778 DCM: fixed the averaging of accel values for update_DCM_fast()
this should improve drift correction for ArduCopter
2012-03-10 10:34:28 +11:00
Andrew Tridgell 145fc91701 AP_Math: added a .zero() method to Vector3f 2012-03-10 10:34:28 +11:00
Andrew Tridgell ae51173656 SITL: fixed delay() to account for signal interrupions
when a timer went off we stopped the delay() code
2012-03-10 10:34:28 +11:00
Andrew Tridgell fe173227de DCM_Test: fixed example code to work with SITL
this also fixes the compass setup
2012-03-10 10:34:27 +11:00
Andrew Tridgell 8424609924 SITL: push noise level to 2.0 for DCM testing 2012-03-10 10:34:27 +11:00
Andrew Tridgell 6ba6e11e7b DCM: added a small amount of accel smoothing to update_DCM_fast() 2012-03-10 10:34:27 +11:00
Andrew Tridgell 3b1782f369 DCM: don't use the z accel sensor for drift correction
the z accel is the noisest, and seems to do more harm than good. Using
just x and y is sufficient for drift correction by assuming the vector
length
2012-03-10 10:34:27 +11:00
Andrew Tridgell 4031320f7c DCM: added a small amount of gyro and accel smoothing
possibly not needed, but convenient to be able to test with different
values
2012-03-10 10:34:27 +11:00
Andrew Tridgell 94d0236b97 DCM: added reporting interfaces for DCM state 2012-03-10 10:34:27 +11:00
Andrew Tridgell 772c30ba86 SITL: added sitl_simstate_send()
used to report simulator state in logs
2012-03-10 10:34:27 +11:00
Andrew Tridgell 9df332f0ae MAVLink: import new message types DCM, HWSTATUS and SIMSTATE 2012-03-10 10:34:27 +11:00
Andrew Tridgell cc8278c1ac DCM: got rid of _error_roll_pitch from object state
this can be a local error variable in common with the yaw code. This
saves 12 bytes in the object.
2012-03-10 10:34:27 +11:00
Jason Short 486c56ce41 Consolidated Barometer pressure sensing to a single filter based on Randy's new filter class. 2012-03-08 23:13:04 -08:00
Jason Short e57b91c2e2 Updated on Barometer - increased the Temp filtering and decreased the pressure filtering to and get less temp noise, faster response from pressure. I'm filtering the Climb rate differently now, so this higher pressure noise should not hurt the derivative calcs at all now. 2012-03-06 20:55:35 -08:00
rmackay9 6c3cf9ad5b AP_RC - removed unused library 2012-03-04 18:21:52 +09:00
Andrew Tridgell 73dafe537e SITL: use the new noise model
use the new noise model at a low level for master until we sort out
DCM noise handling
2012-03-02 18:31:07 +11:00
Andrew Tridgell 5f749325f0 APM_RC: allow the fast RC speed to be passed as a parameter
this will allow users to test different speeds
2012-03-02 17:57:08 +11:00
Andrew Tridgell f4329d2680 AP_Param: ensure we can't have duplicate keys in Parameters.h
this is O(n^2), but only at startup, and takes less than 1ms to run.
It catches a very nasty coding error
2012-03-02 15:48:28 +11:00
Andrew Tridgell 1e8d98cdda I2C: added lockup_count() interface
used for reporting I2C problems
2012-03-02 15:48:27 +11:00
Andrew Tridgell 37275d229d SITL: implement cli()/sei() properly for desktop build
this disables simulated hardware interrupts during critical sections
2012-03-02 15:48:27 +11:00
Jason Short 41b435a487 Updated fastPWM to 490Hz 2012-02-29 22:17:38 -08:00
Pat Hickey 337af0c7a2 AP_Param: nested group recursion into next_group disableable by macro
* c.f. 0251932c81fe7eb, e5515bb6ef82
2012-02-29 19:48:43 -08:00
Pat Hickey 2648694489 AP_Param: One more nexted group recursion disableable by macro
* c.f. e5515bb6ef82
2012-02-29 18:48:54 -08:00
rmackay9 fa34ac076e AP_Compass - fixed compile warning 2012-02-29 22:57:35 +09:00
rmackay9 d81c951849 AP_Baro - fixed small compiler warning to do with order of parameters in constructor 2012-02-29 22:46:29 +09:00
rmackay9 c819a0f68a AP_Compass - fixed small compiler warning to do with order of parameters in constructor 2012-02-29 22:45:49 +09:00
rmackay9 5026b5c192 AP_DCM - fixed small compiler warning to do with order of parameters in constructor 2012-02-29 22:45:26 +09:00
rmackay9 82f81295a7 RC_Channel - fixed small compiler warning 2012-02-29 22:44:29 +09:00
rmackay9 c444cdb3f4 AP_ADC - removed small compiler warning 2012-02-29 22:43:46 +09:00
Pat Hickey eac8b66385 AP_Param: Make nested group recursion disableable by macro
* Eliminates recursive calls inside AP_Param.
  This is important to Pat @ Galois, but not the project in general.
  Recursion depth on these functions is bounded structurally using
  existing nested group constructors (can't create loops in finite space)
  and checked at init time
2012-02-28 16:28:27 -08:00
rmackay9 2b6a10d18b AP_RangeFinder - changed example sketch to work with new Filter library 2012-02-28 21:02:10 +09:00
rmackay9 033347f8ee Filter - updated example sketch to use modified library 2012-02-28 21:01:35 +09:00
rmackay9 645fda2fb2 Filter - added AverageFilter, removed SumFilter
added FilterWithBuffer to allow removal of malloc/free without losing ability to pass around filter objects
2012-02-28 21:01:11 +09:00
Andrew Tridgell cb52b6c6d9 AP_Param: show numerical value in eeprom dump utility 2012-02-28 09:43:49 +11:00
Andrew Tridgell a432232db9 AP_Param: fixed v.load() on a sub-element of a AP_Vector3f
this isn't actually used at the moment in APM, but we should get it
right in case someone does try to load a single element of a vector
2012-02-28 09:43:49 +11:00
Andrew Tridgell 39797c6f33 SITL: simulate noise on each ADC channel separately
scale the noise based on the period of the motors
2012-02-28 09:43:49 +11:00
Andrew Tridgell efe5c0142c SITL: raise the ADC noise level to 8 bits when flying
this is about the level of noise of a aircraft that has a lot of
vibration
2012-02-28 09:43:49 +11:00
Andrew Tridgell cd4fcb694e IMU: removed unused accel_filtered code 2012-02-28 09:43:49 +11:00
Andrew Tridgell 87a6d97f7b AP_Param: fixed setting of CAM_P_G in ArduCopter
the variable CAM_P_G has the same prefix as the CAM_P group. We want
to allow for parameters having a common prefix with a group, so we
need to keep searching after we've found a group that matches the
prefix
2012-02-27 10:54:33 +11:00
Andrew Tridgell fa443bd928 AP_Param: make the templating code a bit clearer
add comments on the arguments, and name them in a clearer way
2012-02-27 10:54:33 +11:00
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
rmackay9 297d2ae457 ModeFilter - corrected shadowed variable compiler warning for drop_high_sample 2012-02-26 17:57:28 +09:00
rmackay9 b9b88ba237 Filter - added AverageFilter - this will be used in place of SumFilter because it removes the possibility of overflows 2012-02-26 17:34:36 +09:00
rmackay9 f53ff8de97 Filter - removed shadowing of variables in constructors for Filter, ModeFilter and SumFilter (sorry tridge!)
increased maximum sample buffer size from 6 to 10
2012-02-26 17:17:46 +09:00
rmackay9 74f7d7a1c0 ModeFilter - remove older ModeFilter library (new library is now in Filter directory) 2012-02-26 15:36:23 +09:00
rmackay9 f264e29814 AP_RangeFinder - cut over to use new ModeFilter from Filter library 2012-02-26 15:34:50 +09:00
rmackay9 c14d7768f7 Filter - first version of filter library include ModeFilter 2012-02-26 15:34:05 +09:00
rmackay9 952e5d7bbc AP_Mount - #include FastSerial first to allow it to compile under Arduino 1.0 2012-02-26 15:31:56 +09:00
Andrew Tridgell d0a6359b37 Compass: use constructor to set initial values for _learn and _use_for_yaw
this ensures they are set if you have MAG_ENABLE==0
2012-02-25 17:36:31 +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 f59297d7a7 Compass: catch the case of a user enabling a compass mid-flight
if a compass has not been initialised at startup we can't enable it
mid-flight, as we don't have the orientation
2012-02-25 14:51:09 +11:00
Andrew Tridgell eb71b26d3f DCM: use the new use_for_yaw() compass method 2012-02-25 14:51:09 +11:00
Andrew Tridgell 664622523d Compass: added COMPASS_LEARN and COMPASS_USE parameters
these allow you to control if the compass should be used for yaw and
if it should learn its offsets. This is useful for locking in compass
offsets once they are confirmed to be good, and for learning offsets
without using them in flights.

The default is to behave the same as previously, which is
COMPASS_LEARN=1 and COMPASS_USE=1
2012-02-25 14:51:08 +11:00
Andrew Tridgell f10097a6d5 AP_Param: added some comments on AP_Vector3f handling 2012-02-25 11:37:20 +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 2e9105c68a AP_Param: added special handling for Vector3f
We would like to be able to use Vector3f as a parameter while exposing
the individual elements of the vector as MAVLink parameters. This
change to AP_Param makes that possible, by giving AP_Vector3f a dual
personality
2012-02-25 11:37:20 +11:00
Andrew Tridgell d6bfceef7c SITL: added -C option to desktop mode
this allows running APM to stdout, which is useful for test sketches
2012-02-25 11:37:20 +11:00
Andrew Tridgell 54aa8297af libs: removed unused library GPS_IMU 2012-02-25 11:37:20 +11:00
Andrew Tridgell 185ab5aea9 libs: removed unusued library GCS_SIMPLE 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 16ed8bc8f6 AP_Math: added rotmat <-> euler functions
these will make the dcm matrix manipulation easier to understand
2012-02-24 11:52:55 +11:00
Andrew Tridgell c354879f1f Compass: ensure we don't produce NAN values for compass heading
this leaves the previous heading values alone if we are at a pitch of
exactly 90 or -90, at which point we can't compute a meaningful
heading
2012-02-24 11:52:55 +11:00
Andrew Tridgell 17d16bc8c6 AP_Math: added safe_sqrt() function
this function will never return NAN. It will return zero for negative
numbers.
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 502fbf6e17 AP_Math: added a safe_asin() function
this adds range checking to asin()
2012-02-24 11:52:55 +11:00
Andrew Tridgell 17170da96e AP_Math: added is_nan() methods to vector3f and matrix3f 2012-02-24 11:52:55 +11:00
Jason Short b094f6ce52 added set integrator 2012-02-23 09:38:08 -08: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 53b87229ff AP_Param: added ParamToken type for variable list traversal 2012-02-19 17:05:28 +11:00
Jason Short 1e37a0ec17 added a limit to range output 2012-02-18 21:08:17 -08:00
Randy Mackay 33aa6fe13b Optflow - added reference to FastSerial to resolve compile error on Arduino 1.0.
also removed reference to DCM (no longer required) and removed some old code.
2012-02-18 18:09:40 +09:00
Andrew Tridgell 9793d04ed1 SITL: increase the amount of noise in the simulated ADC
this increases the noise to 2 bits, which actually can have the effect
of improving accuracy, as it leads to better averaging
2012-02-18 19:27:15 +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 baac883eb1 IMU: move _sensor_cal to general IMU class
this makes it available both in shim and INS subclasses
2012-02-18 10:51:57 +11:00
Andrew Tridgell 882cd4ea83 AP_Param: moved AP_Vector3f and AP_Matrix3f declarations to AP_Math.h
this avoids us needing AP_Math.h in every utility sketch and example
2012-02-18 10:51:57 +11:00
Andrew Tridgell 4b15b63d21 AP_Param: fixed copy-assignment operators for AP_Param vectors 2012-02-18 10:51:57 +11:00
Andrew Tridgell 7f3858cb7f AP_Param: added a set_and_save_ifchanged() method
this can be used to avoid the scan() in more frequenctly saved
variables, such as the MAVLink stream rates in APM
2012-02-18 10:51:57 +11:00
Andrew Tridgell 80a6773b8b AP_Param: added an initialised() method
this will be used by the compass code
2012-02-18 10:51:57 +11:00
justinbeech 62b104cbfa Found free extra 256 bytes of RAM eliminate _clz use from libgcc
Believe it or not, changing / 2^31 to >>31 saved 256 bytes in the "d" segment.

The reason is that GCC version prior to 4.3.5 does not have a count_leading_zeros (clz) assembler macro, so it uses a 256 byte lookup table called _clz
The _clz table gets pulled in if you do 64 bit division.
This tiny change is the only place that we do long long division.
Changing to a shift saves 256 bytes of ram.
2012-02-17 09:46:05 +00:00
Jason Short 24ce02c6a4 made I term return in same pattern as D term 2012-02-16 22:09:22 -08:00
Andrew Tridgell 79d622939a ADC: on channel overflow we should not zero last_ch6_micros
this happens every 64 seconds because of unused channels on the
ADC. Zeroing this creates a bad delta_t value for the DCM code.
2012-02-16 17:48:36 +11:00
Jason Short 026e4a6567 change constant to float 44330.0 2012-02-15 09:10:14 -08:00
Michael Oborne 2f81776b0d eedump ap param in perl 2012-02-15 21:31:58 +08:00
Andrew Tridgell a48a118128 SITL: adjust the SITL compass code to have saner z values 2012-02-15 22:34:16 +11:00
Andrew Tridgell 62326c0f72 Compass: enable compass offsets for HIL compass
this makes the null_offsets algorithm have an effect for the HIL
compass that is used for SITL, which makes for easier testing of
compass calibration
2012-02-15 22:33:50 +11:00
Andrew Tridgell 048aed5427 fixed dump size 2012-02-15 10:44:09 +11:00
Andrew Tridgell 089db43183 show group_element too 2012-02-15 10:42:21 +11:00
Andrew Tridgell ea6a46fc9b AP_Param: added eeprom_aaparam.c dump utility 2012-02-15 10:41:06 +11:00
Andrew Tridgell 4398171374 SITL: catch floating point errors
if we get a FPE then log a message and exit
2012-02-15 08:50:45 +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
Andrew Tridgell 601a991a46 added SITL_debug() macro
this can be used to print a message into the logs in the SITL
simulator. This will be used for critical conditions.
2012-02-15 08:50:45 +11:00
Andrew Tridgell 085cc00c33 RC_Channel_aux: fixed a uninitialied variable error, and save a bit of stack space 2012-02-15 08:50:45 +11:00
Andrew Tridgell 43c56be70c SITL: add some magnetometer offsets
this ensures the compass null_offset algorithm has some work to do in
autotest
2012-02-14 11:26:42 +11:00
Andrew Tridgell f95d7cadc5 fixed SITL GPS heading to be 0..360 2012-02-14 11:26:42 +11:00
Andrew Tridgell 6a42598ade use stdint types in the compass code 2012-02-14 08:35:03 +11:00
Andrew Tridgell be5ffdedbb AP_Param: allow dumping of AP_Vector3f
this means the 'show' command in the CLI shows the compass offsets now
2012-02-14 08:34:50 +11:00
Andrew Tridgell d90dc4d893 GPS: change back to 4Hz for MTK GPS
this will hopefully fix the NO_GPS problems that have been regularly
happening in recent months. I will watch the logs carefully to see if
the problem recurs
2012-02-13 22:50:20 +11:00
Andrew Tridgell 804332c340 AP_Baro: fixed some signed/unsigned warnings
and a potential bug on timer wrap
2012-02-13 21:39:18 +11:00
Andrew Tridgell 74bbc72b11 move AP_Var code and example into libraries/AP_Var
you can use AP_Var by defining USE_AP_VAR
2012-02-13 16:22:53 +11:00
Andrew Tridgell 23ed5c2cee fixed imax load/save in PID 2012-02-13 16:22:53 +11:00
Andrew Tridgell 37cabb4cfa fixed dead zone load/save 2012-02-13 16:22:53 +11:00
Andrew Tridgell 150a67c262 fixed PID initialisation 2012-02-13 16:22:53 +11:00
Andrew Tridgell 47807ec68d RC_Channel_aux: catch invalid function settings
a bad function setting would overwrite the heap
2012-02-13 16:22:53 +11:00
Andrew Tridgell 1f05e7dafb fixed types in GPS detect code
using int everywhere is wasteful and non-portable
2012-02-13 16:22:53 +11:00
Andrew Tridgell d55a0c3a71 added AP_Param::show_all()
this moves the logic into common code
2012-02-13 16:22:52 +11:00
Andrew Tridgell 9175ebe33a change back to 256 max variables in _var_info[]
this keeps the header to 24 bits, and allows the token to be 16
bits. If we need more variables we can put them in a nested group.
2012-02-13 16:22:52 +11:00
Andrew Tridgell 9c5a5473ab added indexes to group info structures 2012-02-13 16:22:52 +11:00
Andrew Tridgell f2a6a31645 AP_Param: added group idx, and change packing of header elements
adding a idx element to the GroupInfo will make it less likely that a
developer will change the IDs of group elements, and make it easier to
see that these IDs are important for identifying a variable in EEPROM

The header packing has changed to make it 24 bits on all platforms,
which allows us to lower the EEPROM variable max size to 1024 bytes
again
2012-02-13 16:22:52 +11:00
Andrew Tridgell 678a1df3be fixed support for AP_PARAM_SPARE
spare group elements are needed if we remove a group parameter
2012-02-13 16:22:52 +11:00
Andrew Tridgell accaf9bb30 fixed build on arduino 1.0 2012-02-13 16:22:52 +11:00
Andrew Tridgell db96303fa0 convert APM_PI library to AP_Param 2012-02-13 16:22:52 +11:00
Andrew Tridgell 452749149f convert AC_PID library to AP_Param 2012-02-13 16:22:52 +11:00
Andrew Tridgell f9eed9bd9e fixed missing return in D value 2012-02-13 16:22:52 +11:00
Andrew Tridgell f760b3c717 restore _fCut that was lost in AP_Param development 2012-02-13 16:22:51 +11:00
Andrew Tridgell 84aef17bb0 fixed initialisation of RC_Channel class 2012-02-13 16:22:51 +11:00
Andrew Tridgell 5418302b38 AP_Param: fixed desktop build 2012-02-13 16:22:51 +11:00
Andrew Tridgell d658bc6f9d desktop: more progmem string functions 2012-02-13 16:22:51 +11:00
Andrew Tridgell 95e107ab75 AP_Param: added generic cast_to_float 2012-02-13 16:22:51 +11:00
Andrew Tridgell 9509c69f42 AP_Param: disable debug ready for production 2012-02-13 16:22:51 +11:00
Andrew Tridgell 5d03f13aa5 AP_Param: make ptype in first() and next() optional 2012-02-13 16:22:51 +11:00
Andrew Tridgell e01af5885f adapt Mavlink_compat.h to AP_Param 2012-02-13 16:22:51 +11:00
Andrew Tridgell bf4a77da81 convert libraries to new typesafe macros 2012-02-13 16:22:51 +11:00
Andrew Tridgell e8c4ecf9fa added nested group support and validation 2012-02-13 16:22:51 +11:00
Andrew Tridgell 94a86204ee added size of Vector6f 2012-02-13 16:22:51 +11:00
Andrew Tridgell 12dac42174 modify RC_Channel for AP_Param 2012-02-13 16:22:51 +11:00
Andrew Tridgell e5a0074312 modify the PID library for AP_Param 2012-02-13 16:22:51 +11:00
Andrew Tridgell e5f3864f81 modify the IMU code for AP_Param 2012-02-13 16:22:51 +11:00
Andrew Tridgell 8c58d95187 modify the compass code for AP_Param 2012-02-13 16:22:51 +11:00
Andrew Tridgell 497a400841 hacks to get AP_Param to compile 2012-02-13 16:22:50 +11:00
Andrew Tridgell 5b842a447f new AP_Param subsystem 2012-02-13 16:22:50 +11:00
justinbeech 69f1613f2c Uncommented cold temp compensation after testing. Fixed read throttle so read rate ends up nailing 100hz, not 90hz. minor commenting improvements. 2012-02-13 00:00:06 +00:00
analoguedevices 0ea6ecf8d1 Removed outdated comment:
"	// deadzone moved to
		//control_in = (abs(control_in) < _dead_zone) ? 0 : control_in;"
2012-02-11 16:51:02 +00:00
Michael Oborne 8ec192cf45 fix uint > int issue - for hil 2012-02-11 11:35:59 +08:00
Pat Hickey 83326a9d62 APM_RC_APM2: Add support for CH_10 and CH_11
* CH_10 is on APM2 pin A10 (based on A1..A8 convention)
* CH_11 is on APM2 pin A11

* Only the code in enable_out, disable_out, and OutputCh needed to change.

* CH_10 and CH_11 always have an output period of 20ms (50Hz).
2012-02-06 22:11:01 -08:00
Randy Mackay 6877b8b3d6 AC_PID Library - added example sketch 2012-02-05 17:35:15 +09:00
Randy Mackay 90b39609c6 APM_PerfMon - removed because it's too big to use with our limited memory now anyway! I have a backup in case we need to resurrect it in the future. 2012-02-05 11:11:59 +09:00
Jason Short af79eb273f Added D term to APM_PI - need to refactor this as a parent class and two child classes to save code space, remove dupes 2012-01-28 21:21:43 -08:00
Randy Mackay 9c26e2369e Arduino 1.0 - GPS_IMU - small fix to make it compile. Does anyone use this lib?! 2012-01-28 17:56:56 +09:00
Randy Mackay 8533aaf5d9 AP_PID, AP_RC_Channel, FastSerial - small changes to make example sketches compile again 2012-01-28 17:54:20 +09:00
Randy Mackay b7ce7bfe18 Arduino 1.0 - small fix to make AP_Baro_MS5611_test.pde compile under Arduino 1.0 2012-01-28 13:21:35 +09:00
Randy Mackay cf25bbfa74 AP_ADC library - tiny fix to make example sketch work after some changes to AP_PeriodicProcess library 2012-01-28 13:12:19 +09: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
Randy Mackay a8b3d2f063 OpticalFlow - fixed minor compiler warnings and moved chip select to A3 for APM2 2012-01-26 23:35:49 +09:00
Randy Mackay 8dee001657 Sonar - changed default pin to A0 2012-01-26 22:50:48 +09:00
Randy Mackay 99506accf4 Optical Flow - added overflow check 2012-01-25 21:45:52 +09:00
Pat Hickey 9195006541 APM_RC examples: add calls to enable_out after init 2012-01-24 09:09:08 -08:00
Andrew Tridgell 9c1e257826 fixed example in PID library 2012-01-23 08:47:46 +11:00
Pat Hickey 602d56304a APM_RC: PWM outputs are disabled by default on init 2012-01-22 12:03:11 -08:00
Pat Hickey 276913a950 APM_RC enable_out and disable_out added to APM1 and APM2
* Outputs still enabled by default
2012-01-22 12:03:11 -08:00
Jason Short 94e7ba8df2 Removed Gyro filter, In the end it doesn't help and I think it could actually hurt gyro integration. 2012-01-20 22:52:29 -08:00
Michael Oborne 6b949511ca change rc norm_output to scale evenly across the entire range 2012-01-20 16:24:55 +08:00
Andrew Tridgell 0dc0d9ddf0 added a simple DCM library example 2012-01-18 21:25:19 +11:00