ArUco is a simple yet great library for augmented reality applications. In this tutorial, I’m gonna show you how to track ArUco marker and estimate their 6DOF pose with ROS.
For this tutorial, you only need a USB camera. You need to calibrate your camera before first. If you don’ know how to that just follow my other tutorial on camera calibration with ROS.
1.So first let’s install the required packages:
1 |
sudo apt-get install ros-indigo-usb-cam ros-indigo-aruco-ros |
2. You need two launch files, one of them will publish images from your USB cam:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<launch> <arg name="video_device" default="/dev/video0" /> <arg name="image_width" default="640" /> <arg name="image_height" default="480" /> <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" > <param name="video_device" value="$(arg video_device)" /> <param name="image_width" value="$(arg image_width)" /> <param name="image_height" value="$(arg image_height)"/> <param name="pixel_format" value="mjpeg" /> <param name="camera_frame_id" value="usb_cam" /> <param name="io_method" value="mmap"/> </node> </launch> |
save it under usb_cam_stream_publisher.launch
3.The other launch file will find the ArUco marker in the image and publish the 6DOF pose. So open your editor and paste the following into that:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<launch> <arg name="markerId" default="701"/> <arg name="markerSize" default="0.05"/> <!-- in meter --> <arg name="eye" default="left"/> <arg name="marker_frame" default="marker_frame"/> <arg name="ref_frame" default=""/> <!-- leave empty and the pose will be published wrt param parent_name --> <arg name="corner_refinement" default="LINES" /> <!-- NONE, HARRIS, LINES, SUBPIX --> <node pkg="aruco_ros" type="single" name="aruco_single"> <remap from="/camera_info" to="/usb_cam/camera_info" /> <remap from="/image" to="/usb_cam/image_raw" /> <param name="image_is_rectified" value="True"/> <param name="marker_size" value="$(arg markerSize)"/> <param name="marker_id" value="$(arg markerId)"/> <param name="reference_frame" value="$(arg ref_frame)"/> <!-- frame in which the marker pose will be refered --> <param name="camera_frame" value="base_link"/> <param name="marker_frame" value="$(arg marker_frame)" /> <param name="corner_refinement" value="$(arg corner_refinement)" /> </node> </launch> |
save it under aruco_marker_finder.launch
4. Now start publishing images from your camera:
1 |
roslaunch usb_cam_stream_publisher.launch |
and find the markers:
1 |
roslaunch aruco_marker_finder.launch markerId:=701 markerSize:=0.05 |
5.To see the results, open rqt_gui:
1 |
rosrun rqt_gui rqt_gui |
6.The topic name of the pose of markers is /aruco_single/pose. You can monitor it by:
1 |
rostopic echo /aruco_single/pose |
7. Generate your aruco marker at:
http://terpconnect.umd.edu/~jwelsh12/enes100/markergen.html
special thanks to sauravag.com.
Great Tutorial
Apt-Get makes it so easy 🙂
Please take a look at RVIZ output:
https://www.youtube.com/watch?v=oXNR8y4qIiI
good work 🙂
I followed the steps shown here but in rqt window I do not see the tracking happening. I can see the image stream using topic /aruco_single/result but /aruco_single/pose provides no information. Can you please tell me what am i missing here?
Thank you
Do a successful calibration and make sure no error is happening when clicked Calibrate button. Then save and commit. I had the same issue and /aruco_single/pose topic gave me some 0.707 and nan values, when echoed. Now that the calibration.py got populated after calibration, everything works fine
i did my camera calibration still i dont get my pose topic not echoing, what is calibration.py
can I ask about the maximum range(distance from the camera) for the aruco marker detection at the same size?
I followed thr steps shown here but in rqt window I do not see the tracking happening. I can see the image stream using topic /aruco_single/result but /aruco_single/pose provides no information. Can you please tell me what am I missing here?
Thank you.
Hi, There could be many reasons, I recommend you to use rqt_graph to see the network and nodes. Can you see the Aruco debug topic in rqt_gui? The image you see there should be the thresholded image from your camera. If this doesn’t work check your image publisher, if you can see the image check the id of your Aruco, is it the same as the Aruco that you printed and you taking the image of it? Good luck
Thank you for the reponse. I have got it worked. Actually I printed the marker following 5 X 5 dictionary format instead of original Aruco dictionary format.
The pose of markers relative to which frame?
Camera frame,
I have succeeded to detect the marker when the distance between the marker and the camera is 180 cm. But I want to detect the marker when the distance between the marker and the camera is 240 cm. How can I do that without changing the size of marker which I used
Hello Sir, I tried your tutorial and I got this error: TF_NAN_INPUT: Ignoring transform for child_frame_id “marker_frame” from authority “unknown_publisher” because of a nan value in the transform (-nan -nan -nan) (0.000000 0.707107 0.707107 0.000000)
at line 244 in /tmp/binarydeb/ros-kinetic-tf2-0.5.20/src/buffer_core.cpp
Do you have any idea how to fix it?
I have the same issue
Hey Sam
I had the same problem. Do proper calibration thinks are gonna work directly after that.
Link: https://ros-developer.com/2017/04/23/camera-calibration-with-ros/
Hi, you have a very cool project. Can you please tell at what angle the script can determine the marker?
Hello sir, I tried your tutorial. I installed Aruco_ros as you described. It’s installed from binary and I am comfortable with building from source. I am new to ROS. The problem that I am facing is that I am unable to go to the directory aruco_ros/launch and launch those 3 files. Please help!!!!
try “roscd aruco_ros ” you can find “launch” folder there. for launching those launch files ,simply type “roslaunch aruco_ros .launch := “.
I am using your package of aruco, when I change the matrix “rotate_to_ros” in “aruco_ros_utils.cpp” to be [1 0 0;0 0 1;0 1 0] I have the following error:
Error: TF_DENORMALIZED_QUATERNION: Ignoring transform for child_frame_id “marker_frame” from authority “unknown_publisher” because of an invalid quaternion in the transform (-0.029012 -0.264665 -0.742686 0.526990)
at line 257 in /tmp/binarydeb/ros-kinetic-tf2-0.5.20/src/buffer_core.cpp
could you help me please?
Anyone knows what is this problem about ?
WARNING: topic [/aruco_single] does not appear to be published yet
Sorry for this basic question, but i am still quite new in ROS, regards
Is your usb_cam_stream_publisher.launch file running without any errors?
Hello,
can I change the direction of axes to show them in a different way in rqt_gui?
I wonder how to convert the Quatranion to Eulers angles. I hope there is some problem in conventions. Can you help me with that.
Also is the distance w.r.t the camera to marker? I mainly require the angle in from camera to the fiducial so which all parameters to be used. Thanks in advance
https://www.youtube.com/watch?v=DHpBkMAqWOU&t=3s
https://github.com/behnamasadi/EigenDemo
hi i m also currently workin on same april tag and multiple mini robot. but i dont know how to control robot using apriltag via rviz. can you please help me out. i will be very thankful to youhttps://www.youtube.com/s/gaming/emoji/7ff574f2/emoji_u1f64f.png
Hello, I don’t know what you mean exactly by controlling the robot via rviz. This video is a bit old but should work out of the box, and you should be able to estimate the distance of the marker from the camera via marker, the rest (planning and control) should be done in another node. Regards.
Hello Admin, Thanks for sharing this content. I was able to detect the marker and want to subscribe to the pose estimation (x,y,z) of my drone (marker is placed on the Drone). Can you guide me to get those coordinates for my drone controlling script?
Thanks in advance
Hello, I’m not sure if I fully understood the problem, so if the marker is on the drone and the camera is on the ground, the camera will show the relative position of the drone to the camera, list all of your ros topics: “rostopic list” and then print out your topic with “rostopic echo“