1
0

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.

grid_mapを使ってみる(1)

Last updated at Posted at 2021-11-18

grid mapの使い方を調べました。
ここでは,インストールとサンプルを1つ動作させます。

ROS

  • noetic

Install

sudo apt install ros-noetic-grid-map*

サンプル

READMEに乗っていた最初のサンプルを実行して見ます.

roslaunch grid_map_demos simple_demo.launch

実行すると以下のように波打ったgrid mapが表示されました.

Screenshot from 2021-11-19 06-35-51.png

launchファイルの中身は以下のようになっていました.

simple_demo.launch
<launch>
  <!-- Launch the grid map simple demo node -->
  <node pkg="grid_map_demos" type="simple_demo" name="grid_map_simple_demo" output="screen" />
  <!-- Launch the grid map visualizer -->
  <node pkg="grid_map_visualization" type="grid_map_visualization" name="grid_map_visualization" output="screen">
    <rosparam command="load" file="$(find grid_map_demos)/config/simple_demo.yaml" />
  </node>
  <!-- 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ファイルのコードからsimple_demogrid_map_visualizationが実行されていることが分かります。

それぞれのノードの役割とトピックについてまとめると以下のようになります。

  • simple_demo : grid mapを作成し配信するノード

  • Pub:grid_map[grid_map_msgs/GridMap]

  • grid_map_visualizatoin : grid mapトピックを受け,ROSのPointCloud2などに変換

  • Sub:grid_map[nav_msgs/OccupancyGrid]

  • Pub:grid_map_pointcloud[sensor_msgs/PointCloud2]

エラー対策

上記launch起動時image_publisher.pyでエラーが発生.

image.png

diff --git a/grid_map_demos/scripts/image_publisher.py b/grid_map_demos/scripts/image_publisher.py
index 9c1745d..7b35337 100755
--- a/grid_map_demos/scripts/image_publisher.py
+++ b/grid_map_demos/scripts/image_publisher.py
@@ -40,7 +40,7 @@ def callback(self):
     rosimage.width = img.shape[1]
     rosimage.height = img.shape[0]
     rosimage.step = img.strides[0]
-    rosimage.data = img.tostring()
+    rosimage.data = img.tobytes()
     rosimage.header.stamp = rospy.Time.now()
     rosimage.header.frame_id = 'map'

まとめ

  • grid_mapを操作するためのツールが色々用意されている.
  • それをPointCloud2などに変換することもできROSとの連携が可能.

次回

次回は,画像をgrid mapに変換するデモを動作させた後,
オリジナルの画像をgrid mapとしてrvizに表示します。

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?