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’ in ‘class 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后顯示的顏色並不影響,直接忽略。
