Commit Graph

346 Commits

Author SHA1 Message Date
Andrew Tridgell 3239a00b23 APM: avoid fetching the DCM matrix twice
also no special case for quaternions
2012-03-10 10:34:32 +11:00
Andrew Tridgell 04826065ef Quaternion: show "Quaternion test" on startup if enabled 2012-03-10 10:34:29 +11:00
Andrew Tridgell aa4beb9753 APM: make it possible to build ArduPlane with quaternion support 2012-03-10 10:34:29 +11:00
Andrew Tridgell a54d6f744e HWSTATUS: if we don't know the voltage, report it as zero
this will tell us if board_voltage() is really working
2012-03-10 10:34:28 +11:00
Andrew Tridgell 8e162ec35b APM: fixed reset of control switch when short_fs_action is disabled
When FS_SHORT_ACTN is 0, we should not re-read the control switch
unless we changed mode on the initial short fs action
2012-03-10 10:34:28 +11:00
Andrew Tridgell 46c91fa0c4 APM: added logging of DCM, HWSTATUS and SIMSTATE 2012-03-10 10:34:27 +11:00
Andrew Tridgell 82dd1cd7ce APM: added board_voltage() function 2012-03-02 15:48:27 +11:00
Pat Hickey 00180e7084 Cleanup: rename files with spaces in their names, replace with underscores
* Skipped /Tools/ArdupilotMegaPlanner/Resources/new...
  and /archive/Configurator/Source/Utilities/TDMS/G...
  because I don't want to mess with that.
2012-02-28 16:14:31 -08:00
rmackay9 630de04bd1 ArduPlane - updated to use new filter library 2012-02-28 21:03:04 +09:00
rmackay9 4501c488b4 ArduPlane - added Filter.h to unbreak the build! 2012-02-26 17:05:56 +09:00
rmackay9 6363da2829 ArduPlane - switch sonar to use new mode filter from filter library 2012-02-26 15:35:42 +09:00
Andrew Tridgell 3fe5b3151b allow MAG_ENABLE to be changed in flight
this disables the compass in DCM if MAG_ENABLE is changed in
flight. Without this we would use a fixed yaw once the compass is
disabled

This also makes sure we don't pass the compass to DCM till we have
done a read. This ensures we have a good compass fix for the initial
DCM heading
2012-02-25 14:51:09 +11:00
Andrew Tridgell 17718720b1 GCS: force scalar type in copy_name()
this enables access to compass offsets over MAVLink
2012-02-25 11:37:20 +11:00
Andrew Tridgell b231112957 DCM: renorm_sqrt_count is now called renorm_range_count 2012-02-23 08:16:08 +11:00
Andrew Tridgell 1fc24b506e AP_Param: update users of AP_Param for ParamToken 2012-02-19 17:05:28 +11:00
Andrew Tridgell b6fdf626e4 APM: expanded parameter area to match ACM
this ensures waypoints and basic eeprom layout remain in sync
2012-02-18 10:51:57 +11:00
Andrew Tridgell 6b357fc66b AP_Param: fixed saving of sensor calibration
this fixes the saving of the accel and gyro calibration to EEPROM,
which was initially broken by the AP_Param conversion
2012-02-18 10:51:57 +11:00
Andrew Tridgell 8355823bc7 APM: use set_and_save_ifchanged() for GCS stream rates
this avoids a lot of EEPROM scan operations when the groundstation
updates the stream rates
2012-02-18 10:51:57 +11:00
Phil f8ed9f0e8d APM: Fix rudder in elevon mode.
elevon planes can have rudders too
2012-02-16 14:43:24 +11:00
Andrew Tridgell 2dcb594f4a APM: changed hold_course for landing to be based on yaw_sensor
when we are in the final stages of a landing (less than 2 seconds from
landing waypoint, or less than 3m above landing altitude) we switch
the navigation to use a fixed course. The code previously used the
crosstrack_bearing for this, but this can lead to a large nav_roll in
this final stage of the approach, which can put a wing into the
runway. In autotest we were seeing a nav_roll value of -45 degrees as
we crossed the transition point for the landing, which often led to a
crash.

This changes the code to use the current yaw_sensor value instead,
which is much less likely to lead to large rolls in the final landing
stages.
2012-02-15 08:50:45 +11:00
Andrew Tridgell c6b6320b43 APM: report the nav_bearing as hold_course when enabled
this gives a more accurate view of the navigation code, as when
hold_course is not -1 it overrides nav_bearing
2012-02-15 08:50:45 +11:00
Andrew Tridgell 252a2d0c9b APM: added some comments related to hold_course
hold_course is either -1 (for disabled) or a course to hold for
takeoff/landing. This makes the code a bit clearer.

