Gazebo Math
API Reference
9.0.0~pre1
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-math
include
gz
math
OccupancyGrid.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2025 Open Source Robotics Foundation
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
#ifndef GZ_MATH_OCCUPANCY_GRID_HH_
18
#define GZ_MATH_OCCUPANCY_GRID_HH_
19
20
#include <cstdint>
21
#include <vector>
22
23
#include <
gz/math/Helpers.hh
>
24
#include <gz/utils/ImplPtr.hh>
25
26
namespace
gz::math
27
{
28
inline
namespace
GZ_MATH_VERSION_NAMESPACE {
29
32
enum class
OccupancyCellState
33
{
35
Free
,
37
Occupied
,
39
Unknown
40
};
41
44
class
GZ_MATH_VISIBLE
OccupancyGrid
45
{
54
public
:
OccupancyGrid
(
double
_resolutionMeters
,
int
_widthCells
,
55
int
_heightCells
,
double
_originX
= 0.0,
double
_originY
= 0.0);
56
63
// be false if resolution is set to zero.
64
public
:
bool
WorldToGrid
(
double
_worldX
,
double
_worldY
,
int
&
_gridX
,
65
int
&
_gridY
)
const
;
66
73
public
:
void
GridToWorld
(
int
_gridX
,
int
_gridY
,
double
&
_worldX
,
74
double
&
_worldY
)
const
;
75
80
public
:
bool
IsValidGridCoordinate
(
int
_gridX
,
int
_gridY
)
const
;
81
86
public
:
OccupancyCellState
CellState
(
int
_gridX
,
int
_gridY
)
const
;
87
92
public
:
void
CellState
(
int
_gridX
,
int
_gridY
,
OccupancyCellState
_state
);
93
101
public
:
int
CalculateIGain
(
int
_x0
,
int
_y0
,
int
_x1
,
int
_y1
);
102
111
public
:
void
MarkLine
(
int
_x0
,
int
_y0
,
int
_x1
,
int
_y1
,
112
OccupancyCellState
_state
);
113
119
public
:
bool
MarkOccupied
(
double
_worldX
,
double
_worldY
);
120
127
public
:
bool
MarkFree
(
double
_worldX0
,
double
_worldY0
,
double
_worldX1
,
128
double
_worldY1
);
129
132
public
:
void
ExportToRGBImage
(
std::vector<uint8_t>
&
_pixels
)
const
;
133
136
public
:
void
RawOccupancy
(
std::vector<int8_t>
&
_data
)
const
;
137
140
public
:
double
Resolution
()
const
;
141
144
public
:
int
Width
()
const
;
145
148
public
:
int
Height
()
const
;
149
152
public
:
double
OriginX
()
const
;
153
156
public
:
double
OriginY
()
const
;
157
159
GZ_UTILS_IMPL_PTR
(dataPtr)
160
};
161
}
162
}
// namespace gz::math
163
164
#endif