GPSSensor.cpp
Go to the documentation of this file.
00001 /* 
00002  * Copyright (c) 2013 University of Jaume-I.
00003  * All rights reserved. This program and the accompanying materials
00004  * are made available under the terms of the GNU Public License v3.0
00005  * which accompanies this distribution, and is available at
00006  * http://www.gnu.org/licenses/gpl.html
00007  * 
00008  * Contributors:
00009  *     Mario Prats
00010  *     Javier Perez
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   //Should get world coords and then transform to the localizedWorld
00022   boost::shared_ptr<osg::Matrix> rMs = getWorldCoords(node_);
00023   osg::Matrixd lMs = *rMs * osg::Matrixd::inverse(rMl_);
00024 
00025   //Now add some gaussian noise
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 }


uwsim
Author(s): Mario Prats , Javier Perez
autogenerated on Fri Aug 28 2015 13:28:58