常常存在這種狀況, 咱們須要在移動設備上錄製一些包含圖像信息的rosbag, 可是若是錄製raw格式的話,佔的內存空間太大, 通常能夠採用錄製compressed模式; 可是通常的代碼中,圖像從sensor_msgs轉換到cv::Mat都是經過原圖像,即raw類型的topic, 這時能夠咱們本身手動添加函數, 便可以訂閱compressed topic的類型; 或者若是該代碼實在麻煩,也能夠之間將錄製好的comppressed包轉換成raw格式;bash
haha@haha:/opt/ros/kinetic/lib/image_transport$ rosrun image_transport list_transports [rosrun] Couldn't find executable named list_transports below /opt/ros/kinetic/share/image_transport
查找發現/opt/ros/kinetic/lib/image_transport 裏面有對應的list_transports的可執行文件,可是在share下沒有,將lib下對應的可執行文件list_transport和republish拷貝進去。
而後便可執行rosrun image_transport list_transports;返回了對應的list:函數
image_transport/compressed image_transport/compressedDepth image_transport/h264 image_transport/raw image_transport/theora
可是執行:spa
rosrun image_transport republish compressed in:=/usb_cam150/image_raw raw out:=/usb_cam150/image_raw
仍是沒有反應,不會提示出錯,也不會終止程序
這是能夠嘗試播放包,好比個人:.net
rosbag play 2020-05-27-09-28-53.bag
這個包的信息以下:code
types: sensor_msgs/CompressedImage [8f7a12909da2c9d3332d540a0977563f] topics: /usb_cam150/image_raw/compressed 3211 msgs : sensor_msgs/CompressedImage /usb_cam180/image_raw/compressed 3211 msgs : sensor_msgs/CompressedImage
可是若是同時運行播包和republish就能夠看到兩個多出來幾個個topic以下:ip
/clock /image_republisher_1597290710044689526/compressed/parameter_descriptions /image_republisher_1597290710044689526/compressed/parameter_updates /image_republisher_1597290789065015274/compressed/parameter_descriptions /image_republisher_1597290789065015274/compressed/parameter_updates /rosout /rosout_agg /usb_cam150/image_raw /usb_cam150/image_raw/compressed /usb_cam180/image_raw /usb_cam180/image_raw/compressed
其中/usb_cam150/image_raw 和/usb_cam180/image_raw 是咱們須要的;內存
總結來說,咱們的目的是將包含壓縮圖像的bag轉換成包含raw圖像的bag,所須要的指令以下:
先運行:get
rosrun image_transport republish compressed in:=/usb_cam150/image_raw raw out:=/usb_cam150/image_raw rosrun image_transport republish compressed in:=/usb_cam180/image_raw raw out:=/usb_cam180/image_raw
再運行:同步
rosbag record -o raw.bag /usb_cam150/image_raw /usb_cam180/image_raw
最後播包:博客
rosbag play 2020-05-27-09-28-53.bag
本文同步分享在 博客「莫奈的三輪車」(CSDN)。
若有侵權,請聯繫 support@oschina.cn 刪除。
本文參與「OSC源創計劃」,歡迎正在閱讀的你也加入,一塊兒分享。