maptransform.h
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2004 Brian Gerkey gerkey@stanford.edu
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  */
20 
21 /*
22  * $Id: maptransform.h 9120 2013-01-07 00:18:52Z jpgr87 $
23  *
24  * Base class for map transform drivers, simply reimplement the transform method
25  * with your trasformation function. See MapScale for example
26  */
27 
28 #ifndef _MAPTRANSFORM_H_
29 #define _MAPTRANSFORM_H_
30 
31 #include <sys/types.h> // required by Darwin
32 #include <stdlib.h>
33 #include <string.h>
34 #include <math.h>
35 
36 #include <libplayercore/playercore.h>
37 
38 // compute linear index for given map coords
39 #define MAP_IDX(mf, i, j) ((mf.width) * (j) + (i))
40 
41 // check that given coords are valid (i.e., on the map)
42 #define MAP_VALID(mf, i, j) ((i >= 0) && (i < mf.width) && (j >= 0) && (j < mf.height))
43 
44 class MapTransform : public Driver
45 {
46  protected:
47  player_map_info_t source_map;
48  player_devaddr_t source_map_addr;
49  char* source_data;
50 
51  player_map_info_t new_map;
52  char* new_data;
53 
54  // get the map from the underlying map device
55  int GetMap();
56  // interpolate the map
57  virtual int Transform() = 0;
58 
59  public:
60  MapTransform(ConfigFile* cf, int section);
61  virtual ~MapTransform();
62 
63  // MessageHandler
64  public: virtual int ProcessMessage(QueuePointer &resp_queue,
65  player_msghdr * hdr,
66  void * data);
67 
68  int Setup();
69  int Shutdown();
70 };
71 
72 #endif
Class for loading configuration file information.
Definition: configfile.h:196
Generic message header.
Definition: player.h:161
Definition: player_interfaces.h:3039
A device address.
Definition: player.h:145
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
Definition: maptransform.cc:197
int Shutdown()
Finalize the driver.
Definition: maptransform.cc:188
An autopointer for the message queue.
Definition: message.h:73
Definition: maptransform.h:44
Base class for all drivers.
Definition: driver.h:108
int Setup()
Initialize the driver.
Definition: maptransform.cc:54