Go to the documentation of this file.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
00028
00029 #include <hector_pose_estimation/measurements/gps.h>
00030 #include <hector_pose_estimation/pose_estimation.h>
00031
00032 namespace hector_pose_estimation {
00033
00034 GPSModel::GPSModel()
00035 : MeasurementModel(MeasurementDimension)
00036 {
00037 position_stddev_ = 10.0;
00038 velocity_stddev_ = 1.0;
00039 parameters().add("position_stddev", position_stddev_);
00040 parameters().add("velocity_stddev", velocity_stddev_);
00041 }
00042
00043 bool GPSModel::init()
00044 {
00045 NoiseCovariance noise = 0.0;
00046 noise(1,1) = noise(2,2) = pow(position_stddev_, 2);
00047 noise(3,3) = noise(4,4) = pow(velocity_stddev_, 2);
00048 this->AdditiveNoiseSigmaSet(noise);
00049 return true;
00050 }
00051
00052 GPSModel::~GPSModel() {}
00053
00054 SystemStatus GPSModel::getStatusFlags() const {
00055 return STATE_XY_VELOCITY | STATE_XY_POSITION;
00056 }
00057
00058 ColumnVector GPSModel::ExpectedValueGet() const {
00059 this->y_(1) = x_(POSITION_X);
00060 this->y_(2) = x_(POSITION_Y);
00061 this->y_(3) = x_(VELOCITY_X);
00062 this->y_(4) = x_(VELOCITY_Y);
00063 return y_;
00064 }
00065
00066 Matrix GPSModel::dfGet(unsigned int i) const {
00067 if (i != 0) return Matrix();
00068 C_(1,POSITION_X) = 1.0;
00069 C_(2,POSITION_Y) = 1.0;
00070 C_(3,VELOCITY_X) = 1.0;
00071 C_(4,VELOCITY_Y) = 1.0;
00072 return C_;
00073 }
00074
00075 GPS::GPS(const std::string &name)
00076 : Measurement_<GPSModel,GPSUpdate>(name)
00077 , reference_(0)
00078 , y_(4)
00079 {
00080 }
00081
00082 GPS::~GPS()
00083 {}
00084
00085 void GPS::onReset() {
00086 reference_ = 0;
00087 }
00088
00089 GPSModel::MeasurementVector const& GPS::getVector(const GPSUpdate &update) {
00090 if (!reference_) {
00091 y_(1) = y_(2) = y_(3) = y_(4) = 0.0/0.0;
00092 return y_;
00093 }
00094
00095 reference_->fromWGS84(update.latitude, update.longitude, y_(1), y_(2));
00096 reference_->fromNorthEast(update.velocity_north, update.velocity_east, y_(3), y_(4));
00097
00098 last_ = update;
00099 return y_;
00100 }
00101
00102 bool GPS::beforeUpdate(PoseEstimation &estimator, const GPSUpdate &update) {
00103
00104 if (timedout()) reference_ = 0;
00105
00106
00107 if (reference_ != estimator.globalReference()) {
00108 reference_ = estimator.globalReference();
00109 reference_->setCurrentPosition(estimator, update.latitude, update.longitude);
00110 }
00111
00112 return true;
00113 }
00114
00115 }