map.c
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.c 1713 2003-08-23 04:03:43Z inspectorg $
26 **************************************************************************/
27 
28 #include <assert.h>
29 #include <math.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <stdio.h>
33 
34 #include "amcl/map/map.h"
35 
36 
37 // Create a new map
39 {
40  map_t *map;
41 
42  map = (map_t*) malloc(sizeof(map_t));
43 
44  // Assume we start at (0, 0)
45  map->origin_x = 0;
46  map->origin_y = 0;
47 
48  // Make the size odd
49  map->size_x = 0;
50  map->size_y = 0;
51  map->scale = 0;
52 
53  // Allocate storage for main map
54  map->cells = (map_cell_t*) NULL;
55 
56  return map;
57 }
58 
59 
60 // Destroy a map
61 void map_free(map_t *map)
62 {
63  free(map->cells);
64  free(map);
65  return;
66 }
67 
68 
69 // Get the cell at the given point
70 map_cell_t *map_get_cell(map_t *map, double ox, double oy, double oa)
71 {
72  int i, j;
73  map_cell_t *cell;
74 
75  i = MAP_GXWX(map, ox);
76  j = MAP_GYWY(map, oy);
77 
78  if (!MAP_VALID(map, i, j))
79  return NULL;
80 
81  cell = map->cells + MAP_INDEX(map, i, j);
82  return cell;
83 }
84 
#define MAP_GXWX(map, x)
Definition: map.h:137
void map_free(map_t *map)
Definition: map.c:61
#define MAP_VALID(map, i, j)
Definition: map.h:141
map_cell_t * cells
Definition: map.h:73
Definition: map.h:46
int size_y
Definition: map.h:70
#define MAP_INDEX(map, i, j)
Definition: map.h:144
double origin_x
Definition: map.h:64
map_t * map_alloc(void)
Definition: map.c:38
double scale
Definition: map.h:67
#define MAP_GYWY(map, y)
Definition: map.h:138
int size_x
Definition: map.h:70
double origin_y
Definition: map.h:64
Definition: map.h:61
map_cell_t * map_get_cell(map_t *map, double ox, double oy, double oa)
Definition: map.c:70


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