7. AR QR code7.1. Overview7.2. Create ARTag7.2.1. Install software package7.2.2. Create AR QR code7.3. ARTag identification7.3.1. Start the identification instance7.3.2. launch file analysis7.3.3. ar_track_alvar node7.3.4. View node graph7.3.5. View tf tree7.3.6. View output information
wiki:http://wiki.ros.org/ar_track_alvar/
Source code:https://github.com/ros-perception/ar_track_alvar.git
Feature pack location:~/yahboomcar_ws/src/yahboomcar_visual
ARTag (AR tag, AR means "augmented reality") is a benchmark marking system that can be understood as a reference for other objects. It looks similar to a QR code.However, its encoding system is still very different from QR codes. It is mostly used in camera calibration, robot positioning, augmented reality (AR) and other applications. One of its important functions is to identify the pose relationship between the object and the camera. ARTag can be attached to the object, or ARTag label can be attached to the plane to calibrate the camera. After the camera recognizes the ARTag, it can calculate the position and attitude of the tag in the camera coordinates.
ar_track_alvar has 4 main functions:
Alvar is newer and more advanced than ARToolkit, which has been the basis for several other ROS AR tag packages. Alvar features adaptive thresholding to handle various lighting conditions, optical flow-based tracking for more stable pose estimation, and an improved tag identification method that does not slow down significantly as the number of tags increases.
file path,
/home/jetson/software/ar_track_ws/src/ar_track_alvar/ar_track_alvar
ar_track_alvar is an open source marker library, which provides examples of pr2+kinect. The first use case of this package is to identify and track gestures from (possibly) multiple AR tags, each considered individually.
xxxxxxxxxx
rosrun ar_track_alvar createMarker
You can enter [ID] and location information here, and enter [-1] to end. One or more can be generated, and the layout can be designed by yourself.
Command + parameters directly generate digital pictures; for example
xxxxxxxxxx
rosrun ar_track_alvar createMarker 11
rosrun ar_track_alvar createMarker -s 5 33
11:The number is the QR code of 11. -s: Specifies the image size. 5:5x5 picture. 33:The number is the QR code of 33. The generated pictures are stored in the directory of the current terminal.
Note: When starting the camera, the camera calibration file needs to be loaded, otherwise it cannot be recognized.
xxxxxxxxxx
roslaunch yahboomcar_visual ar_track.launch open_rviz:=true
In rviz, you need to set the corresponding camera topic name.
xxxxxxxxxx
<launch>
<!-- Set camDevice parameters,the default is USBCam -->
<arg name="open_rviz" default="true"/>
<arg name="marker_size" default="5.0"/>
<arg name="max_new_marker_error" default="0.08"/>
<arg name="max_track_error" default="0.2"/>
<!-- Set camera image topic, camera internal reference topic, camera frame -->
<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="/usb_cam"/>
<!-- Start camera node -->
<include file="$(find usb_cam)/launch/usb_cam-test.launch"/>
<!-- Set the corresponding relationship between the camera coordinate system and the world coordinate system -->
<node pkg="tf" type="static_transform_publisher" name="world_to_cam" args="0 0 0.5 0 1.57 0 world usb_cam 10"/>
<!-- Start AR recognition node -->
<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>
<!-- start rviz -->
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find yahboomcar_visual)/rviz/ar_track.rviz" if="$(arg open_rviz)"/>
</launch>
Node parameters:
topic name | type of data |
---|---|
/camera_info | (sensor_msgs/CameraInfo) |
/image_raw | (sensor_msgs/Image) |
topic name | type of data |
---|---|
/visualization_marker | (visualization_msgs/Marker) |
/ar_pose_marker | (ar_track_alvar/AlvarMarkers) |
Single QR code: Camera coordinate system → AR tag coordinate system
Multiple QR codes: Provides transformation from the camera coordinate system to each AR tag coordinate system (named ar_marker_x), where x is the ID number of the marker.
xxxxxxxxxx
rqt_graph
xxxxxxxxxx
rosrun rqt_tf_tree rqt_tf_tree
Through rviz, we can intuitively see the relative position of the QR code and the camera. The camera and world coordinate system are set by yourself.
xxxxxxxxxx
rostopic echo /ar_pose_marker
The display is as follows:
xxxxxxxxxx
header:
seq: 0
stamp:
secs: 1630584915
nsecs: 196221070
frame_id: "/usb_cam"
id: 3
confidence: 0
pose:
header:
seq: 0
stamp:
secs: 0
nsecs: 0
frame_id: ''
pose:
position:
x: 0.0249847882514
y: 0.0290736736336
z: 0.218054183012
orientation:
x: 0.682039034537
y: 0.681265739969
z: -0.156112715404
w: 0.215240718735