Apollo  6.0
Open source self driving car software
test_tools.h
Go to the documentation of this file.
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 
24 namespace apollo {
25 namespace v2x {
26 namespace ft {
27 
28 bool 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;
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
bool LoadData(const std::string &file, std::vector< base::Object > *objects, const std::string &frame_id)
Definition: test_tools.h:28
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
ObjectType type
Definition: v2x_object.h:182
SensorType sensor_type
Definition: v2x_object.h:146
Definition: v2x_object.h:126
Eigen::Vector3d Vector3d
Definition: frame_transform.h:27
std::string frame_id
Definition: v2x_object.h:160
std::vector< float > sub_type_probs
Definition: v2x_object.h:192
void Set(Val value, Var variance)
Definition: v2x_object.h:77
Infod theta
Definition: v2x_object.h:170
std::vector< float > type_probs
Definition: v2x_object.h:188
Eigen::Matrix3d Matrix3d
Definition: base_map_fwd.h:33
ObjectSubType sub_type
Definition: v2x_object.h:190
Info3d size
Definition: v2x_object.h:178
Info3d position
Definition: v2x_object.h:166