/* * Copyright 2010, * François Bleibel, * Olivier Stasse, * * CNRS/AIST * * This file is part of sot-dynamic-pinocchio. * sot-dynamic-pinocchio is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * sot-dynamic-pinocchio is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. You should * have received a copy of the GNU Lesser General Public License along * with sot-dynamic-pinocchio. If not, see . */ #ifndef __SOT_DYNAMIC_PINOCCHIO_H__ #define __SOT_DYNAMIC_PINOCCHIO_H__ /* --------------------------------------------------------------------- */ /* --- INCLUDE --------------------------------------------------------- */ /* --------------------------------------------------------------------- */ /* STD */ #include #include /* Matrix */ #include /* SOT */ #include #include #include #include #include #include #include /* PINOCCHIO */ #include #include #include #include #include #include /* --------------------------------------------------------------------- */ /* --- API ------------------------------------------------------------- */ /* --------------------------------------------------------------------- */ #if defined (WIN32) # if defined (dynamic_EXPORTS) # define SOTDYNAMIC_EXPORT __declspec(dllexport) # else # define SOTDYNAMIC_EXPORT __declspec(dllimport) # endif #else # define SOTDYNAMIC_EXPORT #endif namespace dynamicgraph { namespace sot { namespace dg = dynamicgraph; namespace command { class SetFile; class CreateOpPoint; } /* --------------------------------------------------------------------- */ /* --- CLASS ----------------------------------------------------------- */ /* --------------------------------------------------------------------- */ /*! @ingroup signals \brief This class provides an inverse dynamic model of the robot. More precisely it wraps the newton euler algorithm implemented by the dynamicsJRLJapan library to make it accessible in the stack of tasks. The robot is described by a VRML file. */ class SOTDYNAMIC_EXPORT DynamicPinocchio :public dg::Entity { friend class sot::command::SetFile; friend class sot::command::CreateOpPoint; // friend class sot::command::InitializeRobot; public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW DYNAMIC_GRAPH_ENTITY_DECL(); /* --- MODEL ATRIBUTES --- */ se3::Model* m_model; se3::Data* m_data; /* --- MODEL ATRIBUTES --- */ public: /* --- SIGNAL ACTIVATION --- */ dg::SignalTimeDependent< dg::Matrix,int >& createEndeffJacobianSignal( const std::string& signame, const std::string& ); dg::SignalTimeDependent< dg::Matrix,int >& createJacobianSignal( const std::string& signame, const std::string& ); void destroyJacobianSignal( const std::string& signame ); dg::SignalTimeDependent< MatrixHomogeneous,int >& createPositionSignal( const std::string&,const std::string& ); void destroyPositionSignal( const std::string& signame ); dg::SignalTimeDependent< dg::Vector,int >& createVelocitySignal( const std::string&,const std::string& ); void destroyVelocitySignal( const std::string& signame ); dg::SignalTimeDependent< dg::Vector,int >& createAccelerationSignal( const std::string&, const std::string& ); void destroyAccelerationSignal( const std::string& signame ); /*! @} */ std::list< dg::SignalBase* > genericSignalRefs; public: /* --- SIGNAL --- */ typedef int Dummy; dg::SignalPtr jointPositionSIN; dg::SignalPtr freeFlyerPositionSIN; dg::SignalPtr jointVelocitySIN; dg::SignalPtr freeFlyerVelocitySIN; dg::SignalPtr jointAccelerationSIN; dg::SignalPtr freeFlyerAccelerationSIN; dg::SignalTimeDependent pinocchioPosSINTERN; dg::SignalTimeDependent pinocchioVelSINTERN; dg::SignalTimeDependent pinocchioAccSINTERN; dg::SignalTimeDependent newtonEulerSINTERN; dg::SignalTimeDependent jacobiansSINTERN; dg::SignalTimeDependent forwardKinematicsSINTERN; dg::SignalTimeDependent ccrbaSINTERN; int& computeNewtonEuler(int& dummy,const int& time ); int& computeForwardKinematics(int& dummy,const int& time ); int& computeCcrba( int& dummy,const int& time ); int& computeJacobians( int& dummy,const int& time ); dg::SignalTimeDependent zmpSOUT; dg::SignalTimeDependent JcomSOUT; dg::SignalTimeDependent comSOUT; dg::SignalTimeDependent inertiaSOUT; dg::SignalTimeDependent& jacobiansSOUT( const std::string& name ); dg::SignalTimeDependent& positionsSOUT( const std::string& name ); dg::SignalTimeDependent& velocitiesSOUT( const std::string& name ); dg::SignalTimeDependent& accelerationsSOUT( const std::string& name ); dg::SignalTimeDependent footHeightSOUT; dg::SignalTimeDependent upperJlSOUT; dg::SignalTimeDependent lowerJlSOUT; dg::SignalTimeDependent upperVlSOUT; dg::SignalTimeDependent upperTlSOUT; dg::Signal inertiaRotorSOUT; dg::Signal gearRatioSOUT; dg::SignalTimeDependent inertiaRealSOUT; dg::SignalTimeDependent MomentaSOUT; dg::SignalTimeDependent AngularMomentumSOUT; dg::SignalTimeDependent dynamicDriftSOUT; public: /* --- CONSTRUCTOR --- */ DynamicPinocchio( const std::string& name); virtual ~DynamicPinocchio( void ); /* --- MODEL CREATION --- */ void displayModel() const { assert(m_model); std::cout<<(*m_model)< (jointType,jointPosition (in parent frame), function_ptr to pinocchio Joint) dg::Vector& getPinocchioPos(dg::Vector& q,const int& time); dg::Vector& getPinocchioVel(dg::Vector& v, const int& time); dg::Vector& getPinocchioAcc(dg::Vector& a, const int&time); //\brief Index list for the first dof of (spherical joints)/ (spherical part of free-flyer joint). std::vector sphericalJoints; }; // std::ostream& operator<<(std::ostream& os, const CjrlJoint& r); } /* namespace sot */} /* namespace dynamicgraph */ #endif // #ifndef __SOT_DYNAMIC_PINOCCHIO_H__