5 const size_t num_points = input_cloud->width * input_cloud->height;
10 constexpr double scan_duration = 0.1;
11 constexpr double one_over_two_pi = 1.0 / (2.0 * M_PI);
17 const double angular_velocity_z =
static_cast<double>(vehicle_velocity.
rotational_velocity);
19 auto& cloud = input_cloud->data;
24 double reference_azimuth = std::numeric_limits<double>::lowest();
25 for (
size_t i = 0; i < num_points; ++i) {
28 double azimuth = -std::atan2(ref_y, ref_x);
29 if (azimuth > reference_azimuth) {
30 reference_azimuth = azimuth;
35 for (
size_t i = 0; i < num_points; ++i) {
40 double azimuth = -std::atan2(y, x);
42 double delta_angle = reference_azimuth - azimuth;
44 double time_offset = delta_angle * one_over_two_pi * scan_duration;
46 Eigen::Vector3d original_point(x, y, z);
47 Eigen::Vector3d deskewed_point = original_point;
50 if (angular_velocity_z != 0.0) {
51 double theta = -angular_velocity_z * time_offset;
52 double cos_theta = std::cos(theta);
53 double sin_theta = std::sin(theta);
55 double x_rot = cos_theta * deskewed_point.x() - sin_theta * deskewed_point.y();
56 double y_rot = sin_theta * deskewed_point.x() + cos_theta * deskewed_point.y();
58 deskewed_point.x() = x_rot;
59 deskewed_point.y() = y_rot;
63 deskewed_point -= linear_velocity * time_offset;
66 float deskewed_xyz[3] = {
static_cast<float>(deskewed_point.x()),
67 static_cast<float>(deskewed_point.y()),
68 static_cast<float>(deskewed_point.z())};
void deskew_point_cloud(sensor_msgs::msg::PointCloud2::SharedPtr &input_cloud, const common_lib::structures::Velocities &vehicle_velocity) const
deskews the point cloud, i.e.