diff --git a/include/hpp/manipulation/graph/graph-component.hh b/include/hpp/manipulation/graph/graph-component.hh index e26850b84c8a04efc562a4eed032e8d913a511fb..36cb8d5b29ecdb3094ca896b54f83c89ada53cb9 100644 --- a/include/hpp/manipulation/graph/graph-component.hh +++ b/include/hpp/manipulation/graph/graph-component.hh @@ -57,6 +57,9 @@ namespace hpp { const ImplicitPtr_t& numConstraint, const segments_t& passiveDofs = segments_t ()); + /// Add a cost function Implicit to the component. + virtual void addNumericalCost (const ImplicitPtr_t& numCost); + /// Reset the numerical constraints stored in the component. virtual void resetNumericalConstraints (); @@ -85,6 +88,9 @@ namespace hpp { /// Get a reference to the NumericalConstraints_t const NumericalConstraints_t& numericalConstraints() const; + /// Get a reference to the NumericalConstraints_t + const NumericalConstraints_t& numericalCosts() const; + /// Get a reference to the NumericalConstraints_t const IntervalsContainer_t& passiveDofs() const; @@ -119,6 +125,8 @@ namespace hpp { NumericalConstraints_t numericalConstraints_; /// Stores the passive dofs for each numerical constraints. IntervalsContainer_t passiveDofs_; + /// Stores the numerical costs. + NumericalConstraints_t numericalCosts_; /// List of LockedJoint constraints: \todo to be removed const LockedJoints_t lockedJoints_; /// A weak pointer to the parent graph. diff --git a/src/graph/graph-component.cc b/src/graph/graph-component.cc index 8b67e2bf5a60529f602d7f6cafaacb43ee47f225..1bed00690e1d099d1dec580c0929a5ff1fc705aa 100644 --- a/src/graph/graph-component.cc +++ b/src/graph/graph-component.cc @@ -59,11 +59,18 @@ namespace hpp { passiveDofs_.push_back (passiveDofs); } + void GraphComponent::addNumericalCost (const ImplicitPtr_t& cost) + { + isInit_ = false; + numericalCosts_.push_back(cost); + } + void GraphComponent::resetNumericalConstraints () { isInit_ = false; numericalConstraints_.clear(); passiveDofs_.clear(); + numericalCosts_.clear(); } void GraphComponent::addLockedJointConstraint @@ -85,6 +92,10 @@ namespace hpp { ++itpdof; } assert (itpdof == passiveDofs_.end ()); + for (NumericalConstraints_t::const_iterator it = numericalCosts_.begin(); + it != numericalCosts_.end(); ++it) { + proj->add (*it, 1); + } return !numericalConstraints_.empty (); } @@ -93,6 +104,11 @@ namespace hpp { return numericalConstraints_; } + const NumericalConstraints_t& GraphComponent::numericalCosts() const + { + return numericalCosts_; + } + const std::vector <segments_t>& GraphComponent::passiveDofs() const { return passiveDofs_; diff --git a/src/graph/validation.cc b/src/graph/validation.cc index 562e307ac0042b4116710a611bb276ecd13bbaee..adfacafda1d7f784520c2f3eadfaccfc397a42e9 100644 --- a/src/graph/validation.cc +++ b/src/graph/validation.cc @@ -41,9 +41,9 @@ namespace hpp { { const NumericalConstraints_t& Ancs = A->numericalConstraints(); const NumericalConstraints_t& Bncs = B->numericalConstraints(); - for (NumericalConstraints_t::const_iterator _nc = Ancs.begin(); - _nc != Ancs.end(); ++_nc) - if (std::find (Bncs.begin(), Bncs.end(), *_nc) == Bncs.end()) + for (NumericalConstraints_t::const_iterator _nc = Bncs.begin(); + _nc != Bncs.end(); ++_nc) + if (std::find (Ancs.begin(), Ancs.end(), *_nc) == Ancs.end()) return false; return true; }