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 3 years have passed since last update.

pcapファイルをrosbagファイルに変換する

Last updated at Posted at 2021-06-28

はじめに

初投稿です。拙い点ご容赦ください。
また、ROS初心者のため間違えているところ等ありましたらご指摘いただけますと幸いです。

以下、velodyne LiDARなどから得られるpcapファイルをrosbagファイルに変換する手順です。
velodyneドライバをビルドした後に変換処理を行うという流れになります。

環境

OS:Ubuntu 18.04 LTS 
ROS:Melodic

velodyne_driverのビルド

すでにROS自体のインストールは完了している前提で、リポジトリからgit cloneしてきたものをビルドするまでに行った手順は以下のようになります。なお、ビルドはcatkin buildではなくcatkin_makeで行いました。

catkinワークスペースの作成

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace

velodyne_driverのgit clone

cd ~/catkin_ws/src
git clone https://github.com/ros-drivers/velodyne

catkin_makeでビルド

cd ~/catkin_ws
catkin_make

エラー

ここで以下のようなエラーが発生しました。

velodyne/velodyne_driver/src/lib/CMakeFiles/velodyne_input.dir/build.make:62: recipe for target 'velodyne/velodyne_driver/src/lib/CMakeFiles/velodyne_input.dir/input.cc.o' failed
    make[2]: *** [velodyne/velodyne_driver/src/lib/CMakeFiles/velodyne_input.dir/input.cc.o] Error 1
    CMakeFiles/Makefile2:5260: recipe for target 'velodyne/velodyne_driver/src/lib/CMakeFiles/velodyne_input.dir/all' failed
    make[1]: *** [velodyne/velodyne_driver/src/lib/CMakeFiles/velodyne_input.dir/all] Error 2

解決法

調べてみるとどうやらライブラリの依存関係の問題のようです。
https://github.com/ros-drivers/velodyne/issues/319

rosdepを使います。もしインストールしてなければ、Melodicの場合以下のようにインストールします。

sudo apt install python-rosdep

rosdep installを実行します。

rosdep install -i --from-paths ~/catkin_ws/src/velodyne

改めてcakint_makeをしたところ、ビルドが成功しました。

cd ~/catkin_ws
catkin_make

変換処理

いよいよpcapファイルをrosbagファイルに変換します。pcapファイルの名前をsample.pcap、rosbagファイルの名前をsample.bagと仮にします。
sample.pcapの場所は~/catkin_ws/src/velodyne/、sample.bagを出力する場所も~/catkin_ws/src/velodyne/とします。

これからターミナルのタブをたくさん開きながら進めていきます。

1つ目のタブ

roscore

2つ目のタブ

roslaunch velodyne_pointcloud 32e_points.launch pcap:=$(pwd)/sample.pcap readonce:=true

3つ目のタブ

rosbag recordでROSトピックの取得を行います。
-O sample.bagでファイル名sample.bagの指定、/velodyne_pointsで今回取得するROSトピックであるvelodyne_pointsトピックの指定を行います。

rosbag record -O sample.bag /velodyne_points

というわけで合計3つターミナルのタブを開いて実行しています。

適当に時間が経ったところでrosbag recordのタブをCtrl+Cで停止するとsample.bagが出力されます。

停止せずに放置しているとsample.bagのファイルサイズがどんどん大きくなってしまうため、
pcapファイルを取得したときの計測時間を予め記録しておいてその時間で止めました。

(他により良い方法をご存じの方がおられたら教えていただけると幸いです。)

参考文献

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?