Commit Graph

215 Commits

Author SHA1 Message Date
Randy Mackay 2bafc36ded AC_WPNav: support rangefinder for terrain following 2016-05-21 10:36:53 +09:00
Tom Pittenger 684ac12dd6 AC_WPNav: fix compile when using AP_TERRAIN_AVAILABLE 0 2016-05-20 12:29:19 -07:00
dgrat 41661f815f AP_Math: Replace the pythagorous* functions with a variadic template
The new function can deal with a variable number of function parameters.
Additionally, I renamed the functions to norm(), because this is the
standard name used in several other projects.
2016-05-10 11:41:26 -03:00
Randy Mackay 1c4b2be16a AC_WPNav: simplify use of terrain to just current location 2016-04-30 10:33:01 +09:00
Randy Mackay e23c869c5d AC_WPNav: fix reporting of set_wp_destination failure 2016-04-30 10:33:01 +09:00
Randy Mackay 9fbfea951a AC_WPNav: spline handles terrain altitudes 2016-04-30 10:33:01 +09:00
Randy Mackay 8b2c479d62 AC_WPNav: straight line waypoints accept terrain 2016-04-30 10:33:01 +09:00
Andrew Tridgell 4908350ccb AC_WPNav: limit WPNAV_ACCEL to that implied by ANGLE_MAX
this prevents an overshoot and backtracking in the navigation code
when WPNAV_ACCEL is unachievable due to an angle limit
2016-04-28 17:47:50 +10:00
Jonathan Challinger 3c4d226b64 AC_WPNav: call renamed functions in AC_AttitudeControl 2015-12-09 19:58:50 +09:00
Lucas De Marchi 2591261af6 Global: rename min and max macros to uppercase
The problem with using min() and max() is that they conflict with some
C++ headers. Name the macros in uppercase instead. We may go case by
case later converting them to be typesafe.

