Nav2 Navigation Stack - humble
humble
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
45
// Description for a single map cell.
46
typedef
struct
47
{
48
// Occupancy state (-1 = free, 0 = unknown, +1 = occ)
49
int
occ_state;
50
51
// Distance to the nearest occupied cell
52
double
occ_dist;
53
54
// Wifi levels
55
// int wifi_levels[MAP_WIFI_MAX_LEVELS];
56
}
map_cell_t
;
57
58
59
// Description for a map
60
typedef
struct
61
{
62
// Map origin; the map is a viewport onto a conceptual larger map.
63
double
origin_x, origin_y;
64
65
// Map scale (m/cell)
66
double
scale;
67
68
// Map dimensions (number of cells)
69
int
size_x, size_y;
70
71
// The map data, stored as a grid
72
map_cell_t
* cells;
73
74
// Max distance at which we care about obstacles, for constructing
75
// likelihood field
76
double
max_occ_dist;
77
}
map_t
;
78
79
80
/**************************************************************************
81
* Basic map functions
82
**************************************************************************/
83
84
// Create a new (empty) map
85
map_t
* map_alloc(
void
);
86
87
// Destroy a map
88
void
map_free(
map_t
* map);
89
90
// Update the cspace distances
91
void
map_update_cspace(
map_t
* map,
double
max_occ_dist);
92
93
94
/**************************************************************************
95
* Range functions
96
**************************************************************************/
97
98
// Extract a single range reading from the map
99
double
map_calc_range(
map_t
* map,
double
ox,
double
oy,
double
oa,
double
max_range);
100
101
102
/**************************************************************************
103
* GUI/diagnostic functions
104
**************************************************************************/
105
106
// Draw the occupancy grid
107
void
map_draw_occ(
map_t
* map,
struct
_rtk_fig_t * fig);
108
109
// Draw the cspace map
110
void
map_draw_cspace(
map_t
* map,
struct
_rtk_fig_t * fig);
111
112
// Draw a wifi map
113
void
map_draw_wifi(
map_t
* map,
struct
_rtk_fig_t * fig,
int
index);
114
115
116
/**************************************************************************
117
* Map manipulation macros
118
**************************************************************************/
119
120
// Convert from map index to world coords
121
#define MAP_WXGX(map, i) (map->origin_x + ((i) - map->size_x / 2) * map->scale)
122
#define MAP_WYGY(map, j) (map->origin_y + ((j) - map->size_y / 2) * map->scale)
123
124
// Convert from world coords to map coords
125
#define MAP_GXWX(map, x) (floor((x - map->origin_x) / map->scale + 0.5) + map->size_x / 2)
126
#define MAP_GYWY(map, y) (floor((y - map->origin_y) / map->scale + 0.5) + map->size_y / 2)
127
128
// Test to see if the given map coords lie within the absolute map bounds.
129
#define MAP_VALID(map, i, j) ((i >= 0) && (i < map->size_x) && (j >= 0) && (j < map->size_y))
130
131
// Compute the cell index for the given map coords.
132
#define MAP_INDEX(map, i, j) ((i) + (j) * map->size_x)
133
134
#ifdef __cplusplus
135
}
136
#endif
137
138
#endif
// NAV2_AMCL__MAP__MAP_HPP_
map_cell_t
Definition:
map.hpp:47
map_t
Definition:
map.hpp:61
Generated by
1.9.1