Firmware
rtl.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Copyright (c) 2013-2017 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  ****************************************************************************/
42 #pragma once
43 
44 #include <px4_module_params.h>
45 
46 #include "navigator_mode.h"
47 #include "mission_block.h"
48 
49 class Navigator;
50 
51 class RTL : public MissionBlock, public ModuleParams
52 {
53 public:
54  enum RTLType {
55  RTL_HOME = 0,
56  RTL_LAND,
57  RTL_MISSION,
58  };
59 
61 
62  ~RTL() = default;
63 
64  void on_inactive() override;
65  void on_activation() override;
66  void on_active() override;
67 
68  void set_return_alt_min(bool min);
69 
70  int rtl_type() const;
71 
72 private:
76  void set_rtl_item();
77 
81  void advance_rtl();
82 
83  enum RTLState {
84  RTL_STATE_NONE = 0,
85  RTL_STATE_CLIMB,
86  RTL_STATE_RETURN,
87  RTL_STATE_TRANSITION_TO_MC,
88  RTL_STATE_DESCEND,
89  RTL_STATE_LOITER,
90  RTL_STATE_LAND,
91  RTL_STATE_LANDED,
92  } _rtl_state{RTL_STATE_NONE};
93 
94  bool _rtl_alt_min{false};
95 
96  DEFINE_PARAMETERS(
97  (ParamFloat<px4::params::RTL_RETURN_ALT>) _param_rtl_return_alt,
98  (ParamFloat<px4::params::RTL_DESCEND_ALT>) _param_rtl_descend_alt,
99  (ParamFloat<px4::params::RTL_LAND_DELAY>) _param_rtl_land_delay,
100  (ParamFloat<px4::params::RTL_MIN_DIST>) _param_rtl_min_dist,
101  (ParamInt<px4::params::RTL_TYPE>) _param_rtl_type
102  )
103 };
void on_activation() override
This function is called one time when mode becomes active, pos_sp_triplet must be initialized here...
Definition: rtl.cpp:68
Definition: rtl.h:51
Definition: px4_param.h:313
Helper class to use mission items.
Definition: mission_block.h:56
Definition: navigator_main.cpp:80
void on_active() override
This function is called while the mode is active.
Definition: rtl.cpp:93
Definition: px4_param.h:318
C++ base class for modules/classes using configuration parameters.
Definition: px4_module_params.h:46
Definition: navigator.h:83
void on_inactive() override
This function is called while the mode is inactive.
Definition: rtl.cpp:55