-
Notifications
You must be signed in to change notification settings - Fork 41
/
Apollo消息格式.cpp
392 lines (247 loc) · 14.6 KB
/
Apollo消息格式.cpp
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
人工发送prediction::PredictionObstacles消息
为提高消息处理的实时性和灵活性,Apollo 3.5的Planning模块不再基于定时器触发更新,而是基于三个输入消息的改变而动态更新,这三个输入消息分别为:prediction::PredictionObstacles、canbus::Chassis、localization::LocalizationEstimate。也就是说,只有上述三个消息同时存在时,Planning模块的消息处理函数PlanningComponent::Proc()才会被调用,而具体的某一类规划算法(例如OnLanePlanning)才会真正工作。
若某条消息因为特殊原因不能及时发送,解决办法就是人工生成假消息。例如,若不能收到prediction::PredictionObstacles消息,则可在在Docker内部通过如下命令生成假prediction::PredictionObstacles消息:
cyber_launch start /apollo/modules/tools/prediction/fake_prediction/fake_prediction.launch
1
该假消息的具体生成代码见/apollo/modules/tools/prediction/fake_prediction,其他假消息的生成可参照该示例撰写。
3.3.2 人工发送perception::TrafficLightDetection消息
调试规划算法时,需要动态改变红绿灯的信号状态,可以通过如下命令人工发送perception::TrafficLightDetection消息来实现:
cyber_launch start /apollo/modules/tools/manual_traffic_light/manual_traffic_light.launch
5.
protobuffer:
zy@zy:~/Desktop/proto$ protoc addressbook.proto --cpp_out=./
6. the pb.h and pb.cc files generated by bazel are localized in the path below:
root@apollo5-apollo-ubuntu14-1:/apollo/bazel-out/local-dbg/genfiles/modules/localization/proto#
7. IMU publish:
http://git.51vr.local/51World/Cybertron/blob/ue4.22/Modules/BridgeApollo/CybertronBridgeApolloCyber/TaskCyberChassisImu.cpp
mCyberImu.publish(angvelX, angvelY, angvelZ, linAccX, linAccY, linAccZ); # 70
8. http://git.51vr.local/51World/Cybertron/blob/ue4.22/Modules/BridgeApollo/CybertronBridgeApolloCyber/TaskCyberPointCloud.cpp
8.1 mCyberPointCloud.publish(
frame,
mPointCloud.width(),
mPointCloud.height(),
mPointCloud.pointstep(),
mPointCloud.data().data()
); //CyberWriterPointCloud::publish(int sequence, int width, int height, int step, const char *data)
8.2 CyberWriterPointCloud mCyberPointCloud; // CyberWriterPointCloud.hpp
cybertron::proto::sensor::DataPointCloud mPointCloud; // the mPointCloud which has been published
In cyvertron the Lidar protobuf:
cybertron::proto::sensor::DataPointCloud // PointCloud.pb.h
8.4 msg.toProtobuf(mPointCloud)
8.5
http://git.51vr.local/51World/Cybertron/blob/master/Modules/Unreal/UnrealNodeBase/CybertronUnrealNodeBase/UnrealSensorTask.cpp_out
void UnrealSensorTask::UpdateLaserRadarOutput(const UnrealBridge::SensorHeader& sensorHeader, int sensorId,
const std::vector<uint8_t>& pointCloudData,
const UnrealBridge::GroundTruthData& groundTruthData)
9. ROS sensor_msgs/PointCloud
以上是标准头信息的主要部分。seq是消息的顺序标识,不需要手动设置,发布节点在发布消息时,会自动累加。stamp 是消息中与数据相关联的时间戳,例如激光数据中,时间戳对应激光数据的采集时间点。frame_id 是消息中与数据相关联的参考系id,例如在在激光数据中,frame_id对应激光数据采集的参考系
#Standard metadata for higher-level flow data types
#sequence ID: consecutively increasing ID
uint32 seq
#Two-integer timestamp that is expressed as:
# * stamp.secs: seconds (stamp_secs) since epoch
# * stamp.nsecs: nanoseconds since stamp_secs
# time-handling sugar is provided by the client library
time stamp
#Frame this data is associated with
# 0: no frame
# 1: global frame
string frame_id
10. Apollo pointcloud.proto:
syntax = "proto2";
package apollo.drivers;
import "modules/common/proto/header.proto";
// 一帧点云
message PointXYZIT {
optional float x = 1 [default = nan]; //
optional float y = 2 [default = nan]; //
optional float z = 3 [default = nan]; //
optional uint32 intensity = 4 [default = 0]; //激光反射强度(Intensity
optional uint64 timestamp = 5 [default = 0]; // 每一个点的时间戳
}
message PointCloud {
optional apollo.common.Header header = 1; //
optional string frame_id = 2; //
optional bool is_dense = 3; //
repeated PointXYZIT point = 4;
optional double measurement_time = 5; //last_time_stamp_ = pointcloud->measurement_time();
optional uint32 width = 6; //
optional uint32 height = 7; //height与width是指点云数据的高和宽,一般无序点云的高为1,宽为点云中激光点的个数;结构化点云的高和宽均大于1。
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11. Cybretron PointCloud.proto
syntax = "proto3";
import "Common/Header.proto";
import "Sensor/ObstacleDetect.proto";
package cybertron.proto.sensor;
enum EPointCloudFieldName
{
EPointCloudFieldName_XYZ = 0; // float x 3
EPointCloudFieldName_Intensity = 1; // uint16
EPointCloudFieldName_Ring = 2; // uint16
EPointCloudFieldName_RGB = 3; // uint8 x 3
EPointCloudFieldName_Segmentation = 4; // uint8
EPointCloudFieldName_InstanceId = 5; // Int32
}
// refer to http://docs.ros.org/api/sensor_msgs/html/msg/PointField.html
enum EPointCloudFieldType
{
EPointCloudFieldType_Unused = 0;
EPointCloudFieldType_Int8 = 1;
EPointCloudFieldType_UInt8 = 2;
EPointCloudFieldType_Int16 = 3;
EPointCloudFieldType_UInt16 = 4;
EPointCloudFieldType_Int32 = 5;
EPointCloudFieldType_UInt32 = 6;
EPointCloudFieldType_Float = 7;
EPointCloudFieldType_Double = 8;
}
message PointCloudField{
EPointCloudFieldName name = 1; //name是指点云包含的域的名称,如“x”、“y”、“z”、“intensity”、“ring”等
uint32 offset = 2; //offset是指在data的每个数据中该域的偏移量
EPointCloudFieldType datatype = 3; //datatype是指以上1~8的数据类型
}
message DataPointCloud {
common.CybertronHeader header = 1;
// 2D structure of the point cloud.
// For unordered point cloud, height is 1 and width is point count of the point cloud.
uint32 width = 2;
uint32 height = 3;
// raw data fields definition.
repeated PointCloudField fields = 4;
// Length of a point in bytes
uint32 pointStep = 5; //pointstep表示每个点的字节长度,常见的为32
// raw data, size should be width * height * pointStep
bytes data = 6; //data表示所有的点的数据,以字节存储。uint8[] data代表vector类型,有size、push_back、clear等操作 // for(unsigned int i = 0; i < num_points; ++i){
// cloud.points[i].x = 0.1*i;
// cloud.points[i].y = 0.1*i;
// cloud.points[i].z = 5;
// cloud.channels[0].values[i] = 255;
// } // }
message PointCloudStamped{
common.Header header = 1;
DataPointCloud pointcloud = 2;
}
message PointCloudWithGroundTruth{
DataPointCloud pointcloud = 1;
GroundTruth ground_truth = 2;
}
5.
protobuffer:
zy@zy:~/Desktop/proto$ protoc addressbook.proto --cpp_out=./
6. the pb.h and pb.cc files generated by bazel are localized in the path below:
root@apollo5-apollo-ubuntu14-1:/apollo/bazel-out/local-dbg/genfiles/modules/localization/proto#
7. IMU publish:
http://git.51vr.local/51World/Cybertron/blob/ue4.22/Modules/BridgeApollo/CybertronBridgeApolloCyber/TaskCyberChassisImu.cpp
mCyberImu.publish(angvelX, angvelY, angvelZ, linAccX, linAccY, linAccZ); # 70
8. http://git.51vr.local/51World/Cybertron/blob/ue4.22/Modules/BridgeApollo/CybertronBridgeApolloCyber/TaskCyberPointCloud.cpp
8.1 mCyberPointCloud.publish(
frame,
mPointCloud.width(),
mPointCloud.height(),
mPointCloud.pointstep(),
mPointCloud.data().data()
); //CyberWriterPointCloud::publish(int sequence, int width, int height, int step, const char *data)
8.2 CyberWriterPointCloud mCyberPointCloud; // CyberWriterPointCloud.hpp
cybertron::proto::sensor::DataPointCloud mPointCloud; // the mPointCloud which has been published
In cyvertron the Lidar protobuf:
cybertron::proto::sensor::DataPointCloud // PointCloud.pb.h
8.4 msg.toProtobuf(mPointCloud)
8.5
http://git.51vr.local/51World/Cybertron/blob/master/Modules/Unreal/UnrealNodeBase/CybertronUnrealNodeBase/UnrealSensorTask.cpp_out
void UnrealSensorTask::UpdateLaserRadarOutput(const UnrealBridge::SensorHeader& sensorHeader, int sensorId,
const std::vector<uint8_t>& pointCloudData,
const UnrealBridge::GroundTruthData& groundTruthData)
9. ROS sensor_msgs/PointCloud
以上是标准头信息的主要部分。seq是消息的顺序标识,不需要手动设置,发布节点在发布消息时,会自动累加。stamp 是消息中与数据相关联的时间戳,例如激光数据中,时间戳对应激光数据的采集时间点。frame_id 是消息中与数据相关联的参考系id,例如在在激光数据中,frame_id对应激光数据采集的参考系
#Standard metadata for higher-level flow data types
#sequence ID: consecutively increasing ID
uint32 seq
#Two-integer timestamp that is expressed as:
# * stamp.secs: seconds (stamp_secs) since epoch
# * stamp.nsecs: nanoseconds since stamp_secs
# time-handling sugar is provided by the client library
time stamp
#Frame this data is associated with
# 0: no frame
# 1: global frame
string frame_id
10. Apollo pointcloud.proto:
syntax = "proto2";
package apollo.drivers;
import "modules/common/proto/header.proto";
// 一帧点云
message PointXYZIT {
optional float x = 1 [default = nan]; //
optional float y = 2 [default = nan]; //
optional float z = 3 [default = nan]; //
optional uint32 intensity = 4 [default = 0]; //激光反射强度(Intensity
optional uint64 timestamp = 5 [default = 0]; // 每一个点的时间戳
}
message PointCloud {
optional apollo.common.Header header = 1; //
optional string frame_id = 2; //
optional bool is_dense = 3; //
repeated PointXYZIT point = 4;
optional double measurement_time = 5; //last_time_stamp_ = pointcloud->measurement_time();
optional uint32 width = 6; //
optional uint32 height = 7; //height与width是指点云数据的高和宽,一般无序点云的高为1,宽为点云中激光点的个数;结构化点云的高和宽均大于1。
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11. Cybretron PointCloud.proto
syntax = "proto3";
import "Common/Header.proto";
import "Sensor/ObstacleDetect.proto";
package cybertron.proto.sensor;
enum EPointCloudFieldName
{
EPointCloudFieldName_XYZ = 0; // float x 3
EPointCloudFieldName_Intensity = 1; // uint16
EPointCloudFieldName_Ring = 2; // uint16
EPointCloudFieldName_RGB = 3; // uint8 x 3
EPointCloudFieldName_Segmentation = 4; // uint8
EPointCloudFieldName_InstanceId = 5; // Int32
}
// refer to http://docs.ros.org/api/sensor_msgs/html/msg/PointField.html
enum EPointCloudFieldType
{
EPointCloudFieldType_Unused = 0;
EPointCloudFieldType_Int8 = 1;
EPointCloudFieldType_UInt8 = 2;
EPointCloudFieldType_Int16 = 3;
EPointCloudFieldType_UInt16 = 4;
EPointCloudFieldType_Int32 = 5;
EPointCloudFieldType_UInt32 = 6;
EPointCloudFieldType_Float = 7;
EPointCloudFieldType_Double = 8;
}
message PointCloudField{
EPointCloudFieldName name = 1; //name是指点云包含的域的名称,如“x”、“y”、“z”、“intensity”、“ring”等
uint32 offset = 2; //offset是指在data的每个数据中该域的偏移量
EPointCloudFieldType datatype = 3; //datatype是指以上1~8的数据类型
}
message DataPointCloud {
common.CybertronHeader header = 1;
// 2D structure of the point cloud.
// For unordered point cloud, height is 1 and width is point count of the point cloud.
uint32 width = 2;
uint32 height = 3;
// raw data fields definition.
repeated PointCloudField fields = 4;
// Length of a point in bytes
uint32 pointStep = 5; //pointstep表示每个点的字节长度,常见的为32
// raw data, size should be width * height * pointStep
bytes data = 6; //data表示所有的点的数据,以字节存储。uint8[] data代表vector类型,有size、push_back、clear等操作 // for(unsigned int i = 0; i < num_points; ++i){
// cloud.points[i].x = 0.1*i;
// cloud.points[i].y = 0.1*i;
// cloud.points[i].z = 5;
// cloud.channels[0].values[i] = 255;
// } // }
message PointCloudStamped{
common.Header header = 1;
DataPointCloud pointcloud = 2;
}
message PointCloudWithGroundTruth{
DataPointCloud pointcloud = 1;
GroundTruth ground_truth = 2;
}