Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * map.h: Global map (grid-based) 00004 * 00005 * Created: Thu May 24 18:44:56 2012 00006 * Copyright 2000 Brian Gerkey 00007 * 2000 Kasper Stoy 00008 * 2012 Tim Niemueller [www.niemueller.de] 00009 ****************************************************************************/ 00010 00011 /* This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL file in the doc directory. 00022 */ 00023 00024 /* From: 00025 * Player - One Hell of a Robot Server (LGPL) 00026 * Copyright (C) 2000 Brian Gerkey & Kasper Stoy 00027 * gerkey@usc.edu kaspers@robotics.usc.edu 00028 */ 00029 /************************************************************************** 00030 * Desc: Global map (grid-based) 00031 * Author: Andrew Howard 00032 * Date: 6 Feb 2003 00033 **************************************************************************/ 00034 00035 #ifndef MAP_H 00036 #define MAP_H 00037 00038 #include <stdint.h> 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /// @cond EXTERNAL 00045 00046 // Forward declarations 00047 struct _rtk_fig_t; 00048 00049 00050 // Limits 00051 #define MAP_WIFI_MAX_LEVELS 8 00052 00053 00054 // Description for a single map cell. 00055 typedef struct 00056 { 00057 // Occupancy state (-1 = free, 0 = unknown, +1 = occ) 00058 int occ_state; 00059 00060 // Distance to the nearest occupied cell 00061 double occ_dist; 00062 00063 // Wifi levels 00064 //int wifi_levels[MAP_WIFI_MAX_LEVELS]; 00065 00066 } map_cell_t; 00067 00068 00069 // Description for a map 00070 typedef struct 00071 { 00072 // Map origin; the map is a viewport onto a conceptual larger map. 00073 double origin_x, origin_y; 00074 00075 // Map scale (m/cell) 00076 double scale; 00077 00078 // Map dimensions (number of cells) 00079 int size_x, size_y; 00080 00081 // The map data, stored as a grid 00082 map_cell_t *cells; 00083 00084 // Max distance at which we care about obstacles, for constructing 00085 // likelihood field 00086 double max_occ_dist; 00087 00088 } map_t; 00089 00090 00091 00092 /************************************************************************** 00093 * Basic map functions 00094 **************************************************************************/ 00095 00096 // Create a new (empty) map 00097 map_t *map_alloc(void); 00098 00099 // Destroy a map 00100 void map_free(map_t *map); 00101 00102 // Get the cell at the given point 00103 map_cell_t *map_get_cell(map_t *map, double ox, double oy, double oa); 00104 00105 // Load an occupancy map 00106 int map_load_occ(map_t *map, const char *filename, double scale, int negate); 00107 00108 // Load a wifi signal strength map 00109 //int map_load_wifi(map_t *map, const char *filename, int index); 00110 00111 // Update the cspace distances 00112 void map_update_cspace(map_t *map, double max_occ_dist); 00113 00114 00115 /************************************************************************** 00116 * Range functions 00117 **************************************************************************/ 00118 00119 // Extract a single range reading from the map 00120 double map_calc_range(map_t *map, double ox, double oy, double oa, double max_range); 00121 00122 00123 /************************************************************************** 00124 * GUI/diagnostic functions 00125 **************************************************************************/ 00126 00127 // Draw the occupancy grid 00128 void map_draw_occ(map_t *map, struct _rtk_fig_t *fig); 00129 00130 // Draw the cspace map 00131 void map_draw_cspace(map_t *map, struct _rtk_fig_t *fig); 00132 00133 // Draw a wifi map 00134 void map_draw_wifi(map_t *map, struct _rtk_fig_t *fig, int index); 00135 00136 00137 /************************************************************************** 00138 * Map manipulation macros 00139 **************************************************************************/ 00140 00141 // Convert from map index to world coords 00142 #define MAP_WXGX(map, i) (map->origin_x + ((i) - map->size_x / 2) * map->scale) 00143 #define MAP_WYGY(map, j) (map->origin_y + ((j) - map->size_y / 2) * map->scale) 00144 00145 // Convert from world coords to map coords 00146 #define MAP_GXWX(map, x) (floor((x - map->origin_x) / map->scale + 0.5) + map->size_x / 2) 00147 #define MAP_GYWY(map, y) (floor((y - map->origin_y) / map->scale + 0.5) + map->size_y / 2) 00148 00149 // Test to see if the given map coords lie within the absolute map bounds. 00150 #define MAP_VALID(map, i, j) ((i >= 0) && (i < map->size_x) && (j >= 0) && (j < map->size_y)) 00151 00152 // Compute the cell index for the given map coords. 00153 #define MAP_INDEX(map, i, j) ((i) + (j) * map->size_x) 00154 00155 /// @endcond 00156 00157 #ifdef __cplusplus 00158 } 00159 #endif 00160 00161 #endif