@@ -323,6 +323,24 @@ autoware_auto_perception_msgs::msg::TrackedObjectKinematics objectKinematicsVXMe
323
323
autoware_auto_perception_msgs::msg::TrackedObjectKinematics output_kinematics;
324
324
// copy main object at first
325
325
output_kinematics = main_obj.kinematics ;
326
+ // if the main object is run opposite direction, flip the main object
327
+ if (output_kinematics.twist_with_covariance .twist .linear .x < 0.0 ) {
328
+ // flip velocity
329
+ output_kinematics.twist_with_covariance .twist .linear .x *= -1.0 ;
330
+ output_kinematics.twist_with_covariance .twist .linear .y *= -1.0 ;
331
+ // flip orientation, convert quaternion to have the opposite direction
332
+ const auto q = tf2::Quaternion (
333
+ output_kinematics.pose_with_covariance .pose .orientation .x ,
334
+ output_kinematics.pose_with_covariance .pose .orientation .y ,
335
+ output_kinematics.pose_with_covariance .pose .orientation .z ,
336
+ output_kinematics.pose_with_covariance .pose .orientation .w );
337
+ const auto q_flip = q * tf2::Quaternion (0 , 0 , 1 , 0 );
338
+ output_kinematics.pose_with_covariance .pose .orientation .x = q_flip.x ();
339
+ output_kinematics.pose_with_covariance .pose .orientation .y = q_flip.y ();
340
+ output_kinematics.pose_with_covariance .pose .orientation .z = q_flip.z ();
341
+ output_kinematics.pose_with_covariance .pose .orientation .w = q_flip.w ();
342
+ }
343
+
326
344
auto sub_obj_ = sub_obj;
327
345
// do not merge reverse direction objects
328
346
if (!objectsHaveSameMotionDirections (main_obj, sub_obj)) {
0 commit comments