00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef PLAN_H
00010 #define PLAN_H
00011
00012 #ifdef __cplusplus
00013 extern "C" {
00014 #endif
00015
00016
00017 struct _rtk_fig_t *fig;
00018
00019
00020
00021 typedef struct _plan_cell_t
00022 {
00023
00024 unsigned short ci, cj;
00025
00026
00027 char occ_state;
00028
00029
00030 float occ_dist;
00031
00032
00033 float plan_cost;
00034
00035
00036 struct _plan_cell_t *plan_next;
00037
00038 } plan_cell_t;
00039
00040
00041
00042 typedef struct
00043 {
00044
00045 int size_x, size_y;
00046
00047
00048 double scale;
00049
00050
00051 double des_min_radius, abs_min_radius;
00052
00053
00054 double max_radius;
00055
00056
00057 double dist_penalty;
00058
00059
00060 plan_cell_t *cells;
00061
00062
00063 int queue_start, queue_len, queue_size;
00064 plan_cell_t **queue;
00065
00066
00067 int waypoint_count, waypoint_size;
00068 plan_cell_t **waypoints;
00069 } plan_t;
00070
00071
00072
00073 plan_t *plan_alloc(double abs_min_radius, double des_min_radius,
00074 double max_radius, double dist_penalty);
00075
00076
00077 void plan_free(plan_t *plan);
00078
00079
00080 void plan_reset(plan_t *plan);
00081
00082 #if 0
00083
00084 int plan_load_occ(plan_t *plan, const char *filename, double scale);
00085 #endif
00086
00087
00088 void plan_update_cspace(plan_t *plan, const char* cachefile);
00089
00090
00091 void plan_update_plan(plan_t *plan, double gx, double gy);
00092
00093
00094 void plan_update_waypoints(plan_t *plan, double px, double py);
00095
00096
00097 int plan_get_waypoint(plan_t *plan, int i, double *px, double *py);
00098
00099
00100 void plan_convert_waypoint(plan_t* plan, plan_cell_t *waypoint,
00101 double *px, double *py);
00102
00103
00104 void plan_draw_grid(plan_t *plan, struct _rtk_fig_t *fig);
00105
00106
00107 void plan_draw_waypoints(plan_t *plan, struct _rtk_fig_t *fig);
00108
00109
00110
00111
00112 int plan_write_cspace(plan_t *plan, const char* fname, short hash);
00113
00114
00115
00116
00117 int plan_read_cspace(plan_t *plan, const char* fname, short hash);
00118
00119
00120
00121 short plan_md5(plan_t* plan);
00122
00123
00124
00125
00126
00127
00128
00129 #define PLAN_SXCX(plan, x) ((x) - (plan->scale * plan->size_x / 2.0))
00130 #define PLAN_SYCY(plan, y) ((y) - (plan->scale * plan->size_y / 2.0))
00131
00132
00133 #define PLAN_CXSX(plan, x) ((x) + (plan->scale * plan->size_x / 2.0))
00134 #define PLAN_CYSY(plan, y) ((y) + (plan->scale * plan->size_y / 2.0))
00135
00136
00137 #define PLAN_WXGX(plan, i) (((i) - plan->size_x / 2) * plan->scale)
00138 #define PLAN_WYGY(plan, j) (((j) - plan->size_y / 2) * plan->scale)
00139
00140
00141 #define PLAN_GXWX(plan, x) (floor((x) / plan->scale + 0.5) + plan->size_x / 2)
00142 #define PLAN_GYWY(plan, y) (floor((y) / plan->scale + 0.5) + plan->size_y / 2)
00143
00144
00145 #define PLAN_VALID(plan, i, j) ((i >= 0) && (i < plan->size_x) && (j >= 0) && (j < plan->size_y))
00146
00147
00148 #define PLAN_INDEX(plan, i, j) ((i) + (j) * plan->size_x)
00149
00150 #ifdef __cplusplus
00151 }
00152 #endif
00153
00154 #endif