start-jsk / rtmros_tutorials

Tutorials for rtmros packages
6 stars 61 forks source link

[hironx_tutorial]change depth_registration value from false to true to fix the gap between XYZ and color #619

Open YUKINA-3252 opened 8 months ago

YUKINA-3252 commented 8 months ago

HIRO頭部のprime senseカメラにおいて、点群の三次元位置情報と色情報がずれていたり、RGB画像とdepth画像の位置情報がずれているといった問題があったので、openni2.launch(https://github.com/ros-drivers/openni2_launch/blob/797cc0b4b765e0701ad8b33872c530732d9d0b23/launch/openni2.launch#L27 )のdepth_registrationの値をfalseからtrueへ変更しました。

(変更前)

Screenshot from 2024-01-11 11-28-06

(変更後)

Screenshot from 2024-01-11 11-24-27

変更後は机の端の点群がより合う(変更前は床面の黒色が変更後よりずれて表れてしまっている)ようになりました。

pazeshun commented 8 months ago

このPRの変更を入れる前(depth_registrationfalseの時)は、以下のようなコマンドで最小限の画像を記録したrosbagを

rosbag record -b 0 /tf /tf_static /head_camera/rgb/camera_info /head_camera/rgb/image_raw/compressed /head_camera/depth/camera_info /head_camera/depth/image_raw/compressedDepth -O test.bag

以下のようなlaunch(もしくはこの一部を抜き出した処理)で再生することで、実機と同じ画像・点群を作ることができました。

<launch>
  <arg name="rosbag_filename" />
  <arg name="depth_registration" value="false" />

  <param name="/use_sim_time" value="true" />
  <node name="rosbag_play"
        pkg="rosbag" type="play"
        args="$(arg rosbag_filename) --clock --loop">
  </node>

  <group ns="/head_camera/rgb">
    <node name="republish"
          pkg="image_transport" type="republish"
          args="compressed raw">
      <remap from="in" to="image_raw" />
      <remap from="out" to="image_raw" />
    </node>
  </group>
  <group ns="/head_camera/depth">
    <node name="republish"
          pkg="image_transport" type="republish"
          args="compressedDepth raw">
      <remap from="in" to="image_raw" />
      <remap from="out" to="image_raw" />
    </node>
  </group>

  <include file="$(find openni2_launch)/launch/openni2.launch">
    <arg name="load_driver" value="false" />
    <arg name="camera" value="head_camera" />
    <arg name="depth_registration" value="$(arg depth_registration)" />
    <arg name="publish_tf" value="false" />
  </include>

</launch>

しかし、このPRの変更を入れると、上記rosbag+launchで作られる画像・点群は実機とは少しずれたものになります。 これは、実機ではdepth_registrationtrueの画像・点群が作られるのに対し、上記rosbag+launchではdepth_registrationfalseのものしか作れないためです。 launchの引数にdepth_registration:=trueを与えても、処理に必要な画像の一部が記録されていないため全ての画像・点群を作ることはできません。

このため、このPRの変更を入れた場合、rosbagを記録・再生する際には以下のどれかを選択する必要があります。

  1. rosbagを使った時は画像・点群が実機と少しずれることを受け入れて、最小限の画像を記録する方法を取る
  2. rosbagの容量が大きくなることを受け入れて、depth_registration:=trueの処理に必要な全ての画像を記録する
  3. 実機にある画像・点群を全て作ることを諦めて、デモに必要なもののみ記録しておく

@Affonso-Gui @MiyabiTane @samejima00 のコードを確認したところ、もともと全部3の手法を取っており、かつ、このPRを入れてもhttps://gitlab.jsk.imi.i.u-tokyo.ac.jp/affonso/detic_ros/-/merge_requests/1 を入れれば問題ない記録・再生の仕方となっているように見えるので、大丈夫だと思われます。 @YUKINA-3252 のデモについては確認中です。