readBinaryOccupancyGrid

Read binary occupancy grid

Description

example

map = readBinaryOccupancyGrid(msg) returns a binaryOccupancyMap 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 binaryOccupancyMap 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