map.c
Go to the documentation of this file.
00001 /*
00002  *  Player - One Hell of a Robot Server
00003  *  Copyright (C) 2000  Brian Gerkey   &  Kasper Stoy
00004  *                      gerkey@usc.edu    kaspers@robotics.usc.edu
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2.1 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Lesser General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Lesser General Public
00017  *  License along with this library; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /**************************************************************************
00022  * Desc: Global map (grid-based)
00023  * Author: Andrew Howard
00024  * Date: 6 Feb 2003
00025  * CVS: $Id: map.c 1713 2003-08-23 04:03:43Z inspectorg $
00026 **************************************************************************/
00027 
00028 #include <assert.h>
00029 #include <math.h>
00030 #include <stdlib.h>
00031 #include <string.h>
00032 #include <stdio.h>
00033 
00034 #include "nav2d_localizer/map.h"
00035 
00036 
00037 // Create a new map
00038 map_t *map_alloc(void)
00039 {
00040   map_t *map;
00041 
00042   map = (map_t*) malloc(sizeof(map_t));
00043 
00044   // Assume we start at (0, 0)
00045   map->origin_x = 0;
00046   map->origin_y = 0;
00047   
00048   // Make the size odd
00049   map->size_x = 0;
00050   map->size_y = 0;
00051   map->scale = 0;
00052   
00053   // Allocate storage for main map
00054   map->cells = (map_cell_t*) NULL;
00055   
00056   return map;
00057 }
00058 
00059 
00060 // Destroy a map
00061 void map_free(map_t *map)
00062 {
00063   free(map->cells);
00064   free(map);
00065   return;
00066 }
00067 
00068 
00069 // Get the cell at the given point
00070 map_cell_t *map_get_cell(map_t *map, double ox, double oy, double oa)
00071 {
00072   int i, j;
00073   map_cell_t *cell;
00074 
00075   i = MAP_GXWX(map, ox);
00076   j = MAP_GYWY(map, oy);
00077   
00078   if (!MAP_VALID(map, i, j))
00079     return NULL;
00080 
00081   cell = map->cells + MAP_INDEX(map, i, j);
00082   return cell;
00083 }
00084 


nav2d_localizer
Author(s): Sebastian Kasperski
autogenerated on Sun Apr 2 2017 03:52:57