📄 map.h
字号:
/************************************************************************** * Desc: Global map (grid-based) * Author: Andrew Howard * Date: 6 Feb 2003 * CVS: $Id: map.h,v 1.3.2.2 2003/04/18 23:43:11 inspectorg Exp $ **************************************************************************/#ifndef MAP_H#define MAP_H#include <stdint.h>#ifdef __cplusplusextern "C" {#endif// Forward declarationsstruct _rtk_fig_t;// Description for a single map cell.typedef struct{ // Occupancy state (-1 = free, 0 = unknown, +1 = occ) int occ_state; // Distance to the nearest occupied cell double occ_dist;} map_cell_t;// Description for a maptypedef struct{ // Map origin; the map is a viewport onto a conceptual larger map. double origin_x, origin_y; // Map scale (m/cell) double scale; // Max occupancy distance value double max_occ_dist; // Map dimensions (number of cells) int size_x, size_y; // The map data, stored as a grid map_cell_t *cells; } map_t;/************************************************************************** * Basic map functions **************************************************************************/// Create a new (empty) mapmap_t *map_alloc(double scale);// Destroy a mapvoid map_free(map_t *map);// Get the cell at the given pointmap_cell_t *map_get_cell(map_t *map, double ox, double oy, double oa);// Load a map file (occupancy grid)int map_load_occ(map_t *map, const char *filename, int negate);// Update the cspace distancesvoid map_update_cspace(map_t *map, double max_occ_dist);/************************************************************************** * Range functions **************************************************************************/// Extract a single range reading from the mapdouble map_calc_range(map_t *map, double ox, double oy, double oa, double max_range);/************************************************************************** * GUI/diagnostic functions **************************************************************************/// Draw the occupancy gridvoid map_draw_occ(map_t *map, struct _rtk_fig_t *fig);// Draw the cspace mapvoid map_draw_cspace(map_t *map, struct _rtk_fig_t *fig);/************************************************************************** * Map manipulation macros **************************************************************************/// Convert from map index to world coords#define MAP_WXGX(map, i) (map->origin_x + ((i) - map->size_x / 2) * map->scale)#define MAP_WYGY(map, j) (map->origin_y + ((j) - map->size_y / 2) * map->scale)// Convert from world coords to map coords#define MAP_GXWX(map, x) (floor((x - map->origin_x) / map->scale + 0.5) + map->size_x / 2)#define MAP_GYWY(map, y) (floor((y - map->origin_y) / map->scale + 0.5) + map->size_y / 2)// Test to see if the given map coords lie within the absolute map bounds.#define MAP_VALID(map, i, j) ((i >= 0) && (i < map->size_x) && (j >= 0) && (j < map->size_y))// Compute the cell index for the given map coords.#define MAP_INDEX(map, i, j) ((i) + (j) * map->size_x)#ifdef __cplusplus}#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -