EqualityConstraint.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2022 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
8 
9 namespace mc_solver
10 {
11 
12 namespace utils
13 {
14 
34 template<typename UpdateT>
35 struct EqualityConstraint : public Constraint<tasks::qp::Equality, UpdateT>
36 {
38 
39  // XXX The following is a hack to work-around the absence of constructor inheritance in GCC 4.7
40  // We enable different constructor based on the UpdateT class
41 
42  template<typename U = UpdateT, typename = typename std::enable_if<std::is_same<U, utils::UpdateRobot>::value>::type>
43  explicit EqualityConstraint(unsigned int rIndex) : Base(rIndex)
44  {
45  }
46 
47  template<typename U = UpdateT, typename = typename std::enable_if<std::is_same<U, utils::UpdateLambda>::value>::type>
48  explicit EqualityConstraint(const tasks::qp::ContactId & cid) : Base(cid)
49  {
50  }
51 
52  template<typename U = UpdateT, typename = typename std::enable_if<std::is_same<U, utils::UpdateForce>::value>::type>
53  EqualityConstraint(const mc_solver::QPSolver & solver, const tasks::qp::ContactId & cid) : Base(solver, cid)
54  {
55  }
56 
57  const Eigen::MatrixXd & AEq() const override { return this->AFull_; }
58 
59  std::string descEq(const std::vector<rbd::MultiBody> &, int i) override
60  {
61  std::stringstream ss;
62  ss << "Failure at line " << i << " for inequality " << this->nameEq();
63  return ss.str();
64  }
65 };
66 
67 } // namespace utils
68 
86 struct EqualityConstraintRobot : public utils::EqualityConstraint<utils::UpdateRobot>
87 {
88  explicit EqualityConstraintRobot(unsigned int rIndex) : utils::EqualityConstraint<utils::UpdateRobot>(rIndex) {}
89 };
90 
114 struct EqualityConstraintLambda : public utils::EqualityConstraint<utils::UpdateLambda>
115 {
116  explicit EqualityConstraintLambda(const tasks::qp::ContactId & cid)
117  : utils::EqualityConstraint<utils::UpdateLambda>(cid)
118  {
119  }
120 };
121 
142 struct EqualityConstraintForce : public utils::EqualityConstraint<utils::UpdateForce>
143 {
144  EqualityConstraintForce(const mc_solver::QPSolver & solver, const tasks::qp::ContactId & cid)
145  : utils::EqualityConstraint<utils::UpdateForce>(solver, cid)
146  {
147  }
148 };
149 
150 } // namespace mc_solver
mc_solver::EqualityConstraintForce
Definition: EqualityConstraint.h:142
mc_solver::EqualityConstraintLambda::EqualityConstraintLambda
EqualityConstraintLambda(const tasks::qp::ContactId &cid)
Definition: EqualityConstraint.h:116
mc_solver::utils::EqualityConstraint::EqualityConstraint
EqualityConstraint(const mc_solver::QPSolver &solver, const tasks::qp::ContactId &cid)
Definition: EqualityConstraint.h:53
mc_solver::QPSolver
Definition: QPSolver.h:85
Constraint.h
mc_solver::EqualityConstraintLambda
Definition: EqualityConstraint.h:114
mc_solver::EqualityConstraintRobot::EqualityConstraintRobot
EqualityConstraintRobot(unsigned int rIndex)
Definition: EqualityConstraint.h:88
mc_solver::EqualityConstraintRobot
Definition: EqualityConstraint.h:86
mc_solver::utils::EqualityConstraint::EqualityConstraint
EqualityConstraint(const tasks::qp::ContactId &cid)
Definition: EqualityConstraint.h:48
mc_solver::utils::EqualityConstraint::AEq
const Eigen::MatrixXd & AEq() const override
Definition: EqualityConstraint.h:57
mc_solver::utils::UpdateLambda
Update< UpdateNrVarsLambda > UpdateLambda
Definition: Update.h:72
mc_solver::utils::EqualityConstraint::EqualityConstraint
EqualityConstraint(unsigned int rIndex)
Definition: EqualityConstraint.h:43
mc_solver::utils::EqualityConstraint::descEq
std::string descEq(const std::vector< rbd::MultiBody > &, int i) override
Definition: EqualityConstraint.h:59
mc_solver::utils::UpdateForce::UpdateForce
UpdateForce(const mc_solver::QPSolver &solver, const tasks::qp::ContactId &cid)
mc_solver::utils::UpdateRobot
Update< UpdateNrVarsRobot > UpdateRobot
Definition: Update.h:71
mc_solver::utils::EqualityConstraint
Definition: EqualityConstraint.h:35
mc_solver::utils::Constraint
Definition: Constraint.h:28
mc_solver::EqualityConstraintForce::EqualityConstraintForce
EqualityConstraintForce(const mc_solver::QPSolver &solver, const tasks::qp::ContactId &cid)
Definition: EqualityConstraint.h:144
mc_solver
Definition: Contact.h:17