Skip to content

Map data

Sascha edited this page May 11, 2021 · 2 revisions

Events

Following events are emitted by the library and contain JSON as message (examples, see below):

Event Description Ozmo 950 command (on/report events are also considered)
Maps available maps (max. 2 for Ozmo 950) getCachedMapInfo
MapSpotAreas available spotAreas per map (as array) getMapSet type="ar"
MapSpotAreaInfo details of a single spotArea getMapSubSet type="ar"
MapVirtualBoundaries available virtual boundaries per map (as array) getMapSet type=["vw", "mw"]
MapVirtualBoundaryInfo details of a single virtual boundary getMapSubSet type=["vw", "mw"]

Example event messages

Maps
{
	[{
		"mapID": "1260001067",
		"mapIndex": 0,
		"mapStatus": 1,
		"mapIsCurrentMap": false,
		"mapIsBuilt": true,
		"mapName": "EG"
	},
	{
		"mapID": "1307200506",
		"mapIndex": 1,
		"mapStatus": 1,
		"mapIsCurrentMap": true,
		"mapIsBuilt": false,
		"mapName": "OG"
	}]
}

MapSpotAreas
{
	"mapID": "1307200506",
	"mapSetID": "207",
	"mapSpotAreas":
	[{
		"mapSpotAreaID": "2"
	},
	{
		"mapSpotAreaID": "0"
	},
	{
		"mapSpotAreaID": "1"
	}]
}

MapSpotAreaInfo
{
	"mapSpotAreaID": "0",
	"mapSpotAreaName": "A",
	"mapID": "1307200506",
	"mapSpotAreaConnections": "1,2",
	"mapSpotAreaSubType": "0",
	"mapSpotAreaBoundaries": "-300,5400;-250,5550;350,5600;500,5750;450,5800;500,5900;750,5500;800,5000;1100,4200;3050,4200;3150,4300;2850,4450;1750,4450;1500,4700;1600,4850;2050,4800;2300,4550;2400,4600;2450,4750;2500,4700;3750,4700;3800,4650;3650,4300;3850,4050;4100,4100;4450,4650;4450,4200;4250,4000;4250,3550;4400,3400;4550,3500;4550,3250;4450,3150;4150,3100;4250,3000;4200,2850;4100,2950;3700,2750;3850,2600;4150,2600;4400,2250;4550,2300;4550,1750;4400,1950;4200,1800;4200,1450;4400,1250;4350,650;4250,650;4250,950;3850,1300;3750,1300;3600,1050;3950,750;2450,750;2350,950;2200,750;1400,750;1300,850;1200,750;950,700;250,700;250,1550;100,1700;150,1800;100,2450;200,2600;100,2850;100,3300;300,3450;250,3800;400,4000;400,4500;0,4900;-250,5350;-300,5400"
}

MapVirtualBoundaries
{
	"mapID":"1675619197",
	"mapVirtualWalls":
	[{
		"mapVirtualBoundaryID":"8",
		"mapVirtualBoundaryType":"vw"
	},
	{
		"mapVirtualBoundaryID":"9",
		"mapVirtualBoundaryType":"vw"
	}],
	"mapNoMopZones":
	[{
		"mapVirtualBoundaryID":"12",
		"mapVirtualBoundaryType":"mw"
	}]
}

MapVirtualBoundaryInfo
{
	"mapID": "1307200506",
	"mapVirtualBoundaryID": "8",
	"mapVirtualBoundaryType": "vw",
	"mapVirtualBoundaryCoordinates": "[-1071,-2228,-1071,-4073,-2298,-4073,-2298,-2228]"
}

Example code

First you have to use the shorcut function to retreive the map data:

vacbot.run("GetMaps");

Then you have to handle the events for using the data of the map (and also the spot areas and virtual boundaries):

vacbot.on('Maps', (maps) => {
    console.log('Maps: ' + JSON.stringify(maps));
    for (const i in maps['maps']) {
        const mapID = maps['maps'][i]['mapID'];
        vacbot.run('GetSpotAreas', mapID);
        vacbot.run('GetVirtualBoundaries', mapID);
    }
});

vacbot.on('MapSpotAreas', (spotAreas) => {
    console.log('MapSpotAreas: ' + JSON.stringify(spotAreas));
    for (const i in spotAreas['mapSpotAreas']) {
        const spotAreaID = spotAreas['mapSpotAreas'][i]['mapSpotAreaID'];
        vacbot.run('GetSpotAreaInfo', spotAreas['mapID'], spotAreaID);
    }
});

vacbot.on('MapSpotAreaInfo', (area) => {
    console.log('MapSpotAreaInfo: ' + JSON.stringify(area));
});

vacbot.on('MapVirtualBoundaries', (virtualBoundaries) => {
    console.log('MapVirtualBoundaries: ' + JSON.stringify(virtualBoundaries));
    const mapID = virtualBoundaries['mapID'];
    const virtualBoundariesCombined = [...virtualBoundaries['mapVirtualWalls'], ...virtualBoundaries['mapNoMopZones']];
    const virtualBoundaryArray = [];
    for (const i in virtualBoundariesCombined) {
        virtualBoundaryArray[virtualBoundariesCombined[i]['mapVirtualBoundaryID']] = virtualBoundariesCombined[i];
    }
    for (const i in virtualBoundaryArray) {
        const mapVirtualBoundaryID = virtualBoundaryArray[i]['mapVirtualBoundaryID'];
        const mapVirtualBoundaryType = virtualBoundaryArray[i]['mapVirtualBoundaryType'];
        vacbot.run('GetVirtualBoundaryInfo', mapID, mapVirtualBoundaryID, mapVirtualBoundaryType);
    }
});

vacbot.on('MapVirtualBoundaryInfo', (virtualBoundary) => {
    console.log('MapVirtualBoundaryInfo: ' + JSON.stringify(virtualBoundary));
});
Clone this wiki locally