Apollo 11.0
自动驾驶开放平台
test_tools.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#include <fstream>
18#include <iostream>
19#include <string>
20#include <vector>
21
23
24namespace apollo {
25namespace v2x {
26namespace ft {
27
28bool LoadData(const std::string& file, std::vector<base::Object>* objects,
29 const std::string& frame_id) {
30 std::fstream fin;
31 fin.open(file.c_str(), std::ios::in);
32 if (!fin) {
33 return false;
34 }
35 std::string line;
36 while (getline(fin, line)) {
37 std::istringstream iss(line);
38 float sub_type_probs, x, y, z, xx, xy, xz, yx, yy, yz, zx, zy, zz;
39 Eigen::Vector3d pos;
40 Eigen::Matrix3d var;
41 int type, sub_type;
42 iss >> type >> sub_type >> sub_type_probs >> x >> y >> z >> xx >> xy >>
43 xz >> yx >> yy >> yz >> zx >> zy >> zz;
44 pos << x, y, z;
45 var << xx, xy, xz, yx, yy, yz, zx, zy, zz;
46 base::Object obj;
47 obj.type = base::ObjectType::VEHICLE;
48 Eigen::Vector3d car_size, bus_size, van_size;
49 Eigen::Matrix3d id_var;
50 car_size << 4.2, 2.0, 1.8;
51 bus_size << 12, 2.2, 3;
52 van_size << 4.5, 2.1, 2;
53 id_var << 1, 0, 0, 0, 1, 0, 0, 0, 1;
54 switch (sub_type) {
55 case 3:
56 obj.sub_type = base::ObjectSubType::CAR;
57 obj.size.Set(car_size, id_var);
58 break;
59 case 4:
60 obj.sub_type = base::ObjectSubType::VAN;
61 obj.size.Set(van_size, id_var);
62 break;
63 case 5:
64 obj.sub_type = base::ObjectSubType::BUS;
65 obj.size.Set(bus_size, id_var);
66 break;
67 default:
68 break;
69 }
70 obj.sensor_type = base::SensorType::MONOCULAR_CAMERA;
71 obj.frame_id = frame_id;
72 obj.position.Set(pos, var);
73 obj.theta.Set(0, 1);
74 obj.type_probs.push_back(0.9f);
75 obj.sub_type_probs.push_back(sub_type_probs);
76 objects->push_back(obj);
77 }
78 return true;
79}
80
81} // namespace ft
82} // namespace v2x
83} // namespace apollo
void Set(Val value, Var variance)
Definition v2x_object.h:77
bool LoadData(const std::string &file, std::vector< base::Object > *objects, const std::string &frame_id)
Definition test_tools.h:28
class register implement
Definition arena_queue.h:37
std::vector< float > type_probs
Definition v2x_object.h:188
std::vector< float > sub_type_probs
Definition v2x_object.h:192