Perception Tool Kit (PTK) API Guide
map.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2018 Texas Instruments Incorporated
4  *
5  * All rights reserved not granted herein.
6  *
7  * Limited License.
8  *
9  * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
10  * license under copyrights and patents it now or hereafter owns or controls to make,
11  * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
12  * terms herein. With respect to the foregoing patent license, such license is granted
13  * solely to the extent that any such patent is necessary to Utilize the software alone.
14  * The patent license shall not apply to any combinations which include this software,
15  * other than combinations with devices manufactured by or for TI ("TI Devices").
16  * No hardware patent is licensed hereunder.
17  *
18  * Redistributions must preserve existing copyright notices and reproduce this license
19  * (including the above copyright notice and the disclaimer and (if applicable) source
20  * code license limitations below) in the documentation and/or other materials provided
21  * with the distribution
22  *
23  * Redistribution and use in binary form, without modification, are permitted provided
24  * that the following conditions are met:
25  *
26  * * No reverse engineering, decompilation, or disassembly of this software is
27  * permitted with respect to any software provided in binary form.
28  *
29  * * any redistribution and use are licensed by TI for use only with TI Devices.
30  *
31  * * Nothing shall obligate TI to provide you with source code for the software
32  * licensed and provided to you in object code.
33  *
34  * If software source code is provided to you, modification and redistribution of the
35  * source code are permitted provided that the following conditions are met:
36  *
37  * * any redistribution and use of the source code, including any resulting derivative
38  * works, are licensed by TI for use only with TI Devices.
39  *
40  * * any redistribution and use of any object code compiled from the source code
41  * and any resulting derivative works, are licensed by TI for use only with TI Devices.
42  *
43  * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
44  *
45  * may be used to endorse or promote products derived from this software without
46  * specific prior written permission.
47  *
48  * DISCLAIMER.
49  *
50  * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
51  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53  * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
54  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
55  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
57  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
58  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59  * OF THE POSSIBILITY OF SUCH DAMAGE.
60  *
61  */
62 #pragma once
63 #ifndef PTK_MAP_H
64 #define PTK_MAP_H
65 
72 #include <stdint.h>
73 
74 #include <perception/base/grid.h>
75 
85 #define PTK_MAP_MAX_NUM_GRIDS_PER_MAP 32U
86 
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
90 
92 
97 #define PTK_MAP_OK ((uint32_t)0)
98 
104 #define PTK_MAP_XCELL_COUNT_INVALID ((uint32_t)-1)
105 
111 #define PTK_MAP_YCELL_COUNT_INVALID ((uint32_t)-2)
112 
118 #define PTK_MAP_ZCELL_COUNT_INVALID ((uint32_t)-3)
119 
125 #define PTK_MAP_GRID_ID_INVALID ((uint32_t)-4)
126 
132 #define PTK_MAP_GRID_DATA_TYPE_INVALID ((uint32_t)-5)
133 
139 #define PTK_MAP_CELL_DATA_SIZE_INVALID ((uint32_t)-6)
140 
151 typedef struct
152 {
156  uint32_t id;
157 
160 
162  uint32_t dataSize;
163 
164 } PTK_GridInfo;
165 
175 typedef struct
176 {
178  uint32_t xCells;
179 
181  uint32_t yCells;
182 
186  uint32_t zCells;
187 
189  float xCellSize;
190 
192  float yCellSize;
193 
197  float zCellSize;
198 
200  float xMin;
201 
203  float yMin;
204 
208  float zMin;
209 
214 
215 } PTK_MapConfig;
216 
236 typedef struct
237 {
240 
241  uint32_t gridOffsets[PTK_MAP_MAX_NUM_GRIDS_PER_MAP];
242 
243 } PTK_Map;
244 
255 uint32_t PTK_Map_getSize(const PTK_MapConfig *config);
256 
271 PTK_Map * PTK_Map_init(uint8_t *mem, const PTK_MapConfig *config);
272 
283 void PTK_Map_clear(PTK_Map *map);
284 
300 uint32_t PTK_Map_copy(PTK_Map *__restrict dst, const PTK_Map *__restrict src);
301 
315 uint32_t PTK_Map_has(const PTK_Map *map, uint32_t id);
316 
330 PTK_Grid * PTK_Map_get(const PTK_Map *map, uint32_t id);
331 
332 #ifdef __cplusplus
333 }
334 #endif
335 
336 #endif
void PTK_Map_clear(PTK_Map *map)
This clears all PTK_Grids internal to the map. It has the same result as if PTK_Grid clear were calle...
uint32_t zCells
Definition: map.h:186
float yMin
Definition: map.h:203
uint32_t xCells
Definition: map.h:178
Map definition.
Definition: map.h:236
uint32_t PTK_Map_copy(PTK_Map *__restrict dst, const PTK_Map *__restrict src)
Copy all constituent PTK_Grids from the given source PTK_Map to the destination PTK_Map. They must have the same PTK_MapConfig or an assertion failure is generated.
uint32_t dataSize
Definition: map.h:162
PTK_MapConfig config
Definition: map.h:239
PTK_Map * PTK_Map_init(uint8_t *mem, const PTK_MapConfig *config)
Initialize an externally allocated piece of memory to be a valid PTK_Map. This also initializes all m...
float xCellSize
Definition: map.h:189
uint32_t id
Definition: map.h:156
uint32_t yCells
Definition: map.h:181
PTK_GridType
Grid data type definition.
Definition: grid.h:120
float zMin
Definition: map.h:208
This defines the common grid functionality which is then used to construct occupancy grids that store...
Map configuration.
Definition: map.h:175
float yCellSize
Definition: map.h:192
float zCellSize
Definition: map.h:197
float xMin
Definition: map.h:200
Grid information.
Definition: map.h:151
uint32_t PTK_Map_has(const PTK_Map *map, uint32_t id)
Test if a PTK_Map contains a PTK_Grid with the specified id.
PTK_Grid * PTK_Map_get(const PTK_Map *map, uint32_t id)
Obtain a pointer to the PTK_Grid matching the specified id.
Grid definition.
Definition: grid.h:233
PTK_GridType type
Definition: map.h:159
uint32_t PTK_Map_getSize(const PTK_MapConfig *config)
Compute how much memory is required to store the complete PTK_Map described by the given configuratio...
#define PTK_MAP_MAX_NUM_GRIDS_PER_MAP
Maximum number of grids per Map - 1. One of the nodes will be used as a NULL node.
Definition: map.h:85