It also resets hold_course in all non-auto modes, to ensure it isn't
used
2012-02-15 08:50:45 +11:00
Andrew Tridgell c93dedc955 when setting airspeed and groundspeed in a mission, don't save to EEPROM
If you include airspeed, throttle or groundspeed changes in a mission
then those should not be saved to EEPROM, as otherwise if you restart
and re-fly the mission you will be starting with different parameters
to the ones you used for the first flight.

This is particularly important for setting the target airspeed when
coming in for a landing. You typically set a low target, but if you
fly again the next day I think it would be a real surprise to find
that your loiter airspeed has then changed to the value from the
landing part of your last mission.

This one can be argued either way, but I think that not saving these
changes is the more conservative choice, and better fits the
'principal of least surprise'
2012-02-14 15:20:44 +11:00
Andrew Tridgell df2ef6ff47 APM: fixed some build warnings 2012-02-14 08:58:56 +11:00
Andrew Tridgell 3907cf81f8 Mavlink: report the corrected pitch via MAVLink
this subtracts the TRIM_PITCH_CD from the pitch reported via
MAVLink. That gives a better indication of the true pitch in the tlog
2012-02-14 08:58:56 +11:00
Andrew Tridgell da16ccf993 fixed some printf casts 2012-02-14 08:34:10 +11:00
Andrew Tridgell c6f3f7065c APM: the CLI fits nicely on the 1280 again now
I find the CLI very useful for testing, so enable it by default on the
1280. Logging is still off by default.
2012-02-14 08:33:49 +11:00
Andrew Tridgell 153575a01c token is 16 bits now 2012-02-13 16:22:53 +11:00
Andrew Tridgell 16a5b5c3ee added AP_Param::show_all()
this moves the logic into common code
2012-02-13 16:22:52 +11:00
Andrew Tridgell 781617cae0 token size for first()/next() is now 16 bits 2012-02-13 16:22:52 +11:00
Andrew Tridgell 50f9d12ad5 go back to 1024 bytes for variables in EEPROM 2012-02-13 16:22:52 +11:00
Andrew Tridgell f5f6e2d4ec added group indexes to GCS_MAVLINK class 2012-02-13 16:22:52 +11:00
Andrew Tridgell a8140d9524 expand parameter area for ArduPlane
this ensures all parameters can be saved without overflow
2012-02-13 16:22:52 +11:00
Andrew Tridgell bbc876fcdf tidy up a comment 2012-02-13 16:22:52 +11:00
Andrew Tridgell 9fe8c079e7 fixed two parameter names 2012-02-13 16:22:51 +11:00
Andrew Tridgell 922139b824 expose mavlink stream rates as parameters 2012-02-13 16:22:51 +11:00
Andrew Tridgell edfb8fe0b7 imported new Parameters code to APM 2012-02-13 16:22:51 +11:00
Andrew Tridgell c4bd17052e import new Parameters.h for AP_Param to APM 2012-02-13 16:22:51 +11:00
Andrew Tridgell ab057d9801 implement dump of all vars in CLI using AP_Param 2012-02-13 16:22:51 +11:00
Andrew Tridgell faa098b2b6 adapt mainline APM code to AP_Param 2012-02-13 16:22:51 +11:00
Sandro Benigno 3932e8b2a1 Battery monitor type 3 cannot calculate battery remaining properly, due it uses only voltage reading. This path set battery_remaining to a value out-of-band for that type of monitoring. It informs to external devices to not show that info. 2012-02-11 21:01:13 -02:00
Andrew Tridgell c95a295fd6 allow for lower serial baud rates
not many people will use less than 9600 baud, except for those wanting
to test extreme range radios, which is what I'm trying to do :-)
2012-02-04 19:07:18 +11:00
Pat Hickey 5cdee95516 ArduPlane: Call APM_RC.enable_out for all channels in init_rc_out. 2012-01-22 12:03:11 -08:00
Michael Oborne e71266c258 change rc norm_output to scale evenly across the entire range 2012-01-20 16:24:55 +08:00
Michael Oborne 9dafc668cd fix SITL attitude hil 2012-01-20 16:04:49 +08:00
analoguedevices 40f37c1037 Increment version number in anticipation of a firmware hex push. 2012-01-16 22:48:46 +00:00
Doug Weibel 78ac65d6c3 Additional commenting on global variables
First pass done.
2012-01-16 10:28:03 -07:00
Doug Weibel a3f9fee3d2 Additional commenting on global variables 2012-01-16 09:45:42 -07:00
Doug Weibel 2ea9db84e0 Update battery monitoring code for ArduCopter
Fixes compatibility for APM2.  Also a significant update to the battery monitoring code:  We previously had monitoring modes for individual cell voltages for 3 and 4 cell lipos.  These have been removed as they were never really supported (the cell voltages were computed but were not reported or recorded anywhere).  Also, some clean-up/prep work was done for supporting monitoring 2 separate battery packs.  The CLI battery and current monitoring tests were consolidated into 1 test.
changed
2012-01-15 17:10:02 -07:00
Doug Weibel 82338f2571 Remove a debugging print 2012-01-15 16:37:07 -07:00
Doug Weibel 3b2196354f Stashing some battery monitoring ratio values in the comments for future use. 2012-01-15 16:35:46 -07:00
Doug Weibel e109992c12 Add a CLI setup action to reset the magnetometer offsets
Since the magnetometer offsets are not available through the MAVLink parameter interface (since they are an AP_Var vector) this little feature allows them to be reset from the CLI.  Useful if you somehow get bad offsets or if you change magnetometer.  If you have a bad set of large offset values I have seen issues with the nulling algorithm have trouble converging to the proper values.  I have never seen it have trouble converging from 0/0/0, so this could be a useful feature from time to time.
2012-01-15 16:15:08 -07:00
Doug Weibel 17b31d0b5b Fix airspeed sensor support for APM2.
Airspeed sensor should be attached to Analog input 0
2012-01-15 16:12:08 -07:00
Doug Weibel 17b3e514dc Just a little more commenting work on global variables 2012-01-15 16:11:02 -07:00
Doug Weibel fd8dc84fac Update battery monitoring code for ArduPlane
Fixes compatibility for APM2.  Also a significant update to the battery monitoring code:  We previously had monitoring modes for individual cell voltages for 3 and 4 cell lipos.  These have been removed as they were never really supported (the cell voltages were computed but were not reported or recorded anywhere).  Also, some clean-up/prep work was done for supporting monitoring 2 separate battery packs.  The CLI battery and current monitoring tests were consolidated into 1 test.
2012-01-15 16:10:28 -07:00
Doug Weibel 622217357c 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
Doug Weibel 6f9c6a3b8e Adding comments for global variables 2012-01-11 12:37:43 -07:00
analoguedevices 47197891e3 Put in commented-out APM2 # defines, to save people the trouble of having to type them in themselves. 2012-01-09 02:00:46 +00:00
Doug Weibel 0fb4082581 Bug fix for issue 438.
The rate in a change alt command does not need to be signed.  The code will determine if the rate needs to be positive or negative
2012-01-08 18:24:55 -07:00
Michael Oborne 5d5800ee1f fix relay on apm 1 AP 2012-01-05 07:51:01 +08:00
Andrew Tridgell 645eac6f38 I2c: default to 5ms timeout, and faster bus speed
we will slow down the speed when we get a failure
2012-01-04 16:36:47 +11:00
Doug Weibel 35fba5d4a3 Tweak to FBW min altitude
Patch from Yury
2011-12-31 15:44:40 -07:00
Jason Short bc7f0a567c Small issue with newline formatting 2011-12-29 23:02:02 -08:00
Michael Oborne 0c75c863de add circle to output modes 2011-12-29 18:21:32 +08:00
Andrew Tridgell 5aca951438 APM: added error checking on barometer read
if the barometer is dead and the GPS has a fix, use the GPS for
altitude
2011-12-28 20:41:53 +11:00
Andrew Tridgell 2c41264a9b APM: added error checking on compass read 2011-12-28 20:41:53 +11:00
Andrew Tridgell c6b8a08918 APM: convert to new I2C library 2011-12-28 20:41:53 +11:00
Andrew Tridgell c91827ee09 geofence: re-breach if user changes mode outside the fence
if the user changes mode while outside the fence, and fencing is still
enabled, then declare a new breach
2011-12-28 17:28:35 +11:00
Andrew Tridgell b108b907e0 APM: Update for DataFlash changes 2011-12-28 16:00:49 +11:00
analoguedevices fefda548d2 Added contributor names, removed "alpha" from firmware name 2011-12-26 17:13:37 +00:00
Andrew Tridgell 4cd4987ae7 APM: fixed some unsigned/signed warnings 2011-12-26 19:17:11 +11:00
Andrew Tridgell d09c344ab8 APM-log: fixed reading of GPS logs 2011-12-26 19:17:11 +11:00
Andrew Tridgell 94cbbf6f28 APM-log: changed to use df_NumPages
this copes with different data flash sizes on APM1 and APM2
2011-12-26 19:17:11 +11:00
Doug Weibel 7779dff355 Correct a bug in throttle failsafe feature 2011-12-24 15:34:31 -07:00
Doug Weibel c40093a1a7 Remove old debug print 2011-12-24 14:26:35 -07:00
Doug Weibel 4009018167 Fix scaling on "turn coordination" yaw PID so that P gain values fall in "usual" range 0.1 to 10. 2011-12-24 14:26:35 -07:00
Andrew Tridgell 66029af574 setup the main loop failsafe after RC library is setup 2011-12-23 11:13:01 +11:00
Andrew Tridgell f7dda9f413 added comment on using GPS ground course 2011-12-23 11:13:01 +11:00
Andrew Tridgell 968ad78df0 APM2: default magnetometer to enabled
all APM2s have a MAG at the moment

