当前位置:网站首页>rosbag data plotting MATLAB
rosbag data plotting MATLAB
2022-07-29 14:24:00 【confused orange】
本文介绍使用matlab对rosbagPlot the data
1rosbag用法
Start either one firstros程序,比如小乌龟,进行控制
一般而言,All it takes is a simple command
cd 桌面
rosbag record -a参考链接:rosbag使用方法汇总
After recording is complete,把bag文件拷到win系统下,打开matlab
2matlab数据处理
clear;
close all;
bag = rosbag('wugui.bag');After performing these three steps,在bagAll topics can be seen under this data


Then get the value of the specific data
sel = select(bag, 'Topic', '/turtle1/cmd_vel');
msgStructs = readMessages(sel,'DataFormat','struct');After reading the data,保存在了msgStructs这个数据里,Open this data,You can see the structure type inside


Take the topic of getting speed for example,比如XThe linear velocity in the direction can be knownLinear->X
Then do a single data fetch
vx1 = cellfun(@(m) double(m.Linear.X),msgStructs);
vy1 = cellfun(@(m) double(m.Linear.Y),msgStructs);然后vx1和vy1就是数组,It can be used for drawing
完整代码
clear;
close all;
bag = rosbag('wugui.bag');
sel = select(bag, 'Topic', '/turtle1/cmd_vel');
msgStructs = readMessages(sel,'DataFormat','struct');
vx1 = cellfun(@(m) double(m.Linear.X),msgStructs);
vy1 = cellfun(@(m) double(m.Linear.Y),msgStructs);
sel = select(bag, 'Topic', '/turtle1/pose');
msgStructs = readMessages(sel,'DataFormat','struct');
d01x = cellfun(@(m) double(m.X),msgStructs);
d01y = cellfun(@(m) double(m.Y),msgStructs);
figure(1)
hold on;
plot(d01x,d01y,'Color','b','LineStyle','-','LineWidth',1);
grid on;
边栏推荐
猜你喜欢
随机推荐
R Error in :missing values are not allowed in subscripted assignments of data frames
中国互联网科技企业群狼围攻,谷歌终于遭受重挫导致利润大跌,它为推动鸿蒙的发展而后悔...
plsql连接oracle使用完毕之后关闭问题
线上支付,出款和收款
力扣541. 反转字符串 II ----双指针解法
【LeetCode】Day105-递增的三元子序列
C#实现线程管理类
kubernetes cks strace etcd
2022年了!还在用定时器实现动画?赶紧试试requestAnimationFrame吧!
已解决SyntaxError: invalid character in identifier
TCP和UDP的基本认识
新来技术总监:谁在用 isXxx 形式定义布尔类型,明天不用来了!
PAT 甲级 A1021 Deepest Root
gdb调试常用概念整理
leetcode linked list topic
Nine kinds of way, teach you to read the resources files in the directory path
还在开发短信验证码登录?试试(本机号码一键登录)
了解 AQS 底层原理
Sqoop导入导出时数据内存溢出
1184. 欧拉回路









