MAV'RIC
navigation.h
1 /*******************************************************************************
2  * Copyright (c) 2009-2014, MAV'RIC Development Team
3  * 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 are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  ******************************************************************************/
31 
32 /*******************************************************************************
33  * \file navigation.h
34  *
35  * \author MAV'RIC Team
36  * \author Nicolas Dousse
37  *
38  * \brief Waypoint navigation controller
39  *
40  ******************************************************************************/
41 
42 
43 #ifndef NAVIGATION_H_
44 #define NAVIGATION_H_
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #include "mavlink_waypoint_handler.h"
51 #include "stabilisation.h"
52 #include "quaternions.h"
53 #include "mavlink_waypoint_handler.h"
54 #include "position_estimation.h"
55 #include "tasks.h"
56 #include "mavlink_communication.h"
57 #include "state.h"
58 #include "remote.h"
59 #include "pid_controller.h"
60 #include <stdbool.h>
61 
62 
66 typedef struct
67 {
68  float dist2vel_gain;
71  float cruise_speed;
74 
75  float dt;
76  uint32_t last_update;
77 
78  float alt_lpf;
79  float LPF_gain;
80 
81  uint8_t loop_count;
82 
84 
85  bool auto_takeoff;
86  bool auto_landing;
87 
88  critical_behavior_enum critical_behavior;
89  auto_landing_behavior_t auto_landing_behavior;
90 
92 
94 
95  bool stop_nav;
97 
100  const quat_t *qe;
106 }navigation_t;
107 
108 typedef struct
109 {
111  float cruise_speed;
113 
115 
116  float alt_lpf;
117  float LPF_gain;
118 
122 
139 bool navigation_init(navigation_t* navigation, navigation_config_t* nav_config, control_command_t* controls_nav, const quat_t* qe, mavlink_waypoint_handler_t* waypoint_handler, const position_estimation_t* position_estimation, state_t* state, const control_command_t* control_joystick, remote_t* remote, mavlink_communication_t* mavlink_communication);
140 
147 void navigation_waypoint_hold_init(mavlink_waypoint_handler_t* waypoint_handler, local_coordinates_t local_pos);
148 
156 task_return_t navigation_update(navigation_t* navigation);
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif // NAVIGATION_H_
bool critical_next_state
Flag to change critical state in its dedicated state machine.
Definition: navigation.h:91
bool stop_nav_there
Flag to stop the navigation and fly to the stopping waypoint.
Definition: navigation.h:96
uint32_t last_update
The time of the last navigation update in ms.
Definition: navigation.h:76
float dist2vel_gain
The gain linking the distance to the goal to the actual speed.
Definition: navigation.h:68
The configuration structure of the remote.
Definition: remote.h:150
bool auto_landing_next_state
Flag to change critical state in its dedicated state machine.
Definition: navigation.h:93
mav_mode_t mode
The mode of the MAV to have a memory of its evolution.
Definition: navigation.h:83
float alt_lpf
The low-pass filtered altitude for auto-landing.
Definition: navigation.h:116
float max_climb_rate
Max climb rate in m/s.
Definition: navigation.h:72
float soft_zone_size
Soft zone of the velocity controller.
Definition: navigation.h:114
The navigation structure.
Definition: navigation.h:66
uint8_t loop_count
A counter for sending MAVLink messages at a lower rate than the function.
Definition: navigation.h:81
float max_climb_rate
Max climb rate in m/s.
Definition: navigation.h:112
mavlink_waypoint_handler_t * waypoint_handler
The pointer to the waypoint handler structure.
Definition: navigation.h:101
auto_landing_behavior_t auto_landing_behavior
The autolanding behavior enum.
Definition: navigation.h:89
float dist2vel_gain
The gain linking the distance to the goal to the actual speed.
Definition: navigation.h:110
const position_estimation_t * position_estimation
The pointer to the position estimation structure in central_data.
Definition: navigation.h:102
control_command_t * controls_nav
The pointer to the navigation control structure.
Definition: navigation.h:98
bool auto_takeoff
The flag to start and end the auto takeoff procedure.
Definition: navigation.h:85
pid_controller_t wpt_nav_controller
waypoint navigation controller
Definition: navigation.h:70
float LPF_gain
The value of the low-pass filter gain.
Definition: navigation.h:79
float soft_zone_size
Soft zone of the velocity controller.
Definition: navigation.h:73
PID controller.
Definition: pid_controller.h:95
The control command typedef.
Definition: stabilisation.h:77
state_t * state
The pointer to the state structure in central_data.
Definition: navigation.h:103
Definition: navigation.h:108
critical_behavior_enum critical_behavior
The critical behavior enum.
Definition: navigation.h:88
pid_controller_t wpt_nav_controller
waypoint navigation controller
Definition: navigation.h:120
float dt
The time interval between two navigation updates.
Definition: navigation.h:75
float LPF_gain
The value of the low-pass filter gain.
Definition: navigation.h:117
float alt_lpf
The low-pass filtered altitude for auto-landing.
Definition: navigation.h:78
remote_t * remote
The pointer to the remote structure.
Definition: navigation.h:105
The state structure.
Definition: state.h:79
Unit quaternion.
Definition: quaternions.h:62
bool auto_landing
The flag to start and end the auto landing procedure.
Definition: navigation.h:86
const control_command_t * control_joystick
The pointer to the joystick control structure.
Definition: navigation.h:99
const quat_t * qe
The pointer to the attitude quaternion structure.
Definition: navigation.h:100
pid_controller_t hovering_controller
hovering controller
Definition: navigation.h:119
const mavlink_stream_t * mavlink_stream
The pointer to the MAVLink stream structure.
Definition: navigation.h:104
Definition: mav_modes.h:147
Local coordinates structure.
Definition: coord_conventions.h:73
bool stop_nav
Flag to start/stop the navigation from a button in case of problems.
Definition: navigation.h:95
The position estimator structure.
Definition: position_estimation.h:79
float cruise_speed
The cruise speed in m/s.
Definition: navigation.h:111
pid_controller_t hovering_controller
hovering controller
Definition: navigation.h:69
float cruise_speed
The cruise speed in m/s.
Definition: navigation.h:71