OmniDriver.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This library is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU Lesser General Public License as published by    *
00007 * the Free Software Foundation; either version 2.1 of the License, or (at     *
00008 * your option) any later version.                                             *
00009 *                                                                             *
00010 * This library is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
00013 * for more details.                                                           *
00014 *                                                                             *
00015 * You should have received a copy of the GNU Lesser General Public License    *
00016 * along with this library; if not, write to the Free Software Foundation,     *
00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
00018 *******************************************************************************
00019 *                               SOFA :: Modules                               *
00020 *                                                                             *
00021 * Authors: The SOFA Team and external contributors (see Authors.txt)          *
00022 *                                                                             *
00023 * Contact information: contact@sofa-framework.org                             *
00024 ******************************************************************************/
00025 #ifndef SOFA_COMPONENT_ODESOLVER_OMNISOLVER_H
00026 #define SOFA_COMPONENT_ODESOLVER_OMNISOLVER_H
00027 
00028 #include <sofa/core/componentmodel/behavior/OdeSolver.h>
00029 #include <sofa/simulation/common/OdeSolverImpl.h>
00030 #include <sofa/simulation/tree/GNode.h>
00031 #include <sofa/component/linearsolver/NewMatMatrix.h>
00032 #include <sofa/component/linearsolver/NewMatVector.h>
00033 #include <sofa/component/MechanicalObject.h>
00034 #include <sofa/defaulttype/VecTypes.h>
00035 #include <sofa/defaulttype/RigidTypes.h>
00036 #include <sofa/component/container/ArticulatedHierarchyContainer.h>
00037 
00038 #include <sofa/component/controller/ForceFeedback.h>
00039 
00040 #include <sofa/core/componentmodel/behavior/BaseController.h>
00041 //Sensable include
00042 #include <HD/hd.h>
00043 #include <HDU/hduVector.h>
00044 #include <HDU/hduError.h>
00045 #include <sofa/helper/LCPcalc.h>
00046 
00047 namespace sofa
00048 {
00049 
00050 namespace component
00051 {
00052 
00053 namespace controller
00054 {
00055 
00056 
00057 using namespace sofa::defaulttype;
00058 using namespace sofa::component::linearsolver;
00059 using core::objectmodel::Data;
00060 
00062 typedef struct {
00063     int nupdates;
00064     HDboolean m_buttonState1;       /* Has the device button has been pressed. */
00065     HDboolean m_buttonState2;       /* Has the device button has been pressed. */
00066     hduVector3Dd m_devicePosition; /* Current device coordinates. */
00067     HDErrorInfo m_error;
00068     Vec3d pos;
00069     Quat quat;
00070     bool ready;
00071     bool stop;
00072 } DeviceData;
00073 
00074 typedef struct {
00075     ForceFeedback* forceFeedback;
00076     simulation::tree::GNode *context;
00077     Mat3x3d rotation;
00078     Vec3d translation;
00079     double scale;
00080     double forceScale;
00081     DeviceData servoDeviceData;
00082     DeviceData deviceData;
00083 } OmniData;
00084 
00088 class OmniDriver : public core::componentmodel::behavior::BaseController
00089 {
00090 
00091 public:
00092     Data<double> scale;
00093     Data<double> forceScale;
00094     Data<Vec3d> position;
00095     Data<Vec3d> orientation;
00096 
00097     simulation::tree::GNode *context; //->propagateEvent()
00098     //ForceFeedback* forceFeedback;
00099     OmniData* data;
00100     void init();
00101     void reinit();
00102     void setForceFeedback(ForceFeedback* ff);
00103     OmniDriver();
00104     ~OmniDriver();
00105     void cleanup();
00106 private:
00107     void handleEvent(core::objectmodel::Event *);
00108 };
00109 
00110 } // namespace controller
00111 
00112 } // namespace component
00113 
00114 } // namespace sofa
00115 
00116 #endif

Generated on Sun Nov 23 02:50:35 2008 for Sofa by  doxygen 1.5.7.1