maptransform.h

00001 /*
00002  *  Player - One Hell of a Robot Server
00003  *  Copyright (C) 2004  Brian Gerkey gerkey@stanford.edu    
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  */
00020 
00021 /*
00022  * $Id: maptransform.h 4135 2007-08-23 19:58:48Z gerkey $
00023  *
00024  * Base class for map transform drivers, simply reimplement the transform method
00025  * with your trasformation function. See MapScale for example
00026  */
00027 
00028 #ifndef _MAPTRANSFORM_H_
00029 #define _MAPTRANSFORM_H_
00030 
00031 #include <sys/types.h> // required by Darwin
00032 #include <netinet/in.h>
00033 #include <stdlib.h>
00034 #include <string.h>
00035 #include <math.h>
00036 
00037 #include <libplayercore/playercore.h>
00038 
00039 // compute linear index for given map coords
00040 #define MAP_IDX(mf, i, j) ((mf.width) * (j) + (i))
00041 
00042 // check that given coords are valid (i.e., on the map)
00043 #define MAP_VALID(mf, i, j) ((i >= 0) && (i < mf.width) && (j >= 0) && (j < mf.height))
00044 
00045 class MapTransform : public Driver
00046 {
00047   protected:
00048     player_map_info_t source_map;
00049     player_devaddr_t source_map_addr;
00050     char* source_data;
00051 
00052         player_map_info_t new_map;
00053     char* new_data;
00054 
00055     // get the map from the underlying map device
00056     int GetMap();
00057     // interpolate the map
00058     virtual int Transform() = 0;
00059     
00060   public:
00061     MapTransform(ConfigFile* cf, int section);
00062     virtual ~MapTransform();
00063 
00064     // MessageHandler
00065     public: virtual int ProcessMessage(QueuePointer &resp_queue, 
00066                                      player_msghdr * hdr, 
00067                                      void * data);   
00068                                      
00069     int Setup();
00070     int Shutdown();
00071 };
00072 
00073 #endif

Last updated 12 September 2005 21:38:45