1 | #ifndef LIB3DV_DETAIL_PROTOCOL_H
|
---|
2 | #define LIB3DV_DETAIL_PROTOCOL_H
|
---|
3 |
|
---|
4 | /* lib3dv/detail/protocol.h
|
---|
5 | *
|
---|
6 | * Copyright (C) 2013 VisLab
|
---|
7 | *
|
---|
8 | * This file is part of 3dv-client; you can redistribute it and/or modify
|
---|
9 | * it under the terms of the GNU Lesser General Public License as published by
|
---|
10 | * the Free Software Foundation; either version 3 of the License, or (at
|
---|
11 | * your option) any later version.
|
---|
12 | *
|
---|
13 | * This program is distributed in the hope that it will be useful, but
|
---|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
16 | * General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU Lesser General Public License
|
---|
19 | * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "declspecs.h"
|
---|
23 |
|
---|
24 | #include <stdint.h>
|
---|
25 |
|
---|
26 | namespace protocol
|
---|
27 | {
|
---|
28 | /**
|
---|
29 | * @brief Possible payload types.
|
---|
30 | **/
|
---|
31 | struct payload
|
---|
32 | {
|
---|
33 | enum types
|
---|
34 | {
|
---|
35 | IMAGE_INFO_HEADER = 0, ///< image info header.
|
---|
36 | IMAGE_DATA, ///< image data.
|
---|
37 | TERRAIN_INFO_HEADER,
|
---|
38 | TERRAIN_DATA,
|
---|
39 | OBSTACLES_MAP_INFO_HEADER,
|
---|
40 | OBSTACLES_MAP_DATA,
|
---|
41 | COMMAND,
|
---|
42 | KEEP_ALIVE,
|
---|
43 | MOTION_INFO_HEADER,
|
---|
44 | MOTION_DATA,
|
---|
45 | CLASSIFICATION_INFO_HEADER,
|
---|
46 | CLASSIFICATION_DATA,
|
---|
47 | NUM
|
---|
48 | };
|
---|
49 | };
|
---|
50 |
|
---|
51 | struct version
|
---|
52 | {
|
---|
53 | static const unsigned char MAX_SUPPORTED = 10;
|
---|
54 | };
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * @brief An image info packet.
|
---|
58 | **/
|
---|
59 | DECLSPEC_PACKED(
|
---|
60 | struct image_info_header
|
---|
61 | {
|
---|
62 | uint32_t m_size; ///< image data buffer size [bytes].
|
---|
63 | uint16_t m_width; ///< image width [px].
|
---|
64 | uint16_t m_height; ///< image height [px].
|
---|
65 | uint8_t m_channels; ///< image channels.
|
---|
66 | uint8_t m_bpp; ///< image bytes per pixel [Bpp].
|
---|
67 | uint8_t m_type; ///< image type. @see protocol::image_type
|
---|
68 | uint8_t m_format; ///< image format. @see protocol::image_format
|
---|
69 | int64_t m_timestamp; ///< image timestamp. Measures elapsed time from linux epoch (1970-1-1) to the beginning of processing [usec].
|
---|
70 | });
|
---|
71 |
|
---|
72 | DECLSPEC_PACKED(
|
---|
73 | struct terrain_info_header
|
---|
74 | {
|
---|
75 | uint32_t m_size; ///< terrain data size [bytes].
|
---|
76 | int16_t m_x_min; ///< minimum x distance [cm].
|
---|
77 | uint8_t m_x_cell_num; ///< x cells number.
|
---|
78 | uint8_t m_x_cell_size; ///< size of a cell, x direction [cm].
|
---|
79 | int16_t m_y_min; ///< minimum y distance [cm].
|
---|
80 | uint8_t m_y_cell_num; ///< y cells number.
|
---|
81 | uint8_t m_y_cell_size; ///< the size of a cell, y direction [cm].
|
---|
82 | });
|
---|
83 |
|
---|
84 | DECLSPEC_PACKED(
|
---|
85 | struct obstacles_map_info_header
|
---|
86 | {
|
---|
87 | uint32_t m_size; ///< obstacles data size [bytes].
|
---|
88 | uint16_t m_obstacles_num; ///< obstacles number.
|
---|
89 | });
|
---|
90 |
|
---|
91 | DECLSPEC_PACKED(
|
---|
92 | struct obstacle_info_header
|
---|
93 | {
|
---|
94 | uint32_t m_guid; ///< obstacle guid.
|
---|
95 | uint16_t m_stixel_num; ///< stixels number.
|
---|
96 | });
|
---|
97 |
|
---|
98 | DECLSPEC_PACKED(
|
---|
99 | struct classifier_info_header
|
---|
100 | {
|
---|
101 | uint32_t m_size;
|
---|
102 | uint16_t m_candidates_num;
|
---|
103 | int64_t m_timestamp;
|
---|
104 | });
|
---|
105 |
|
---|
106 | DECLSPEC_PACKED(
|
---|
107 | struct classifier_data
|
---|
108 | {
|
---|
109 | uint32_t m_guid;
|
---|
110 | uint16_t m_x0; ///box coordinate in right image.
|
---|
111 | uint16_t m_y0;
|
---|
112 | uint16_t m_x1;
|
---|
113 | uint16_t m_y1;
|
---|
114 | uint32_t m_confidence; ///< confidence of the detection.
|
---|
115 | uint8_t m_category; ///< category.
|
---|
116 | //uint32_t m_wp_lb_x;
|
---|
117 | //uint32_t m_wp_lb_y;
|
---|
118 | //uint32_t m_wp_lb_z;
|
---|
119 |
|
---|
120 |
|
---|
121 | });
|
---|
122 |
|
---|
123 | DECLSPEC_PACKED(
|
---|
124 | struct stixel
|
---|
125 | {
|
---|
126 | uint16_t m_dx; ///< stixel size (X axis) [cm].
|
---|
127 | uint16_t m_dy; ///< stixel size (Y axis) [cm].
|
---|
128 | int16_t m_x; ///< stixel X position [cm];
|
---|
129 | int16_t m_y; ///< stixel Y position [cm];
|
---|
130 | int16_t m_z; ///< stixel Z position [cm];
|
---|
131 | uint16_t m_height; ///< stixel height [cm];
|
---|
132 | });
|
---|
133 |
|
---|
134 | DECLSPEC_PACKED(
|
---|
135 | struct motion_info_header
|
---|
136 | {
|
---|
137 | uint32_t m_size; ///< pose data size [bytes].
|
---|
138 | uint16_t m_poses_num; ///< poses number.
|
---|
139 | });
|
---|
140 |
|
---|
141 |
|
---|
142 | DECLSPEC_PACKED(
|
---|
143 | struct pose_info_header
|
---|
144 | {
|
---|
145 | uint32_t m_size; ///< pose data size [bytes].
|
---|
146 | uint8_t m_type; ///< pose type @see lib3dv::pose
|
---|
147 | uint16_t m_pose_num; ///< pose element number
|
---|
148 | int64_t m_timestamp; ///< pose timestamp. Measures elapsed time from linux epoch (1970-1-1) to the beginning of processing [usec].
|
---|
149 | });
|
---|
150 |
|
---|
151 | /**
|
---|
152 | * @brief A data packet header.
|
---|
153 | **/
|
---|
154 | DECLSPEC_PACKED(
|
---|
155 | struct data_header
|
---|
156 | {
|
---|
157 | uint32_t m_offset; ///< data offset [bytes].
|
---|
158 | });
|
---|
159 |
|
---|
160 | /**
|
---|
161 | * @brief A device info packet.
|
---|
162 | **/
|
---|
163 | DECLSPEC_PACKED(
|
---|
164 | struct device_info
|
---|
165 | {
|
---|
166 | uint8_t m_guid[16]; ///< device guid.
|
---|
167 | uint16_t m_capabilities; ///< device capabilities.
|
---|
168 | uint8_t m_application_version[3]; ///< application version (0 -> major, 1 -> minor, 2 -> step).
|
---|
169 | uint8_t m_framework_version[3]; ///< application version (0 -> major, 1 -> minor, 2 -> step).
|
---|
170 | });
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * @brief A command packet.
|
---|
174 | **/
|
---|
175 | DECLSPEC_PACKED(
|
---|
176 | struct command_header
|
---|
177 | {
|
---|
178 | uint32_t m_size;
|
---|
179 | uint8_t m_type;
|
---|
180 | });
|
---|
181 |
|
---|
182 | /**
|
---|
183 | * @brief A propertys list info header.
|
---|
184 | **/
|
---|
185 | DECLSPEC_PACKED(
|
---|
186 | struct params_info_header
|
---|
187 | {
|
---|
188 | uint16_t m_params_num;
|
---|
189 | });
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * @brief A property info.
|
---|
193 | **/
|
---|
194 | DECLSPEC_PACKED(
|
---|
195 | struct param_info
|
---|
196 | {
|
---|
197 | uint8_t m_value_type;
|
---|
198 | uint16_t m_value_address;
|
---|
199 | uint8_t m_category;
|
---|
200 | uint8_t m_readonly;
|
---|
201 | uint8_t m_value_description_size;
|
---|
202 | });
|
---|
203 |
|
---|
204 | /**
|
---|
205 | * @brief A generic packet header.
|
---|
206 | **/
|
---|
207 | DECLSPEC_PACKED(
|
---|
208 | struct packet_header
|
---|
209 | {
|
---|
210 | uint8_t m_magic[4];
|
---|
211 | uint8_t m_protocol_version;
|
---|
212 | uint32_t m_guid;
|
---|
213 | uint32_t m_fragment;
|
---|
214 | uint32_t m_total_fragments;
|
---|
215 | uint8_t m_error;
|
---|
216 | uint8_t m_payload_type;
|
---|
217 | });
|
---|
218 | }
|
---|
219 |
|
---|
220 | #endif
|
---|