Main Content

getPointCloud

Get point cloud image fromTurtleBotcamera

Description

example

pcloud= getPointCloud(tbot)waits for the next published point cloud message from the TurtleBot®connected through the interface object,tbot, and returns the point cloud image. If no message is received in five seconds, the function displays an error.

[pcloud,pcloudMsg] = getPointCloud(tbot)also returns the received ROS point cloud message.

[___] = getPointCloud(tbot,timeout)waits for the next point cloud image fortimeoutseconds. If no new message is received in that time, the function displays an error. A timeout of zero returns the latest received message without waiting. If no message has been received, the function returns an empty matrix forpcloudand an empty message forpcloudMsg, if specified.

Examples

collapse all

Connect to the TurtleBot robot. Change'192.168.1.1'to the IP address of the robot.

tbot = turtlebot('192.168.1.1');

获得最新的点云图像从TurtleBot.

pcloud = getPointCloud(tbot);

Connect to the TurtleBot robot. Change'192.168.1.1'to the IP address of the robot.

tbot = turtlebot('192.168.1.1');

Get the latest point cloud image and message from the TurtleBot.

[pcloud,pcloudMsg] = getPointCloud(tbot);

Get RGB values for each point in the point cloud message usingreadRGB. You can read other information as MATLAB®data types includingreadXYZandreadAllFieldNames.

rgb = readRGB (pcloudMsg);

Connect to the TurtleBot robot. Change'192.168.1.1'to the IP address of the robot.

tbot = turtlebot('192.168.1.1');

Get the latest point cloud image and message from the TurtleBot.

[pcloud,pcloudMsg] = getPointCloud(tbot);

Plot the point cloud usingscatter3.

scatter3(pcloudMsg)

Input Arguments

collapse all

TurtleBot interface object, specified as aturtlebotobject. The object contains properties for activating subscribers and accessing topic names relevant to the TurtleBot. The properties contain the topic name and active status of different subscribers for the TurtleBot. When you create the object withturtlebot, the properties available are:

tbot = turtlebot
tbot = turtlebot with properties: Velocity: [1x1 struct] ColorImage: [1x1 struct] GrayImage: [1x1 struct] DepthImage: [1x1 struct] PointCloud: [1x1 struct] LaserScan: [1x1 struct] Odometry: [1x1 struct] OdometryReset: [1x1 struct] IMU: [1x1 struct] TransformFrames: {0x1 cell} TopicNames: {3x1 cell}

For properties with relevant ROS data messages , you can view the topic name and a subscriber’s active status. A specific subscriber is active for the givenTopicNameif活跃的equals 1.

tbot.Velocity
ans = TopicName: '/mobile_base/commands/velocity' Active: 1

Timeout for receiving an image, specified as a scalar in seconds. The function returns an error aftertimeoutseconds. Iftimeoutequals zero, the function returns the latest image. If the TurtleBot has no latest message, the function returns a blank image and blank image message.

Output Arguments

collapse all

Point cloud image, returned as a structure containing these fields:

  • XYZ— Ann-by-3 matrix containing thexyz-coordinates of allnpoints. Each row represents one 3–D point.

  • RGB— Ann-by-3 matrix containing the RGB values of allnpoints. Each row corresponds to the one 3-D point inpcloud.XYZ.

'sensor_msgs/PointCloud2'ROS point cloud message, returned as aPointCloud2object handle.

Introduced in R2016a