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.

readBinaryOccupancyGrid

Read binary occupancy grid

Syntax

map = readBinaryOccupancyGrid(msg)
map = readBinaryOccupancyGrid(msg,thresh)
map = readBinaryOccupancyGrid(msg,thresh,val)

Description

example

map = readBinaryOccupancyGrid(msg) returns a robotics.BinaryOccupancyGrid object by reading the data inside a ROS message, msg, which must be a 'nav_msgs/OccupancyGrid' message. All message data values greater than or equal to the occupancy threshold are set to occupied, 1, in the map. All other values, including unknown values (-1) are set to unoccupied, 0, in the map.

map = readBinaryOccupancyGrid(msg,thresh) specifies a threshold, thresh, for occupied values. All values greater than or equal to the threshold are set to occupied, 1. All other values are set to unoccupied, 0.

example

map = readBinaryOccupancyGrid(msg,thresh,val) specifies a value to set for unknown values (-1 ). By default, all unknown values are set to unoccupied, 0.

Examples

collapse all

Create a occupancy grid message and populate it with data.

msg = rosmessage('nav_msgs/OccupancyGrid');
msg.Info.Height = 10; 
msg.Info.Width = 10; 
msg.Info.Resolution = 0.1; 
msg.Data = 100*rand(100,1);

Read data from message. Show the map.

map = readBinaryOccupancyGrid(msg);
show(map)

Create a occupancy grid message and populate it with data.

msg = rosmessage('nav_msgs/OccupancyGrid');
msg.Info.Height = 10; 
msg.Info.Width = 10; 
msg.Info.Resolution = 0.1; 
msg.Data = 100*rand(100,1);

Read data from message. Specify the threshold value and what unknown values should be set as. Show the map.

map = readBinaryOccupancyGrid(msg,65,1);
show(map)

Input Arguments

collapse all

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

Threshold for occupied values, specified as a scalar. Any value greater than or equal to the threshold is set to occupied, 1. All other values are set to unoccupied, 0.

Data Types: double

Value to replace unknown values, specified as either 0 or 1. Unknown message values (-1) are set to the given value.

Data Types: double | logical

Output Arguments

collapse all

Binary occupancy grid, returned as a BinaryOccupancyGrid object handle. map is converted from a 'nav_msgs/OccupancyGrid' message on the ROS network. It is an object with a grid of binary values, where 1 indicates an occupied location and 0 indications an unoccupied location.

Introduced in R2015a