rflex_configs.h
00001 /*  Player - One Hell of a Robot Server
00002  *  Copyright (C) 2000
00003  *     Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
00004  *
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  */
00021 
00022 /* some basic structures and conversions needed by everything
00023  *
00024  * data for the conversions and everything else will be grabbed out of
00025  * the general configuration file
00026  *
00027  * note - they way it is now is the right way to do it, BUT:
00028  * if your a hacker and want things to run fast - put all the configurations
00029  * here as #define's, this will allow the precompiler to precompute combined
00030  * conversions, this is much preferable to modifying the rest of the code
00031  * if you really need the speed that badly
00032  */
00033 
00034 // NOTICE! - this file declares rflex_configs extern, intended to link to 
00035 // the rflex_configs declared in rflex.cc
00036 
00037 #ifndef RFLEX_CONFIGS_H
00038 #define RFLEX_CONFIGS_H
00039 
00040 #include <math.h>
00041 #include <libplayerinterface/player.h>
00042 
00043 //normalizes an angle in radians to -M_PI<theta<M_PI
00044 inline double normalize_theta(double theta){
00045   while(theta>M_PI)
00046     theta-=2*M_PI;
00047   while(theta<-M_PI)
00048     theta+=2*M_PI;
00049   return theta;
00050 }
00051 
00052 //structures for holding general configuration of robot
00053 typedef struct rflex_config_t{
00054   char serial_port[256];
00055   //length of the robot in m
00056   double m_length;
00057   //width of the robot in m
00058   double m_width;
00059   //m*odo_distance_conversion : m to rflex arbitrary odometry units (trans)
00060   double odo_distance_conversion;
00061   //rad*odo_angle_conversion : rad to rflex arbitrary odometry units (rot)
00062   double odo_angle_conversion;
00063   //mm*range_distance_conversion : m to rflex arbitrary range units
00064   double range_distance_conversion;
00065   //default translational acceleration in m/sec
00066   double mPsec2_trans_acceleration;
00067   //default rotational acceleration in rad/sec
00068   double radPsec2_rot_acceleration;
00069 
00070   // absolute heading dio address (if ommited then absolute heading not used)
00071   int heading_home_address;
00072   // home on startup
00073   bool home_on_start;
00074   
00075   // use rflex joystick to command robot?
00076   bool use_joystick;
00077   double joy_pos_ratio, joy_ang_ratio;
00078   
00079   //maximum number of sonar supported by modules
00080   //(generally 16*number of sonar controller boards, or banks)
00081   int max_num_sonars;
00082   //total number of physical sonar
00083   int num_sonars;
00084   //how long to buffer for filter (filter just takes smallest of last n readings)
00085   int sonar_age;
00086   //number of physical sonar sonar controller boards or banks on your robot
00087   int num_sonar_banks;
00088   // number of sonars that can be attached to each sonar controller (16)
00089   int num_sonars_possible_per_bank;
00090   // number of actual sonar attached to each sonar controller, (in each bank)
00091   int *num_sonars_in_bank;
00092   // pose of each sonar on the robot (x,y,t) in rad and mm
00093   // note i is forwards, j is left
00094   player_pose3d_t *mrad_sonar_poses;
00095   //not sure what these do yet actually
00096   long sonar_echo_delay;
00097   long sonar_ping_delay;
00098   long sonar_set_delay;
00099   // options to support 2nd sonar bank
00100   long sonar_2nd_bank_start;
00101   long sonar_1st_bank_end;
00102   long sonar_max_range; // in mm
00103 
00104   
00105   // bumper configs
00106   unsigned short bumper_count;
00107   int bumper_address;
00109   int bumper_style;
00110   player_bumper_define_t * bumper_def;
00111 
00112   // power configs
00113   float power_offset;
00114   
00115   // ir configs
00116   player_ir_pose_t ir_poses;
00117   int ir_base_bank;
00118   int ir_bank_count;
00119   int ir_total_count;
00120   int * ir_count; 
00121   double * ir_a; 
00122   double * ir_b; 
00123   float ir_min_range;
00124   float ir_max_range;
00125 }  rflex_config_t;
00126 
00127 //notice - every file that includes this header gets a GLOBAL rflex_configs!!
00128 // be careful
00129 extern rflex_config_t rflex_configs;
00130 
00131 /************ conversions ********************/
00132 /*** rather obvious - ARB stands for arbitrary (look above) ***/
00133 
00134 //player uses degrees, but I use radians (so cos, and sin work correctly)
00135 #define ARB2RAD_ODO_CONV(x) ((x)/rflex_configs.odo_angle_conversion)
00136 #define RAD2ARB_ODO_CONV(x) ((x)*rflex_configs.odo_angle_conversion)
00137 #define ARB2M_ODO_CONV(x) ((x)/rflex_configs.odo_distance_conversion)
00138 #define M2ARB_ODO_CONV(x) ((x)*rflex_configs.odo_distance_conversion)
00139 
00140 #define ARB2M_RANGE_CONV(x) (x/rflex_configs.range_distance_conversion)
00141 #define M2ARB_RANGE_CONV(x) (x*rflex_configs.range_distance_conversion)
00142 
00143 #endif
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 
00152 

Last updated 12 September 2005 21:38:45