-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use cv::Mat to represent the rotation matrix and cv::Vec3d for the translation and the apriltag vector.
https://docs.opencv.org/3.4/dc/d84/group__core__basic.html#gab9e0ab642a3e01742916763173b72232
https://docs.opencv.org/3.4/dc/d84/group__core__basic.html#gab9e0ab642a3e01742916763173b72232
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++){ |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this 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
No description provided.