Skip to content

Commit 64a7213

Browse files
authored
Merge pull request #458 from rosflight/ptt/board_h
moved structure definitions from rosflight_structs.h into board.h, del…
2 parents a2b33f4 + 8c524cf commit 64a7213

File tree

6 files changed

+125
-172
lines changed

6 files changed

+125
-172
lines changed

boards/varmint_h7/common/drivers/Packets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
//#include "Ubx.h"
4242
#include <stdint.h>
4343

44-
#include "interface/rosflight_structs.h"
44+
#include "board.h"
4545

4646
#define SERIAL_MAX_PAYLOAD_SIZE (256 + 8) // for MAVLINK1, really 255+8, added 1 byte to make it an even multiple of 8
4747
typedef struct //__attribute__((__packed__))

boards/varmint_h7/common/drivers/misc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
#include <stdint.h>
4242
#include <stm32h7xx_hal.h>
43-
#include "rosflight_structs.h"
43+
#include "board.h"
4444

4545
#ifdef __cplusplus
4646
extern "C" {

include/interface/board.h

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,130 @@
3636
#include <cstddef>
3737
#include <cstdint>
3838

39-
#include "rosflight_structs.h"
39+
#include "board.h"
4040

4141
namespace rosflight_firmware
4242
{
43+
44+
typedef struct //__attribute__((__packed__))
45+
{
46+
uint64_t timestamp; // us, time of data read complete
47+
uint64_t complete; //
48+
uint16_t status; // device dependent
49+
} PacketHeader;
50+
51+
typedef struct //__attribute__((__packed__))
52+
{
53+
PacketHeader header;
54+
float voltage;
55+
float current;
56+
float temperature; // STM32 temperature, not batter temperature
57+
} BatteryStruct;
58+
59+
typedef struct //__attribute__((__packed__))
60+
{
61+
PacketHeader header;
62+
float accel[3]; // rad/s
63+
float gyro[3]; // rad/s
64+
float temperature; // K
65+
} ImuStruct;
66+
67+
typedef struct //__attribute__((__packed__))
68+
{
69+
PacketHeader header;
70+
float pressure; // Pa
71+
float temperature; // K
72+
union
73+
{
74+
float altitude;
75+
float ias; //speed;
76+
};
77+
} PressureStruct;
78+
79+
enum class SensorRangeType // c.f., ROSFLIGHT_RANGE_TYPE
80+
{
81+
ROSFLIGHT_RANGE_SONAR = 0, /* | */
82+
ROSFLIGHT_RANGE_LIDAR = 1, /* | */
83+
END = 2, /* | */
84+
};
85+
86+
typedef struct //__attribute__((__packed__))
87+
{
88+
PacketHeader header;
89+
float range; // m
90+
float min_range; // m
91+
float max_range; // m
92+
SensorRangeType type; // ROSFLIGHT_RANGE_SONAR, ROSFLIGHT_RANGE_SONAR
93+
} RangeStruct;
94+
95+
typedef struct //__attribute__((packed))
96+
{
97+
PacketHeader header; //
98+
float flux[3]; // T, magnetic flux density
99+
float temperature; // K
100+
} MagStruct;
101+
102+
enum class GNSSFixType // quality from GGA
103+
{
104+
GNSS_FIX_TYPE_NO_FIX = 0,
105+
GNSS_FIX_TYPE_DEAD_RECKONING_ONLY = 1,
106+
GNSS_FIX_TYPE_2D_FIX = 2,
107+
GNSS_FIX_TYPE_3D_FIX = 3,
108+
GNSS_FIX_TYPE_GNSS_PLUS_DEAD_RECKONING = 4,
109+
GNSS_FIX_TYPE_TIME_FIX_ONLY = 5,
110+
GNSS_FIX_RTK_FLOAT = 6,
111+
GNSS_FIX_RTK_FIXED = 7,
112+
END = 8
113+
};
114+
115+
typedef struct //__attribute__((__packed__))
116+
{
117+
PacketHeader header;
118+
uint64_t pps; // most recent pps timestamp (us)
119+
int64_t unix_seconds; // Unix time, in seconds
120+
int32_t unix_nanos;
121+
uint8_t fix_type;
122+
uint8_t num_sat;
123+
double lon;
124+
double lat;
125+
float height_msl;
126+
float vel_n;
127+
float vel_e;
128+
float vel_d;
129+
float h_acc;
130+
float v_acc;
131+
float speed_accy;
132+
} GnssStruct;
133+
134+
typedef struct
135+
{
136+
bool imu;
137+
bool gnss;
138+
bool baro;
139+
bool mag;
140+
bool diff_pressure;
141+
bool sonar;
142+
bool battery;
143+
} got_flags;
144+
145+
// 16 analog + 8 digital MUST BE > 14 (Mavlink message size is hardware to 14)
146+
#define RC_STRUCT_CHANNELS 24
147+
typedef struct //__attribute__((packed))
148+
{
149+
PacketHeader header;
150+
uint8_t nChan;
151+
float chan[RC_STRUCT_CHANNELS];
152+
bool frameLost;
153+
bool failsafeActivated;
154+
} RcStruct;
155+
156+
typedef struct //__attribute__((__packed__))
157+
{
158+
PacketHeader header;
159+
float q[4]; // quaternions
160+
float rate[3];
161+
} AttitudeStruct;
162+
43163
class Board
44164
{
45165
public:

include/interface/rosflight_structs.h

Lines changed: 0 additions & 167 deletions
This file was deleted.

include/rc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#ifndef ROSFLIGHT_FIRMWARE_RC_H
3333
#define ROSFLIGHT_FIRMWARE_RC_H
3434

35-
#include "rosflight_structs.h"
35+
#include "board.h"
3636

3737
#include "param_listener.h"
3838

include/sensors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#include "estimator.h"
4545

46-
#include "rosflight_structs.h"
46+
#include "board.h"
4747

4848
namespace rosflight_firmware
4949
{

0 commit comments

Comments
 (0)