MAV'RIC
mavlink_waypoint_handler.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 mavlink_waypoint_handler.h
34  *
35  * \author MAV'RIC Team
36  * \author Nicolas Dousse
37  *
38  * \brief The MAVLink waypoint handler
39  *
40  ******************************************************************************/
41 
42 
43 #ifndef MAVLINK_WAYPOINT_HANDLER__
44 #define MAVLINK_WAYPOINT_HANDLER__
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #include "mavlink_stream.h"
51 #include "stdbool.h"
52 #include "position_estimation.h"
53 #include "imu.h"
54 #include "mavlink_message_handler.h"
55 #include "mavlink_communication.h"
56 #include "state.h"
57 #include "qfilter.h"
58 
59 #define MAX_WAYPOINTS 10
60 
61 /*
62  * N.B.: Reference Frames and MAV_CMD_NAV are defined in "maveric.h"
63  */
64 
68 typedef struct
69 {
70  uint8_t frame;
71  uint16_t command;
72  uint8_t current;
73  uint8_t autocontinue;
74  float param1;
75  float param2;
76  float param3;
77  float param4;
78  double x;
79  double y;
80  double z;
82 
83 typedef struct
84 {
85  waypoint_struct_t waypoint_list[MAX_WAYPOINTS];
89 
93  float dist2wp_sqr;
94 
96 
99 
102 
104 
105  uint32_t start_timeout;
107 
109  const ahrs_t* ahrs;
113 
115 
121 void waypoint_handler_init_homing_waypoint(mavlink_waypoint_handler_t* waypoint_handler);
122 
128 void waypoint_handler_init_waypoint_list(mavlink_waypoint_handler_t* waypoint_handler);
129 
141 bool waypoint_handler_init( mavlink_waypoint_handler_t* waypoint_handler,
142  position_estimation_t* position_estimation,
143  const ahrs_t* ahrs, state_t* state,
144  mavlink_communication_t* mavlink_communication,
145  const mavlink_stream_t* mavlink_stream);
146 
152 void waypoint_handler_nav_plan_init(mavlink_waypoint_handler_t* waypoint_handler);
153 
161 task_return_t waypoint_handler_control_time_out_waypoint_msg(mavlink_waypoint_handler_t* waypoint_handler);
162 
171 local_coordinates_t waypoint_handler_set_waypoint_from_frame(waypoint_struct_t* current_waypoint, global_position_t origin);
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 
177 #endif // MAVLINK_WAYPOINT_HANDLER__
The MAVLink waypoint structure.
Definition: mavlink_waypoint_handler.h:68
Structure containing the Attitude and Heading Reference System.
Definition: ahrs.h:58
uint8_t autocontinue
Flag to tell whether the vehicle should auto continue to the next waypoint once it reaches the curren...
Definition: mavlink_waypoint_handler.h:73
uint8_t current
Flag to tell whether the waypoint is the current one or not.
Definition: mavlink_waypoint_handler.h:72
uint16_t command
The MAV_CMD_NAV id of the waypoint.
Definition: mavlink_waypoint_handler.h:71
float param4
Parameter depending on the MAV_CMD_NAV id.
Definition: mavlink_waypoint_handler.h:77
uint8_t frame
The reference frame of the waypoint.
Definition: mavlink_waypoint_handler.h:70
double z
The value on the z axis (depends on the reference frame)
Definition: mavlink_waypoint_handler.h:80
The state structure.
Definition: state.h:79
float param3
Parameter depending on the MAV_CMD_NAV id.
Definition: mavlink_waypoint_handler.h:76
Global position structure.
Definition: coord_conventions.h:60
float param2
Parameter depending on the MAV_CMD_NAV id.
Definition: mavlink_waypoint_handler.h:75
double x
The value on the x axis (depends on the reference frame)
Definition: mavlink_waypoint_handler.h:78
float param1
Parameter depending on the MAV_CMD_NAV id.
Definition: mavlink_waypoint_handler.h:74
Local coordinates structure.
Definition: coord_conventions.h:73
The position estimator structure.
Definition: position_estimation.h:79
double y
The value on the y axis (depends on the reference frame)
Definition: mavlink_waypoint_handler.h:79