localization/amcl/map/map.h
1/*
2 * Player - One Hell of a Robot Server
3 * Copyright (C) 2003
4 * Andrew Howard
5 * Brian Gerkey
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 */
22
23
24/**************************************************************************
25 * Desc: Global map (grid-based)
26 * Author: Andrew Howard
27 * Date: 6 Feb 2003
28 * CVS: $Id$
29 **************************************************************************/
30
31#ifndef MAP_H
32#define MAP_H
33
34#if !defined (WIN32)
35 #include <stdint.h>
36#endif
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42// Forward declarations
43struct _rtk_fig_t;
44
45
46// Limits
47#define MAP_WIFI_MAX_LEVELS 8
48
49
50// Description for a single map cell.
51typedef struct
52{
53 // Occupancy state (-1 = free, 0 = unknown, +1 = occ)
54 int occ_state;
55
56 // Distance to the nearest occupied cell
57 double occ_dist;
58
59 // Wifi levels
60 int wifi_levels[MAP_WIFI_MAX_LEVELS];
61
63
64
65// Description for a map
66typedef struct
67{
68 // Map origin; the map is a viewport onto a conceptual larger map.
69 double origin_x, origin_y;
70
71 // Map scale (m/cell)
72 double scale;
73
74 // Max occupancy distance value
75 double max_occ_dist;
76
77 // Map dimensions (number of cells)
78 int size_x, size_y;
79
80 unsigned char data_range;
81
82 // The map data, stored as a grid
83 map_cell_t *cells;
84
85} map_t;
86
87
88
89/**************************************************************************
90 * Basic map functions
91 **************************************************************************/
92
93// Create a new (empty) map
94map_t *map_alloc(void);
95
96// Destroy a map
97void map_free(map_t *map);
98
99// Get the cell at the given point
100map_cell_t *map_get_cell(map_t *map, double ox, double oy, double oa);
101
102// Load an occupancy map
103int map_load_occ(map_t *map, const char *filename, double scale, int negate);
104
105// Load a wifi signal strength map
106int map_load_wifi(map_t *map, const char *filename, int index);
107
108// Update the cspace distances
109void map_update_cspace(map_t *map, double max_occ_dist);
110
111
112/**************************************************************************
113 * Range functions
114 **************************************************************************/
115
116// Extract a single range reading from the map
117double map_calc_range(map_t *map, double ox, double oy, double oa, double max_range);
118
119
120/**************************************************************************
121 * GUI/diagnostic functions
122 **************************************************************************/
123
124// Draw the occupancy grid
125void map_draw_occ(map_t *map, struct _rtk_fig_t *fig);
126
127// Draw the cspace map
128void map_draw_cspace(map_t *map, struct _rtk_fig_t *fig);
129
130// Draw a wifi map
131void map_draw_wifi(map_t *map, struct _rtk_fig_t *fig, int index);
132
133
134/**************************************************************************
135 * Map manipulation macros
136 **************************************************************************/
137
138// Convert from map index to world coords
139#define MAP_WXGX(map, i) (map->origin_x + ((i) - map->size_x / 2) * map->scale)
140#define MAP_WYGY(map, j) (map->origin_y + ((j) - map->size_y / 2) * map->scale)
141
142// Convert from world coords to map coords
143#define MAP_GXWX(map, x) (floor((x - map->origin_x) / map->scale + 0.5) + map->size_x / 2)
144#define MAP_GYWY(map, y) (floor((y - map->origin_y) / map->scale + 0.5) + map->size_y / 2)
145
146// Test to see if the given map coords lie within the absolute map bounds.
147#define MAP_VALID(map, i, j) ((i >= 0) && (i < map->size_x) && (j >= 0) && (j < map->size_y))
148
149// Compute the cell index for the given map coords.
150#define MAP_INDEX(map, i, j) ((i) + (j) * map->size_x)
151
152#ifdef __cplusplus
153}
154#endif
155
156#endif
Definition localization/amcl/map/map.h:52
Definition localization/amcl/map/map.h:67