Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <uwsim/VirtualRangeSensor.h>
00014 #include <uwsim/UWSimUtils.h>
00015 #include <iostream>
00016
00017 #include <osg/PositionAttitudeTransform>
00018 VirtualRangeSensor::VirtualRangeSensor()
00019 {
00020 }
00021
00022 VirtualRangeSensor::VirtualRangeSensor(std::string name, std::string parentName, osg::Node *root, osg::Node *trackNode, double range,
00023 bool visible,unsigned int mask)
00024 {
00025 init(name,parentName, root, trackNode, range, visible,mask);
00026 }
00027
00028 void VirtualRangeSensor::init(std::string name, std::string parentName, osg::Node *root, osg::Node *trackNode, double range, bool visible,unsigned int mask)
00029 {
00030 this->name = name;
00031 this->parentLinkName=parentName;
00032 this->root = root;
00033
00034 this->trackNode = trackNode;
00035
00036 osg::ref_ptr < osg::Node > axis = UWSimGeometry::createSwitchableFrame();
00037
00038 axis->asGroup()->addChild(UWSimGeometry::createLabel(name));
00039 this->trackNode->asGroup()->addChild(axis);
00040
00041 this->range = range;
00042 this->visible = visible;
00043
00044
00045 node_tracker = new IntersectorUpdateCallback(range, visible, root);
00046 trackNode->setUpdateCallback(node_tracker);
00047 trackNode->asGroup()->addChild(node_tracker->geode);
00048
00049 if(node_tracker->geode)
00050 node_tracker->geode->setNodeMask(mask);
00051 }
00052
00053 int VirtualRangeSensor::getTFTransform(tf::Pose & pose, std::string & parent){
00054 parent=parentLinkName;
00055 pose.setOrigin(tf::Vector3(trackNode->asTransform()->asPositionAttitudeTransform()->getPosition().x(),
00056 trackNode->asTransform()->asPositionAttitudeTransform()->getPosition().y(),
00057 trackNode->asTransform()->asPositionAttitudeTransform()->getPosition().z()));
00058 pose.setRotation( tf::Quaternion(trackNode->asTransform()->asPositionAttitudeTransform()->getAttitude().x(),
00059 trackNode->asTransform()->asPositionAttitudeTransform()->getAttitude().y(),
00060 trackNode->asTransform()->asPositionAttitudeTransform()->getAttitude().z(),
00061 trackNode->asTransform()->asPositionAttitudeTransform()->getAttitude().w()));
00062 return 1;
00063
00064 }
00065