@@ -282,15 +282,39 @@ bool EKFModule::measurement_update_pose(
282
282
return true ;
283
283
}
284
284
285
- geometry_msgs::msg::PoseWithCovarianceStamped EKFModule::compensate_pose_with_z_delay (
286
- const PoseWithCovariance & pose, const double delay_time)
285
+ geometry_msgs::msg::PoseWithCovarianceStamped EKFModule::compensate_rph_with_delay (
286
+ const PoseWithCovariance & pose, tf2::Vector3 last_angular_velocity, const double delay_time)
287
287
{
288
- const auto rpy = autoware::universe_utils::getRPY (pose.pose .pose .orientation );
289
- const double dz_delay = kalman_filter_.getXelement (IDX::VX) * delay_time * std::sin (-rpy.y );
290
- PoseWithCovariance pose_with_z_delay;
291
- pose_with_z_delay = pose;
292
- pose_with_z_delay.pose .pose .position .z += dz_delay;
293
- return pose_with_z_delay;
288
+ tf2::Quaternion delta_orientation;
289
+ if (last_angular_velocity.length () > 0.0 ) {
290
+ delta_orientation.setRotation (
291
+ last_angular_velocity.normalized (), last_angular_velocity.length () * delay_time);
292
+ } else {
293
+ delta_orientation.setValue (0.0 , 0.0 , 0.0 , 1.0 );
294
+ }
295
+
296
+ tf2::Quaternion prev_orientation = tf2::Quaternion (
297
+ pose.pose .pose .orientation .x , pose.pose .pose .orientation .y , pose.pose .pose .orientation .z ,
298
+ pose.pose .pose .orientation .w );
299
+
300
+ tf2::Quaternion curr_orientation;
301
+ curr_orientation = prev_orientation * delta_orientation;
302
+ curr_orientation.normalize ();
303
+
304
+ PoseWithCovariance pose_with_delay;
305
+ pose_with_delay = pose;
306
+ pose_with_delay.header .stamp =
307
+ rclcpp::Time (pose.header .stamp ) + rclcpp::Duration::from_seconds (delay_time);
308
+ pose_with_delay.pose .pose .orientation .x = curr_orientation.x ();
309
+ pose_with_delay.pose .pose .orientation .y = curr_orientation.y ();
310
+ pose_with_delay.pose .pose .orientation .z = curr_orientation.z ();
311
+ pose_with_delay.pose .pose .orientation .w = curr_orientation.w ();
312
+
313
+ const auto rpy = autoware::universe_utils::getRPY (pose_with_delay.pose .pose .orientation );
314
+ const double delta_z = kalman_filter_.getXelement (IDX::VX) * delay_time * std::sin (-rpy.y );
315
+ pose_with_delay.pose .pose .position .z += delta_z;
316
+
317
+ return pose_with_delay;
294
318
}
295
319
296
320
bool EKFModule::measurement_update_twist (
0 commit comments