Apollo 11.0
自动驾驶开放平台
v2x_object.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#pragma once
18
19#include <memory>
20#include <string>
21#include <vector>
22
23#include <Eigen/Core>
24
25#include "absl/strings/str_cat.h"
26
30
31namespace apollo {
32namespace v2x {
33namespace ft {
34namespace base {
35
41
42enum class V2xType {
43 UNKNOWN = 0,
44 ZOMBIES_CAR = 1,
45 BLIND_ZONE = 2,
46 HOST_VEHICLE = 13,
47};
48
49enum class MessageType {
51 ROADSIDE = 0,
52 VEHICLE = 1,
53};
54
55// Value and Variance
56template <typename Val, typename Var>
57class Info {
58 public:
59 Info() = default;
60 Info(Val val, Var var) {
61 value_ = val;
62 variance_ = var;
63 }
64 ~Info() = default;
65 // Info(const Info &) = delete;
66 Info(const Info &rhs) {
67 value_ = rhs.value_;
68 variance_ = rhs.variance_;
69 }
70 // Info &operator=(const Info &) = delete;
71 Info &operator=(const Info &rhs) {
72 value_ = rhs.value_;
73 variance_ = rhs.variance_;
74 return *this;
75 }
76
77 void Set(Val value, Var variance) {
78 value_ = value;
79 variance_ = variance;
80 }
81 Val Value() const { return value_; }
82
83 Var Variance() const { return variance_; }
84
85 protected:
86 Val value_ = {};
87 Var variance_ = {};
88};
89
90class Info3f : public Info<Eigen::Vector3f, Eigen::Matrix3f> {
91 public:
93 value_.setZero();
94 variance_.setZero();
95 }
96 ~Info3f() = default;
97
98 float x() const { return value_(0); }
99
100 float y() const { return value_(1); }
101
102 float z() const { return value_(2); }
103
104 float length() const { return value_(0); }
105
106 float width() const { return value_(1); }
107
108 float height() const { return value_(2); }
109};
110
111class Info3d : public Info<Eigen::Vector3d, Eigen::Matrix3d> {
112 public:
113 double x() const { return value_(0); }
114
115 double y() const { return value_(1); }
116
117 double z() const { return value_(2); }
118
119 double length() const { return value_(0); }
120
121 double width() const { return value_(1); }
122
123 double height() const { return value_(2); }
124};
125
126struct alignas(16) Object {
132 typedef Eigen::Vector2f Point2f;
133 typedef Eigen::Vector3f Point3f;
134 Object() : is_temporary_lost(false, 0.0) {}
135 ~Object() = default;
136 Object(const Object &) = default;
137 Object &operator=(const Object &) = default;
138 bool operator<(const Object &rhs) const { return timestamp < rhs.timestamp; }
139 bool operator>(const Object &rhs) const { return timestamp > rhs.timestamp; }
140 bool operator==(const Object &rhs) const {
141 return timestamp == rhs.timestamp;
142 }
143 std::string ToString() const;
144 void Reset();
145 // camera, lidar, radar and others
146 SensorType sensor_type = SensorType::UNKNOWN_SENSOR_TYPE;
147 // ROADSIDE
149 // @brief sensor-specific object supplements, optional
152 // message timestamp
153 double timestamp = 0.0;
154 // original sensor timestamp
155 double sensor_timestamp = 0.0;
156 // @brief age of the tracked object, required
157 double tracking_time = 0.0;
158 // @brief timestamp of latest measurement, required
160 std::string frame_id = "";
161 // @brief track id, required
162 int track_id = -1;
163 // @breif object id per frame, required
164 int global_id = -1;
165 // @brief center position of the boundingbox (x, y, z), required
167 // @brief anchor point, required
169 // 0-2Pi from east
171 // @brief theta variance, required
173 // @brief main direction of the object, required
175 /* @brief size = [length, width, height] of boundingbox
176 length is the size of the main direction, required
177 */
179 // @brief convex hull of the object, required
180 // Point3f polygon;
181 // @brief object type, required
182 ObjectType type = ObjectType::UNKNOWN;
183
185 // @brief type variance, required
186 double type_variance = 1.0;
187 // @brief probability for each type, required
188 std::vector<float> type_probs;
189 // @brief object sub-type, optional
190 ObjectSubType sub_type = ObjectSubType::UNKNOWN;
191 // @brief probability for each sub-type, optional
192 std::vector<float> sub_type_probs;
193
194 std::vector<std::vector<Info3d>> tentacles;
195
196 std::vector<Info3d> polygon;
197
198 // tracking information
199 // @brief the variance of tracked
201 // @brief velocity of the object, required
203 // @brief acceleration of the object, required
205 // @brief motion state of the tracked object, required
207
209 std::string DebugString() const {
210 return absl::StrCat("id: ", track_id, ", ", //
211 "time: ", timestamp, ", ", //
212 "sensor type: ", sensor_type, ", ", //
213 "x: ", position.x(), ", ", //
214 "y: ", position.y(), ", ", //
215 "vx: ", velocity.x(), ", ", //
216 "vy: ", velocity.y(), ", ", //
217 "yaw: ", theta.Value());
218 }
219};
220
221typedef std::shared_ptr<Object> ObjectPtr;
222typedef std::shared_ptr<const Object> ObjectConstPtr;
223
224struct alignas(16) ObjectList {
225 ObjectList() = default;
226 ~ObjectList() = default;
227 ObjectList(const ObjectList &) = default;
228 ObjectList &operator=(const ObjectList &) = default;
229 bool operator<(const ObjectList &rhs) const {
230 return timestamp < rhs.timestamp;
231 }
232 bool operator>(const ObjectList &rhs) const {
233 return timestamp > rhs.timestamp;
234 }
235 bool operator==(const ObjectList &rhs) const {
236 return timestamp == rhs.timestamp;
237 }
238
239 SensorType sensor_type;
240 // @brief sensor-specific object supplements, optional
242 // LidarObjectSupplement lidar_supplement;
243 // RadarObjectSupplement radar_supplement;
245
246 // message timestamp
247 double timestamp = 0.0;
248 // original sensor timestamp
249 double sensor_timestamp = 0.0;
250 // @brief age of the tracked object, require
251 std::string frame_id = "";
252
253 std::vector<ObjectPtr> objects;
254};
255
256typedef std::shared_ptr<ObjectList> ObjectListPtr;
257typedef std::shared_ptr<const ObjectList> ObjectListConstPtr;
258
259} // namespace base
260} // namespace ft
261} // namespace v2x
262} // namespace apollo
Info & operator=(const Info &rhs)
Definition v2x_object.h:71
Info(const Info &rhs)
Definition v2x_object.h:66
Info(Val val, Var var)
Definition v2x_object.h:60
void Set(Val value, Var variance)
Definition v2x_object.h:77
SensorType
Sensor types are set in the order of lidar, radar, camera, ultrasonic Please make sure SensorType has...
Definition sensor_meta.h:29
std::shared_ptr< const Object > ObjectConstPtr
Definition v2x_object.h:222
std::shared_ptr< Object > ObjectPtr
Definition v2x_object.h:221
std::shared_ptr< const ObjectList > ObjectListConstPtr
Definition v2x_object.h:257
std::shared_ptr< ObjectList > ObjectListPtr
Definition v2x_object.h:256
class register implement
Definition arena_queue.h:37
ObjectList(const ObjectList &)=default
bool operator<(const ObjectList &rhs) const
Definition v2x_object.h:229
std::vector< ObjectPtr > objects
Definition v2x_object.h:253
ObjectList & operator=(const ObjectList &)=default
bool operator>(const ObjectList &rhs) const
Definition v2x_object.h:232
bool operator==(const ObjectList &rhs) const
Definition v2x_object.h:235
FusionObjectSupplement fusion_supplement
Definition v2x_object.h:244
CameraObjectSupplement camera_supplement
Definition v2x_object.h:241
std::vector< Info3d > polygon
Definition v2x_object.h:196
bool operator<(const Object &rhs) const
Definition v2x_object.h:138
Info< double, double > Infod
Definition v2x_object.h:129
std::string ToString() const
std::vector< float > type_probs
Definition v2x_object.h:188
FusionObjectSupplement fusion_supplement
Definition v2x_object.h:151
std::string DebugString() const
Definition v2x_object.h:209
bool operator>(const Object &rhs) const
Definition v2x_object.h:139
std::vector< float > sub_type_probs
Definition v2x_object.h:192
CameraObjectSupplement camera_supplement
Definition v2x_object.h:150
Info< bool, float > Infob
Definition v2x_object.h:127
Info< Eigen::Vector2d, Eigen::Matrix2d > Info2d
Definition v2x_object.h:131
Object & operator=(const Object &)=default
std::vector< std::vector< Info3d > > tentacles
Definition v2x_object.h:194
Object(const Object &)=default
Info< float, float > Infof
Definition v2x_object.h:128
bool operator==(const Object &rhs) const
Definition v2x_object.h:140
Info< Eigen::Vector2f, Eigen::Matrix2f > Info2f
Definition v2x_object.h:130