diff options
author | Anton Babushkin <anton.babushkin@me.com> | 2014-05-22 19:52:22 +0200 |
---|---|---|
committer | Anton Babushkin <anton.babushkin@me.com> | 2014-05-22 19:52:22 +0200 |
commit | 4ee647015a5fa4c2d8e324e75a9f2d749a1b6ca6 (patch) | |
tree | 170085deb72fd93ca334649dc7666f52f000de54 /src/modules/navigator/navigator_main.cpp | |
parent | 1ce1ece0bb7433d1c8498adc5cd4426f5400d20e (diff) | |
download | px4-firmware-4ee647015a5fa4c2d8e324e75a9f2d749a1b6ca6.tar.gz px4-firmware-4ee647015a5fa4c2d8e324e75a9f2d749a1b6ca6.tar.bz2 px4-firmware-4ee647015a5fa4c2d8e324e75a9f2d749a1b6ca6.zip |
navigator: takeoff fix, always reach takeoff altitude, even if first waypoint is lower
Diffstat (limited to 'src/modules/navigator/navigator_main.cpp')
-rw-r--r-- | src/modules/navigator/navigator_main.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/modules/navigator/navigator_main.cpp b/src/modules/navigator/navigator_main.cpp index 87c893079..8eedcc90e 100644 --- a/src/modules/navigator/navigator_main.cpp +++ b/src/modules/navigator/navigator_main.cpp @@ -1477,27 +1477,27 @@ Navigator::check_mission_item_reached() acceptance_radius = _parameters.acceptance_radius; } - float dist = -1.0f; - float dist_xy = -1.0f; - float dist_z = -1.0f; - - /* calculate AMSL altitude for this waypoint */ - float wp_alt_amsl = _mission_item.altitude; - - if (_mission_item.altitude_is_relative) - wp_alt_amsl += _home_pos.alt; - - dist = get_distance_to_point_global_wgs84(_mission_item.lat, _mission_item.lon, wp_alt_amsl, - (double)_global_pos.lat, (double)_global_pos.lon, _global_pos.alt, - &dist_xy, &dist_z); - if (_do_takeoff) { - if (_global_pos.alt > wp_alt_amsl - acceptance_radius) { - /* require only altitude for takeoff */ + /* require only altitude for takeoff */ + if (_global_pos.alt > _pos_sp_triplet.current.alt - acceptance_radius) { _waypoint_position_reached = true; } } else { + float dist = -1.0f; + float dist_xy = -1.0f; + float dist_z = -1.0f; + + /* calculate AMSL altitude for this waypoint */ + float wp_alt_amsl = _mission_item.altitude; + + if (_mission_item.altitude_is_relative) + wp_alt_amsl += _home_pos.alt; + + dist = get_distance_to_point_global_wgs84(_mission_item.lat, _mission_item.lon, wp_alt_amsl, + (double)_global_pos.lat, (double)_global_pos.lon, _global_pos.alt, + &dist_xy, &dist_z); + if (dist >= 0.0f && dist <= acceptance_radius) { _waypoint_position_reached = true; } |