lasertransform.h
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2000 Brian Gerkey & Kasper Stoy
4  * gerkey@usc.edu kaspers@robotics.usc.edu
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  */
22 //
23 // Desc: Base class for laser transformations (i.e. cspace etc)
24 // Author: Andrew Howard
25 // Date: 1 Sep 2002
26 // CVS: $Id$
27 //
28 // Theory of operation -
29 //
30 // Requires - Laser device.
31 //
33 
34 
35 
36 #include <errno.h>
37 #include <string.h>
38 #include <math.h>
39 #include <stdlib.h> // for atoi(3)
40 #if !defined (WIN32)
41  #include <unistd.h>
42 #endif
43 
44 #include <libplayercore/playercore.h>
45 
46 // Driver for computing the free c-space from a laser scan.
47 class LaserTransform : public Driver
48 {
49  // Constructor
50  public: LaserTransform( ConfigFile* cf, int section);
51 
52  // MessageHandler
53  public: virtual int ProcessMessage(QueuePointer & resp_queue,
54  player_msghdr * hdr,
55  void * data);
56 
57  // Setup/shutdown routines.
58  public: virtual int Setup();
59  public: virtual int Shutdown();
60 
61  protected:
62  // Process laser data. Returns non-zero if the laser data has been
63  // updated.
64  virtual int UpdateLaser(player_laser_data_t * data) = 0;
65 
66  // Process requests. Returns 1 if the configuration has changed.
67  int HandleRequests();
68 
69  // Handle geometry requests.
70  void HandleGetGeom(void *client, void *req, int reqlen);
71 
72  // Laser stuff.
73  Device *laser_device;
74  player_devaddr_t laser_addr;
75  struct timeval laser_timestamp;
76 
77  // Fiducila stuff (the data we generate).
78  player_laser_data_t data;
79  struct timeval time;
80 };
81 
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
Definition: toranger.cc:91
#define PLAYER_WARN1(msg, a)
Definition: error.h:90
QueuePointer ret_queue
Last requester's queue.
Definition: driver.h:186
virtual void Publish(player_devaddr_t addr, QueuePointer &queue, uint8_t type, uint8_t subtype, void *src=NULL, size_t deprecated=0, double *timestamp=NULL, bool copy=true)
Publish a message via one of this driver's interfaces.
uint32_t host
The "host" on which the device resides.
Definition: player.h:148
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:159
A rectangular bounding box, used to define the size of an object.
Definition: player.h:255
double ReadFloat(int section, const char *name, double value)
Read a floating point (double) value.
A pose in the plane.
Definition: player.h:218
double ReadTupleLength(int section, const char *name, int index, double value)
Read a length from a tuple (includes units conversion)
Generic message header.
Definition: player.h:162
int Subscribe(QueuePointer &sub_queue)
Subscribe the given queue to this device.
uint8_t type
Message type; must be one of PLAYER_MSGTYPE_*.
Definition: player.h:166
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
Definition: lasertransform.cc:86
Encapsulates a device (i.e., a driver bound to an interface)
Definition: device.h:75
double px
X [m].
Definition: player.h:220
uint8_t subtype
Message subtype; interface specific.
Definition: player.h:168
double ReadTupleFloat(int section, const char *name, int index, double value)
Read a float (double) from a tuple field.
Definition: lasertransform.h:48
double ReadAngle(int section, const char *name, double value)
Read an angle (includes unit conversion).
int ReadInt(int section, const char *name, int value)
Read an integer value.
double ReadLength(int section, const char *name, double value)
Read a length (includes unit conversion, if any).
void ClearFilter(void)
Clear (i.e., turn off) message filter.
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
QueuePointer InQueue
Queue for all incoming messages for this driver.
Definition: driver.h:285
double py
Y [m].
Definition: player.h:222
#define PLAYER_ERROR2(msg, a, b)
Definition: error.h:83
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:112
void PutMsg(QueuePointer &resp_queue, uint8_t type, uint8_t subtype, void *src, size_t deprecated, double *timestamp)
Send a message to this device.
virtual int Setup()
Initialize the driver.
Definition: lasertransform.cc:52
virtual int Setup(void)
Initialize the driver.
Definition: toranger.cc:58
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
static bool MatchDeviceAddress(player_devaddr_t addr1, player_devaddr_t addr2)
Compare two addresses.
Definition: device.h:201
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
#define PLAYER_MSGTYPE_RESP_NACK
A negative response message.
Definition: player.h:125
double ReadTupleAngle(int section, const char *name, int index, double value)
Read an angle form a tuple (includes units conversion)
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
int GetTupleCount(int section, const char *name)
Get the number of values in a tuple.
Class for loading configuration file information.
Definition: configfile.h:197
virtual int Setup()
Initialize the driver.
Definition: driver.h:386
A device address.
Definition: player.h:146
virtual int Shutdown(void)
Finalize the driver.
Definition: toranger.cc:70
An autopointer for the message queue.
Definition: message.h:74
virtual int Shutdown()
Finalize the driver.
Definition: lasertransform.cc:76
void SetFilter(int host, int robot, int interf, int index, int type, int subtype)
Set filter values.
A pose in space.
Definition: player.h:229
#define PLAYER_ERROR(msg)
Definition: error.h:81
player_devaddr_t device_addr
Default device address (single-interface drivers)
Definition: driver.h:269
double timestamp
Time associated with message contents (seconds since epoch)
Definition: player.h:170
uint32_t size
Size in bytes of the payload to follow.
Definition: player.h:174
#define PLAYER_WARN(msg)
Warning message macros.
Definition: error.h:89
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:99
virtual int Shutdown()
Finalize the driver.
Definition: driver.h:393
double pa
yaw [rad]
Definition: player.h:224
Base class for all drivers.
Definition: driver.h:109
Definition: toranger.h:33
#define PLAYER_MSG0(level, msg)
General messages.
Definition: error.h:105
int Unsubscribe(QueuePointer &sub_queue)
Unsubscribe the given queue from this device.
#define PLAYER_MSGTYPE_SYNCH
A synch message.
Definition: player.h:117
player_devaddr_t addr
Device to which this message pertains.
Definition: player.h:164
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:76