Home
FAQ
Player
Stage
Gazebo
Contrib
Documentation
Publications
Contributors
Users

Project
Download
Bugs/Feedback
Mailing lists

Radish

Old news
Old stuff

amcl.h

Go to the documentation of this file.
00001 /*
00002  *  Player - One Hell of a Robot Server
00003  *  Copyright (C) 2000  Brian Gerkey   &  Kasper Stoy
00004  *                      gerkey@usc.edu    kaspers@robotics.usc.edu
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00022 //
00023 // Desc: Adaptive Monte-Carlo localization
00024 // Author: Andrew Howard
00025 // Date: 6 Feb 2003
00026 // CVS: $Id: amcl.h,v 1.9 2005/03/18 22:38:19 gerkey Exp $
00027 //
00028 // Theory of operation:
00029 //  TODO
00030 //
00031 // Requires: position (odometry), laser, sonar, gps
00032 // Provides: localization
00033 //
00035 
00036 #ifndef AMCL_H
00037 #define AMCL_H
00038 
00039 #ifdef INCLUDE_RTKGUI
00040 #include "rtk.h"
00041 #endif
00042 
00043 #include "player.h"
00044 #include "device.h"
00045 #include "devicetable.h"
00046 #include "drivertable.h"
00047 
00048 #include "pf/pf.h"
00049 #include "amcl_sensor.h"
00050 
00051 
00052 // Pose hypothesis
00053 typedef struct
00054 {
00055   // Total weight (weights sum to 1)
00056   double weight;
00057 
00058   // Mean of pose esimate
00059   pf_vector_t pf_pose_mean;
00060 
00061   // Covariance of pose estimate
00062   pf_matrix_t pf_pose_cov;
00063   
00064 } amcl_hyp_t;
00065 
00066 
00067 
00068 // Incremental navigation driver
00069 class AdaptiveMCL : public Driver
00070 {
00072   // Top half methods; these methods run in the server thread (except for
00073   // the sensor Init and Update functions, which run in the driver thread).
00075 
00076   // Constructor
00077   public: AdaptiveMCL(ConfigFile* cf, int section);
00078 
00079   // Destructor
00080   public: virtual ~AdaptiveMCL(void);
00081 
00082   // Setup/shutdown routines.
00083   public: virtual int Setup(void);
00084   public: virtual int Shutdown(void);
00085 
00086   // Check for updated sensor data
00087   public: virtual void Update(void);
00088   
00090   // Middle methods: these methods facilitate communication between the top
00091   // and bottom halfs.
00093 
00094   // Push data onto the queue
00095   private: void Push(AMCLSensorData *data);
00096 
00097   // Take a peek at the queue
00098   private: AMCLSensorData *Peek(void);
00099 
00100   // Pop data from the queue
00101   private: AMCLSensorData *Pop(void);
00102 
00104   // Bottom half methods; these methods run in the device thread
00106   
00107   // Main function for device thread.
00108   private: virtual void Main(void);
00109 
00110   // Device thread finalization
00111   private: virtual void MainQuit();
00112 
00113   // Initialize the filter
00114   private: void InitFilter(void);
00115 
00116   // Update/initialize the filter with new sensor data
00117   private: bool UpdateFilter();
00118 
00119   // Put new localization data
00120   private: void PutDataLocalize(uint32_t tsec, uint32_t tusec);
00121 
00122   // Put new position data
00123   private: void PutDataPosition(uint32_t tsec, uint32_t tusec, pf_vector_t delta);
00124 
00125   // Process requests.  Returns 1 if the configuration has changed.
00126   private: int HandleRequests(void);
00127 
00128   // Handle geometry requests.
00129   private: void HandleGetGeom(void *client, void *request, int len);
00130 
00131   // Handle the set pose request
00132   private: void HandleSetPose(void *client, void *request, int len);
00133 
00134   // Handle the get particles request
00135   private: void HandleGetParticles(void *client, void *request, int len);
00136 
00137 #ifdef INCLUDE_RTKGUI
00138   // Set up the GUI
00139   private: int SetupGUI(void);
00140 
00141   // Shut down the GUI
00142   private: int ShutdownGUI(void);
00143 
00144   // Update the GUI
00145   private: void UpdateGUI(void);
00146 
00147   // Draw the current best pose estimate
00148   private: void DrawPoseEst();
00149 #endif
00150 
00152   // Properties
00154 
00155   // interfaces we might be using
00156   private: player_device_id_t position_id;
00157   private: player_device_id_t localize_id;
00158   
00159   // List of all sensors
00160   private: int sensor_count;
00161   private: AMCLSensor *sensors[16];
00162 
00163   // Index of sensor providing initialization model
00164   private: int init_sensor;
00165 
00166   // Index of sensor providing action model
00167   private: int action_sensor;
00168 
00169   // Particle filter
00170   private: pf_t *pf;
00171   private: int pf_min_samples, pf_max_samples;
00172   private: double pf_err, pf_z;
00173 
00174   // Sensor data queue
00175   private: int q_size, q_start, q_len;
00176   private: AMCLSensorData **q_data;
00177   
00178   // Current particle filter pose estimates
00179   private: int hyp_count;
00180   private: amcl_hyp_t hyps[PLAYER_LOCALIZE_MAX_HYPOTHS];
00181 
00182   // Has the filter been initialized?
00183   private: bool pf_init;
00184 
00185   // Initial pose estimate; used for filter initialization
00186   private: pf_vector_t pf_init_pose_mean;
00187   private: pf_matrix_t pf_init_pose_cov;
00188 
00189   // Last odometric pose value used to update filter
00190   private: pf_vector_t pf_odom_pose;
00191 
00192   // Minimum update distances
00193   private: double min_dr, min_da;
00194 
00195 #ifdef INCLUDE_RTKGUI
00196   // RTK stuff; for testing only
00197   private: int enable_gui;
00198   private: rtk_app_t *app;
00199   private: rtk_canvas_t *canvas;
00200   private: rtk_fig_t *map_fig;
00201   private: rtk_fig_t *pf_fig;
00202   private: rtk_fig_t *robot_fig;
00203 #endif
00204 
00205 #ifdef INCLUDE_OUTFILE
00206   private: FILE *outfile;
00207 #endif
00208 };
00209 
00210 #endif

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