@@ -34,9 +34,7 @@ enum AgentLabel { VEHICLE = 0, PEDESTRIAN = 1, CYCLIST = 2 };
34
34
*/
35
35
struct AgentState
36
36
{
37
- /* *
38
- * @brief Construct a new instance filling all elements by `0.0f`.
39
- */
37
+ // Construct a new instance filling all elements by `0.0f`.
40
38
AgentState () : data_({0 .0f }) {}
41
39
42
40
/* *
@@ -84,33 +82,49 @@ struct AgentState
84
82
std::copy (itr, itr + dim (), data_.begin ());
85
83
}
86
84
87
- static size_t dim () { return AgentStateDim; }
88
-
89
- /* *
90
- * @brief Construct a new instance filling all elements by `0.0f`.
91
- *
92
- * @return AgentState
93
- */
85
+ // Construct a new instance filling all elements by `0.0f`.
94
86
static AgentState empty () noexcept { return AgentState (); }
95
87
96
- /* *
97
- * @brief Return the address pointer of data array.
98
- *
99
- * @return float*
100
- */
88
+ // Return the agent state dimensions `D`.
89
+ static size_t dim () { return AgentStateDim; }
90
+
91
+ // Return the address pointer of data array.
101
92
float * data_ptr () noexcept { return data_.data (); }
102
93
94
+ // Return the x position.
103
95
float x () const { return x_; }
96
+
97
+ // Return the y position.
104
98
float y () const { return y_; }
99
+
100
+ // Return the z position.
105
101
float z () const { return z_; }
102
+
103
+ // Return the length of object size.
106
104
float length () const { return length_; }
105
+
106
+ // Return the width of object size.
107
107
float width () const { return width_; }
108
+
109
+ // Return the height of object size.
108
110
float height () const { return height_; }
111
+
112
+ // Return the yaw angle `[rad]`.
109
113
float yaw () const { return yaw_; }
114
+
115
+ // Return the x velocity.
110
116
float vx () const { return vx_; }
117
+
118
+ // Return the y velocity.
111
119
float vy () const { return vy_; }
120
+
121
+ // Return the x acceleration.
112
122
float ax () const { return ax_; }
123
+
124
+ // Return the y acceleration.
113
125
float ay () const { return ay_; }
126
+
127
+ // Return `true` if the value is `1.0`.
114
128
bool is_valid () const { return is_valid_ == 1 .0f ; }
115
129
116
130
private:
@@ -163,34 +177,19 @@ struct AgentHistory
163
177
{
164
178
}
165
179
166
- static size_t state_dim () { return AgentStateDim; }
167
-
168
- /* *
169
- * @brief Return the history length.
170
- *
171
- * @return size_t History length.
172
- */
180
+ // Return the history time length `T`.
173
181
size_t length () const { return max_time_length_; }
174
182
175
- /* *
176
- * @brief Return the data size of history `T * D`.
177
- *
178
- * @return size_t
179
- */
183
+ // Return the number of agent state dimensions `D`.
184
+ static size_t state_dim () { return AgentStateDim; }
185
+
186
+ // Return the data size of history `T * D`.
180
187
size_t size () const { return max_time_length_ * state_dim (); }
181
188
182
- /* *
183
- * @brief Return the shape of history matrix ordering in `(T, D)`.
184
- *
185
- * @return std::tuple<size_t, size_t>
186
- */
189
+ // Return the shape of history matrix ordering in `(T, D)`.
187
190
std::tuple<size_t , size_t > shape () const { return {max_time_length_, state_dim ()}; }
188
191
189
- /* *
190
- * @brief Return the object id.
191
- *
192
- * @return const std::string&
193
- */
192
+ // Return the object id.
194
193
const std::string & object_id () const { return object_id_; }
195
194
196
195
size_t label_index () const { return label_index_; }
@@ -220,10 +219,7 @@ struct AgentHistory
220
219
latest_time_ = current_time;
221
220
}
222
221
223
- /* *
224
- * @brief Update history with all-zeros state, but latest time is not updated.
225
- *
226
- */
222
+ // Update history with all-zeros state, but latest time is not updated.
227
223
void update_empty () noexcept
228
224
{
229
225
// remove the state at the oldest timestamp
@@ -235,11 +231,7 @@ struct AgentHistory
235
231
}
236
232
}
237
233
238
- /* *
239
- * @brief Return the address pointer of data array.
240
- *
241
- * @return float* The pointer of data array.
242
- */
234
+ // Return the address pointer of data array.
243
235
float * data_ptr () noexcept { return data_.data (); }
244
236
245
237
/* *
@@ -264,11 +256,7 @@ struct AgentHistory
264
256
*/
265
257
bool is_valid_latest () const { return get_latest_state ().is_valid (); }
266
258
267
- /* *
268
- * @brief Get the latest agent state.
269
- *
270
- * @return AgentState
271
- */
259
+ // Get the latest agent state at `T`.
272
260
AgentState get_latest_state () const
273
261
{
274
262
const auto & latest_itr = (data_.begin () + state_dim () * (max_time_length_ - 1 ));
@@ -338,49 +326,55 @@ struct AgentData
338
326
}
339
327
}
340
328
341
- static size_t state_dim () { return AgentStateDim; }
329
+ // Return the number of classes `C`.
342
330
static size_t num_class () { return 3 ; } // TODO(ktro2828): Do not use magic number.
331
+
332
+ // Return the number of target agents `B`.
343
333
size_t num_target () const { return num_target_; }
334
+
335
+ // Return the number of agents `N`.
344
336
size_t num_agent () const { return num_agent_; }
337
+
338
+ // Return the timestamp length `T`.
345
339
size_t time_length () const { return time_length_; }
340
+
341
+ // Return the number of agent state dimensions `D`.
342
+ static size_t state_dim () { return AgentStateDim; }
343
+
344
+ // Return the index of ego.
346
345
int sdc_index () const { return sdc_index_; }
346
+
347
+ // Return the vector of indices of target agents, in shape `[B]`.
347
348
const std::vector<size_t > & target_index () const { return target_index_; }
349
+
350
+ // Return the vector of label indices of all agents, in shape `[N]`.
348
351
const std::vector<size_t > & label_index () const { return label_index_; }
352
+
353
+ // Return the vector of label indices of target agents, in shape `[B]`.
349
354
const std::vector<size_t > & target_label_index () const { return target_label_index_; }
355
+
356
+ // Return the vector of timestamps in shape `[T]`.
350
357
const std::vector<float > & timestamps () const { return timestamps_; }
351
358
359
+ // Return the number of all elements `N*T*D`.
352
360
size_t size () const { return num_agent_ * time_length_ * state_dim (); }
353
- size_t input_dim () const { return num_agent_ + time_length_ + num_class () + 3 ; }
354
361
355
- /* *
356
- * @brief Return the data shape ordering in (N, T, D).
357
- *
358
- * @return std::tuple<size_t, size_t, size_t>
359
- */
362
+ // Return the number of state dimensions of MTR input `T+C+D+3`.
363
+ size_t input_dim () const { return time_length_ + state_dim () + num_class () + 3 ; }
364
+
365
+ // Return the data shape ordering in (N, T, D).
360
366
std::tuple<size_t , size_t , size_t > shape () const
361
367
{
362
368
return {num_agent_, time_length_, state_dim ()};
363
369
}
364
370
365
- /* *
366
- * @brief Return the address pointer of data array.
367
- *
368
- * @return float* The pointer of data array.
369
- */
371
+ // Return the address pointer of data array.
370
372
float * data_ptr () noexcept { return data_.data (); }
371
373
372
- /* *
373
- * @brief Return the address pointer of data array for target agents.
374
- *
375
- * @return float* The pointer of data array for target agents.
376
- */
374
+ // Return the address pointer of data array for target agents.
377
375
float * target_data_ptr () noexcept { return target_data_.data (); }
378
376
379
- /* *
380
- * @brief Return the address pointer of data array for ego vehicle.
381
- *
382
- * @return float* The pointer of data array for ego vehicle.
383
- */
377
+ // Return the address pointer of data array for ego vehicle.
384
378
float * ego_data_ptr () noexcept { return ego_data_.data (); }
385
379
386
380
private:
@@ -397,6 +391,7 @@ struct AgentData
397
391
std::vector<float > ego_data_;
398
392
};
399
393
394
+ // Get label names from label indices.
400
395
std::vector<std::string> getLabelNames (const std::vector<size_t > & label_index)
401
396
{
402
397
std::vector<std::string> label_names;
0 commit comments