This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Read occupancy grid message


map = readOccupancyGrid(msg)



map = readOccupancyGrid(msg) returns an OccupancyGrid object by reading the data inside a ROS message, msg, which must be a 'nav_msgs/OccupancyGrid' message. All message data values are converted to probabilities from 0 to 1. The unknown values (-1) in the message are set as 0.5 in the map.


collapse all

Create a nav_msgs/OccupancyGrid ROS message.

msg = rosmessage('nav_msgs/OccupancyGrid');

Populate the ROS occupancy grid message with data.

msg.Info.Height = 10;
msg.Info.Width = 10;
msg.Info.Resolution = 0.1;
msg.Data = 100*rand(100,1);

Read the msg data and convert to an OccupancyGrid object.

map = readOccupancyGrid(msg);

Input Arguments

collapse all

'nav_msgs/OccupancyGrid' ROS message, specified as an OccupancyGrid ROS message object handle.

Output Arguments

collapse all

Occupancy grid, returned as an robotics.OccupancyGrid object handle.

Introduced in R2016b