InequalityConstraint.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 InequalityConstraint : public Constraint<tasks::qp::Inequality, 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 InequalityConstraint(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 InequalityConstraint(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  InequalityConstraint(const mc_solver::QPSolver & solver, const tasks::qp::ContactId & cid) : Base(solver, cid)
54  {
55  }
56 
57  const Eigen::MatrixXd & AInEq() const override { return this->AFull_; }
58 
59  std::string descInEq(const std::vector<rbd::MultiBody> &, int i) override
60  {
61  std::stringstream ss;
62  ss << "Failure at line " << i << " for inequality " << this->nameInEq();
63  return ss.str();
64  }
65 };
66 
67 } // namespace utils
68 
86 struct InequalityConstraintRobot : public utils::InequalityConstraint<utils::UpdateRobot>
87 {
88  explicit InequalityConstraintRobot(unsigned int rIndex) : utils::InequalityConstraint<utils::UpdateRobot>(rIndex) {}
89 };
90 
115 struct InequalityConstraintLambda : public utils::InequalityConstraint<utils::UpdateLambda>
116 {
117  explicit InequalityConstraintLambda(const tasks::qp::ContactId & cid)
118  : utils::InequalityConstraint<utils::UpdateLambda>(cid)
119  {
120  }
121 };
122 
143 struct InequalityConstraintForce : public utils::InequalityConstraint<utils::UpdateForce>
144 {
145  InequalityConstraintForce(const mc_solver::QPSolver & solver, const tasks::qp::ContactId & cid)
146  : utils::InequalityConstraint<utils::UpdateForce>(solver, cid)
147  {
148  }
149 };
150 
151 } // namespace mc_solver
mc_solver::utils::InequalityConstraint
Definition: InequalityConstraint.h:35
mc_solver::QPSolver
Definition: QPSolver.h:85
Constraint.h
mc_solver::InequalityConstraintForce::InequalityConstraintForce
InequalityConstraintForce(const mc_solver::QPSolver &solver, const tasks::qp::ContactId &cid)
Definition: InequalityConstraint.h:145
mc_solver::utils::InequalityConstraint::InequalityConstraint
InequalityConstraint(const tasks::qp::ContactId &cid)
Definition: InequalityConstraint.h:48
mc_solver::InequalityConstraintForce
Definition: InequalityConstraint.h:143
mc_solver::utils::InequalityConstraint::InequalityConstraint
InequalityConstraint(const mc_solver::QPSolver &solver, const tasks::qp::ContactId &cid)
Definition: InequalityConstraint.h:53
mc_solver::InequalityConstraintRobot::InequalityConstraintRobot
InequalityConstraintRobot(unsigned int rIndex)
Definition: InequalityConstraint.h:88
mc_solver::utils::UpdateLambda
Update< UpdateNrVarsLambda > UpdateLambda
Definition: Update.h:72
mc_solver::InequalityConstraintRobot
Definition: InequalityConstraint.h:86
mc_solver::utils::InequalityConstraint::InequalityConstraint
InequalityConstraint(unsigned int rIndex)
Definition: InequalityConstraint.h:43
mc_solver::InequalityConstraintLambda::InequalityConstraintLambda
InequalityConstraintLambda(const tasks::qp::ContactId &cid)
Definition: InequalityConstraint.h:117
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::Constraint
Definition: Constraint.h:28
mc_solver::InequalityConstraintLambda
Definition: InequalityConstraint.h:115
mc_solver::utils::InequalityConstraint::AInEq
const Eigen::MatrixXd & AInEq() const override
Definition: InequalityConstraint.h:57
mc_solver
Definition: Contact.h:17
mc_solver::utils::InequalityConstraint::descInEq
std::string descInEq(const std::vector< rbd::MultiBody > &, int i) override
Definition: InequalityConstraint.h:59