Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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 }
mavlink_block_message_handler
void mavlink_block_message_handler(const mavlink_message_t *msg)
Definition: blocks.c:64
mavlink_mission_cancel_timer
void mavlink_mission_cancel_timer(void)
Definition: mission_manager.c:67
MAVLINK_TIMEOUT
#define MAVLINK_TIMEOUT
Definition: mission_manager.h:35
mavlink_mission_set_timer
void mavlink_mission_set_timer(void)
Definition: mission_manager.c:57
STATE_IDLE
@ STATE_IDLE
Definition: mission_manager.h:40
mavlink_mission_mgr::rem_sysid
uint8_t rem_sysid
Definition: mission_manager.h:50
common_nav.h
mavlink_mission_mgr::timer_id
int timer_id
Definition: mission_manager.h:52
msg
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
Definition: high_speed_logger_direct_memory.c:134
sys_time_update_timer
void sys_time_update_timer(tid_t id, float duration)
Update the duration until a timer elapses.
Definition: sys_time.c:70
mavlink_mission_mgr::rem_compid
uint8_t rem_compid
Definition: mission_manager.h:51
mavlink_mission_mgr::current_block
uint8_t current_block
Definition: mission_manager.h:47
nav_block
uint8_t nav_block
Definition: common_flight_plan.c:35
sys_time.h
Architecture independent timing functions.
mavlink_mission_mgr::seq
uint16_t seq
Definition: mission_manager.h:49
mission_manager.h
Common functions used within the mission library, blocks and waypoints cannot be send simultaneously ...
mavlink_mission_mgr::state
enum MAVLINK_MISSION_MGR_STATES state
Definition: mission_manager.h:48
navigation.h
sys_time_register_timer
tid_t sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition: sys_time.c:43
mavlink_send_mission_ack
void mavlink_send_mission_ack(void)
Definition: mission_manager.c:107
sys_time_cancel_timer
void sys_time_cancel_timer(tid_t id)
Cancel a system timer by id.
Definition: sys_time.c:60
blocks.h
PPRZ specific mission block implementation.
mavlink_mission_periodic
void mavlink_mission_periodic(void)
update current block and send if changed
Definition: mission_manager.c:90
mavlink_mission_init
void mavlink_mission_init(mavlink_mission_mgr *mgr)
Definition: mission_manager.c:51
sys_time_check_and_ack_timer
static bool sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
Definition: sys_time.h:114
mavlink_mission_message_handler
void mavlink_mission_message_handler(const mavlink_message_t *msg)
Definition: mission_manager.c:75