Nav2 Navigation Stack - jazzy
jazzy
ROS 2 Navigation Stack
nav2_amcl
include
nav2_amcl
map
map.hpp
1
/*
2
* Player - One Hell of a Robot Server
3
* Copyright (C) 2000 Brian Gerkey & Kasper Stoy
4
* gerkey@usc.edu kaspers@robotics.usc.edu
5
*
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
*
20
*/
21
/**************************************************************************
22
* Desc: Global map (grid-based)
23
* Author: Andrew Howard
24
* Date: 6 Feb 2003
25
* CVS: $Id: map.h 1713 2003-08-23 04:03:43Z inspectorg $
26
**************************************************************************/
27
28
#ifndef NAV2_AMCL__MAP__MAP_HPP_
29
#define NAV2_AMCL__MAP__MAP_HPP_
30
31
#include <stdint.h>
32
33
#ifdef __cplusplus
34
extern
"C"
{
35
#endif
36
37
// Forward declarations
38
struct
_rtk_fig_t;
39
40
41
// Limits
42
#define MAP_WIFI_MAX_LEVELS 8
43
44
// make sure that the sizeof(map_cell_t) == 5
45
#pragma pack(push, 1)
46
// Description for a single map cell.
47
typedef
struct
48
{
49
// Occupancy state (-1 = free, 0 = unknown, +1 = occ)
50
int8_t occ_state;
51
52
// Distance to the nearest occupied cell
53
float
occ_dist;
54
55
// Wifi levels
56
// int wifi_levels[MAP_WIFI_MAX_LEVELS];
57
}
map_cell_t
;
58
#pragma pack(pop)
59
60
// Description for a map
61
typedef
struct
62
{
63
// Map origin; the map is a viewport onto a conceptual larger map.
64
double
origin_x, origin_y;
65
66
// Map scale (m/cell)
67
double
scale;
68
69
// Map dimensions (number of cells)
70
int
size_x, size_y;
71
72
// The map data, stored as a grid
73
map_cell_t
* cells;
74
75
// Max distance at which we care about obstacles, for constructing
76
// likelihood field
77
double
max_occ_dist;
78
}
map_t
;
79
80
81
/**************************************************************************
82
* Basic map functions
83
**************************************************************************/
84
85
// Create a new (empty) map
86
map_t
* map_alloc(
void
);
87
88
// Destroy a map
89
void
map_free(
map_t
* map);
90
91
// Update the cspace distances
92
void
map_update_cspace(
map_t
* map,
double
max_occ_dist);
93
94
95
/**************************************************************************
96
* Range functions
97
**************************************************************************/
98
99
// Extract a single range reading from the map
100
double
map_calc_range(
map_t
* map,
double
ox,
double
oy,
double
oa,
double
max_range);
101
102
103
/**************************************************************************
104
* GUI/diagnostic functions
105
**************************************************************************/
106
107
// Draw the occupancy grid
108
void
map_draw_occ(
map_t
* map,
struct
_rtk_fig_t * fig);
109
110
// Draw the cspace map
111
void
map_draw_cspace(
map_t
* map,
struct
_rtk_fig_t * fig);
112
113
// Draw a wifi map
114
void
map_draw_wifi(
map_t
* map,
struct
_rtk_fig_t * fig,
int
index);
115
116
117
/**************************************************************************
118
* Map manipulation macros
119
**************************************************************************/
120
121
// Convert from map index to world coords
122
#define MAP_WXGX(map, i) (map->origin_x + ((i) - map->size_x / 2) * map->scale)
123
#define MAP_WYGY(map, j) (map->origin_y + ((j) - map->size_y / 2) * map->scale)
124
125
// Convert from world coords to map coords
126
#define MAP_GXWX(map, x) (floor((x - map->origin_x) / map->scale + 0.5) + map->size_x / 2)
127
#define MAP_GYWY(map, y) (floor((y - map->origin_y) / map->scale + 0.5) + map->size_y / 2)
128
129
// Test to see if the given map coords lie within the absolute map bounds.
130
#define MAP_VALID(map, i, j) ((i >= 0) && (i < map->size_x) && (j >= 0) && (j < map->size_y))
131
132
// Compute the cell index for the given map coords.
133
#define MAP_INDEX(map, i, j) ((i) + (j) * map->size_x)
134
135
#ifdef __cplusplus
136
}
137
#endif
138
139
#endif
// NAV2_AMCL__MAP__MAP_HPP_
map_cell_t
Definition:
map.hpp:48
map_t
Definition:
map.hpp:62
Generated by
1.9.1