Rasters
As an alternative to voxels, the map component can store what an adapter ingests as a raster: a 2D image in which each pixel covers a fixed area of the ground. Rasters suit flat environments, such as the occupancy grid produced by a 2D lidar, where they are smaller and cheaper to publish than voxels, and can be viewed and edited as an ordinary image.
There are two raster node types:
- A raster map is a single image.
- A raster tiler divides the image into square tiles, and creates a raster map for each tile as it is needed. Tiles which have not been drawn on take up no space, so a tiler can cover a large area at a fine resolution.
An adapter chooses which it writes using its outputMode setting: "rastermap" or "rastertiler". See Output Settings. Adapters which support rasters are ros.pointcloud2, ros.laser-scan, ros.occupancy-grid, spot and static-pointcloud.
Raster Settings
The image is described by the rasterSettings object of the adapter.
| Setting | Type | Description | Default |
|---|---|---|---|
resolutionX | number | The size of a pixel, in metres, in the X direction. If only one of resolutionX and resolutionY is given the other is set to the same value, giving square pixels. The ros.pointcloud2 and ros.laser-scan adapters require a resolution; ros.occupancy-grid takes it from the grid when it is not given. | |
resolutionY | number | The size of a pixel, in metres, in the Y direction. | |
pixelFormat | string | How each pixel is stored. One of "gray8" (one byte per pixel), "gray16" (two bytes per pixel) or "rgba" (four bytes per pixel, with transparency). | "rgba" |
imageFormat | string | How the image is encoded. One of "png", "tiff" or "raw". A "raw" image is a plain array of pixels with no header. | "png" |
tileWidth | integer | The width of a tile in pixels. Only used by a raster tiler. | 512 |
tileHeight | integer | The height of a tile in pixels. Only used by a raster tiler. | 512 |
unknownColor | colour | The colour reported for areas which no tile covers, and used to fill the gaps when a tiled image is assembled. | Transparent |
A colour can be written as a CSS colour string, such as "red", "#ff0000" or "rgba(255, 0, 0, 1)", or as an object: {"r": 255, "g": 0, "b": 0, "a": 255}.
Mapping Settings
The mappingSettings object of the adapter chooses the colours used to draw what the adapter has observed. Each is a colour, as above.
| Setting | Description | Default |
|---|---|---|
occupiedColor | The colour of space containing an obstacle. | Green: rgb(0, 200, 0) |
unoccupiedColor | The colour of space which is known to be free. | Transparent |
unexploredColor | The colour of space which has not been observed. If unknownColor is not set it takes this value, so that areas the robot has not visited look unexplored. | Transparent |
Example
"uniqueAdapterName": {
"enabled": true,
"type": "ros.laser-scan",
"settings": {
"source": "/ros/scan",
"outputMode": "rastertiler",
"rasterSettings": {
"resolutionX": 0.05,
"pixelFormat": "rgba",
"tileWidth": 256,
"tileHeight": 256
},
"mappingSettings": {
"occupiedColor": "black",
"unexploredColor": "#cccccc"
}
}
}
Working with Rasters
The pixels of a raster can be read and changed with the raster services of the dynamic map; see Data Model. Together with the Raster File adapter, which keeps a raster node synchronised with an image file on disk, this allows a map to be drawn in an image editor.