How to modify rosbag?如何修改rosbag?

Ubuntu16.04,kinetic

 

本文示例修改使用rosbag中的frame id

 

http://wiki.ros.org/bag_tools中,能找到

change_camera_info.py 

usage: change_frame_id.py [-h] -o OUTPUT_BAGFILE -i INPUT_BAGFILE -f FRAME_ID
                          -t TOPIC [TOPIC ...]

reate a new bagfile from an existing one replacing the frame id of requested
topics.

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT_BAGFILE     output bagfile
  -i INPUT_BAGFILE      input bagfile
  -f FRAME_ID           desired frame_id name in the topics
  -t TOPIC [TOPIC ...]  topic(s) to change

 

准备修改包的frame id,问题是,发现完整版的ros似乎没有安装bag_tools?什么回事呢?

 

看了F&A后,发现是一个老生常谈的问题How to use bag_tools? bag_tools因为缺失需要c++编译的executable,这个包已经损坏了,并且只能从源码source安装,使用git clone或者直接下载整个.zip文件后,解压,将bag_tools复制到catkin_ws中,进行catkin_make,出现另外一个问题(我觉得有可能是opencv版本兼容问题,也有可能不是):

00:04:39.904 In file included from /opt/ros/kinetic/include/opencv-3.3.1/opencv2/core.hpp:59:0,
00:04:39.904                  from /opt/ros/kinetic/include/opencv-3.3.1/opencv2/core/core.hpp:48,
00:04:39.904                  from /opt/ros/kinetic/include/image_proc/processor.h:37,
00:04:39.904                  from /opt/ros/kinetic/include/stereo_image_proc/processor.h:37,
00:04:39.904                  from /tmp/binarydeb/ros-kinetic-bag-tools-0.0.3/src/process_stereo.cpp:34:
00:04:39.904 /opt/ros/kinetic/include/opencv-3.3.1/opencv2/core/mat.hpp: In instantiation of ‘class cv::Mat_<unsigned int>’:
00:04:39.904 /opt/ros/kinetic/include/stereo_image_proc/processor.h:180:30:   required from here
00:04:39.904 /opt/ros/kinetic/include/opencv-3.3.1/opencv2/core/mat.hpp:2150:50: error: no type named ‘channel_type’ inclass cv::DataType<unsigned int>00:04:39.904      typedef typename DataType<_Tp>::channel_type channel_type;
00:04:39.904  

 

解决方法为https://github.com/srv/srv_tools/issues/17中提到的

在bag_tools/src下的三个文件extract_images.cpp, extract_stereo_images.cpp 和 process_stereo.cpp前面加上

#define OPENCV_TRAITS_ENABLE_DEPRECATED

编译通过,perfect!

 

接下来修改frame id,将你所要的修改frame id的rosbag文件copy到bag_tools/dataset中,

执行

./scripts/change_frame_id.py -o ./dataset/subsetcopy01.bag -i ./dataset/subset01.bag -f /openni_rgb_optical_frame -t /camera/color/image_raw

/camera/aligned_depth_to_color/image_raw

 

使用ls命令时,发现没有修改过的rosbag显示为绿色,修改后的则为白色。

好像ls后显示的颜色并不影响,直接忽略。

posted @ 2018-07-03 20:18  LIN_Weilin  阅读(2125)  评论(0编辑  收藏  举报