Changes generated with:

	git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)max(/\1MAX(/g'
	git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)min(/\1MIN(/g'
2015-12-01 16:28:09 -02:00
Caio Marcelo de Oliveira Filho e867a06383 AC_WPNav: use millis/micros/panic functions 2015-11-20 12:28:13 +09:00
Jonathan Challinger f9c7f15052 AC_WPNav: WPNAV_LOIT_SPEED WPNAV_LOIT_MAXA take effect immediately 2015-11-18 22:12:39 +09:00
Lucas De Marchi 831d8acca5 Remove use of PROGMEM
Now variables don't have to be declared with PROGMEM anymore, so remove
them. This was automated with:

    git grep -l -z PROGMEM | xargs -0 sed -i 's/ PROGMEM / /g'
    git grep -l -z PROGMEM | xargs -0 sed -i 's/PROGMEM//g'

The 2 commands were done so we don't leave behind spurious spaces.

AVR-specific places were not changed.
2015-10-30 14:35:16 +09:00
Randy Mackay adee13d729 AC_WPNav: handle ekf position reset in Loiter and Brake 2015-10-30 12:24:17 +09:00
Randy Mackay 040ec481f4 AC_WPNav: loiter uses pos_control.shift_pos_xy_target 2015-10-30 12:24:09 +09:00
Randy Mackay c52f16b86f AC_WPNav: increase param description max for LOIT_JERK 2015-10-29 12:16:30 +09:00
Randy Mackay 49c4a133d7 AC_WPNav: set jerk separately for wpnav and loiter 2015-10-29 12:10:47 +09:00
Jonathan Challinger 853f8bfaf4 AC_WPNav: stop gradually in loiter 2015-10-28 20:21:55 +09:00
Leonard Hall 5ab2a19173 AC_WPNav: loiter limits lean angle for alt loss 2015-09-07 15:10:11 +09:00
Randy Mackay 7706102d1e AC_WPNav: add shift_loiter_target method
Shift the loiter target and freeze the feedforward if necessary
2015-08-31 18:00:24 +09:00
Andrew Tridgell f6f2973acd AC_WPNav: make changes in WPNAV_ACCEL take effect immediately
this makes it easier to tune the waypoint controller in auto mode
2015-08-31 11:10:35 +10:00
Gustavo Jose de Sousa ee2c388bb0 AC_WPNav: standardize inclusion of libaries headers
This commit changes the way libraries headers are included in source files:

 - If the header is in the same directory the source belongs to, so the
 notation '#include ""' is used with the path relative to the directory
 containing the source.

 - If the header is outside the directory containing the source, then we use
 the notation '#include <>' with the path relative to libraries folder.

Some of the advantages of such approach:

 - Only one search path for libraries headers.

 - OSs like Windows may have a better lookup time.
2015-08-11 16:28:41 +10:00
Randy Mackay fb9cc124c8 AC_WPNav: replace hardcoded 0.02 with pos_control dt 2015-08-05 14:14:54 +09:00
Leonard Hall 8195f45d6c AC_WPNav: fix spline height loss 2015-08-05 14:14:49 +09:00
Randy Mackay aa7a151fe5 AC_WPNav: init flags
Resolves Coverity warning
2015-06-08 14:46:39 +09:00
Randy Mackay 0077cac1b7 AC_WPNav: rename stop to brake 2015-05-17 14:44:33 +09:00
Randy Mackay 61c851885f AC_WPNav: remove unused set_spline_dest_and_vel 2015-05-13 22:40:08 +09:00
Randy Mackay 7056484ef0 Copter: fix spline overshoot 2015-05-13 22:40:06 +09:00
Andrew Tridgell c08b62f9e4 AC_WPNAV: revert AP_Math class change 2015-05-05 13:27:05 +10:00
Tom Pittenger 7fd285f483 AC_WPNav: Compiler warnings: nuke fast_atan2()
per Randy's suggestion, fast_atan2() is no longer necessary over atan2() because only copter uses it and copter is no longer supported on future builds of APM

ccd578664f (commitcomment-11025083)
2015-05-05 13:27:03 +10:00
Tom Pittenger 1b84bbc3e7 AC_WPNav: Compiler warnings: add in the appropriate whitrespace 2015-05-05 13:27:02 +10:00
Tom Pittenger 913d00f525 AP_WPNav: compiler warnings: apply is_zero(float) or is_equal(float) 2015-05-05 13:26:54 +10:00
Jonathan Challinger 2b29060a4e AC_WPNav: remove unused set_loiter_velocity 2015-05-01 16:46:53 +09:00
Randy Mackay 33431acaa4 AC_WPNav: protect against div-by-zero related to gnd_speed_limit 2015-04-28 13:53:19 +09:00
Paul Riseborough 7481217445 AC_WPNav: Improve application of EKF optical flow speed limit 2015-04-28 13:53:17 +09:00
Randy Mackay 35874292a0 AC_WPNav: move stop below all loiter methods
No functional change
2015-04-26 16:26:53 +09:00
Robert Lefebvre 4a7fe83b0f AC_WPNav: Create Stop Mode functions 2015-04-26 16:11:45 +09:00
Randy Mackay 39213584da AC_WPNav: minor comment and formatting changes 2015-04-14 14:50:58 +09:00
Jonathan Challinger fd55068620 AC_WPNav: fix double-twitch on stop in loiter 2015-04-14 14:50:55 +09:00
Jonathan Challinger 1da410a6c6 AC_WPNav: allow user to tune loiter 2015-04-14 14:50:53 +09:00
Randy Mackay fc4442bf61 AC_WPNav: rename xy_mode 2015-02-06 17:00:57 +09:00
Jonathan Challinger 626521c366 AC_WPNav: update usage of update_xy_controller 2015-02-06 17:00:53 +09:00
Jonathan Challinger 6eab698e85 AC_WPNav: remove various timing hacks 2014-12-31 14:03:20 +09:00
Jonathan Challinger 5438d38df5 AC_WPNav: provide reset_I to init_xy_controller 2014-12-31 14:03:16 +09:00
Randy Mackay 4a1ba9b186 AC_WPNav: minor const fix 2014-12-27 13:19:32 +09:00
priseborough 11fb51ceba AC_WPNav: Add nav velocity gain scaler to interfaces
Allows gains to be adjusted to compensate for optical flow noise
2014-12-06 18:16:50 +11:00
priseborough 5fa0c59310 AC_WPNav: Add EKF ground speed limit to loiter speed control
This is required to prevent the speed controller saturating the optical flow sensor during low altitude flying.
2014-12-06 18:16:50 +11:00
Jonathan Challinger 2cc65dffe0 AC_WPNav: add set_spline_dest_and_vel function 2014-11-17 14:38:46 -08:00
Clay McClure 71586d40e3 AC_WPNav: minor fix to comments 2014-11-06 11:53:56 +09:00
Jonathan Challinger 369839c7ca AC_WPNav: Use target yaw instead of current yaw for close waypoints 2014-10-31 15:23:52 +09:00
Randy Mackay e80328d3a5 AC_WPNav: bug fix sanity check of set_speed_xy
This corrects a bug that allowed the waypoint speed to be set to zero
2014-10-21 22:10:22 +09:00
Randy Mackay dbe1c55666 AC_WPNav: add shift_wp_origin_to_current_pos for takeoff
This shifts the origin to the vehicle's current position and should be
called just before take-off to ensure there are no sudden roll or pitch
moves on takeoff.
2014-09-29 15:26:18 +09:00
Randy Mackay 765420ee04 AC_WPNav: add loiter_soften_for_landing method
This resets the position target to the current location.
2014-09-19 16:43:10 +09:00
Randy Mackay ad37fc0408 AC_WPNav: WP_SPEED_DN parameter range to 0~500
Previous permissible descent speed of 10m/s was unnecessarily lenient.
Users can still bypass the suggested range through the MP's full
parameter list if they really want a very high descent speed.
2014-09-18 10:44:33 +09:00
Randy Mackay 1c6606cc58 AC_WPNav: resolve twitch when passing spline waypoints
The target positions target velocity was being reset to zero as we
passed through a spline waypoint.
2014-08-28 11:00:51 +09:00
Randy Mackay 3fd2b3b4a1 AC_WPNav: init members to resolve compiler warnings 2014-08-14 11:27:30 +09:00
Randy Mackay 2b64c511ed AC_WPNav: update yaw only when track is at least 2m 2014-07-06 17:02:12 +09:00
Randy Mackay c9661cfb09 AC_WPNav: integrate set_desired_velocity_xy function name change 2014-07-06 17:01:10 +09:00
Randy Mackay a2f54fdf2c AC_WPNav: smooth waypoint by freezing feed-forward and allowing overshoot
First part of this fix is freezing the position controller's xy-axis
feed foward as we transition to the new segment.
Second part is work-around for straight line segments in that we allow
the target point to actually overshoot the end of the segment by up to
2m if the segment is a "fast waypoint".  Ideally we would instead notice
the waypoint has been completed and take any left over time or distance
and move our target along the track towards the next waypoint but that
would require a much larger change to allow the wpnav lib to hold the
next two waypoints.
2014-06-10 20:03:01 +09:00
Randy Mackay ce85d1f6b2 AC_WPNav: use curr pos target as spline origin
We only use the current target position as origin if the waypoint
controller is active (i..e has been used in the past 1 second).  This is
consistent with how we initialise straight line waypoints
2014-06-10 20:02:59 +09:00
lthall 8bbce7e658 AC_PosControl: freeze feed forward for alt control in Auto 2014-06-10 20:02:36 +09:00
Randy Mackay f23e94707c AC_WPNav: use fast_atan2 for bearing calcs 2014-06-06 18:51:08 +09:00
Randy Mackay efd6d6dc70 AC_WPNav: spline div by zero fix
Also add check for straight line navigation to ensure speed is not
reduced below zero when it hits the leash limit
Also minor formatting changes
2014-06-05 22:23:38 +09:00
lthall 0912bec8f5 Spline div zero and leash limit fix 2014-06-05 22:23:35 +09:00
Randy Mackay cde7d31dad AC_WPNav: fix divide by zero when origin and dest are same location 2014-05-22 21:18:24 +09:00
Randy Mackay 597d5227f5 AC_WPNav: rename set_loiter_target to init_loiter_target 2014-05-19 12:27:25 +09:00
Randy Mackay e7b3c00767 AC_WPNav: set_loiter_target uses set_xy_target
Loiter is only a horizontal position controller so it should not set the
z-axis position.
Moved pos_control.set_speed and accel functions so order matches
init_loiter_targets function order
2014-05-19 12:27:20 +09:00
Ju1ien aed5787c1b AC_WPNav: bug fix for loiter init in Hybrid
AC_PosControl::init_xy_controller() has been added to PosControl and is
called by init_loiter_target.
Hybrid is currently using set_loiter_target function to init the loiter
controller. So we have to call init_xy_controller() by set_loiter_target
function.
What happens otherwise?
In AC_PosControl::update_xy_controller, we update "now" with
now = hal.scheduler->millis();
and, as _last_update_xy_ms has not been updated previously by
init_xy_controller(), we just call init_xy_controller().
So, _dt_xy  will be negative and used anyways in all the functions and
PID called by update_xy_controller.
That will avoid at least _accel_target.x/y to be set to 0 but I'm not
sure for the high values, probably an I_term that is not reset and
reached very high value.
Or maybe a cast error somewhere... no clue at all
2014-05-19 12:27:16 +09:00
Randy Mackay 091ff91a70 WPNav: add wp_and_spline_init to set speeds an init pos controller 2014-05-08 16:15:50 +09:00
lthall b38c484874 AC_WPNav: add LOIT_JERK parameter
Limit accel output from loiter controller.
Call new pos_control.init_xy_controller when loiter starts
Remove sudden stop when pilot requested acceleration is zero

Pair programmed with Randy
2014-05-08 16:15:38 +09:00
Randy Mackay fd9f8f571f AC_WPNav: replace inav, ahrs pointers with references 2014-05-08 16:15:26 +09:00
Randy Mackay 7dd366d84e AC_WPNav: init_loiter sets speed, accel before calcing stopping distance
The stopping distance depends upon the speed and acceleration so these
must be updated first
2014-04-30 21:46:18 +09:00
Randy Mackay 0103ae2eb0 AC_WPNav: add WPNAV_ACCEL_Z
Allows configurable z-axis acceleration during missions
2014-04-30 21:46:12 +09:00
Randy Mackay 510c9920a6 AC_WPNav: rename get_horizontal_velocity to get_speed_xy
This new method name is consistent with the equivalent in the
AC_PosControl class
2014-04-30 21:46:06 +09:00
Randy Mackay ad99918fee AC_WPNav: recalc leash lengths if set_horizontal_velocity is called
Resolves bug in which do-set-speed allowed reducing the speed during the
mission but not increasing it.
Slow down distance is also recalculated.
Unnecessary call to calc_wp_leash_length removed from
set_spline_origin_and_destination.
2014-04-24 13:16:08 +09:00
Randy Mackay 46fba47c8e AC_WPNav: slow target point's speed near destination 2014-04-24 13:16:00 +09:00
Randy Mackay 7c02a02bd8 AC_WPNav: reset_I flag moved to position controller 2014-04-23 15:00:14 +09:00
Randy Mackay 4d5b73b968 AC_WPNav: add reset_I to set_loiter_target 2014-04-23 15:00:07 +09:00
Ju1ien 5d0476e522 AC_WPNav: add reset_I to init_loiter_target 2014-04-23 14:59:47 +09:00
Randy Mackay 559a258ede AC_WPNav: bug fix to limit target point from moving beyond leash
Also pull Z-axis acceleration from position controller instead of using
#define
2014-04-22 23:05:11 +09:00
Randy Mackay 648787a6c8 AC_WPNav: rename some definitions 2014-04-21 15:06:29 +09:00
Randy Mackay 2167dd7d3e AC_WPNav: update target speed immediately 2014-04-21 14:51:26 +09:00
Randy Mackay d382fa51ee AC_WPNav: run loiter and wp nav at 50hz on Pixhawk 2014-04-21 13:32:02 +09:00
Randy Mackay 72d2712c4e AC_WPNav: integrate update_xy_controller name change 2014-04-21 13:31:58 +09:00
Randy Mackay 60f522a094 AC_WPNav: set_wp_destination to use current target
Previously we used the projected stopping point if the vehicle had not
reached the destination but this could lead to large jumps in target
position
2014-04-13 22:42:50 +09:00
Randy Mackay 15da01cf3a AC_WPNav: replace safe_sqrt with pythagorous2 2014-04-01 20:43:45 +09:00
Randy Mackay b15d4379d8 AC_WPNav: use atan2f, make methods const 2014-03-30 23:09:51 +09:00
Randy Mackay d27ca53a9d AC_WPNav: spline sets origin vel to zero when no prev segment
Issue caught by Michael Oborne
2014-03-30 15:19:18 +09:00
Randy Mackay 7dfde39e19 AC_WPNav: advance_spline to use dt 2014-03-30 15:02:07 +09:00
Randy Mackay c0458b786a AC_WPNav: check acceleration is non zero 2014-03-30 11:52:44 +09:00
Randy Mackay f0f3688172 AC_WPNav: rounder corners for short spline segments 2014-03-30 11:52:41 +09:00
Randy Mackay 197683d539 WPNav: clean up spline comments 2014-03-29 17:57:47 +09:00
Randy Mackay 24eb195aa3 WPNav: add yaw control for straight line wp nav 2014-03-28 09:23:13 +09:00
Randy Mackay b42b12f7be AC_WPNav: add get_spline_yaw 2014-03-28 09:23:07 +09:00
Randy Mackay e5e71ce371 WPNav: add spline support 2014-03-28 09:22:53 +09:00
Randy Mackay 98bdbb7fed AC_WPNav: set loiter accel to 1/2 of speed
Bug fix from Leonard.
Also fixed some formatting.
2014-02-20 21:37:45 +09:00
Randy Mackay 9e31f0b985 AC_WPNav: use PosControl accessor
Saves 2bytes of RAM
2014-02-15 05:27:50 +11:00
Randy Mackay d4e4620159 AC_WPNav: remove unused PID references 2014-02-15 05:27:39 +11:00
Randy Mackay fc427967ae AC_WPNav: set wp origin to horiz and vert stopping point
Also bug fix to set pos_control's down speed as a negative number
2014-02-15 05:27:39 +11:00
Randy Mackay 4cd45e2edf AC_WPNav: remove debug 2014-02-15 05:27:38 +11:00