Home
FAQ
Player
Stage
Gazebo
Contrib
Documentation
Publications
Contributors
Users

Project
Download
Bugs/Feedback
Mailing lists

Radish

Old news
Old stuff

map.h

Go to the documentation of this file.
00001 
00002 /**************************************************************************
00003  * Desc: Global map (grid-based)
00004  * Author: Andrew Howard
00005  * Date: 6 Feb 2003
00006  * CVS: $Id: map.h,v 1.7 2003/08/23 04:03:43 inspectorg Exp $
00007  **************************************************************************/
00008 
00009 #ifndef MAP_H
00010 #define MAP_H
00011 
00012 #include <stdint.h>
00013 
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018 // Forward declarations
00019 struct _rtk_fig_t;
00020 
00021   
00022 // Limits
00023 #define MAP_WIFI_MAX_LEVELS 8
00024 
00025   
00026 // Description for a single map cell.
00027 typedef struct
00028 {
00029   // Occupancy state (-1 = free, 0 = unknown, +1 = occ)
00030   int occ_state;
00031 
00032   // Distance to the nearest occupied cell
00033   double occ_dist;
00034 
00035   // Wifi levels
00036   int wifi_levels[MAP_WIFI_MAX_LEVELS];
00037 
00038 } map_cell_t;
00039 
00040 
00041 // Description for a map
00042 typedef struct
00043 {
00044   // Map origin; the map is a viewport onto a conceptual larger map.
00045   double origin_x, origin_y;
00046   
00047   // Map scale (m/cell)
00048   double scale;
00049 
00050   // Max occupancy distance value
00051   double max_occ_dist;
00052 
00053   // Map dimensions (number of cells)
00054   int size_x, size_y;
00055   
00056   // The map data, stored as a grid
00057   map_cell_t *cells;
00058   
00059 } map_t;
00060 
00061 
00062 
00063 /**************************************************************************
00064  * Basic map functions
00065  **************************************************************************/
00066 
00067 // Create a new (empty) map
00068 map_t *map_alloc(void);
00069 
00070 // Destroy a map
00071 void map_free(map_t *map);
00072 
00073 // Get the cell at the given point
00074 map_cell_t *map_get_cell(map_t *map, double ox, double oy, double oa);
00075 
00076 // Load an occupancy map
00077 int map_load_occ(map_t *map, const char *filename, double scale, int negate);
00078 
00079 // Load a wifi signal strength map
00080 int map_load_wifi(map_t *map, const char *filename, int index);
00081 
00082 // Update the cspace distances
00083 void map_update_cspace(map_t *map, double max_occ_dist);
00084 
00085 
00086 /**************************************************************************
00087  * Range functions
00088  **************************************************************************/
00089 
00090 // Extract a single range reading from the map
00091 double map_calc_range(map_t *map, double ox, double oy, double oa, double max_range);
00092 
00093 
00094 /**************************************************************************
00095  * GUI/diagnostic functions
00096  **************************************************************************/
00097 
00098 // Draw the occupancy grid
00099 void map_draw_occ(map_t *map, struct _rtk_fig_t *fig);
00100 
00101 // Draw the cspace map
00102 void map_draw_cspace(map_t *map, struct _rtk_fig_t *fig);
00103 
00104 // Draw a wifi map
00105 void map_draw_wifi(map_t *map, struct _rtk_fig_t *fig, int index);
00106 
00107 
00108 /**************************************************************************
00109  * Map manipulation macros
00110  **************************************************************************/
00111 
00112 // Convert from map index to world coords
00113 #define MAP_WXGX(map, i) (map->origin_x + ((i) - map->size_x / 2) * map->scale)
00114 #define MAP_WYGY(map, j) (map->origin_y + ((j) - map->size_y / 2) * map->scale)
00115 
00116 // Convert from world coords to map coords
00117 #define MAP_GXWX(map, x) (floor((x - map->origin_x) / map->scale + 0.5) + map->size_x / 2)
00118 #define MAP_GYWY(map, y) (floor((y - map->origin_y) / map->scale + 0.5) + map->size_y / 2)
00119 
00120 // Test to see if the given map coords lie within the absolute map bounds.
00121 #define MAP_VALID(map, i, j) ((i >= 0) && (i < map->size_x) && (j >= 0) && (j < map->size_y))
00122 
00123 // Compute the cell index for the given map coords.
00124 #define MAP_INDEX(map, i, j) ((i) + (j) * map->size_x)
00125 
00126 #ifdef __cplusplus
00127 }
00128 #endif
00129 
00130 #endif

Generated on Tue May 3 14:15:34 2005 for Player by doxygen 1.3.6