41
41
namespace autoware ::multi_object_tracker
42
42
{
43
43
BicycleTracker::BicycleTracker (const rclcpp::Time & time, const types::DynamicObject & object)
44
- : Tracker(time, object), logger_(rclcpp::get_logger(" BicycleTracker" ))
44
+ : Tracker(time, object), logger_(rclcpp::get_logger(" BicycleTracker" )),
45
+ tracking_offset_ (Eigen::Vector2d::Zero())
45
46
{
46
47
// velocity deviation threshold
47
48
// if the predicted velocity is close to the observed velocity,
@@ -220,11 +221,25 @@ bool BicycleTracker::measureWithShape(const types::DynamicObject & object)
220
221
// update motion model
221
222
motion_model_.updateExtendedState (object_extension.x );
222
223
224
+ // update offset into object position
225
+ {
226
+ // rotate back the offset vector from object coordinate to global coordinate
227
+ const double yaw = motion_model_.getStateElement (IDX::YAW);
228
+ const double offset_x_global =
229
+ tracking_offset_.x () * std::cos (yaw) - tracking_offset_.y () * std::sin (yaw);
230
+ const double offset_y_global =
231
+ tracking_offset_.x () * std::sin (yaw) + tracking_offset_.y () * std::cos (yaw);
232
+ motion_model_.adjustPosition (-gain * offset_x_global, -gain * offset_y_global);
233
+ // update offset (object coordinate)
234
+ tracking_offset_.x () = gain_inv * tracking_offset_.x ();
235
+ tracking_offset_.y () = gain_inv * tracking_offset_.y ();
236
+ }
237
+
223
238
return true ;
224
239
}
225
240
226
241
bool BicycleTracker::measure (
227
- const types::DynamicObject & object , const rclcpp::Time & time,
242
+ const types::DynamicObject & in_object , const rclcpp::Time & time,
228
243
const types::InputChannel & channel_info)
229
244
{
230
245
// check time gap
@@ -238,9 +253,11 @@ bool BicycleTracker::measure(
238
253
}
239
254
240
255
// update object
241
- measureWithPose (object);
256
+ types::DynamicObject updating_object = in_object;
257
+ shapes::calcAnchorPointOffset (object_, tracking_offset_, updating_object);
258
+ measureWithPose (updating_object);
242
259
if (channel_info.trust_extension ) {
243
- measureWithShape (object );
260
+ measureWithShape (updating_object );
244
261
}
245
262
246
263
return true ;
0 commit comments