PX4 Firmware
PX4 Autopilot Software http://px4.io
VtolLandDetector.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 /**
35  * @file VtolLandDetector.cpp
36  * Land detection algorithm for VTOL
37  *
38  * @author Roman Bapst <bapstroma@gmail.com>
39  * @author Julian Oes <julian@oes.ch>
40  */
41 
42 #include <drivers/drv_hrt.h>
43 
44 #include "VtolLandDetector.h"
45 
46 namespace land_detector
47 {
48 
50 {
54 }
55 
57 {
58  // If in Fixed-wing mode, only trigger if disarmed
60  return !_actuator_armed.armed;
61  }
62 
64 }
65 
67 {
68  // If in Fixed-wing mode, only trigger if disarmed
70  return !_actuator_armed.armed;
71  }
72 
73  // this is returned from the mutlicopter land detector
75 
76  // for vtol we additionally consider airspeed
77  if (hrt_elapsed_time(&_airspeed.timestamp) < 500 * 1000 && _airspeed.confidence > 0.99f
78  && PX4_ISFINITE(_airspeed.indicated_airspeed_m_s)) {
79 
81 
82  } else {
83  // if airspeed does not update, set it to zero and rely on multicopter land detector
84  _airspeed_filtered = 0.0f;
85  }
86 
87  // only consider airspeed if we have been in air before to avoid false
88  // detections in the case of wind on the ground
89  if (_was_in_air && (_airspeed_filtered > _param_lndfw_airspd_max.get())) {
90  landed = false;
91  }
92 
93  _was_in_air = !landed;
94 
95  return landed;
96 }
97 
98 } // namespace land_detector
#define VEHICLE_TYPE_FIXED_WING
bool _was_in_air
indicates whether the vehicle was in the air in the previous iteration
actuator_armed_s _actuator_armed
Definition: LandDetector.h:148
void _update_topics() override
Updates subscribed uORB topics.
High-resolution timer with callouts and timekeeping.
uORB::Subscription _vehicle_status_sub
float confidence
Definition: airspeed.h:57
void _update_topics() override
Updates subscribed uORB topics.
float _airspeed_filtered
low pass filtered airspeed
static hrt_abstime hrt_elapsed_time(const hrt_abstime *then)
Compute the delta between a timestamp taken in the past and now.
Definition: drv_hrt.h:102
float indicated_airspeed_m_s
Definition: airspeed.h:54
uint64_t timestamp
Definition: airspeed.h:53
Land detection implementation for VTOL also called hybrids.
bool update(void *dst)
Update the struct.