1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

tfをrvizのインタラクティブマーカーから設定

Last updated at Posted at 2022-03-20

はじめに

以下のパッケージを使うとrviz内のインタラクティブマーカでtf設定ができます。それをためしたメモ

環境

ros-noetic

内容

  • インストール
git clone https://github.com/lucasw/rviz_interactive_tf.git

catkin build 
または
cd ~/catkin_ws
catkin make

source ~/catkin_ws/devel/setup.bash
  • 実行
roslaunch rviz_interactive_tf demo.launch 

Screenshot from 2022-03-20 12-30-36.png

program

ちなみにlaunchの中はこんな感じです.

<?xml version="1.0"?>
<launch>
  <node name="itf" pkg="rviz_interactive_tf" type="interactive_tf" ns="itf1">
    <param name="parent_frame" value="map"/>
    <param name="frame" value="tf1"/>
  </node>
  <!-- when these are chained together, the marker controls don't
      appear unless I switch rviz to the tf1 frame, then move tf2,
      then I can go back to the map frame and see tf2 markers -->
  <node name="itf" pkg="rviz_interactive_tf" type="interactive_tf" ns="itf2">
    <param name="parent_frame" value="tf1"/>
    <param name="frame" value="tf2"/>
  </node>
  <node name="rviz" pkg="rviz" type="rviz"
      args="-d $(find rviz_interactive_tf)/config/interactive_tf.rviz"/>
</launch>

以下のようrviz_interactive_tfパッケージのinteractive_tfノードを呼び出して,paramで親と子のfrmae名を指定すればok

 <node name="itf" pkg="rviz_interactive_tf" type="interactive_tf" ns="itf1">
    <param name="parent_frame" value="map"/>
    <param name="frame" value="tf1"/>
  </node>

設定したtfの値はrostopic echo /tfとすれば取得できます

  - 
    header: 
      seq: 0
      stamp: 
        secs: 1660977839
        nsecs: 761851298
      frame_id: "base_link"
    child_frame_id: "camera_depth_optical_frame"
    transform: 
      translation: 
        x: -0.056215815246105194
        y: 0.2537241578102112
        z: 0.8296752572059631
      rotation: 
        x: 0.048909555696312945
        y: 0.9972522335770526
        z: -0.04807596233112703
        w: 0.028009638218031027

tfの値が決定したらstatic_transform_publisherで値を固定してあげます

<node pkg="tf"  type="static_transform_publisher" name="world_to_map" args="0.0001 0 0 0 0 0 /world /map 10" />

さいごに

手動でLidarやデプスカメラなどのセンサー取り付け位置を調べたり,rviz上のロボットを動かしたりできて色々と便利そうですね

追記

rviz_interactive_tfパッケージには,Dynamic reconfigureからtfの位置を設定するためのスクリプトが用意されています.

こちらを使用したほうが数値を指定したtfの設定もできるので微調整が可能かと思われます.

以下に実行方法や使用手順のメモを記載しておきます.

  • 実行方法

依存ライブラリのインストール

sudo apt install ros-noetic-ddynamic-reconfigure-python

プログラムの立ち上げ

roscore
rosrun rviz_interactive_tf ddr_tf.py

デバックようにrvizの立ち上げ & tfの可視化

rviz

Screenshot from 2023-07-28 07-47-37.png

dynamic_reconfigure設定用GUIの立ち上げ

rosrun rqt_reconfigure rqt_reconfigure

Screenshot from 2023-07-28 07-50-04.png

設定した値を保存したい場合GUI上の左上のsaveボタンを押して実施します

値のロードは、rosrun dynamic_reconfigure dynparam load後にddr_tf.pyのノード名 + 保存したパラメータファイル名を指定して実施します

rosrun dynamic_reconfigure dynparam load /ddr_to_tf aaa.yaml
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?