map.h
Go to the documentation of this file.
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 MAP_H
29 #define MAP_H
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 
57 } map_cell_t;
58 
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
74 
75  // Max distance at which we care about obstacles, for constructing
76  // likelihood field
77  double max_occ_dist;
78 
79 } map_t;
80 
81 
82 
83 /**************************************************************************
84  * Basic map functions
85  **************************************************************************/
86 
87 // Create a new (empty) map
88 map_t *map_alloc(void);
89 
90 // Destroy a map
91 void map_free(map_t *map);
92 
93 // Get the cell at the given point
94 map_cell_t *map_get_cell(map_t *map, double ox, double oy, double oa);
95 
96 // Load an occupancy map
97 int map_load_occ(map_t *map, const char *filename, double scale, int negate);
98 
99 // Load a wifi signal strength map
100 //int map_load_wifi(map_t *map, const char *filename, int index);
101 
102 // Update the cspace distances
103 void map_update_cspace(map_t *map, double max_occ_dist);
104 
105 
106 /**************************************************************************
107  * Range functions
108  **************************************************************************/
109 
110 // Extract a single range reading from the map
111 double map_calc_range(map_t *map, double ox, double oy, double oa, double max_range);
112 
113 
114 /**************************************************************************
115  * GUI/diagnostic functions
116  **************************************************************************/
117 
118 // Draw the occupancy grid
119 void map_draw_occ(map_t *map, struct _rtk_fig_t *fig);
120 
121 // Draw the cspace map
122 void map_draw_cspace(map_t *map, struct _rtk_fig_t *fig);
123 
124 // Draw a wifi map
125 void map_draw_wifi(map_t *map, struct _rtk_fig_t *fig, int index);
126 
127 
128 /**************************************************************************
129  * Map manipulation macros
130  **************************************************************************/
131 
132 // Convert from map index to world coords
133 #define MAP_WXGX(map, i) (map->origin_x + ((i) - map->size_x / 2) * map->scale)
134 #define MAP_WYGY(map, j) (map->origin_y + ((j) - map->size_y / 2) * map->scale)
135 
136 // Convert from world coords to map coords
137 #define MAP_GXWX(map, x) (floor((x - map->origin_x) / map->scale + 0.5) + map->size_x / 2)
138 #define MAP_GYWY(map, y) (floor((y - map->origin_y) / map->scale + 0.5) + map->size_y / 2)
139 
140 // Test to see if the given map coords lie within the absolute map bounds.
141 #define MAP_VALID(map, i, j) ((i >= 0) && (i < map->size_x) && (j >= 0) && (j < map->size_y))
142 
143 // Compute the cell index for the given map coords.
144 #define MAP_INDEX(map, i, j) ((i) + (j) * map->size_x)
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif
void map_update_cspace(map_t *map, double max_occ_dist)
Definition: map_cspace.cpp:120
map_cell_t * cells
Definition: map.h:73
Definition: map.h:46
int size_y
Definition: map.h:70
int map_load_occ(map_t *map, const char *filename, double scale, int negate)
Definition: map_store.c:39
double scale
Definition: map.h:67
double occ_dist
Definition: map.h:52
double map_calc_range(map_t *map, double ox, double oy, double oa, double max_range)
Definition: map_range.c:38
map_cell_t * map_get_cell(map_t *map, double ox, double oy, double oa)
Definition: map.c:70
double origin_y
Definition: map.h:64
int occ_state
Definition: map.h:49
Definition: map.h:61
void map_draw_cspace(map_t *map, struct _rtk_fig_t *fig)
void map_draw_wifi(map_t *map, struct _rtk_fig_t *fig, int index)
void map_draw_occ(map_t *map, struct _rtk_fig_t *fig)
void map_free(map_t *map)
Definition: map.c:61
map_t * map_alloc(void)
Definition: map.c:38
double max_occ_dist
Definition: map.h:77


amcl
Author(s): Brian P. Gerkey, contradict@gmail.com
autogenerated on Thu Jan 21 2021 04:05:36