matlab下,rosbag文件读取

matlab下,rosbag文件读取:


filepath=fullfile('F:','Leon Files','MH_01_easy.bag')  

bag=rosbag(filepath) 


其中filepath也不用这么麻烦的写,直接filepath = 'D:/123/123.bag' 就行



在工作区中找到bag,在Avaliable Topics中找到想要的话题 x;




最后运行这两条来提取指定的消息

geometry_message=select(bag,'MessageType','geometry_msgs/PointStamped')  

data=readMessages(geometry_message)  

完毕



另外,readMessages存在一些一直错误可能会导致read失败

加上一句即可,like that:

laserdata=readMessages(geometry_message,'DataFormat', 'struct') ;

你可能感兴趣的:(matlab下,rosbag文件读取)