Update.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 
9 
10 namespace mc_solver
11 {
12 
13 namespace utils
14 {
15 
17 {
18 };
19 
20 template<typename UpdateNrVars>
21 struct Update : public UpdateNrVars, UpdateTag
22 {
23  static_assert(std::is_same<UpdateNrVars, UpdateNrVarsRobot>::value
24  || std::is_same<UpdateNrVars, UpdateNrVarsLambda>::value,
25  "This should not be instanciated with unexpected UpdateNrVars classes");
26 
27 protected:
28  // XXX The following is a hack to work-around the absence of constructor inheritance in GCC 4.7
29  // We enable different constructor based on the UpdateNrVars class
30 
31  template<typename U = UpdateNrVars,
32  typename = typename std::enable_if<std::is_same<U, UpdateNrVarsRobot>::value>::type>
33  explicit Update(unsigned int rIndex) : UpdateNrVars(rIndex)
34  {
35  }
36 
37  template<typename U = UpdateNrVars,
38  typename = typename std::enable_if<std::is_same<U, UpdateNrVarsLambda>::value>::type>
39  explicit Update(const tasks::qp::ContactId & cid) : UpdateNrVars(cid)
40  {
41  }
42 
43  virtual ~Update() {}
44 
46  virtual void compute() = 0;
47 
49  virtual const Eigen::MatrixXd & A() const = 0;
50 
51  void updateImpl(const std::vector<rbd::MultiBody> &,
52  const std::vector<rbd::MultiBodyConfig> &,
53  const tasks::qp::SolverData &)
54  {
55  compute();
56  const auto & A_ = A();
57  auto nInEq = A_.rows();
58  AFull_.setZero(nInEq, UpdateNrVars::nrVars_);
59  AFull_.block(0, UpdateNrVars::ABegin_, nInEq, A_.cols()) = A_;
60  }
61 
63  Eigen::MatrixXd AFull_;
64 };
65 
66 template<typename T>
67 struct IsUpdate : public std::is_base_of<UpdateTag, T>
68 {
69 };
70 
73 
74 struct MC_SOLVER_DLLAPI UpdateForce : public Update<UpdateNrVarsLambda>
75 {
76 protected:
77  UpdateForce(const mc_solver::QPSolver & solver, const tasks::qp::ContactId & cid);
78 
79  void updateImpl(const std::vector<rbd::MultiBody> &,
80  const std::vector<rbd::MultiBodyConfig> &,
81  const tasks::qp::SolverData &);
82 
83 private:
86 
87  Eigen::MatrixXd ALambda_;
88 };
89 
90 } // namespace utils
91 
92 } // namespace mc_solver
ContactWrenchMatrixToLambdaMatrix.h
mc_solver::utils::Update::Update
Update(unsigned int rIndex)
Definition: Update.h:33
mc_solver::utils::Update::~Update
virtual ~Update()
Definition: Update.h:43
mc_solver::utils::Update::Update
Update(const tasks::qp::ContactId &cid)
Definition: Update.h:39
mc_solver::QPSolver
Definition: QPSolver.h:85
mc_solver::utils::IsUpdate
Definition: Update.h:67
mc_solver::utils::Update::compute
virtual void compute()=0
mc_solver::utils::UpdateForce
Definition: Update.h:74
mc_solver::utils::Update
Definition: Update.h:21
mc_solver::utils::Update::A
virtual const Eigen::MatrixXd & A() const =0
mc_solver::utils::Update::AFull_
Eigen::MatrixXd AFull_
Definition: Update.h:63
mc_solver::utils::Update::updateImpl
void updateImpl(const std::vector< rbd::MultiBody > &, const std::vector< rbd::MultiBodyConfig > &, const tasks::qp::SolverData &)
Definition: Update.h:51
mc_solver
Definition: Contact.h:17
mc_solver::utils::UpdateTag
Definition: Update.h:16
MC_SOLVER_DLLAPI
#define MC_SOLVER_DLLAPI
Definition: api.h:50
mc_solver::utils::ContactWrenchMatrixToLambdaMatrix
Definition: ContactWrenchMatrixToLambdaMatrix.h:108
UpdateNrVars.h