00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef ARROBOTPARAMS_H
00028 #define ARROBOTPARAMS_H
00029
00030 #include "ariaTypedefs.h"
00031 #include "ArConfig.h"
00032
00034 class ArRobotParams : public ArConfig
00035 {
00036 public:
00038 ArRobotParams();
00040 virtual ~ArRobotParams();
00042 const char *getClassName(void) const { return myClass; }
00044 const char *getSubClassName(void) const { return mySubClass; }
00046 double getRobotRadius(void) const { return myRobotRadius; }
00048 double getRobotDiagonal(void) const { return myRobotDiagonal; }
00050 double getRobotWidth(void) const { return myRobotWidth; }
00052 double getRobotLength(void) const { return myRobotLength; }
00054 bool isHolonomic(void) const { return myHolonomic; }
00056 bool hasMoveCommand(void) const { return myHaveMoveCommand; }
00058 int getAbsoluteMaxVelocity(void) const { return myAbsoluteMaxVelocity; }
00060 int getAbsoluteMaxRotVelocity(void) const { return myAbsoluteMaxRVelocity; }
00062 bool getRequestIOPackets(void) const { return myRequestIOPackets; }
00064 bool getRequestEncoderPackets(void) const { return myRequestEncoderPackets; }
00066 int getSwitchToBaudRate(void) { return mySwitchToBaudRate; }
00068 double getAngleConvFactor(void) const { return myAngleConvFactor; }
00070 double getDistConvFactor(void) const { return myDistConvFactor; }
00072 double getVelConvFactor(void) const { return myVelConvFactor; }
00074 double getRangeConvFactor(void) const { return myRangeConvFactor; }
00076 double getDiffConvFactor(void) const { return myDiffConvFactor; }
00078 double getVel2Divisor(void) const { return myVel2Divisor; }
00080 double getGyroScaler(void) const { return myGyroScaler; }
00082 bool haveTableSensingIR(void) const { return myTableSensingIR; }
00084 bool haveNewTableSensingIR(void) const { return myNewTableSensingIR; }
00086 bool haveFrontBumpers(void) const { return myFrontBumpers; }
00088 int numFrontBumpers(void) const { return myNumFrontBumpers; }
00090 bool haveRearBumpers(void) const { return myRearBumpers; }
00092 int numRearBumpers(void) const { return myNumRearBumpers; }
00094 int getNumIR(void) const { return myNumIR; }
00096 bool haveIR(int number)
00097 {
00098 if (myIRMap.find(number) != myIRMap.end())
00099 return true;
00100 else
00101 return false;
00102 }
00104 int getIRX(int number)
00105 {
00106 std::map<int, std::map<int, int> >::iterator it;
00107 std::map<int, int>::iterator it2;
00108 if ((it = myIRMap.find(number)) == myIRMap.end())
00109 return 0;
00110 if ((it2 = (*it).second.find(IR_X)) == (*it).second.end())
00111
00112 return 0;
00113 return (*it2).second;
00114 }
00116 int getIRY(int number)
00117 {
00118 std::map<int, std::map<int, int> >::iterator it;
00119 std::map<int, int>::iterator it2;
00120 if ((it = myIRMap.find(number)) == myIRMap.end())
00121 return 0;
00122 if ((it2 = (*it).second.find(IR_Y)) == (*it).second.end())
00123 return 0;
00124 return (*it2).second;
00125 }
00126 int getIRType(int number)
00127 {
00128 std::map<int, std::map<int, int> >::iterator it;
00129 std::map<int, int>::iterator it2;
00130 if ((it = myIRMap.find(number)) == myIRMap.end())
00131 return 0;
00132 if ((it2 = (*it).second.find(IR_TYPE)) == (*it).second.end())
00133 return 0;
00134 return (*it2).second;
00135 }
00136 int getIRCycles(int number)
00137 {
00138 std::map<int, std::map<int, int> >::iterator it;
00139 std::map<int, int>::iterator it2;
00140 if ((it = myIRMap.find(number)) == myIRMap.end())
00141 return 0;
00142 if ((it2 = (*it).second.find(IR_CYCLES)) == (*it).second.end())
00143 return 0;
00144 return (*it2).second;
00145 }
00147 int getNumSonar(void) const { return myNumSonar; }
00149 bool haveSonar(int number)
00150 {
00151 if (mySonarMap.find(number) != mySonarMap.end())
00152 return true;
00153 else
00154 return false;
00155 }
00157 int getSonarX(int number)
00158 {
00159 std::map<int, std::map<int, int> >::iterator it;
00160 std::map<int, int>::iterator it2;
00161 if ((it = mySonarMap.find(number)) == mySonarMap.end())
00162 return 0;
00163 if ((it2 = (*it).second.find(SONAR_X)) == (*it).second.end())
00164 return 0;
00165 return (*it2).second;
00166 }
00168 int getSonarY(int number)
00169 {
00170 std::map<int, std::map<int, int> >::iterator it;
00171 std::map<int, int>::iterator it2;
00172 if ((it = mySonarMap.find(number)) == mySonarMap.end())
00173 return 0;
00174 if ((it2 = (*it).second.find(SONAR_Y)) == (*it).second.end())
00175 return 0;
00176 return (*it2).second;
00177 }
00179 int getSonarTh(int number)
00180 {
00181 std::map<int, std::map<int, int> >::iterator it;
00182 std::map<int, int>::iterator it2;
00183 if ((it = mySonarMap.find(number)) == mySonarMap.end())
00184 return 0;
00185 if ((it2 = (*it).second.find(SONAR_TH)) == (*it).second.end())
00186 return 0;
00187 return (*it2).second;
00188 }
00190 bool getLaserPossessed(void) const { return myLaserPossessed; }
00192 const char *getLaserPort(void) const { return myLaserPort; }
00194 bool getLaserPowerControlled(void) const { return myLaserPowerControlled; }
00196 bool getLaserFlipped(void) const { return myLaserFlipped; }
00198 int getLaserX(void) const { return myLaserX; }
00200 int getLaserY(void) const { return myLaserY; }
00202 double getLaserTh(void) const { return myLaserTh; }
00204 const char *getLaserIgnore(void) const { return myLaserIgnore; }
00206 bool hasSettableVelMaxes(void) const { return mySettableVelMaxes; }
00208 int getTransVelMax(void) const { return myTransVelMax; }
00210 int getRotVelMax(void) const { return myRotVelMax; }
00212 bool hasSettableAccsDecs(void) const { return mySettableAccsDecs; }
00214 int getTransAccel(void) const { return myTransAccel; }
00216 int getTransDecel(void) const { return myTransDecel; }
00218 int getRotAccel(void) const { return myRotAccel; }
00220 int getRotDecel(void) const { return myRotDecel; }
00222 bool save(void);
00223 protected:
00224 char myClass[1024];
00225 char mySubClass[1024];
00226 double myRobotRadius;
00227 double myRobotDiagonal;
00228 double myRobotWidth;
00229 double myRobotLength;
00230 bool myHolonomic;
00231 int myAbsoluteMaxRVelocity;
00232 int myAbsoluteMaxVelocity;
00233 bool myHaveMoveCommand;
00234 bool myRequestIOPackets;
00235 bool myRequestEncoderPackets;
00236 int mySwitchToBaudRate;
00237 double myAngleConvFactor;
00238 double myDistConvFactor;
00239 double myVelConvFactor;
00240 double myRangeConvFactor;
00241 double myDiffConvFactor;
00242 double myVel2Divisor;
00243 double myGyroScaler;
00244 bool myTableSensingIR;
00245 bool myNewTableSensingIR;
00246 bool myFrontBumpers;
00247 int myNumFrontBumpers;
00248 bool myRearBumpers;
00249 int myNumRearBumpers;
00250 bool myLaserPossessed;
00251 char myLaserPort[1024];
00252 bool myLaserFlipped;
00253 bool myLaserPowerControlled;
00254 int myLaserX;
00255 int myLaserY;
00256 double myLaserTh;
00257 char myLaserIgnore[1024];
00258
00259 bool mySettableVelMaxes;
00260 int myTransVelMax;
00261 int myRotVelMax;
00262 bool mySettableAccsDecs;
00263 int myTransAccel;
00264 int myTransDecel;
00265 int myRotAccel;
00266 int myRotDecel;
00267
00268
00269 int myNumIR;
00270 std::map<int, std::map<int, int> > myIRMap;
00271 enum IRInfo
00272 {
00273 IR_X,
00274 IR_Y,
00275 IR_TYPE,
00276 IR_CYCLES
00277 };
00278 void internalSetIR(int num, int type, int cycles, int x, int y);
00279 bool parseIRUnit(ArArgumentBuilder *builder);
00280 const std::list<ArArgumentBuilder *> *getIRUnits(void);
00281 std::list<ArArgumentBuilder *> myGetIRUnitList;
00282 ArRetFunctorC<const std::list<ArArgumentBuilder *> *, ArRobotParams> myIRUnitGetFunctor;
00283 ArRetFunctor1C<bool, ArRobotParams, ArArgumentBuilder *> myIRUnitSetFunctor;
00284
00285
00286 int myNumSonar;
00287 std::map<int, std::map<int, int> > mySonarMap;
00288 enum SonarInfo
00289 {
00290 SONAR_X,
00291 SONAR_Y,
00292 SONAR_TH
00293 };
00294 void internalSetSonar(int num, int x, int y, int th);
00295 bool parseSonarUnit(ArArgumentBuilder *builder);
00296 const std::list<ArArgumentBuilder *> *getSonarUnits(void);
00297 std::list<ArArgumentBuilder *> myGetSonarUnitList;
00298 ArRetFunctorC<const std::list<ArArgumentBuilder *> *, ArRobotParams> mySonarUnitGetFunctor;
00299 ArRetFunctor1C<bool, ArRobotParams, ArArgumentBuilder *> mySonarUnitSetFunctor;
00300 };
00301
00302 #endif // ARROBOTPARAMS_H