Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
rotwing_state.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Dennis van Wijngaarden <D.C.vanWijngaarden@tudelft.nl>
3  *
4  * This file is part of paparazzi
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
26 #ifndef ROTWING_STATE_H
27 #define ROTWING_STATE_H
28 
29 #include "std.h"
30 
31 /* Magnitude skew angle jump away from quad */
32 #ifndef ROTWING_SKEW_ANGLE_STEP
33 #define ROTWING_SKEW_ANGLE_STEP 55.0
34 #endif
35 
36 /* Preferred pitch angle for the quad mode (deg) */
37 #ifndef ROTWING_QUAD_PREF_PITCH
38 #define ROTWING_QUAD_PREF_PITCH -5.0
39 #endif
40 
47 };
48 
51  struct {
52  bool skew_angle_valid : 1; // Skew angle didn't timeout
53  bool hover_motors_enabled : 1; // Hover motors command is enabled
54  bool hover_motors_idle : 1; // Hover motors are idling (throttle < IDLE_THROTTLE)
55  bool hover_motors_running : 1; // Hover motors are running (RPM >= MIN_RPM)
56  bool pusher_motor_running : 1; // Pusher motor is running (RPM >= MIN_RPM)
57  bool skew_forced : 1; // Skew angle is forced
58  };
59 };
60 
62  /* Control */
63  enum rotwing_states_t state; // Current state
64  enum rotwing_states_t nav_state; // Desired navigation state (requested only by NAV and can be overruled by RC)
65  bool hover_motors_enabled; // Hover motors enabled (> idle throttle)
66 
67  /* Skew */
68  float sp_skew_angle_deg; // Setpoint skew angle in degrees
69  float ref_model_skew_angle_deg; // Reference model skew angle in degrees
70  float meas_skew_angle_deg; // Measured skew angle in degrees
71  float meas_skew_angle_time; // Time of the last skew angle measurement
72  bool force_skew; // Force skew angle to a certain value by the GCS
73  int16_t skew_cmd; // Skewing command in pprz values
74 
75  /* Airspeeds */
76  float fw_min_airspeed; // Minimum airspeed (stall+margin)
77  float cruise_airspeed; // Airspeed for cruising
78  float min_airspeed; // Minimum airspeed for bounding
79  float max_airspeed; // Maximum airspeed for bounding
80 
81  /* RPM measurements*/
82  int32_t meas_rpm[5]; // Measured RPM of the hover and pusher motors
83  float meas_rpm_time[5]; // Time of the last RPM measurement
84 
85  /* Sim failures */
86  bool fail_skew_angle; // Skew angle sensor failure
87  bool fail_hover_motor; // Hover motor failure
88  bool fail_pusher_motor; // Pusher motor failure
89 };
90 extern struct rotwing_state_t rotwing_state;
91 
92 void rotwing_state_init(void);
93 void rotwing_state_periodic(void);
98 
102 void rotwing_state_update_WP_height(uint8_t wp_id, float height);
103 
104 #endif // ROTWING_STATE_H
struct State state
Definition: state.c:36
bool rotwing_state_pusher_motor_running(void)
bool rotwing_state_hover_motors_running(void)
enum rotwing_states_t state
Definition: rotwing_state.h:63
int32_t meas_rpm[5]
Definition: rotwing_state.h:82
float meas_skew_angle_time
Definition: rotwing_state.h:71
void rotwing_state_init(void)
bool rotwing_state_hover_motors_idling(void)
Check if hover motors are idling (COMMAND_THRUST < ROTWING_QUAD_IDLE_MIN_THRUST) for ROTWING_QUAD_IDL...
bool rotwing_state_skew_angle_valid(void)
float meas_rpm_time[5]
Definition: rotwing_state.h:83
bool hover_motors_enabled
Definition: rotwing_state.h:65
float ref_model_skew_angle_deg
Definition: rotwing_state.h:69
float sp_skew_angle_deg
Definition: rotwing_state.h:68
void rotwing_state_set_transition_wp(uint8_t wp_id)
float meas_skew_angle_deg
Definition: rotwing_state.h:70
bool rotwing_state_choose_circle_direction(uint8_t wp_id)
rotwing_states_t
Definition: rotwing_state.h:41
@ ROTWING_STATE_FREE
Definition: rotwing_state.h:46
@ ROTWING_STATE_REQUEST_HOVER
Definition: rotwing_state.h:43
@ ROTWING_STATE_FORCE_FW
Definition: rotwing_state.h:44
@ ROTWING_STATE_FORCE_HOVER
Definition: rotwing_state.h:42
@ ROTWING_STATE_REQUEST_FW
Definition: rotwing_state.h:45
struct rotwing_state_t rotwing_state
Definition: rotwing_state.c:99
void rotwing_state_periodic(void)
enum rotwing_states_t nav_state
Definition: rotwing_state.h:64
void rotwing_state_update_WP_height(uint8_t wp_id, float height)
void rotwing_state_set(enum rotwing_states_t state)
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98