forked from mavlink/c_uart_interface_example
-
Notifications
You must be signed in to change notification settings - Fork 7
/
offboard_setup.h
86 lines (74 loc) · 2.39 KB
/
offboard_setup.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/** This example is public domain. */
/**
* @file offboard_setup.h
*
* @brief setup functions for off-board
*
* @author Trent Lukaczyk, <[email protected]>
* @author Jaycee Lock, <[email protected]>
*
*/
// ------------------------------------------------------------------------------
// Includes
// ------------------------------------------------------------------------------
#include <iostream>
#include <cstdlib>
#include <unistd.h>
#include <cmath>
#include <string.h>
#include <inttypes.h>
#include <fstream>
#include <signal.h>
using std::string;
using namespace std;
#include <common/mavlink.h>
// ------------------------------------------------------------------------------
// Defines
// ------------------------------------------------------------------------------
// XXX should go in mavlink
/**
* Defines for mavlink_set_position_target_local_ned_t.type_mask
*
* Bitmask to indicate which dimensions should be ignored by the vehicle
*
* a value of 0b0000000000000000 or 0b0000001000000000 indicates that none of
* the setpoint dimensions should be ignored.
*
* If bit 10 is set the floats afx afy afz should be interpreted as force
* instead of acceleration.
*
* Mapping:
* bit 1: x,
* bit 2: y,
* bit 3: z,
* bit 4: vx,
* bit 5: vy,
* bit 6: vz,
* bit 7: ax,
* bit 8: ay,
* bit 9: az,
* bit 10: is force setpoint,
* bit 11: yaw,
* bit 12: yaw rate
* remaining bits unused
*
* Combine bitmasks with bitwise &
*
* Example for position and yaw angle:
* uint16_t type_mask =
* MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_POSITION &
* MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_YAW_ANGLE;
*
*/
#define MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_POSITION 0b0001111111110000
#define MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_VELOCITY 0b1110001111110000
#define MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_ACCELERATION 0b1111110001110000
#define MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_FORCE 0b1111110001110000
#define MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_YAW_ANGLE 0b1111111111010000
#define MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_YAW_RATE 0b1111111111100000
// ------------------------------------------------------------------------------
// Function prototypes
// ------------------------------------------------------------------------------
int toggle_offboard(float sw);
void start_offboard(void);
void stop_offboard(void);