Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <uwsim/UWSimUtils.h>
00014 #include <uwsim/DVLSensor.h>
00015 #include <osg/io_utils>
00016
00017 osg::Vec3d DVLSensor::getMeasurement()
00018 {
00019
00020 boost::shared_ptr<osg::Matrix> rMs = getWorldCoords(node_);
00021 osg::Matrixd lMs = *rMs * osg::Matrixd::inverse(rMl_);
00022 osg::Vec3d x = lMs.getTrans();
00023
00024 ros::Time tnow = ros::Time::now();
00025 ros::Duration ellapsed_time = tnow - tprevious_;
00026 tprevious_ = tnow;
00027
00028
00029 osg::Vec3d v = (x - xprevious_) / ellapsed_time.toSec();
00030 xprevious_ = x;
00031
00032
00033 osg::Matrixd sRl = osg::Matrixd::inverse(lMs);
00034 sRl.setTrans(0, 0, 0);
00035 osg::Vec4d vh(v.x(), v.y(), v.z(), 1);
00036 osg::Vec4d vdvl = vh * sRl;
00037
00038
00039 static boost::normal_distribution<> normal(0, std_);
00040 static boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > var_nor(rng_, normal);
00041 vdvl[0] += var_nor();
00042 vdvl[1] += var_nor();
00043 vdvl[2] += var_nor();
00044
00045 return osg::Vec3d(vdvl.x(), vdvl.y(), vdvl.z());
00046 }
00047