walking与Matlab入门教程-发布里程计并使用订阅者回调绘制位置
walking与Matlab入门教程-发布里程计并使用订阅者回调绘制位置
说明:
- 介绍如何在Matlab发布里程计并使用订阅者回调绘制位置
步骤:
- 启动小车
ros2 launch walking_bringup robot.launch.py
打开Matlab软件
在C:\Users\XXX\Documents\MATLAB\Examples\R2022a\ros\ManageQualityOfServicePoliciesInROS2Example目录下,新建一个m文件
代码如下:
setenv("ROS_DOMAIN_ID","2")
robotNode= ros2node("/simple_robot")
odomPub = ros2publisher(robotNode,"/odom","nav_msgs/Odometry",...
"Reliability","reliable");
hFig = figure;
hAxesReliable = axes("Parent",hFig);
title("Robot Position (Reliable Connection)")
xlabel("X (m)")
ylabel("Y (m)")
odomPlotSub = ros2subscriber(robotNode,"/odom",...
@(msg)exampleHelperROS2PlotOdom(msg,hAxesReliable,"ok"),...
"Reliability","reliable");
load robotPoseLidarData.mat odomData
for iMsg = 1:numel(odomData)
send(odomPub,odomData(iMsg))
end
pause(5)
点击“运行”
结果如下:
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号