Robot Agent  1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pheromone.h
Go to the documentation of this file.
1 
12 #ifndef __PHEROMONE_H
13 #define __PHEROMONE_H
14 
15 /* -- Includes -- */
16 /* project libraries */
17 #include "enviroment.h"
18 #include "robot.h"
19 #include "config.h"
20 
21 
22 /* -- Types -- */
23 
27 typedef struct s_PHEROMONE_STRUCT
28 {
29  int **map; // Pointer to 2D array of pheromone
30  int **eval_stencil; // Pointer to 2D array of smell stencil
31  int **pheromone_stencil; // Pointer to 2D array of pheromone stencil
32 
33  int width; // Width/size of pheromone grid cell
34 
35  int x_cells; // Number of grid cells in x direction
36  int y_cells; // NUmber of grid cells in y direction
37 
38  int eval_cells; // Number of cells in x and y direction in smell stencil (area is square)
39  int pheromone_cells; // Number of cells in x and y direction in pheromone stencil (area is square)
40 
41  int lifetime; // Lifetime of a pheromone
42 
43  int pheromone_radius; // Radius of pheromone (approx. because it will be fitted to the grid)
44 
45  int eval_radius; // Radius of evaluation area (approx. because it will be fitted to the grid)
46  int eval_dist; // Distance from robot center to evaluation area (approx. because it will be fitted to the grid)
47 
52 
53 } pheromone_t;
54 
59 {
60  int num; // Sector number
61  int size; // Sector size
62  int timestamp; // Sector base timestamp
63  unsigned char data[s_CONFIG_PHEROMONE_SECTOR_MAX_SIZE]; // Sector data
64 
66 
67 /* -- Enumerates -- */
68 
73 {
74  s_PH_LEFT = 0,
80 };
81 
82 /* -- Constants -- */
83 
84 /* -- Function Prototypes -- */
85 
87  int width,
88  int lifetime,
89  int pheromone_radius,
90  int eval_radius,
91  int eval_dist,
92  int sector_max_size); // Initialize pheromones
93 void pheromone_destroy(pheromone_t *ph); // Deinitialize pheromones
94 void pheromone_make_stencil(int ***stencil, int size); // Make stencil - generate circle area in 2D array
95 void pheromone_put(pheromone_t *ph, int x, int y); // Put pheromone in pheromone map
96 int pheromone_eval(pheromone_t *ph, robot_t *robot); // Evaluate smell in pheromone map and return new heading direction
97 
98 void pheromone_map_update(pheromone_t *ph, pheromone_map_sector_t *phms); // Update pheromone map
99 pheromone_map_sector_t **pheromone_map_extract(pheromone_t *ph); // Extract array of pheromone map sectors
100 void pheromone_map_destroy(pheromone_t *ph, pheromone_map_sector_t **phms); // Destroy (free memory) array of pheromone map sectors
101 
102  #endif /* __PHEROMONE_H */
int ** eval_stencil
Definition: pheromone.h:30
int ** pheromone_stencil
Definition: pheromone.h:31
Pheromone structure.
Definition: pheromone.h:27
void pheromone_make_stencil(int ***stencil, int size)
Definition: pheromone.c:146
#define s_CONFIG_PHEROMONE_SECTOR_MAX_SIZE
Definition: config.h:85
int pheromone_eval(pheromone_t *ph, robot_t *robot)
Definition: pheromone.c:219
pheromone_map_sector_t ** pheromone_map_extract(pheromone_t *ph)
Definition: pheromone.c:371
s_PHEROMONE_DIR
Enum for directions.
Definition: pheromone.h:72
void pheromone_map_update(pheromone_t *ph, pheromone_map_sector_t *phms)
Definition: pheromone.c:336
Robot structure.
Definition: robot.h:25
unsigned char data[s_CONFIG_PHEROMONE_SECTOR_MAX_SIZE]
Definition: pheromone.h:63
struct s_PHEROMONE_STRUCT pheromone_t
Pheromone structure.
struct s_PHEROMONE_MAP_SECTOR_STRUCT pheromone_map_sector_t
Pheromone Map Sector structure.
pheromone_t * pheromone_init(enviroment_t *env, int width, int lifetime, int pheromone_radius, int eval_radius, int eval_dist, int sector_max_size)
Definition: pheromone.c:40
void pheromone_put(pheromone_t *ph, int x, int y)
Definition: pheromone.c:174
void pheromone_destroy(pheromone_t *ph)
Definition: pheromone.c:109
void pheromone_map_destroy(pheromone_t *ph, pheromone_map_sector_t **phms)
Definition: pheromone.c:449
Pheromone Map Sector structure.
Definition: pheromone.h:58
Enviroment Structure - room points, tags, room point number, tag number.
Definition: enviroment.h:49