AprilTag結合realsense d435i測試

1)安裝apriltag

1.下載apriltag代碼。參考官方的教程下載安裝。網上其他博客已失效。

https://github.com/AprilRobotics/apriltag_ros

export ROS_DISTRO=melodic               # Set this to your distro, e.g. kinetic or melodic
source /opt/ros/$ROS_DISTRO/setup.bash  # Source your ROS distro 
mkdir -p ~/catkin_ws/src                # Make a new workspace 
cd ~/catkin_ws/src                      # Navigate to the source space
git clone https://github.com/AprilRobotics/apriltag.git      # Clone Apriltag library
git clone https://github.com/AprilRobotics/apriltag_ros.git  # Clone Apriltag ROS wrapper
cd ~/catkin_ws                          # Navigate to the workspace
rosdep install --from-paths src --ignore-src -r -y  # Install any missing packages
catkin build    # Build all packages in the workspace (catkin_make_isolated will work also)

2)測試運行

2.rosrun

 

3.啓動相機

    roslaunch realsense2_camera rs_camera.launch

 

2.1)修改apriltag配文件

4.修改配置文件~/catkin_ws/src/apriltag_ros/apriltag_ros/config/tags.yaml

修改tag_bundles中的id=0這一行的size信息爲自己實際打印二維碼的寬度(單位是米)。

# # Definitions of tags to detect
#
# ## General remarks
#
# - All length in meters
# - Ellipsis (...) signifies that the previous element can be repeated multiple times.
#
# ## Standalone tag definitions
# ### Remarks
#
# - name is optional
#
# ### Syntax
#
# standalone_tags:
#   [
#     {id: ID, size: SIZE, name: NAME},
#     ...
#   ]
standalone_tags:
  [
  ]
# ## Tag bundle definitions
# ### Remarks
#
# - name is optional
# - x, y, z have default values of 0 thus they are optional
# - qw has default value of 1 and qx, qy, qz have default values of 0 thus they are optional
#
# ### Syntax
#
# tag_bundles:
#   [
#     {
#       name: 'CUSTOM_BUNDLE_NAME',
#       layout:
#         [
#           {id: ID, size: SIZE, x: X_POS, y: Y_POS, z: Z_POS, qw: QUAT_W_VAL, qx: QUAT_X_VAL, qy: QUAT_Y_VAL, qz: QUAT_Z_VAL},
#           ...
#         ]
#     },
#     ...
#   ]

tag_bundles:
  [
    {
      name: 'my_bundle',
      layout:
        [
          {id: 0, size: 0.151, x: 0.0000, y: 0.0000, z: 0.0, qw: 0.707, qx: 0.0, qy: 0.0, qz: -0.707},
          {id: 1, size: 0.143, x: 1.2000, y: 0.0000, z: 0.0, qw: 0.707, qx: 0.0, qy: 0.0, qz: -0.707},
          {id: 2, size: 0.143, x: 2.4000, y: 0.0000, z: 0.0, qw: 0.707, qx: 0.0, qy: 0.0, qz: -0.707},
          {id: 3, size: 0.143, x: 3.6000, y: 0.0000, z: 0.0, qw: 0.707, qx: 0.0, qy: 0.0, qz: -0.707},
          {id: 4, size: 0.143, x: 4.8000, y: 0.0000, z: 0.0, qw: 0.707, qx: 0.0, qy: 0.0, qz: -0.707}
        ]


    }
  ]

5.修改配置文件~/catkin_ws/src/apriltag_ros/apriltag_ros/config/settings.yaml

修改tag_family

# AprilTag 3 code parameters
# Find descriptions in apriltag/include/apriltag.h:struct apriltag_detector
#                      apriltag/include/apriltag.h:struct apriltag_family
tag_family:        'tag16h5' # options: tagStandard52h13, tagStandard41h12, tag36h11, tag25h9, tag16h5, tagCustom48h12, tagCircle21h7, tagCircle49h12
tag_threads:       2          # default: 2
tag_decimate:      1.0        # default: 1.0
tag_blur:          0.0        # default: 0.0
tag_refine_edges:  1          # default: 1
tag_debug:         0          # default: 0
# Other parameters
publish_tf:        true       # default: false

6.編輯launch文件

2.2)啓動檢測

7.啓動apriltag節點

cd ~/catkin
source devel_isolated/setup.bash
cd ~/catkin_ws/src/apriltag_ros/apriltag_ros/launch
roslaunch apriltag_ros continuous_detection.launch

8.獲取位姿信息

cd ~/catkin
source devel_isolated/setup.bash
rostopic echo /tag_detections

9.可視化檢測信息

cd ~/catkin
source devel_isolated/setup.bash
rostopic echo /tag_detections_image

#新開窗口
rosrun rviz rviz

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章