Turtlebot与Matlab入门教程-寻找蓝色小球
说明:
- 介绍TurtleBot如何寻找一个蓝色的球
安装支持包:
- 在MATLAB 主页选项卡,附加功能 > 获取附加功能,然后选择“TurtleBot-Based Robots”,或者,使用roboticsAddons命令
步骤:
在turtlebot端:
- [turtlebot] 启动turtlebot
roslaunch turtlebot_bringup minimal.launch
- [turtlebot] 启动kinect
roslaunch freenect_launch freenect-registered-xyzrgb.launch
- [turtlebot] 查看kinect,是否正常显示图像
rosrun image_view image_view image:=/camera/rgb/image_color
在Matlab端:
- 运行Tune_the_Blue_Ball_Detetion.m:
- 代码如下:
rosshutdown
ipaddress = '192.168.0.93';
rosinit(ipaddress);
handles.colorImgSub = exampleHelperTurtleBotEnableColorCamera;
handles.cliffSub = rossubscriber('/mobile_base/events/cliff', 'BufferSize', 5);
handles.bumpSub = rossubscriber('/mobile_base/sensors/bumper_pointcloud', 'BufferSize', 5);
handles.soundPub = rospublisher('/mobile_base/commands/sound', 'kobuki_msgs/Sound');
handles.velPub = rospublisher('/mobile_base/commands/velocity');
blueBallParams.blueMax = 110;
blueBallParams.darkMin = 30;
latestImg = readImage(handles.colorImgSub.LatestMessage);
[c,~,ball] = exampleHelperTurtleBotFindBlueBall(latestImg,blueBallParams);
exampleHelperTurtleBotPlotObject(latestImg,ball,c);
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号