Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

ROS2 hubmle環境にArUcoマーカーの認識をつける

実際のところ

JMU-ROBOTICS-VIVAさんのros2_arucoを使用します

環境構築

キャリブレーションを行った上でost.yamlファイルを適切な場所においておく

ビルド

rosdepで何故か入らないので

sudo apt-get install ros-humble-tf-transformations

さらに、OpenCV pythonのライブラリが4.7からインターフェイスが変わった関係で

pip install opencv-contrib-python==4.6.0.66
$ cd dev_ws/src
$ git clone https://github.com/JMU-ROBOTICS-VIVA/ros2_aruco.git -b humble
$ cd ..

ビルド実施
Raspberry Pi 4BとRealsense D435の組み合わせなので、Qtまわりでビルド失敗するgazebo系は飛ばしています

$ colcon build --packages-skip realsense_gazebo_plugin xarm_gazebo xarm_planner

使用

マーカーの生成

デフォだとDICT_5X5_250のものが生成されます。
替えたい場合は --dictionary オプションで指定。

$ ros2 run ros2_aruco aruco_generate_marker --id 42
実行

DICT_5X5_250のマーカーサイズが10cm=0.1m、カメラがRasPi4BのRealsense D435のケースでは以下のような感じになります
(realsense2_cameraは先に起動しておいてください)

$ ros2 run ros2_aruco aruco_node --ros-args -p marker_size:=0.1 -p image_topic:=/camera/camera/color/image_raw -p camera_info_topic:=/camera/camera/color/camera_info

試しにトピック内容を確認しときます

$ ros2 topic info /aruco_markers
Type: ros2_aruco_interfaces/msg/ArucoMarkers
Publisher count: 1
Subscription count: 0

画角の中でDICT_5x5のID=42のマーカー動かし、その様子を読むとこんな感じ
結構

$ ros2 topic echo /aruco_markers
header:
  stamp:
    sec: 1697079067
    nanosec: 47821777
  frame_id: camera_color_optical_frame
marker_ids:
- 42
poses:
- position:
    x: -0.014340230843221665
    y: 0.04541124134020066
    z: 0.8333144763922312
  orientation:
    x: 0.9970457343243315
    y: 0.032748568591268415
    z: 0.03998359230571906
    w: 0.05682118678105546
---
header:
  stamp:
    sec: 1697079067
    nanosec: 81179443
  frame_id: camera_color_optical_frame
marker_ids:
- 42
poses:
- position:
    x: -0.009487610521737102
    y: 0.046256120321855214
    z: 0.833102752779483
  orientation:
    x: 0.9942479774523191
    y: 0.028283850044668407
    z: 0.060166346320995545
    w: 0.08397019667123372
---
header:
  stamp:
    sec: 1697079067
    nanosec: 114537109
  frame_id: camera_color_optical_frame
marker_ids:
- 42
poses:
- position:
    x: -0.0038821139120598894
    y: 0.046213250873967174
    z: 0.8303160400498403
  orientation:
    x: 0.99166368348326
    y: 0.024339255290264566
    z: 0.033505239903708746
    w: 0.12201695952335141
---
header:
...