DredgeTool.h
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 
00014 #ifndef DREDGE_TOOL_H_
00015 #define DREDGE_TOOL_H_
00016 #include "SimulatedDevice.h"
00017 using namespace uwsim;
00018 
00019 //PARTICLE SYSTEM FUNCTIONS
00020 
00021 #include <osgParticle/ModularEmitter>
00022 #include <osgParticle/ParticleSystemUpdater>
00023 #include <osgParticle/BoxPlacer>
00024 
00025 #include <osgParticle/FluidFrictionOperator>
00026 #include <osgParticle/ModularProgram>
00027 
00028 //This operator attracts the particles to a sink (dredge tool).
00029 //This class could be in UWSimUtils as it is not specific for Dredge Tool, but I left it here because I think
00030 // it will not be used anywhere else
00031 class AttractOperator : public osgParticle::Operator
00032 {
00033   public:
00034     AttractOperator() : osgParticle::Operator(), _magnitude(1.0f), _killSink(true){}
00035     AttractOperator( const AttractOperator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY )
00036       : osgParticle::Operator(copy, copyop), _magnitude(copy._magnitude), _killSink(copy._killSink)
00037       {}
00038     META_Object( spin, AttractOperator );
00039 
00041     void setMagnitude( float mag ) { _magnitude = mag; }
00043     float getMagnitude() const { return _magnitude; }
00045     void setKillSink( bool kill ) { _killSink = kill; }
00047     bool getKillSink() const { return _killSink; }
00049     inline void operate( osgParticle::Particle* P, double dt );
00050 
00051   protected:
00052     virtual ~AttractOperator() {}
00053     AttractOperator& operator=( const AttractOperator& ) { return *this; }
00054     float _magnitude;
00055     bool _killSink;
00056 };
00057 
00058 //Creates a particle system
00059 osgParticle::ParticleSystem* createSmokeParticles( osg::Group* parent, osgParticle::RandomRateCounter * rrc);
00060 
00061 
00062 //Driver/ROSInterface configuration
00063 class DredgeTool_Config : public SimulatedDeviceConfig
00064 {
00065 public:
00066   //XML members
00067   std::string target;
00068   double offsetp[3];
00069   double offsetr[3];
00070   //constructor
00071   DredgeTool_Config(std::string type_) :
00072       SimulatedDeviceConfig(type_)
00073   {
00074   }
00075 };
00076 
00077 //Driver/ROSInterface factory class
00078 class DredgeTool_Factory : public SimulatedDeviceFactory
00079 {
00080 public:
00081   //this is the only place the device/interface type is set
00082   DredgeTool_Factory(std::string type_ = "DredgeTool") :
00083       SimulatedDeviceFactory(type_)
00084   {
00085   }
00086   ;
00087 
00088   SimulatedDeviceConfig::Ptr processConfig(const xmlpp::Node* node, ConfigFile * config);
00089   bool applyConfig(SimulatedIAUV * auv, Vehicle &vehicleChars, SceneBuilder *sceneBuilder, size_t iteration);
00090 };
00091 
00092 //can be a sparate header file for actual implementation classes...
00093 
00094 #include "ConfigXMLParser.h"
00095 #include "ROSInterface.h"
00096 #include <ros/ros.h>
00097 #include "UWSimUtils.h"
00098 
00099 //Driver class
00100 class DredgeTool : public SimulatedDevice, public AbstractDredgeTool
00101 {
00102   osg::ref_ptr<osg::Node> target;
00103   osgParticle::ParticleSystem* smoke;
00104   osgParticle::RandomRateCounter * rrc;
00105 
00106   //Number of particles in the system (this should decrease slowly)
00107   int particles;
00108 
00109   void applyPhysics(BulletPhysics * bulletPhysics)
00110   {
00111   }
00112 public:
00113   std::string info; //Device's property
00114 
00115   DredgeTool(DredgeTool_Config * cfg, osg::ref_ptr<osg::Node> target);
00116 
00117   virtual boost::shared_ptr<osg::Matrix> getDredgePosition();
00118 
00119   void dredgedParticles(int nparticles);
00120 
00121 
00122 };
00123 
00124 
00125 #endif


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