protocol.h
Go to the documentation of this file.
1 #ifndef PROTOCOL_H
2 #define PROTOCOL_H
3 
4 #include <stdint.h>
5 
6 namespace ric_interface
7 {
8  namespace protocol
9  {
10  enum class Type
11  {
12  KEEP_ALIVE = 100,
13  LOGGER = 101,
14  ULTRASONIC = 102,
15  LASER = 103,
16  IMU = 104,
17  GPS = 105,
18  SERVO = 106,
19  EMERGENCY_ALARM = 107
20  };
21 
22  const uint16_t MAX_PKG_SIZE = 512;
23  const uint8_t HEADER_CODE = 200;
24  const uint8_t HEADER_INDX = 0;
25  const uint8_t PKG_SIZE_INDX = 1;
26 
27  struct package
28  {
29  uint8_t type = 0;
30  };
31 
32  struct keepalive : package
33  {
34  keepalive() { type = (uint8_t)Type::KEEP_ALIVE; }
35  };
36 
37  struct logger : package
38  {
39  logger() { type = (uint8_t)Type::LOGGER; }
40  char msg[30];
41  int32_t value = 0;
42  };
43 
44  struct sensor : package
45  {
46 
47  };
48 
49  struct actuator : package
50  {
51  };
52 
54  {
55  emergency_alarm() { type = (uint8_t)Type::EMERGENCY_ALARM; }
56  bool is_on = false;
57  };
58 
59  struct ultrasonic : sensor
60  {
61  ultrasonic() { type = (uint8_t)Type::ULTRASONIC; }
62  uint16_t distance_mm = 0;
63  };
64 
65  struct laser : sensor
66  {
67  laser() { type = (uint8_t)Type::LASER; }
68  uint16_t distance_mm = 0;
69  };
70 
71  struct imu : sensor
72  {
73  imu() { type = (uint8_t)Type::IMU; }
74  float roll_rad = 0,
75  pitch_rad = 0,
76  yaw_rad = 0,
77  accl_x_rad = 0,
78  accl_y_rad = 0,
79  accl_z_rad = 0,
80  gyro_x_rad = 0,
81  gyro_y_rad = 0,
82  gyro_z_rad = 0,
83  mag_x_rad = 0,
84  mag_y_rad = 0,
85  mag_z_rad = 0;
86  };
87 
88  struct gps : sensor
89  {
90  gps() { type = (uint8_t)Type::GPS; }
91  float lat = 0,
92  lon = 0;
93 
94  float speed = 0,
95  angle = 0;
96 
97  float elevation = 0;
98 
99  /* E, N, S, W */
100  char lat_mark = 0,
101  lon_mark = 0;
102 
103  uint8_t hour = 0,
104  minute = 0,
105  seconds = 0,
106  year = 0,
107  month = 0,
108  day = 0;
109 
110  uint8_t fix_quality = 0,
111  satellites = 0;
112 
113  bool fix = false;
114  };
115 
116 
117  struct servo : actuator
118  {
119  servo() { type = (uint8_t)Type::SERVO; }
120  uint16_t cmd = 0; //servo command 1000-2000
121  };
122  }
123 }
124 
125 
126 
127 #endif //PROTOCOL_H
const uint8_t HEADER_INDX
Definition: protocol.h:24
const uint8_t PKG_SIZE_INDX
Definition: protocol.h:25
const uint16_t MAX_PKG_SIZE
Definition: protocol.h:22
const uint8_t HEADER_CODE
Definition: protocol.h:23


ric_interface
Author(s):
autogenerated on Wed Jan 3 2018 03:48:20