INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
gbxnovatelacfr/driver.h00001 /* 00002 * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics 00003 * http://gearbox.sf.net/ 00004 * Copyright (c) 2004-2010 Matthew Ridley, Ben Upcroft, Michael Moser 00005 * 00006 * This distribution is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef GBXNOVATELACFR_DRIVER_H 00012 #define GBXNOVATELACFR_DRIVER_H 00013 00014 #include <cstdlib> 00015 #include <string> 00016 #include <memory> 00017 #include <vector> 00018 00019 // forward declarations 00020 // users don't need to know about serial devices or Tracers or imu decoders 00021 namespace gbxserialacfr{ 00022 class Serial; 00023 } 00024 namespace gbxutilacfr{ 00025 class Tracer; 00026 } 00027 namespace gbxnovatelutilacfr{ 00028 class ImuDecoder; 00029 } 00030 00033 namespace gbxnovatelacfr{ 00034 00036 class SimpleConfig{ 00037 public: 00040 SimpleConfig(std::string serialDevice, int baudRate, std::string imuType, std::vector<double > &imuToGpsOffset): 00041 serialDevice_(serialDevice), 00042 baudRate_(baudRate), 00043 imuType_(imuType), 00044 imuToGpsOffset_(imuToGpsOffset) {}; 00045 00047 // 00053 bool isValid() const; 00055 std::string toString() const; 00056 00057 std::string serialDevice_; 00058 int baudRate_; 00059 std::string imuType_; 00060 std::vector<double > imuToGpsOffset_; 00061 }; 00062 00064 class GpsOnlyConfig{ 00065 public: 00066 GpsOnlyConfig(std::string serialDevice, int baudRate): 00067 serialDevice_(serialDevice), 00068 baudRate_(baudRate) {}; 00069 00071 // 00075 bool isValid() const; 00076 std::string toString() const; 00077 00078 std::string serialDevice_; 00079 int baudRate_; 00080 }; 00081 00083 // 00087 class Config{ 00088 public: 00090 // 00092 Config(const SimpleConfig &simpleCfg); 00094 // 00096 Config(const GpsOnlyConfig &gpsOnlyCfg); 00098 Config(); 00099 00101 // 00109 bool isValid(); 00111 std::string toString() const; 00112 00114 // 00116 std::string serialDevice_; 00117 int baudRate_; 00119 00121 // 00123 bool enableImu_; 00124 std::string imuType_; 00125 00126 00129 // 00131 bool enableInsPva_; 00132 bool enableGpsPos_; 00133 bool enableGpsVel_; 00134 bool enableRawImu_; 00135 bool ignoreUnknownMessages_; 00136 00138 00143 // 00145 double dtInsPva_; 00146 double dtGpsPos_; 00147 double dtGpsVel_; 00148 bool fixInvalidRateSettings_; 00149 00151 00153 // 00155 std::vector<double > imuToGpsOffset_; 00156 std::vector<double > imuToGpsOffsetUncertainty_; 00157 bool enableInsOffset_; 00158 std::vector<double > insOffset_; 00159 bool enableInsPhaseUpdate_; 00160 00162 00164 // 00166 bool enableCDGPS_; 00167 bool enableSBAS_; 00168 bool enableRTK_; 00169 bool enableUseOfOmniStarCarrier_; 00170 00172 00178 // 00180 bool enableSetImuOrientation_; 00181 int setImuOrientation_; 00182 bool enableVehicleBodyRotation_; 00183 std::vector<double > vehicleBodyRotation_; 00184 std::vector<double > vehicleBodyRotationUncertainty_; 00185 00187 private: 00188 }; 00189 00191 enum StatusMessageType { 00192 NoMsg, 00193 Initialising, 00194 Ok, 00195 Warning, 00196 Fault 00197 }; 00198 00200 std::string toString( StatusMessageType type ); 00201 00202 00204 // 00206 enum GpsSolutionStatusType{ 00207 SolComputed=0, 00208 InsufficientObs=1, 00209 NoConvergence=2, 00210 Singularity=3, 00211 CovTrace=4, 00212 TestDist=5, 00213 ColdStart=6, 00214 VHLimit=7, 00215 Variance=8, 00216 Residuals=9, 00217 DeltaPos=10, 00218 NegativeVar=11, 00219 ReservedGpsSolutionStatusType12=12, 00220 IntegrityWarning=13, 00221 InsInactive=14, 00222 InsAligning=15, 00223 InsBad=16, 00224 ImuUnplugged=17, 00225 Pending=18, 00226 InvalidFix=19, 00227 UnknownGpsSolutionStatusType 00228 }; 00229 00231 std::string toString( GpsSolutionStatusType type ); 00232 00234 // 00236 enum GpsPosVelType{ 00237 None=0, 00238 FixedPos=1, 00239 FixedHeight=2, 00240 ReservedGpsPosVelType3=3, 00241 FloatConv=4, 00242 WideLane=5, 00243 NarrowLane=6, 00244 ReservedGpsPosVelType7=7, 00245 DopplerVelocity=8, 00246 ReservedGpsPosVelType9=9, 00247 ReservedGpsPosVelType10=10, 00248 ReservedGpsPosVelType11=11, 00249 ReservedGpsPosVelType12=12, 00250 ReservedGpsPosVelType13=13, 00251 ReservedGpsPosVelType14=14, 00252 ReservedGpsPosVelType15=15, 00253 Single=16, 00254 PsrDiff=17, 00255 Waas=18, 00256 Propagated=19, 00257 Omnistar=20, 00258 ReservedGpsPosVelType21=21, 00259 ReservedGpsPosVelType22=22, 00260 ReservedGpsPosVelType23=23, 00261 ReservedGpsPosVelType24=24, 00262 ReservedGpsPosVelType25=25, 00263 ReservedGpsPosVelType26=26, 00264 ReservedGpsPosVelType27=27, 00265 ReservedGpsPosVelType28=28, 00266 ReservedGpsPosVelType29=29, 00267 ReservedGpsPosVelType30=30, 00268 ReservedGpsPosVelType31=31, 00269 L1Float=32, 00270 IonoFreeFloat=33, 00271 NarrowFloat=34, 00272 L1Int=48, 00273 WideInt=49, 00274 NarrowInt=50, 00275 RtkDirectIns=51, 00276 Ins=52, 00277 InsPsrSp=53, 00278 InsPsrDiff=54, 00279 InsRtkFloat=55, 00280 InsRtkFixed=56, 00281 OmniStarHp=64, 00282 OmniStarXp=65, 00283 CdGps=66, 00284 UnknownGpsPosVelType 00285 }; 00286 00288 std::string toString( GpsPosVelType type ); 00289 00291 enum DataType { 00293 InsPva, 00295 BestGpsPos, 00297 BestGpsVel, 00299 RawImu 00300 }; 00301 00303 class GenericData { 00304 public: 00305 virtual ~GenericData(){}; 00306 virtual DataType type() const=0; 00307 virtual std::string toString() const=0; 00308 private: 00309 }; 00310 00312 class InsPvaData : public GenericData { 00313 public: 00314 DataType type() const { 00315 return InsPva; 00316 } 00317 std::string toString() const; 00318 int gpsWeekNr; 00319 double secIntoWeek; 00320 double latitude; 00321 double longitude; 00322 double height; 00323 00326 // 00328 double northVelocity; 00329 double eastVelocity; 00330 double upVelocity; 00331 00333 00336 // 00338 double roll; 00339 double pitch; 00340 double azimuth; 00341 00343 00344 StatusMessageType statusMessageType; 00345 std::string statusMessage; 00346 00347 int timeStampSec; 00348 int timeStampUSec; 00349 }; 00350 00352 class BestGpsPosData : public GenericData { 00353 public: 00354 DataType type() const { 00355 return BestGpsPos; 00356 } 00357 std::string toString() const; 00358 int gpsWeekNr; 00359 unsigned int msIntoWeek; 00360 GpsSolutionStatusType solutionStatus; // 00361 GpsPosVelType positionType; // 00362 double latitude; 00363 double longitude; 00364 double heightAMSL; 00365 float undulation; 00366 unsigned int datumId; // 00367 float sigmaLatitude; 00368 float sigmaLongitude; 00369 float sigmaHeight; 00370 char baseStationId[4]; // 00371 float diffAge; 00372 float solutionAge; 00373 int numObservations; 00374 int numL1Ranges; 00375 int numL1RangesRTK; 00376 int numL2RangesRTK; 00377 00378 StatusMessageType statusMessageType; 00379 std::string statusMessage; 00380 00381 int timeStampSec; 00382 int timeStampUSec; 00383 }; 00384 00386 class BestGpsVelData : public GenericData { 00387 public: 00388 DataType type() const { 00389 return BestGpsVel; 00390 } 00391 std::string toString() const; 00392 int gpsWeekNr; 00393 unsigned int msIntoWeek; 00394 GpsSolutionStatusType solutionStatus; // 00395 GpsPosVelType velocityType; // 00396 float latency; 00397 float diffAge; 00398 double horizontalSpeed; 00399 double trackOverGround; 00400 double verticalSpeed; 00401 00402 StatusMessageType statusMessageType; 00403 std::string statusMessage; 00404 00405 int timeStampSec; 00406 int timeStampUSec; 00407 }; 00408 00410 class RawImuData : public GenericData { 00411 public: 00412 DataType type() const { 00413 return RawImu; 00414 } 00415 std::string toString() const; 00416 int gpsWeekNr; 00417 double secIntoWeek; 00418 00419 00420 00421 // 00423 double zDeltaV; 00424 double yDeltaV; 00425 double xDeltaV; 00426 00428 00432 // 00434 double zDeltaAng; 00435 double yDeltaAng; 00436 double xDeltaAng; 00437 00439 00440 StatusMessageType statusMessageType; 00441 std::string statusMessage; 00442 00443 int timeStampSec; 00444 int timeStampUSec; 00445 }; 00446 00449 class Driver { 00450 public: 00451 00454 // 00456 00458 // 00460 Driver( const Config &cfg); 00463 Driver( const Config &cfg, gbxutilacfr::Tracer &tracer); 00465 ~Driver(); 00466 00472 std::auto_ptr<GenericData> read(); 00473 00474 private: 00475 00476 // does the leg-work for the constructor (via the following guys) 00477 void configure(); 00478 // establish a serial connection to the receiver 00479 void connectToHardware(); 00480 // set parameters related to the IMU 00481 void configureImu(); 00482 // set parameters related to the INS 00483 void configureIns(); 00484 // set parameters related to GPS 00485 void configureGps(); 00486 // turn on data messages we are interested in 00487 void requestData(); 00488 00489 std::auto_ptr<gbxnovatelutilacfr::ImuDecoder> imuDecoder_; 00490 00491 std::auto_ptr<gbxserialacfr::Serial> serial_; 00492 int baud_; 00493 00494 Config config_; 00495 std::auto_ptr<gbxutilacfr::Tracer> tracerInternal_; 00496 gbxutilacfr::Tracer& tracer_; 00497 }; 00498 00499 00500 } // namespace 00502 #endif |