PX4 Firmware
PX4 Autopilot Software http://px4.io
tiltrotor.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2015 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 tiltrotor.h
36 *
37 * @author Roman Bapst <bapstroman@gmail.com>
38 *
39 */
40 
41 #ifndef TILTROTOR_H
42 #define TILTROTOR_H
43 #include "vtol_type.h"
44 #include <parameters/param.h>
45 #include <drivers/drv_hrt.h>
46 
47 class Tiltrotor : public VtolType
48 {
49 
50 public:
51 
52  Tiltrotor(VtolAttitudeControl *_att_controller);
53  ~Tiltrotor() override = default;
54 
55  void update_vtol_state() override;
56  void update_transition_state() override;
57  void fill_actuator_outputs() override;
58  void update_mc_state() override;
59  void update_fw_state() override;
60  void waiting_on_tecs() override;
61 
62 private:
63 
64  struct {
65  float tilt_mc; /**< actuator value corresponding to mc tilt */
66  float tilt_transition; /**< actuator value corresponding to transition tilt (e.g 45 degrees) */
67  float tilt_fw; /**< actuator value corresponding to fw tilt */
70 
71  struct {
77 
78  enum class vtol_mode {
79  MC_MODE = 0, /**< vtol is in multicopter mode */
80  TRANSITION_FRONT_P1, /**< vtol is in front transition part 1 mode */
81  TRANSITION_FRONT_P2, /**< vtol is in front transition part 2 mode */
82  TRANSITION_BACK, /**< vtol is in back transition mode */
83  FW_MODE /**< vtol is in fixed wing mode */
84  };
85 
86  /**
87  * Specific to tiltrotor with vertical aligned rear engine/s.
88  * These engines need to be shut down in fw mode. During the back-transition
89  * they need to idle otherwise they need too much time to spin up for mc mode.
90  */
91 
92 
93  struct {
94  vtol_mode flight_mode; /**< vtol flight mode, defined by enum vtol_mode */
95  hrt_abstime transition_start; /**< absoulte time at which front transition started */
97 
98  float _tilt_control{0.0f}; /**< actuator value for the tilt servo */
99 
100  void parameters_update() override;
101 
102 };
103 #endif
void update_vtol_state() override
Update vtol state.
Definition: tiltrotor.cpp:87
struct Tiltrotor::@143 _params_handles_tiltrotor
float tilt_fw
actuator value corresponding to fw tilt
Definition: tiltrotor.h:67
void update_transition_state() override
Update transition state.
Definition: tiltrotor.cpp:222
void update_mc_state() override
Update multicopter state.
Definition: tiltrotor.cpp:206
High-resolution timer with callouts and timekeeping.
vtol is in front transition part 1 mode
Global flash based parameter store.
struct Tiltrotor::@142 _params_tiltrotor
param_t front_trans_dur_p2
Definition: tiltrotor.h:75
vtol is in multicopter mode
float front_trans_dur_p2
Definition: tiltrotor.h:68
vtol_mode flight_mode
vtol flight mode, defined by enum vtol_mode
Definition: tiltrotor.h:94
param_t tilt_transition
Definition: tiltrotor.h:73
void update_fw_state() override
Update fixed wing state.
Definition: tiltrotor.cpp:214
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
Definition: drv_hrt.h:58
float tilt_transition
actuator value corresponding to transition tilt (e.g 45 degrees)
Definition: tiltrotor.h:66
void fill_actuator_outputs() override
Write data to actuator output topic.
Definition: tiltrotor.cpp:342
vtol is in front transition part 2 mode
~Tiltrotor() override=default
Tiltrotor(VtolAttitudeControl *_att_controller)
Definition: tiltrotor.cpp:47
param_t tilt_fw
Definition: tiltrotor.h:74
void waiting_on_tecs() override
Special handling opportunity for the time right after transition to FW before TECS is running...
Definition: tiltrotor.cpp:333
param_t tilt_mc
Definition: tiltrotor.h:72
float _tilt_control
actuator value for the tilt servo
Definition: tiltrotor.h:98
struct Tiltrotor::@144 _vtol_schedule
Specific to tiltrotor with vertical aligned rear engine/s.
void parameters_update() override
Definition: tiltrotor.cpp:66
vtol is in back transition mode
vtol is in fixed wing mode
float tilt_mc
actuator value corresponding to mc tilt
Definition: tiltrotor.h:65
hrt_abstime transition_start
absoulte time at which front transition started
Definition: tiltrotor.h:95
uint32_t param_t
Parameter handle.
Definition: param.h:98