6 Model::Model(
const std::string& name,
int ndofs,
bool freeRoot,
const std::string& jointTorqueVariableName,
7 const std::string& forceVariableName,
const std::string& configurationVariableName,
8 const std::string& internalDofsSuffix,
const std::string& externalDofsSuffix)
11 , _fixedRoot(!freeRoot)
16 int n_int = _dofs-FREE_DOFS;
29 _jointDamping = VectorXd::Zero(_tau->
getSize());
50 delete _modelContacts;
62 return _dofs-FREE_DOFS;
93 propagate<EVT_CHANGE_VALUE>();
101 propagate<EVT_CHANGE_VALUE>();
111 void Model::setState(
const Eigen::Displacementd& H_root,
const VectorXd& q,
const Eigen::Twistd& T_root,
const VectorXd& q_dot)
146 return (*static_cast<CompositeVariable*>(_q))(0);
154 return (*static_cast<CompositeVariable*>(_q))(1);
160 return (*static_cast<CompositeVariable*>(_q_dot))(0);
168 return (*static_cast<CompositeVariable*>(_q_dot))(1);
174 return (*static_cast<CompositeVariable*>(_q_ddot))(0);
182 return (*static_cast<CompositeVariable*>(_q_ddot))(1);
188 return* _modelContacts;
205 _jointDamping = damping;
210 return _jointDamping;
215 throw std::runtime_error(
"[Model::doGetSegmentIndex] This function was not overriden for a specific model");
220 throw std::runtime_error(
"[Model::doGetSegmentName] This function was not overriden for a specific model");
223 void Model::invalidate(
int timestamp)
241 assert(index>=0 && index <
nbDofs());
257 throw std::runtime_error(
"[Model::doGetDofIndex] This function was not overriden for a specific model");
262 throw std::runtime_error(
"[Model::doGetDofName] This function was not overriden for a specific model");
268 throw std::runtime_error(
"[Model::doSegmentName] This function was not overriden for a specific model");
274 throw std::runtime_error(
"[Model::doDofName] This function was not overriden for a specific model");
virtual int doGetDofIndex(const std::string &name) const
Variable & getRootVelocityVariable() const
Variable & getInternalVelocityVariable() const
virtual Variable & getTimeDerivative()
Get the time derivative/primitive of the variable.
int nbInternalDofs() const
virtual const std::string doDofName(const std::string &name) const
void setJointVelocities(const Eigen::VectorXd &q_dot)
void setValue(const VectorXd &value)
Declaration file of the Model class.
const Eigen::VectorXd & getJointDamping() const
virtual const std::string & doGetSegmentName(int index) const =0
Variable & getRootAccelerationVariable() const
virtual void doSetState(const Eigen::VectorXd &q, const Eigen::VectorXd &q_dot)
virtual void doSetFreeFlyerVelocity(const Eigen::Twistd &T_root)=0
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
void setJointPositions(const Eigen::VectorXd &q)
yarp::os::Semaphore modelMutex
Variable & getConfigurationVariable() const
virtual void doSetJointVelocities(const Eigen::VectorXd &q_dot)=0
Variable & getInternalAccelerationVariable() const
int getSegmentIndex(const std::string &name) const
void setState(const Eigen::VectorXd &q, const Eigen::VectorXd &q_dot)
Variable & getRootConfigurationVariable() const
virtual const std::string doSegmentName(const std::string &name) const
Variable & getInternalConfigurationVariable() const
This class represents a variable in a mathematical sense.
void setJointDamping(const Eigen::VectorXd &damping)
virtual const std::string & doGetDofName(int index) const
virtual void doInvalidate()
int getDofIndex(const std::string &name) const
void setFreeFlyerVelocity(const Eigen::Twistd &T_root)
void setFreeFlyerPosition(const Eigen::Displacementd &H_root)
const std::string & getSegmentName(int index) const
Variable & getJointTorqueVariable() const
Variable & getAccelerationVariable() const
const std::string SegmentName(const std::string &name) const
const std::string DofName(const std::string &name) const
bool hasFixedRoot() const
A concatenation of base variables and other composite variables.
Model(const std::string &name, int ndofs, bool freeRoot, const std::string &jointTorqueVariableName="tau", const std::string &forceVariableName="f", const std::string &configurationVariableName="q", const std::string &internalDofsSuffix="_int", const std::string &externalDofsSuffix="_root")
virtual void doSetJointPositions(const Eigen::VectorXd &q)=0
void disconnect(Derived &object, void(Base::*callbackToErase)(int)) const
Disconnect non-static method.
void connect(Derived &object, void(Base::*newCallback)(int)) const
Call this method to register a non-static method as a callback.
virtual void doSetFreeFlyerPosition(const Eigen::Displacementd &H_root)=0
ModelContacts & getModelContacts() const
Implements a basic variable.
virtual int doGetSegmentIndex(const std::string &name) const =0
const std::string & getDofName(int index) const
virtual int nbSegments() const =0
Variable & getVelocityVariable() const