PX4 Firmware
PX4 Autopilot Software http://px4.io
land.cpp
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2013-2016 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 /**
34  * @file land.cpp
35  *
36  * Helper class to land at the current position
37  *
38  * @author Andreas Antener <andreas@uaventure.com>
39  */
40 
41 #include "land.h"
42 #include "navigator.h"
43 
45  MissionBlock(navigator)
46 {
47 }
48 
49 void
51 {
52  /* set current mission item to Land */
57 
58  /* convert mission item to current setpoint */
60  pos_sp_triplet->previous.valid = false;
63  pos_sp_triplet->next.valid = false;
64 
66 
68 }
69 
70 void
72 {
73  /* for VTOL update landing location during back transition */
74  if (_navigator->get_vstatus()->is_vtol &&
77  pos_sp_triplet->current.lat = _navigator->get_global_position()->lat;
78  pos_sp_triplet->current.lon = _navigator->get_global_position()->lon;
80  }
81 
82 
87 
91  }
92 }
void on_active() override
This function is called while the mode is active.
Definition: land.cpp:71
Helper class to land at the current position.
struct position_setpoint_s next
struct position_setpoint_s previous
struct vehicle_land_detected_s * get_land_detected()
Definition: navigator.h:157
Navigator * _navigator
struct position_setpoint_s current
struct vehicle_global_position_s * get_global_position()
Definition: navigator.h:156
mission_item_s _mission_item
void mission_apply_limitation(mission_item_s &item)
General function used to adjust the mission item based on vehicle specific limitations.
void on_activation() override
This function is called one time when mode becomes active, pos_sp_triplet must be initialized here...
Definition: land.cpp:50
void reset_mission_item_reached()
Reset all reached flags.
struct position_setpoint_triplet_s * get_position_setpoint_triplet()
Definition: navigator.h:153
Land(Navigator *navigator)
Definition: land.cpp:44
struct mission_result_s * get_mission_result()
Definition: navigator.h:152
bool mission_item_to_position_setpoint(const mission_item_s &item, position_setpoint_s *sp)
Convert a mission item to a position setpoint.
struct vehicle_status_s * get_vstatus()
Definition: navigator.h:159
void set_mission_result_updated()
Definition: navigator.h:146
void set_land_item(struct mission_item_s *item, bool at_current_location)
Set a land mission item.
void set_can_loiter_at_sp(bool can_loiter)
Setters.
Definition: navigator.h:144
void set_position_setpoint_triplet_updated()
Definition: navigator.h:145
void set_idle_item(struct mission_item_s *item)
Set idle mission item.