Install the packages:

sudo apt-get install ros-kinetic-ar-track-alvar

We are going to use a webcam but you can also use a kinect. To use the camera, we need to install the right drivers:

# web cam driver
sudo apt-get install ros-kinetic-usb-cam
# Kinect driver
sudo apt-get install ros-kinetic-freenect-launch

Run the usb camera:

rosrun usb_cam usb_cam_node

You should be able to see the input image in RViz (TODO: Provide details on how to see image)

Print the AR markers:

Create a launch file to use for running the tracker. You should update the marker size after measuring it since the size might differ depending on how you printed the marker. Save the files as usb_cam_ar_track.launch.

<launch>

    <arg name="marker_size"          default="5.0" />
    <arg name="max_new_marker_error" default="0.05" />
    <arg name="max_track_error"      default="0.05" />

    <arg name="cam_image_topic"      default="/usb_cam/image_raw" />
    <arg name="cam_info_topic"       default="/usb_cam/camera_info" />
    <arg name="output_frame"         default="/map" />

    <node name="ar_track_alvar" pkg="ar_track_alvar" type="individualMarkersNoKinect" respawn="false" output="screen">
		<param name="marker_size"           type="double" value="$(arg marker_size)" />
		<param name="max_new_marker_error"  type="double" value="$(arg max_new_marker_error)" />
		<param name="max_track_error"       type="double" value="$(arg max_track_error)" />
		<param name="output_frame"          type="string" value="$(arg output_frame)" />

		<remap from="camera_image"  to="$(arg cam_image_topic)" />
		<remap from="camera_info"   to="$(arg cam_info_topic)" />
	</node>
</launch>

Set the appropriate output frame so that the default /map frame maps to the header_cam camera output frame:

rosrun tf2_ros static_transform_publisher 0 0 0 0 0 0 1 /map /header_cam

Now it’s time to run the AR tracker:

roslaunch usb_cam_ar_track.launch

Open up RViz and add the TF topic. You should see TFs corresponding to the AR tag.