thanks to Chris for the suggestion
2011-12-22 17:51:14 +11:00
Andrew Tridgell ef3c5c071a failsafe: make sure we clear any RC override in manual failsafe 2011-12-22 10:55:43 +11:00
Andrew Tridgell c6633d7bc9 fixed HIL build 2011-12-21 23:31:39 +11:00
Andrew Tridgell ad63c10ab7 APM: added failsafe support
we now pass all channels through at 50Hz if the main loop stops
running, regardless of why. This gives us a reasonable failsafe, as
long as the low level RC library is still working, and interrupts
don't get completely disabled.
2011-12-21 23:31:39 +11:00
Andrew Tridgell 0aab4da1a1 mainloop_count should be uint16_t 2011-12-21 23:31:38 +11:00
Andrew Tridgell 61b2b2e32a always declare a timer_scheduler
we should always run this code
2011-12-21 23:31:38 +11:00
Andrew Tridgell 73146bae5d APM: show temperature in airpressure test
useful for tracking down baro bugs
2011-12-19 18:52:56 +11:00
Andrew Tridgell 98406e842b geofence: send fence status messages on fence events
this ensures the fence status goes out as soon as possible, which
means the messages arrive in a sane order on the GCS
2011-12-19 11:25:59 +11:00
Andrew Tridgell 226470c614 APM: added RST_SWITCH_CH parameter
This is useful for switching back to the mode indicated by the control
switch after a failsafe or fence breach. I was just changing modes
each time, but it is far more elegant to have a spring loaded switch
for "I am ready to take control again", rather than continually
changing modes.
2011-12-19 11:25:59 +11:00
Andrew Tridgell 54b8aab0ac Log: fixed logging dependence on compiler arg eval order 2011-12-18 17:31:45 +11:00
Andrew Tridgell 8a7d064842 APM: run mavlink loop while erasing logs 2011-12-18 10:19:52 +11:00
Andrew Tridgell ce035fc324 geofence: enable return to old control mode via FENCE_CHANNEL
if you disable fencing with the fence channel switch while still in
GUIDED mode to the return point, then reset the control mode back to
the transmitter control mode
2011-12-18 10:00:44 +11:00
Andrew Tridgell 5d2301ef47 fixed airspeed sensor for ArduPlane on APM2
we were trying to use a non-existant ADC chip!
2011-12-17 07:29:09 +11:00
Andrew Tridgell 4bbd5392ef removed AperiodicProcess code
this code was never being used, and was more complex than it was
worth.
2011-12-17 07:29:09 +11:00
Andrew Tridgell ed17f64459 geofence: added FENCE_TRIGGERED_PIN
this allows for a digital pin to be set high when the geofence
triggers. This pin can be connected to an external failsafe device
2011-12-17 07:29:08 +11:00
Michael Oborne eed0eea13b apm 1280 disables 2011-12-16 22:26:39 +08:00
Andrew Tridgell 1ab2b416a3 geofence: store fence points as int32_t
this keeps maximum precision in fence boundaries
2011-12-16 20:11:51 +11:00
Andrew Tridgell b3327c64de geofence: added fence status reporting and faster altitude check 2011-12-16 20:11:51 +11:00
Andrew Tridgell a6e451c1b2 geofence: don't trim control surfaces on geo-fence breach
the user input is likely to be bad
2011-12-16 20:11:51 +11:00
Andrew Tridgell 1b64185b18 geofence: main geo-fence code
this implements the primary logic of geo-fencing
2011-12-16 20:11:51 +11:00
Andrew Tridgell 238c25c05e geofence: added geo-fencing control parameters 2011-12-16 20:11:51 +11:00
Andrew Tridgell 1455ff4a91 removed an unused variable 2011-12-16 20:09:49 +11:00