PX4 Firmware
PX4 Autopilot Software http://px4.io
LandingTargetEstimator.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2013-2018 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 LandingTargetEstimator.h
36  * Landing target position estimator. Filter and publish the position of a landing target on the ground as observed by an onboard sensor.
37  *
38  * @author Nicolas de Palezieux (Sunflower Labs) <ndepal@gmail.com>
39  * @author Mohammed Kabir <kabir@uasys.io>
40  *
41  */
42 
43 #pragma once
44 
45 #include <px4_platform_common/workqueue.h>
46 #include <drivers/drv_hrt.h>
47 #include <parameters/param.h>
48 #include <uORB/Publication.hpp>
49 #include <uORB/Subscription.hpp>
57 #include <matrix/math.hpp>
58 #include <mathlib/mathlib.h>
59 #include <matrix/Matrix.hpp>
60 #include "KalmanFilter.h"
61 
62 
64 {
65 
67 {
68 public:
69 
71  virtual ~LandingTargetEstimator() = default;
72 
73  /*
74  * Get new measurements and update the state estimate
75  */
76  void update();
77 
78 protected:
79 
80  /*
81  * Update uORB topics.
82  */
83  void _update_topics();
84 
85  /*
86  * Update parameters.
87  */
88  void _update_params();
89 
90  /* timeout after which filter is reset if target not seen */
91  static constexpr uint32_t landing_target_estimator_TIMEOUT_US = 2000000;
92 
95 
98 
100 
101 private:
102 
103  enum class TargetMode {
104  Moving = 0,
105  Stationary
106  };
107 
108  /**
109  * Handles for parameters
110  **/
111  struct {
119  } _paramHandle;
120 
121  struct {
122  float acc_unc;
123  float meas_unc;
127  float scale_x;
128  float scale_y;
129  } _params;
130 
135 
140 
141  // keep track of which topics we have received
145  bool _new_irlockReport{false};
147  // keep track of whether last measurement was rejected
148  bool _faulty{false};
149 
154  hrt_abstime _last_predict{0}; // timestamp of last filter prediction
155  hrt_abstime _last_update{0}; // timestamp of last filter update (used to check timeout)
156 
157  void _check_params(const bool force);
158 
159  void _update_state();
160 };
161 
162 
163 } // namespace landing_target_estimator
uORB::Publication< landing_target_pose_s > _targetPosePub
High-resolution timer with callouts and timekeeping.
Global flash based parameter store.
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
Definition: uORB.h:87
struct landing_target_estimator::LandingTargetEstimator::@100 _paramHandle
Handles for parameters.
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
Definition: drv_hrt.h:58
struct landing_target_estimator::LandingTargetEstimator::@101 _params
A simple matrix template library.
uORB::Publication< landing_target_innovations_s > _targetInnovationsPub
uint32_t param_t
Parameter handle.
Definition: param.h:98