70 , isFreeFloating(m.nbDofs() - m.nbInternalDofs()>0)
74 , taskSEConstraintFunction()
75 , frictionConstraint(NULL)
79 , projector(MatrixXd::Identity(m.nbDofs(),m.nbDofs()))
80 , taskiProjector(MatrixXd::Identity(m.nbDofs(),m.nbDofs()))
82 , taskHasBeenInitialized(false)
83 , contactForceConstraintHasBeenSavedInSolver(false)
84 , contactPointHasBeenSavedInModel(false)
85 , frictionConstraintIsRegisteredInConstraint(false)
86 , isRegisteredAsObjective(false)
87 , isRegisteredAsConstraint(false)
88 , isPointContactTask(false)
89 , innerObjectiveFunction(NULL)
90 , innerTaskAsObjective(NULL)
91 , regulationObjectiveFunction(NULL)
92 , regulationObjective(NULL)
94 innerTaskAsConstraint.
set(NULL);
99 const int outDim = frictionFunction->getDimension();
101 frictionConstraint.
set( reinterpret_cast<LinearizedCoulombFunction *>(
new LinearFunction(fcVar, MatrixXd::Identity(outDim, inDim), VectorXd::Zero(outDim))) );
114 if (innerTaskAsObjective)
119 if (regulationObjective)
121 std::cout<<
"----"<<std::endl;
131 innerTaskAsConstraint.
set(innerObjectiveFunction);
145 :
Task(taskName, innerModel, feature, featureDes)
146 , pimpl(new
Pimpl(taskName, innerModel, feature))
158 :
Task(taskName, innerModel, feature)
159 , pimpl(new
Pimpl(taskName, innerModel, feature))
173 pimpl->solver = &solver;
174 pimpl->seConstraint = &seConstraint;
177 int featn = pimpl->feature->getDimension();
178 pimpl->innerObjectiveFunction =
new LinearFunction(pimpl->fcVar, Eigen::MatrixXd::Identity(featn, featn), Eigen::VectorXd::Zero(featn));
179 pimpl->regulationObjectiveFunction =
new LinearFunction(pimpl->fcVar, Eigen::MatrixXd::Identity(featn, featn),Eigen::VectorXd::Zero(featn));
181 pimpl->connectFunctionnWithObjectiveAndConstraint();
187 if (pimpl->isRegisteredAsObjective)
189 pimpl->solver->removeObjective(*pimpl->innerTaskAsObjective);
193 pimpl->solver->removeObjective(*pimpl->regulationObjective);
196 if (pimpl->isRegisteredAsConstraint)
198 pimpl->solver->removeConstraint(pimpl->innerTaskAsConstraint);
201 if (pimpl->frictionConstraintIsRegisteredInConstraint)
203 pimpl->solver->removeConstraint(pimpl->frictionConstraint.getConstraint());
212 return pimpl->fcVar.getValue();
218 output = pimpl->fcVar.getValue();
226 if ( ! pimpl->contactPointHasBeenSavedInModel )
228 pimpl->innerModel.getModelContacts().addContactPoint(pimpl->fcVar,
getFeature());
229 pimpl->contactPointHasBeenSavedInModel =
true;
263 pimpl->solver->addConstraint(pimpl->frictionConstraint.getConstraint());
265 pimpl->frictionConstraintIsRegisteredInConstraint =
true;
281 pimpl->solver->removeConstraint(pimpl->frictionConstraint.getConstraint());
282 pimpl->frictionConstraintIsRegisteredInConstraint =
false;
301 pimpl->frictionFunction->setMargin(
getMargin());
312 pimpl->solver->addObjective(*pimpl->innerTaskAsObjective);
313 pimpl->solver->addObjective(*pimpl->regulationObjective);
314 if (pimpl->isFreeFloating)
315 pimpl->seConstraint->addFunction(*pimpl->taskSEConstraintFunction);
317 pimpl->isRegisteredAsObjective =
true;
330 pimpl->solver->removeObjective(*pimpl->innerTaskAsObjective);
331 pimpl->solver->removeObjective(*pimpl->regulationObjective);
332 if (pimpl->isFreeFloating)
333 pimpl->seConstraint->removeFunction(*pimpl->taskSEConstraintFunction);
334 pimpl->isRegisteredAsObjective =
false;
348 pimpl->solver->addConstraint(pimpl->innerTaskAsConstraint);
349 pimpl->solver->addObjective(*pimpl->regulationObjective);
350 if (pimpl->isFreeFloating)
351 pimpl->seConstraint->addFunction(*pimpl->taskSEConstraintFunction);
353 pimpl->isRegisteredAsConstraint =
true;
365 pimpl->solver->removeObjective(*pimpl->regulationObjective);
366 pimpl->solver->removeConstraint(pimpl->innerTaskAsConstraint);
367 if (pimpl->isFreeFloating)
368 pimpl->seConstraint->removeFunction(*pimpl->taskSEConstraintFunction);
369 pimpl->isRegisteredAsConstraint =
false;
386 if (pimpl->innerTaskAsObjective)
389 pimpl->innerTaskAsObjective->getFunction().changeWeight(
getWeight());
402 if (pimpl->isFreeFloating)
407 pimpl->taskSEConstraintFunction->changeA( Jt.topRows(pimpl->taskSEConstraintFunction->getDimension()) );
409 pimpl->taskSEConstraintFunction->changeA( PJt.topRows(pimpl->taskSEConstraintFunction->getDimension()) );
427 pimpl->innerObjectiveFunction->changeb(f);
432 const MatrixXd& A = pimpl->frictionFunction->getA();
434 pimpl->frictionConstraint.getFunction().changeA(A);
435 pimpl->frictionConstraint.getFunction().changeb(b);
445 std::string errmsg = std::string(
"[GHCJTTask::doActivateAsObjective]: task '") +
getName() + std::string(
"' not connected to any solver; Call prior that 'GHCJTController::addTask' to connect to the solver inside the controller.\n");
446 throw std::runtime_error(std::string(errmsg));
459 pimpl->alpha = alpha;
465 return pimpl->feature->getDimension();
475 pimpl->indexBegin = index;
480 return pimpl->indexBegin;
485 pimpl->indexEnd = index;
490 return pimpl->indexEnd;
495 pimpl->projector = proj;
500 return pimpl->projector;
505 pimpl->taskiProjector = proj;
510 return pimpl->taskiProjector;
515 return pimpl->innerObjectiveFunction;
virtual void doSetMargin()
void setIndexBegin(int index)
Define task class for GHCJT controller. It inherits from the task class defined in the ocra framework...
const Eigen::MatrixXd & getJacobian() const
int nbInternalDofs() const
void setProjector(Eigen::MatrixXd &proj)
void addContactPointInModel()
bool contactPointHasBeenSavedInModel
GHCJTTask(const std::string &taskName, const Model &innerModel, Feature::Ptr feature, Feature::Ptr featureDes)
LinearFunction * getInnerObjectiveFunction() const
void connectToController(ocra::OneLevelSolver &_solver, SumOfLinearFunctions &seConstraint)
const Eigen::VectorXd & getErrorDot() const
bool taskHasBeenInitialized
void setTaskiProjector(Eigen::MatrixXd &proj)
virtual void doDeactivateAsConstraint()
virtual void doSetWeight()
const Eigen::MatrixXd & getPriority() const
LinearFunction * regulationObjectiveFunction
boost::shared_ptr< LinearFunction > taskSEConstraintFunction
Declaration file of the Model class.
virtual void doActivateAsConstraint()
const Eigen::MatrixXd & getDamping() const
boost::shared_ptr< LinearizedCoulombFunction > frictionFunction
const std::string & getName() const
const Variable & getVariable() const
const Eigen::VectorXd & getError() const
LinearizedCoulombFunction class.
const Eigen::Vector3d & getFrictionConstraintOffset() const
int getTaskDimension() const
Feature interface, used by tasks to compute errors and jacobians.
Objective< SquaredLinearFunction > * innerTaskAsObjective
bool isBodyContactConstraint() const
virtual void doDeactivateContactMode()
const Eigen::VectorXd & getComputedForce() const
void disconnectFromController()
Feature::Ptr getFeature() const
Declaration file of the LinearFunction class.
bool contactForceConstraintHasBeenSavedInSolver
virtual void doDeactivateAsObjective()
virtual T & getFunction(void)
This class represents a variable in a mathematical sense.
const Eigen::MatrixXd & getProjector() const
EqualZeroConstraintPtr< LinearFunction > innerTaskAsConstraint
Declaration file of the WeightedSquareDistanceFunction class.
const Eigen::MatrixXd & getTaskiProjector() const
virtual void doSetFrictionCoeff()
void setIndexEnd(int index)
int getIndexBegin() const
SquaredLinearFunction class.
Declaration file of the LinearizedCoulombFunction class.
Objective< SquaredLinearFunction > * regulationObjective
A generic abstract class the solvers that can be used in the wOcra Controller.
virtual void doGetOutput(Eigen::VectorXd &output) const
double getFrictionCoeff() const
void setWeight(double weight)
void checkIfConnectedToController() const
bool isPointContactTask() const
const Eigen::VectorXd & getEffort() const
bool isRegisteredAsConstraint
ocra::OneLevelSolver * solver
const Eigen::VectorXd & getWeight() const
SumOfLinearFunctions * seConstraint
void setPriority(Eigen::MatrixXd &alpha)
virtual void doActivateAsObjective()
bool isRegisteredAsObjective
bool frictionConstraintIsRegisteredInConstraint
Pimpl(const std::string &name, const Model &m, const Feature &s)
virtual void doActivateContactMode()
Implements a basic variable.
void connectFunctionnWithObjectiveAndConstraint()
LinearFunction * innerObjectiveFunction
LessThanZeroConstraintPtr< LinearizedCoulombFunction > frictionConstraint
const Eigen::MatrixXd & getStiffness() const
void removeContactPointInModel()
const std::string & getTaskName() const