Read 3-D map from Octomap ROS message



map = readOccupancyMap3D(msg) reads the data inside a ROS 'octomap_msgs/Octomap' message to return an occupancyMap3D object. All message data values are converted to probabilities from 0 to 1.


collapse all

Load Octomap ROS messages and read them into MATLAB® as an OccupancyMap3D object.

Load the Octomap ROS messages. The Octomap map messages were previously recorded in a rosbag and read into MATLAB® as ROS message objects. You could also get these ROS messages live on a network.

load octomap_msgs
  ROS Octomap message with properties:

    MessageType: 'octomap_msgs/Octomap'
         Header: [1x1 Header]
         Binary: 0
             Id: 'OcTree'
     Resolution: 0.0500
           Data: [1175340x1 int8]

  Use showdetails to show the contents of the message

Read the data from the ROS messages into an occupancyMap3D object. Display each map.

for i = 1:length(octomapMsgs)
    msg = octomapMsgs{i};
    map{i} = readOccupancyMap3D(msg);

Input Arguments

collapse all

'octomap_msgs/Octomap' ROS message, specified as an Octomap object handle. Get this message by subscribing to an 'octomap_msgs/Octomap' topic using rossubscriber on a live ROS network or by creating your own message using rosmessage.

Output Arguments

collapse all

3-D occupancy map, returned as an occupancyMap3D object handle.

Introduced in R2018a