Skip to content

Potential rotation parameter unit mismatch in MakeRotationGrid (degrees vs radians) #73

@zz990099

Description

@zz990099

Hello! Thank you for your excellent work! We are currently migrating the FoundationPose algorithm portion to a non-ROS environment for our use, and during this process, we noticed a potential issue worth verifying.

In the sampling section of FoundationPose, specifically in the MakeRotationGrid function, the current implementation uses Eigen::AngleAxisf(inplane_rot, Eigen::Vector3f::UnitZ()) to specify rotation about the Z-axis. Since inplane_rot appears to be in degrees, while the Eigen::AngleAxisf constructor expects radians (as per Eigen documentation), this might cause misalignment with the Python implementation during model rendering.

After modifying the input to use radians, here are our test results showing improved alignment:

Image

Codes we modified:

std::vector<Eigen::Matrix4f> MakeRotationGrid(const std::vector<std::string>& symmetry_planes, unsigned int n_views = 40, int inplane_step = 60) {
  auto cam_in_obs = SampleViewsIcosphere(n_views);

  std::vector<Eigen::Matrix4f> rot_grid;
  for (unsigned int i = 0; i < cam_in_obs.size(); i++) {
    for (double inplane_rot = 0; inplane_rot < 360; inplane_rot += inplane_step) {
      Eigen::Matrix4f cam_in_ob = cam_in_obs[i];
      auto R_inplane = Eigen::Affine3f::Identity();
      R_inplane.rotate(Eigen::AngleAxisf(0, Eigen::Vector3f::UnitX()))
          .rotate(Eigen::AngleAxisf(0, Eigen::Vector3f::UnitY()))
          .rotate(Eigen::AngleAxisf(inplane_rot / 180.0f * M_PI, Eigen::Vector3f::UnitZ()));

      cam_in_ob = cam_in_ob * R_inplane.matrix();
      Eigen::Matrix4f ob_in_cam = cam_in_ob.inverse();
      rot_grid.push_back(ob_in_cam);
    }
  }

  std::vector<Eigen::Matrix4f> symmetry_tfs = GenerateSymmetricPoses(symmetry_planes);
  symmetry_tfs.push_back(Eigen::Matrix4f::Identity());
  auto clustered_poses = ClusterPoses(30.0, 99999.0, rot_grid, symmetry_tfs);
  GXF_LOG_DEBUG("[FoundationposeSampling] %lu poses left after clustering", clustered_poses.size());
  return std::move(clustered_poses);
}

We would greatly appreciate your insights on this observation. If this is indeed a valid adjustment, we would be happy to submit a pull request with your permission. Please let us know your thoughts when convenient.

Thank you for your time and consideration!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions