一、turtlebot_gazebo走圈
打开gazebo_turelebot
roslaunch turtlebot_gazebo turtlebot_world.launch
m文件:
while(1)
velocity = 0.2;
angular = 0.1;
robot = rospublisher('/mobile_base/commands/velocity') ;
velmsg = rosmessage(robot);
velmsg.Linear.X = velocity;
velmsg.Angular.Z = angular;
send(robot,velmsg);
end
二、获取机器人3+4元素
while(1)
velocity = 0.2;
angular = 0.1;
robot = rospublisher('/mobile_base/commands/velocity') ;
velmsg = rosmessage(robot);
velmsg.Linear.X = velocity;
velmsg.Angular.Z = angular;
send(robot,velmsg);
odom = rossubscriber('/odom');
odomdata = receive(odom);
pose = odomdata.Pose.Pose;
x = pose.Position.X;
y = pose.Position.Y;
z = pose.Position.Z;
quat = pose.Orientation;
angles = quat2eul([quat.W quat.X quat.Y quat.Z]);
theta = rad2deg(angles(1));
[x, y , z, theta]
end
三、获取机器人的传感器(kinect等)数据
imsub = rossubscriber('/camera/rgb/image_raw/compressed');
tic;
while toc < 20
img = receive(imsub);
imshow(readImage(img))
end
获取camera的图像。