前回grid_mapのinstall方法やデモの動作をしました。
今回はオリジナルの画像をgrid_mapとして表示したいと思います。
デモ
まず標準で用意されている画像をgrid mapとして表示するデモを実行します。
roslaunch grid_map_demos image_to_gridmap_demo.launch
すると以下のようなgrid mapがrviz上に表示されます。
launchの中は次のようになっています。
image_to_gridmap.launch
<launch>
<rosparam command="load" file="$(find grid_map_demos)/config/image_to_gridmap_demo.yaml" />
<!-- Load the image. -->
<node pkg="grid_map_demos" type="image_publisher.py" name="image_publisher" output="screen">
<param name="image_path" value="$(find grid_map_demos)/data/eth_logo.png" />
<param name="topic" value="~image" />
</node>
<!-- Launch the grid map image to grid map demo node. -->
<node pkg="grid_map_demos" type="image_to_gridmap_demo" name="image_to_gridmap_demo" output="screen" />
<!-- Launch the grid map visualizer -->
<node pkg="grid_map_visualization" type="grid_map_visualization" name="grid_map_visualization" output="screen" />
<!-- Launch RViz with the demo configuration -->
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find grid_map_demos)/rviz/grid_map_demo.rviz" />
</launch>
オリジナル画像の出力
先程のデモを参考に次はオリジナルの画像を出力してみます。
以下のようにlaunchを作成します。image_path
は自分の使用した画像のパスを入力してください。
image_to_gridmap.launch
<launch>
<rosparam command="load" file="$(find grid_map_demos)/config/image_to_gridmap_demo.yaml" />
<!-- Load the image. -->
<node pkg="grid_map_demos" type="image_publisher.py" name="image_publisher" output="screen">
<param name="image_path" value="$(find grid_map_samples)/src/template_match.png" />
<param name="topic" value="~image" />
</node>
<!-- Launch the grid map image to grid map demo node. -->
<node pkg="grid_map_demos" type="image_to_gridmap_demo" name="image_to_gridmap_demo" output="screen">
<param name="resulution" value="0.01" />
<param name="max_height" value="1.0" />
</node>
<!-- Launch the grid map visualizer -->
<node pkg="grid_map_visualization" type="grid_map_visualization" name="grid_map_visualization" output="screen" />
<!-- Launch RViz with the demo configuration -->
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find grid_map_demos)/rviz/grid_map_demo.rviz" />
</launch>
今回は以下のようなopencvのtemplate matchサンプルの結果の画像を使用しました。(opencv templat matching サンプル)
実行すると以下のようになり,2次元の結果を立体的に表示できました。