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

Rotate translation vector to robot coordinates #61

Merged
merged 9 commits into from
Jan 18, 2025
Merged

Conversation

maxspier
Copy link
Member

No description provided.

@maxspier maxspier requested a review from cgpadwick January 18, 2025 02:44
Copy link
Collaborator

@cgpadwick cgpadwick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/ws_server.cu Outdated
double translationBefore[3] = {pose.t->data[0], pose.t->data[1], pose.t->data[2]};
double translationAfter[3][3];

for(int i = 0; i < 3; i++){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't quite right. we want to multiply the april tag vector by the R matrix and then add the translation, like this v' = R * v + T.

Let's use the open cv matrices cv::Mat and cv::Vec3d instead of multiplying them by hand. OpenCV has optimized matrix multiply implementations that are much faster than a hand multiply (and it's easier to read).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking something like this:

cv::Mat matrix = (cv::Mat_<double>(3, 3) << 
                       1, 2, 3,
                       4, 5, 6,
                       7, 8, 9);

    // 2. Create a 3D vector
    cv::Vec3d vec(1.0, 2.0, 3.0);

    // 3. Convert the cv::Vec3d into a 3x1 cv::Mat (column vector)
    cv::Mat vecMat = cv::Mat(vec); // This becomes a 3x1 matrix

    // 4. Multiply the 3x3 matrix by the 3x1 vector
    cv::Mat resultMat = matrix * vecMat; // Result will be a 3x1 matrix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Just changed the double array to the different data structure.

Left a todo for crystal to add the translation stuff (they were doing that).

@maxspier maxspier requested a review from cgpadwick January 18, 2025 19:26
@maxspier maxspier requested a review from cgpadwick January 18, 2025 22:14
Copy link
Collaborator

@cgpadwick cgpadwick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks Max! We'll merge it as is and then perhaps later read translations/rotations from a different file but this will do for now

@maxspier maxspier merged commit 282b626 into main Jan 18, 2025
1 check passed
@cgpadwick cgpadwick deleted the Matrix-Rotation branch February 4, 2025 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants