|
| 1 | +/**************************************************************************** |
| 2 | + * |
| 3 | + * Copyright (c) 2014 MAVlink Development Team. All rights reserved. |
| 4 | + * Author: Trent Lukaczyk, <aerialhedgehog@gmail.com> |
| 5 | + * Jaycee Lock, <jaycee.lock@gmail.com> |
| 6 | + * Lorenz Meier, <lm@inf.ethz.ch> |
| 7 | + * |
| 8 | + * Redistribution and use in source and binary forms, with or without |
| 9 | + * modification, are permitted provided that the following conditions |
| 10 | + * are met: |
| 11 | + * |
| 12 | + * 1. Redistributions of source code must retain the above copyright |
| 13 | + * notice, this list of conditions and the following disclaimer. |
| 14 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 15 | + * notice, this list of conditions and the following disclaimer in |
| 16 | + * the documentation and/or other materials provided with the |
| 17 | + * distribution. |
| 18 | + * 3. Neither the name PX4 nor the names of its contributors may be |
| 19 | + * used to endorse or promote products derived from this software |
| 20 | + * without specific prior written permission. |
| 21 | + * |
| 22 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 25 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 26 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 27 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 28 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 29 | + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 30 | + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 31 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 32 | + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 33 | + * POSSIBILITY OF SUCH DAMAGE. |
| 34 | + * |
| 35 | + ****************************************************************************/ |
| 36 | + |
| 37 | +/** |
| 38 | + * @file mavlink_control.h |
| 39 | + * |
| 40 | + * @brief An example offboard control process via mavlink, definition |
| 41 | + * |
| 42 | + * This process connects an external MAVLink UART device to send an receive data |
| 43 | + * |
| 44 | + * @author Trent Lukaczyk, <aerialhedgehog@gmail.com> |
| 45 | + * @author Jaycee Lock, <jaycee.lock@gmail.com> |
| 46 | + * @author Lorenz Meier, <lm@inf.ethz.ch> |
| 47 | + * |
| 48 | + */ |
| 49 | + |
| 50 | + |
| 51 | +// ------------------------------------------------------------------------------ |
| 52 | +// Includes |
| 53 | +// ------------------------------------------------------------------------------ |
| 54 | + |
| 55 | +#include <iostream> |
| 56 | +#include <stdio.h> |
| 57 | +#include <cstdlib> |
| 58 | +#include <unistd.h> |
| 59 | +#include <cmath> |
| 60 | +#include <string.h> |
| 61 | +#include <inttypes.h> |
| 62 | +#include <fstream> |
| 63 | +#include <signal.h> |
| 64 | +#include <time.h> |
| 65 | +#include <sys/time.h> |
| 66 | + |
| 67 | +using std::string; |
| 68 | +using namespace std; |
| 69 | + |
| 70 | +#include "Mavlink/common/mavlink.h" |
| 71 | + |
| 72 | +#include "autopilot_interface.h" |
| 73 | +#include "serial_port.h" |
| 74 | + |
| 75 | + |
| 76 | +// ------------------------------------------------------------------------------ |
| 77 | +// Prototypes |
| 78 | +// ------------------------------------------------------------------------------ |
| 79 | + |
| 80 | +int main(int argc, char **argv); |
| 81 | +int top(int argc, char **argv); |
| 82 | + |
| 83 | +void commands(Autopilot_Interface &autopilot_interface); |
| 84 | +void parse_commandline(int argc, char **argv, char *&uart_name, int &baudrate); |
| 85 | + |
| 86 | +// quit handler |
| 87 | +Autopilot_Interface *autopilot_interface_quit; |
| 88 | +Serial_Port *serial_port_quit; |
| 89 | +void quit_handler( int sig ); |
| 90 | + |
| 91 | +struct aircraftinfo { |
| 92 | + |
| 93 | + //Aircraft positions |
| 94 | + // 0: current position, 1: last position (one second in the past), 2: very last position (two seconds in the past) |
| 95 | + float lat [3]; |
| 96 | + float lon [3]; |
| 97 | + float alt [3]; |
| 98 | + |
| 99 | + //Aircraft velocity and accelerations |
| 100 | + //0: current velocity/acceleration, 1: last velocity (one second in the past) |
| 101 | + float VelocityX [2]; |
| 102 | + float VelocityY [2]; |
| 103 | + float xAcc; |
| 104 | + float yAcc; |
| 105 | + |
| 106 | + //Information for the predict function |
| 107 | + //0: Predicted point |
| 108 | + //1: Point that is .01 second in front of the predicted point |
| 109 | + //2: Distance between predicted point 0 and 1 |
| 110 | + float futureDistx [3]; |
| 111 | + float futureDisty [3]; |
| 112 | + //Predicted heading |
| 113 | + float Hdg; |
| 114 | + |
| 115 | + uint8_t priority; |
| 116 | + |
| 117 | +}; |
0 commit comments