hpp-constraints  6.0.0
Definition of basic geometric constraints for motion planning
qp-static-stability.hh
Go to the documentation of this file.
1 // Copyright (c) 2015, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28 
29 #ifndef HPP_CONSTRAINTS_QP_STATIC_STABILITY_HH
30 #define HPP_CONSTRAINTS_QP_STATIC_STABILITY_HH
31 
34 #include <hpp/constraints/fwd.hh>
36 #include <qpOASES.hpp>
37 
38 namespace hpp {
39 namespace constraints {
40 
44 
50 // counter-balance the gravity force and momentum of a kinematics chain.
55  public:
56  static const Eigen::Matrix<value_type, 6, 1> Gravity;
57 
61 
67  QPStaticStability(const std::string& name, const DevicePtr_t& robot,
68  const Contacts_t& contacts,
69  const CenterOfMassComputationPtr_t& com);
70 
74  QPStaticStability(const std::string& name, const DevicePtr_t& robot,
75  const std::vector<ForceData>& contacts,
76  const CenterOfMassComputationPtr_t& com);
77 
78  static QPStaticStabilityPtr_t create(const std::string& name,
79  const DevicePtr_t& robot,
80  const Contacts_t& contacts,
81  const CenterOfMassComputationPtr_t& com);
82 
83  static QPStaticStabilityPtr_t create(const std::string& name,
84  const DevicePtr_t& robot,
85  const std::vector<ForceData>& contacts,
86  const CenterOfMassComputationPtr_t& com);
87 
89  const Contacts_t& contacts,
90  const CenterOfMassComputationPtr_t& com);
91 
92  MatrixOfExpressions<>& phi() { return phi_; }
93 
94  protected:
95  bool isEqual(const DifferentiableFunction& other) const {
96  const QPStaticStability& castother =
97  dynamic_cast<const QPStaticStability&>(other);
98  if (!DifferentiableFunction::isEqual(other)) return false;
99 
100  if (name() != castother.name()) return false;
101  if (robot_ != castother.robot_) return false;
102  if (nbContacts_ != castother.nbContacts_) return false;
103  if (com_ != castother.com_) return false;
104  if (Zeros != castother.Zeros) return false;
105  if (nWSR != castother.nWSR) return false;
106 
107  return true;
108  }
109 
110  private:
111  static const Eigen::Matrix<value_type, 6, 1> MinusGravity;
112 
113  qpOASES::real_t* Zeros;
114  const qpOASES::int_t nWSR;
115 
116  void impl_compute(LiegroupElementRef result,
117  ConfigurationIn_t argument) const;
118 
119  void impl_jacobian(matrixOut_t jacobian, ConfigurationIn_t argument) const;
120 
121  qpOASES::returnValue solveQP(vectorOut_t result) const;
122 
123  bool checkQPSol() const;
124  bool checkStrictComplementarity() const;
125 
126  DevicePtr_t robot_;
127  std::size_t nbContacts_;
129 
131  typedef Eigen::Matrix<qpOASES::real_t, Eigen::Dynamic, Eigen::Dynamic,
132  Eigen::RowMajor>
133  RowMajorMatrix_t;
134  typedef Eigen::Map<RowMajorMatrix_t> InvertStorageOrderMap_t;
135  typedef Eigen::Map<Eigen::Matrix<qpOASES::real_t, Eigen::Dynamic, 1> >
136  VectorMap_t;
137  typedef Eigen::Map<const vector_t> ConstVectorMap_t;
138 
139  mutable RowMajorMatrix_t H_;
140  mutable vector_t G_;
141  mutable qpOASES::QProblemB qp_;
142  mutable MoE_t phi_;
143  mutable vector_t primal_, dual_;
144 };
146 } // namespace constraints
147 } // namespace hpp
148 
149 #endif // HPP_CONSTRAINTS_STATIC_STABILITY_HH
Definition: differentiable-function.hh:63
virtual bool isEqual(const DifferentiableFunction &other) const
Definition: differentiable-function.hh:206
const std::string & name() const
Get function name.
Definition: differentiable-function.hh:122
Matrix having Expression elements.
Definition: symbolic-calculus.hh:871
Definition: qp-static-stability.hh:54
static QPStaticStabilityPtr_t create(const std::string &name, const DevicePtr_t &robot, const Contacts_t &contacts, const CenterOfMassComputationPtr_t &com)
StaticStability::Contacts_t Contacts_t
Definition: qp-static-stability.hh:59
ConvexShapeContact::ForceData ForceData
Definition: qp-static-stability.hh:60
MatrixOfExpressions & phi()
Definition: qp-static-stability.hh:92
static const Eigen::Matrix< value_type, 6, 1 > Gravity
Definition: qp-static-stability.hh:56
static QPStaticStabilityPtr_t create(const DevicePtr_t &robot, const Contacts_t &contacts, const CenterOfMassComputationPtr_t &com)
StaticStability::Contact_t Contact_t
Definition: qp-static-stability.hh:58
static QPStaticStabilityPtr_t create(const std::string &name, const DevicePtr_t &robot, const std::vector< ForceData > &contacts, const CenterOfMassComputationPtr_t &com)
QPStaticStability(const std::string &name, const DevicePtr_t &robot, const std::vector< ForceData > &contacts, const CenterOfMassComputationPtr_t &com)
bool isEqual(const DifferentiableFunction &other) const
Definition: qp-static-stability.hh:95
QPStaticStability(const std::string &name, const DevicePtr_t &robot, const Contacts_t &contacts, const CenterOfMassComputationPtr_t &com)
std::vector< Contact_t > Contacts_t
Definition: static-stability.hh:60
#define HPP_CONSTRAINTS_DLLAPI
Definition: config.hh:88
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:109
shared_ptr< QPStaticStability > QPStaticStabilityPtr_t
Definition: fwd.hh:132
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:106
Eigen::Ref< matrix_t > matrixOut_t
Definition: fwd.hh:58
pinocchio::CenterOfMassComputationPtr_t CenterOfMassComputationPtr_t
Definition: fwd.hh:112
pinocchio::vectorOut_t vectorOut_t
Definition: fwd.hh:61
pinocchio::vector_t vector_t
Definition: fwd.hh:59
pinocchio::LiegroupElementRef LiegroupElementRef
Definition: fwd.hh:66
Definition: active-set-differentiable-function.hh:36
Definition: convex-shape-contact.hh:117
Definition: static-stability.hh:49