Home
FAQ
Player
Stage
Gazebo
Contrib
Documentation
Publications
Contributors
Users

Project
Download
Bugs/Feedback
Mailing lists

Radish

Old news
Old stuff

plan.h

Go to the documentation of this file.
00001 
00002 /**************************************************************************
00003  * Desc: Path planning
00004  * Author: Andrew Howard
00005  * Date: 10 Oct 2002
00006  * CVS: $Id: plan.h,v 1.6 2005/04/06 21:39:05 gerkey Exp $
00007 **************************************************************************/
00008 
00009 #ifndef PLAN_H
00010 #define PLAN_H
00011 
00012 #ifdef __cplusplus
00013 extern "C" {
00014 #endif
00015 
00016 // Forward declarations
00017 struct _rtk_fig_t *fig;
00018 
00019 
00020 // Description for a grid single cell
00021 typedef struct _plan_cell_t
00022 {
00023   // Cell index in grid map
00024   unsigned short ci, cj;
00025   
00026   // Occupancy state (-1 = free, 0 = unknown, +1 = occ)
00027   char occ_state;
00028 
00029   // Distance to the nearest occupied cell
00030   float occ_dist;
00031 
00032   // Distance (cost) to the goal
00033   float plan_cost;
00034 
00035   // The next cell in the plan
00036   struct _plan_cell_t *plan_next;
00037   
00038 } plan_cell_t;
00039 
00040 
00041 // Planner info
00042 typedef struct
00043 {
00044   // Grid dimensions (number of cells)
00045   int size_x, size_y;
00046 
00047   // Grid scale (m/cell)
00048   double scale;
00049 
00050   // Effective robot radius
00051   double des_min_radius, abs_min_radius;
00052 
00053   // Max radius we will consider
00054   double max_radius;
00055 
00056   // Penalty factor for cells inside the max radius
00057   double dist_penalty;
00058 
00059   // The grid data
00060   plan_cell_t *cells;
00061   
00062   // Queue of cells to update
00063   int queue_start, queue_len, queue_size;
00064   plan_cell_t **queue;
00065 
00066   // Waypoints
00067   int waypoint_count, waypoint_size;
00068   plan_cell_t **waypoints;
00069 } plan_t;
00070 
00071 
00072 // Create a planner
00073 plan_t *plan_alloc(double abs_min_radius, double des_min_radius,
00074                    double max_radius, double dist_penalty);
00075 
00076 // Destroy a planner
00077 void plan_free(plan_t *plan);
00078 
00079 // Reset the plan
00080 void plan_reset(plan_t *plan);
00081 
00082 #if 0
00083 // Load the occupancy values from an image file
00084 int plan_load_occ(plan_t *plan, const char *filename, double scale);
00085 #endif
00086 
00087 // Construct the configuration space from the occupancy grid.
00088 void plan_update_cspace(plan_t *plan, const char* cachefile);
00089 
00090 // Generate the plan
00091 void plan_update_plan(plan_t *plan, double gx, double gy);
00092 
00093 // Generate a path to the goal
00094 void plan_update_waypoints(plan_t *plan, double px, double py);
00095 
00096 // Get the ith waypoint; returns zero if there are no more waypoints
00097 int plan_get_waypoint(plan_t *plan, int i, double *px, double *py);
00098 
00099 // Convert given waypoint cell to global x,y
00100 void plan_convert_waypoint(plan_t* plan, plan_cell_t *waypoint, 
00101                            double *px, double *py);
00102 
00103 // Draw the grid
00104 void plan_draw_grid(plan_t *plan, struct _rtk_fig_t *fig);
00105 
00106 // Draw waypoints
00107 void plan_draw_waypoints(plan_t *plan, struct _rtk_fig_t *fig);
00108 
00109 // Write the cspace occupancy distance values to a file, one per line.
00110 // Read them back in with plan_read_cspace().
00111 // Returns non-zero on error.
00112 int plan_write_cspace(plan_t *plan, const char* fname, short hash);
00113 
00114 // Read the cspace occupancy distance values from a file, one per line.
00115 // Write them in first with plan_read_cspace().
00116 // Returns non-zero on error.
00117 int plan_read_cspace(plan_t *plan, const char* fname, short hash);
00118 
00119 // Compute and return the 16-bit MD5 hash of the map data in the given plan
00120 // object.
00121 short plan_md5(plan_t* plan);
00122 
00123 /**************************************************************************
00124  * Plan manipulation macros
00125  **************************************************************************/
00126 
00127 // Convert from origin-at-lower-left-corner (like Stage) to
00128 // origin-at-center.
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 // Convert from origin-at-center to origin-at-lower-left-corner (like Stage).
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 // Convert from plan index to world coords
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 // Convert from world coords to plan coords
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 // Test to see if the given plan coords lie within the absolute plan bounds.
00145 #define PLAN_VALID(plan, i, j) ((i >= 0) && (i < plan->size_x) && (j >= 0) && (j < plan->size_y))
00146 
00147 // Compute the cell index for the given plan coords.
00148 #define PLAN_INDEX(plan, i, j) ((i) + (j) * plan->size_x)
00149 
00150 #ifdef __cplusplus
00151 }
00152 #endif
00153 
00154 #endif

Generated on Tue May 3 14:15:35 2005 for Player by doxygen 1.3.6