-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathexample_bp.h
152 lines (114 loc) · 3.45 KB
/
example_bp.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// Code generated by bitproto. DO NOT EDIT.
// Proto drone describes the structure of the drone.
#ifndef __BITPROTO__DRONE_H__
#define __BITPROTO__DRONE_H__ 1
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
#if defined(__cplusplus)
extern "C" {
#endif
#define BITPROTO_OPTIMIZATION_MODE 1
typedef int32_t Timestamp; // 32bit
typedef int32_t TernaryInt32[3]; // 96bit
typedef uint8_t DroneStatus; // 3bit
#define DRONE_STATUS_UNKNOWN 0
#define DRONE_STATUS_STANDBY 1
#define DRONE_STATUS_RISING 2
#define DRONE_STATUS_LANDING 3
#define DRONE_STATUS_FLYING 4
typedef uint8_t PropellerStatus; // 2bit
#define PROPELLER_STATUS_UNKNOWN 0
#define PROPELLER_STATUS_IDLE 1
#define PROPELLER_STATUS_ROTATING 2
typedef uint8_t RotatingDirection; // 2bit
#define ROTATING_DIRECTION_UNKNOWN 0
#define ROTATING_DIRECTION_CLOCK_WISE 1
#define ROTATING_DIRECTION_ANTI_CLOCK_WISE 2
typedef uint8_t PowerStatus; // 2bit
#define POWER_STATUS_UNKNOWN 0
#define POWER_STATUS_OFF 1
#define POWER_STATUS_ON 2
typedef uint8_t LandingGearStatus; // 2bit
#define LANDING_GEAR_STATUS_UNKNOWN 0
#define LANDING_GEAR_STATUS_UNFOLDED 1
#define LANDING_GEAR_STATUS_FOLDED 2
// Number of bytes to encode struct Propeller
#define BYTES_LENGTH_PROPELLER 2
struct Propeller {
uint8_t id; // 8bit
PropellerStatus status; // 2bit
RotatingDirection direction; // 2bit
};
// Number of bytes to encode struct Power
#define BYTES_LENGTH_POWER 2
struct Power {
uint8_t battery; // 8bit
PowerStatus status; // 2bit
bool is_charging; // 1bit
};
// Number of bytes to encode struct Network
#define BYTES_LENGTH_NETWORK 5
struct Network {
// Degree of signal, between 1~10.
uint8_t signal; // 4bit
// The timestamp of the last time received heartbeat packet.
Timestamp heartbeat_at; // 32bit
};
// Number of bytes to encode struct LandingGear
#define BYTES_LENGTH_LANDING_GEAR 1
struct LandingGear {
LandingGearStatus status; // 2bit
};
// Number of bytes to encode struct Position
#define BYTES_LENGTH_POSITION 12
struct Position {
uint32_t latitude; // 32bit
uint32_t longitude; // 32bit
uint32_t altitude; // 32bit
};
// Number of bytes to encode struct Pose
#define BYTES_LENGTH_POSE 12
// Pose in flight. https://en.wikipedia.org/wiki/Aircraft_principal_axes
struct Pose {
int32_t yaw; // 32bit
int32_t pitch; // 32bit
int32_t roll; // 32bit
};
// Number of bytes to encode struct Flight
#define BYTES_LENGTH_FLIGHT 36
struct Flight {
struct Pose pose; // 96bit
// Velocity at X, Y, Z axis.
TernaryInt32 velocity; // 96bit
// Acceleration at X, Y, Z axis.
TernaryInt32 acceleration; // 96bit
};
// Number of bytes to encode struct PressureSensor
#define BYTES_LENGTH_PRESSURE_SENSOR 6
struct PressureSensor {
int32_t pressures[2]; // 48bit
};
// Number of bytes to encode struct Drone
#define BYTES_LENGTH_DRONE 67
struct Drone {
DroneStatus status; // 3bit
struct Position position; // 96bit
struct Flight flight; // 288bit
struct Propeller propellers[4]; // 48bit
struct Power power; // 11bit
struct Network network; // 36bit
struct LandingGear landing_gear; // 2bit
struct PressureSensor pressure_sensor; // 48bit
};
// Encode struct Drone to given buffer s.
int EncodeDrone(struct Drone *m, unsigned char *s);
// Decode struct Drone from given buffer s.
int DecodeDrone(struct Drone *m, unsigned char *s);
#if defined(__cplusplus)
}
#endif
#endif