Research Tutorial

How To: Tracking ArUco markers using a USB Webcam and ROS

For my research I needed to setup ROS to use ArUco so that I could track these ArUco markers placed randomly in the environment and localize my robot.

Assuming that you have your catkin workspace setup, here are the steps:

1.  $cd ~/catkin_ws/src/

2. $git clone https://github.com/pal-robotics/aruco_ros.git

3. $cd ..

4. $catkin_make install

5. $sudo apt-get install ros-indigo-usb-cam

6. $source install/setup.bash

7. $cd src/aruco_ros/aruco_ros/launch/

Now you need to modify the single.launch file so that you remap the image and camera info to the topics published by usb_cam node.

<launch>

<arg name=”markerId” default=”582″/>
<arg name=”markerSize” default=”0.034″/> <!– in m –>
<arg name=”eye” default=”left”/>
<arg name=”marker_frame” default=”aruco_marker_frame”/>
<arg name=”ref_frame” default=””/> <!– leave empty and the pose will be published wrt param parent_name –>
<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=”stereo_gazebo_$(arg eye)_camera_optical_frame”/>
<param name=”marker_frame” value=”$(arg marker_frame)” />
</node>

</launch>

8. Open 4 terminal windows:

Terminal 1: $roscore

Terminal 2: $roslaunch usb_cam-stream.launch

First paste this into a new file named usb_cam-stream.launch:

<launch>
<node name=”usb_cam” pkg=”usb_cam” type=”usb_cam_node” output=”screen” >
<param name=”video_device” value=”/dev/video0″ />
<param name=”image_width” value=”640″ />
<param name=”image_height” value=”480″ />
<param name=”pixel_format” value=”mjpeg” />
<param name=”camera_frame_id” value=”usb_cam” />
<param name=”io_method” value=”mmap”/>
</node>
</launch>

Terminal 3:

$cd ~/catkin_ws/src/aruco_ros/aruco_ros/launch/

$roslaunch single.launch

Terminal 4: $rosrun image_view image_view image:=/aruco_single/result

Recommended Articles