00001
00002
00003
00004
00005
00006
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
00019 struct _rtk_fig_t;
00020
00021
00022
00023 #define MAP_WIFI_MAX_LEVELS 8
00024
00025
00026
00027 typedef struct
00028 {
00029
00030 int occ_state;
00031
00032
00033 double occ_dist;
00034
00035
00036 int wifi_levels[MAP_WIFI_MAX_LEVELS];
00037
00038 } map_cell_t;
00039
00040
00041
00042 typedef struct
00043 {
00044
00045 double origin_x, origin_y;
00046
00047
00048 double scale;
00049
00050
00051 double max_occ_dist;
00052
00053
00054 int size_x, size_y;
00055
00056
00057 map_cell_t *cells;
00058
00059 } map_t;
00060
00061
00062
00063
00064
00065
00066
00067
00068 map_t *map_alloc(void);
00069
00070
00071 void map_free(map_t *map);
00072
00073
00074 map_cell_t *map_get_cell(map_t *map, double ox, double oy, double oa);
00075
00076
00077 int map_load_occ(map_t *map, const char *filename, double scale, int negate);
00078
00079
00080 int map_load_wifi(map_t *map, const char *filename, int index);
00081
00082
00083 void map_update_cspace(map_t *map, double max_occ_dist);
00084
00085
00086
00087
00088
00089
00090
00091 double map_calc_range(map_t *map, double ox, double oy, double oa, double max_range);
00092
00093
00094
00095
00096
00097
00098
00099 void map_draw_occ(map_t *map, struct _rtk_fig_t *fig);
00100
00101
00102 void map_draw_cspace(map_t *map, struct _rtk_fig_t *fig);
00103
00104
00105 void map_draw_wifi(map_t *map, struct _rtk_fig_t *fig, int index);
00106
00107
00108
00109
00110
00111
00112
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
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
00121 #define MAP_VALID(map, i, j) ((i >= 0) && (i < map->size_x) && (j >= 0) && (j < map->size_y))
00122
00123
00124 #define MAP_INDEX(map, i, j) ((i) + (j) * map->size_x)
00125
00126 #ifdef __cplusplus
00127 }
00128 #endif
00129
00130 #endif