Paparazzi UAS  v5.15_devel-47-g0391b4d
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mission_manager.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Lodewijk Sikkel <l.n.c.sikkel@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, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
27 // Include own header
29 
33 
34 // include mavlink headers, but ignore some warnings
35 #pragma GCC diagnostic push
36 #pragma GCC diagnostic ignored "-Wswitch-default"
37 #include "mavlink/paparazzi/mavlink.h"
38 #pragma GCC diagnostic pop
39 
40 // for waypoints, include correct header until we have unified API
41 #ifdef AP
43 #else
45 #endif
46 #include "generated/flight_plan.h"
47 
48 #include "mcu_periph/sys_time.h"
49 
50 
52 {
53  mgr->seq = 0;
54  mgr->timer_id = -1;
55 }
56 
58 {
59  if (mission_mgr.timer_id < 0) {
61  }
62  else {
64  }
65 }
66 
68 {
69  if (mission_mgr.timer_id >= 0) {
71  }
72  mission_mgr.timer_id = -1;
73 }
74 
75 void mavlink_mission_message_handler(const mavlink_message_t *msg)
76 {
78 
80 
81  if (msg->msgid == MAVLINK_MSG_ID_MISSION_ACK) {
82  MAVLINK_DEBUG("Received MISSION_ACK message\n");
85  MAVLINK_DEBUG("State: %d\n", mission_mgr.state);
86  }
87 }
88 
91 {
92  // FIXME: really use the SCRIPT_ITEM message to indicate current block?
95  mavlink_msg_script_current_send(MAVLINK_COMM_0, nav_block);
97  }
98  // check if we had a timeout on a transaction
102  mission_mgr.seq = 0;
103  MAVLINK_DEBUG("Warning: Mavlink mission request timed out!\n");
104  }
105 }
106 
108 {
109  mavlink_msg_mission_ack_send(MAVLINK_COMM_0, mission_mgr.rem_sysid, mission_mgr.rem_compid,
110  MAV_MISSION_ACCEPTED);
112  MAVLINK_DEBUG("Sent MISSION_ACK message\n");
113 }
void mavlink_mission_message_handler(const mavlink_message_t *msg)
void sys_time_cancel_timer(tid_t id)
Cancel a system timer by id.
Definition: sys_time.c:60
void mavlink_mission_periodic(void)
update current block and send if changed
uint8_t nav_block
void mavlink_mission_init(mavlink_mission_mgr *mgr)
#define MAVLINK_TIMEOUT
Common functions used within the mission library, blocks and waypoints cannot be send simultaneously ...
Architecture independent timing functions.
void mavlink_block_message_handler(const mavlink_message_t *msg)
Definition: blocks.c:64
Rotorcraft navigation functions.
void mavlink_mission_cancel_timer(void)
void mavlink_mission_set_timer(void)
static bool sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
Definition: sys_time.h:114
void sys_time_update_timer(tid_t id, float duration)
Update the duration until a timer elapses.
Definition: sys_time.c:70
void mavlink_send_mission_ack(void)
enum MAVLINK_MISSION_MGR_STATES state
PPRZ specific mission block implementation.
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
tid_t sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition: sys_time.c:43