AprilRobotics / apriltag

AprilTag is a visual fiducial system popular for robotics research.
https://april.eecs.umich.edu/software/apriltag
Other
1.59k stars 534 forks source link

Estimate camera pose from detected apriltag's pose #193

Closed gft-ai closed 2 years ago

gft-ai commented 2 years ago

Hi guys, thank you for your amazing work.

I am trying to localise my robot using apriltags. So right now I can get the pose of the detected tag but I am not sure how to calculate the pose of the camera which is attached on my robot from it.

Could anyone point me in the right direction please?

Thanks a lot!

christian-rauch commented 2 years ago

The AprilTag pose is the transformation from your camera optical frame to the tag frame. The camera pose with respect to the AprilTag frame is then just the inverse.

gft-ai commented 2 years ago

The AprilTag pose is the transformation from your camera optical frame to the tag frame. The camera pose with respect to the AprilTag frame is then just the inverse.

Oh great, I just realised I am actually using your implementation (apriltag_ros) for ROS2.

So would that mean I would have to inverse the homography matrix and multiply that with the 3d translation of the apriltag' pose?

I apologies if this is a very basic and dumb question.

christian-rauch commented 2 years ago

So would that mean I would have to inverse the homography matrix and multiply that with the 3d translation of the apriltag' pose?

No. The node already gives you the 3D transformation between camera and tag. That is the tag pose in the camera frame. If you want the camera pose in the tag frame, you just have to compute the inverse (T^(-1)) of the transformation.

Alternatively, you can just use ROS tf2 listener to query the inverse transform by switching source and target frame. A Python tutorial for ROS1 can be found here: http://wiki.ros.org/tf2/Tutorials/Writing a tf2 listener (Python). You have to copy pate that URLs ith spaces.

If you need more information about transformations and/or how to use them with ROS, I suggest looking at https://robotics.stackexchange.com and https://discourse.ros.org.

gft-ai commented 2 years ago

Great. Thank you so much for your help!