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/GPSSensor.h>
00015 #include <osg/io_utils>
00016
00017 #include <osg/PositionAttitudeTransform>
00018
00019 osg::Vec3d GPSSensor::getMeasurement()
00020 {
00021
00022 boost::shared_ptr<osg::Matrix> rMs = getWorldCoords(node_);
00023 osg::Matrixd lMs = *rMs * osg::Matrixd::inverse(rMl_);
00024
00025
00026 static boost::normal_distribution<> normal(0, std_);
00027 static boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > var_nor(rng_, normal);
00028
00029 return lMs.getTrans() + osg::Vec3d(var_nor(), var_nor(), var_nor());
00030 }
00031
00032 double GPSSensor::depthBelowWater()
00033 {
00034 boost::shared_ptr<osg::Matrix> rMs = getWorldCoords(node_);
00035 return -(rMs->getTrans().z() - oscene_->getOceanScene()->getOceanSurfaceHeight());
00036 }
00037
00038 int GPSSensor::getTFTransform(tf::Pose & pose, std::string & parent){
00039 parent=parentLinkName;
00040 pose.setOrigin(tf::Vector3(parent_->asTransform()->asPositionAttitudeTransform()->getPosition().x(),
00041 parent_->asTransform()->asPositionAttitudeTransform()->getPosition().y(),
00042 parent_->asTransform()->asPositionAttitudeTransform()->getPosition().z()));
00043 pose.setRotation( tf::Quaternion(parent_->asTransform()->asPositionAttitudeTransform()->getAttitude().x(),
00044 parent_->asTransform()->asPositionAttitudeTransform()->getAttitude().y(),
00045 parent_->asTransform()->asPositionAttitudeTransform()->getAttitude().z(),
00046 parent_->asTransform()->asPositionAttitudeTransform()->getAttitude().w()));
00047 return 1;
00048
00049 }