Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[registration] redundant codes #6227

Open
YeHuanjie opened this issue Jan 24, 2025 · 3 comments
Open

[registration] redundant codes #6227

YeHuanjie opened this issue Jan 24, 2025 · 3 comments

Comments

@YeHuanjie
Copy link
Contributor

YeHuanjie commented Jan 24, 2025

I found redundant codes in ppf.h line96 and ppf_registration.hpp line153

Eigen::Vector3f model_point_transformed = transform_mg * model_point;
float angle = std::atan2 ( -model_point_transformed(2), model_point_transformed(1));
if (std::sin (angle) * model_point_transformed(2) < 0.0f)
    angle *= (-1);
p.alpha_m = -angle;

and

const Eigen::Vector3f scene_point_transformed = transform_sg * scene_point;
float alpha_s =
    std::atan2(-scene_point_transformed(2), scene_point_transformed(1));
if (std::sin(alpha_s) * scene_point_transformed(2) < 0.0f)
    alpha_s *= (-1);
alpha_s *= (-1);

There are too many (-1) in codes. In fact, they are redundant.

Image

To verify my hypothesis, I conducted the following experiment.
I run the above codes and simplified code, comparing their results.

    for (int x = -10; x <= 10; x++)
    {
        for (int y = -10; y <= 10; y++)
        {
            float float_x = (float) x;
            float float_y = (float) y;
            // simplified
            float vanilla_alpha_s = std::atan2(float_y, float_x);
            // pcl
            float pcl_alpha_s = std::atan2(-float_y, float_x);
            if (std::sin(alpha_s) * float_y < 0.0f)
            {
                pcl_alpha_s *= (-1);
            }
            std::cout << "x: " << x << " y: " << y
                << " vanilla_alpha_s: " << vanilla_alpha_s
                << " magic_alpha_s: " << pcl_alpha_s  << std::endl;
        }
    }

Image

So, the codes can be simplified as follows:

Eigen::Vector3f model_point_transformed = transform_mg * model_point;
float angle = std::atan2 (model_point_transformed(2), model_point_transformed(1));
p.alpha_m = -angle;

However, I am confused with the (-1). It makes no sense here.

@YeHuanjie YeHuanjie added kind: bug Type of issue status: triage Labels incomplete labels Jan 24, 2025
@YeHuanjie
Copy link
Contributor Author

YeHuanjie commented Jan 24, 2025

According to 《A Method for 6D Pose Estimation of Free-Form Rigid Objects Using Point Pair Features on Range Data》, I guess the (-1) should be here:

Image

Image

@mvieth
Copy link
Member

mvieth commented Jan 26, 2025

I am not sure if I completely understand what you suggest. Maybe create a pull request or post a git diff, then I can see the exact changes you propose?
Although, looking at the scatter plot, "simplified" and "pcl" differ at -pi and +pi? I am unsure whether this might cause any problems in the rest of the ppf code?

@mvieth mvieth added module: registration kind: proposal Type of issue and removed kind: bug Type of issue status: triage Labels incomplete labels Jan 26, 2025
@YeHuanjie
Copy link
Contributor Author

Apologies for the late reply, I just got back from vacation.
Here is the pull request:
#6230

Although, looking at the scatter plot, "simplified" and "pcl" differ at -pi and +pi? I am unsure whether this might cause any problems in the rest of the ppf code?

As far as I know, PI and -PI are the same for rotation axis.
And my experiments show that results are the same w/o this commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants