amcl_laser.h
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2000 Brian Gerkey et al.
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  */
21 //
22 // Desc: LASER sensor model for AMCL
23 // Author: Andrew Howard
24 // Date: 17 Aug 2003
25 // CVS: $Id$
26 //
28 
29 #ifndef AMCL_LASER_H
30 #define AMCL_LASER_H
31 
32 #include "amcl_sensor.h"
33 #include "map/map.h"
34 #include "models/laser.h"
35 
36 // Laser sensor data
38 {
39  public:
40  AMCLLaserData () {ranges=NULL;};
41  virtual ~AMCLLaserData() {delete [] ranges;};
42  // Laser range data (range, bearing tuples)
43  public: int range_count;
44  public: double range_max;
45  public: double (*ranges)[2];
46 };
47 
48 
49 // Laseretric sensor model
50 class AMCLLaser : public AMCLSensor
51 {
52  // Default constructor
53  public: AMCLLaser(AdaptiveMCL & aAMCL, player_devaddr_t addr);
54 
55  // Load the model
56  public: virtual int Load(ConfigFile* cf, int section);
57 
58  // Unload the model
59  public: virtual int Unload(void);
60 
61  // Initialize the model
62  public: virtual int Setup(void);
63 
64  // Finalize the model
65  public: virtual int Shutdown(void);
66 
67  // Process message for this interface
68  public: virtual int ProcessMessage(QueuePointer &resp_queue,
69  player_msghdr * hdr,
70  void * data);
71  // Check for new sensor measurements
72  //private: virtual AMCLSensorData *GetData(void);
73 
74  // Update the filter based on the sensor model. Returns true if the
75  // filter has been updated.
76  public: virtual bool UpdateSensor(pf_t *pf, AMCLSensorData *data);
77 
78  // Determine the probability for the given pose
79  private: static double SensorModel(AMCLLaserData *data,
80  pf_sample_set_t* set);
81 
82  // retrieve the map
83  private: int SetupMap(void);
84 
85  // Device info
86  private: player_devaddr_t laser_addr;
87  private: player_devaddr_t map_addr;
88  private: Device *laser_dev;
89 
90  // Current data timestamp
91  private: double time;
92 
93  // The laser map
94  private: map_t *map;
95 
96  // Laser offset relative to robot
97  private: pf_vector_t laser_pose;
98 
99  // Max beams to consider
100  private: int max_beams;
101 
102  // Laser range variance
103  private: double range_var;
104 
105  // Probability of bad range readings
106  private: double range_bad;
107 
108 #ifdef INCLUDE_RTKGUI
109  // Setup the GUI
110  private: virtual void SetupGUI(rtk_canvas_t *canvas, rtk_fig_t *robot_fig);
111 
112  // Finalize the GUI
113  private: virtual void ShutdownGUI(rtk_canvas_t *canvas, rtk_fig_t *robot_fig);
114 
115  // Draw sensor data
116  public: virtual void UpdateGUI(rtk_canvas_t *canvas, rtk_fig_t *robot_fig, AMCLSensorData *data);
117 
118  // Figures
119  private: rtk_fig_t *fig, *map_fig;
120 #endif
121 };
122 
123 
124 
125 
126 #endif
Definition: amcl_sensor.h:44
#define PLAYER_MSG1(level, msg, a)
Error message macros.
Definition: error.h:106
#define PLAYER_MSG3(level, msg, a, b, c)
Error message macros.
Definition: error.h:108
Definition: pf_vector.h:42
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:159
double ReadFloat(int section, const char *name, double value)
Read a floating point (double) value.
Definition: amcl_sensor.h:106
Definition: amcl.h:71
Generic message header.
Definition: player.h:162
int Subscribe(QueuePointer &sub_queue)
Subscribe the given queue to this device.
Encapsulates a device (i.e., a driver bound to an interface)
Definition: device.h:75
Definition: pf.h:94
Definition: amcl_laser.h:38
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 * GetPayload()
Get pointer to payload.
Definition: message.h:188
#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
Definition: pf.h:111
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
Class for loading configuration file information.
Definition: configfile.h:197
A device address.
Definition: player.h:146
An autopointer for the message queue.
Definition: message.h:74
Definition: pf.h:63
#define PLAYER_ERROR(msg)
Error message macros.
Definition: error.h:81
Definition: localization/amcl/map/map.h:67
double timestamp
Time associated with message contents (seconds since epoch)
Definition: player.h:170
Reference-counted message objects.
Definition: message.h:133
Message * Request(QueuePointer &resp_queue, uint8_t type, uint8_t subtype, void *src, size_t deprecated, double *timestamp, bool threaded=true)
Make a request of another device.
#define PLAYER_WARN(msg)
Warning message macros.
Definition: error.h:89
Definition: localization/amcl/map/map.h:52
#define PLAYER_MSG0(level, msg)
General messages.
Definition: error.h:105
int Unsubscribe(QueuePointer &sub_queue)
Unsubscribe the given queue from this device.
uint16_t index
Which device of that interface.
Definition: player.h:155
Definition: amcl_laser.h:51