GCC Code Coverage Report


Directory: ./
File: include/hpp/constraints/static-stability.hh
Date: 2025-05-05 12:19:30
Exec Total Coverage
Lines: 0 12 0.0%
Branches: 0 16 0.0%

Line Branch Exec Source
1 // Copyright (c) 2014, 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_STATIC_STABILITY_HH
30 #define HPP_CONSTRAINTS_STATIC_STABILITY_HH
31
32 #include <hpp/constraints/config.hh>
33 #include <hpp/constraints/deprecated.hh>
34 #include <hpp/constraints/differentiable-function.hh>
35 #include <hpp/constraints/fwd.hh>
36 #include <hpp/constraints/symbolic-calculus.hh>
37 #include <vector>
38
39 namespace hpp {
40 namespace constraints {
41
42 /// \addtogroup constraints
43 /// \{
44 class HPP_CONSTRAINTS_DLLAPI StaticStability : public DifferentiableFunction {
45 public:
46 static const value_type G;
47 static const Eigen::Matrix<value_type, 6, 1> Gravity;
48
49 struct Contact_t {
50 JointPtr_t joint;
51 vector3_t point;
52 vector3_t normal;
53 bool operator==(Contact_t const& other) const {
54 if (joint != other.joint) return false;
55 if (point != other.point) return false;
56 if (normal != other.normal) return false;
57 return true;
58 }
59 };
60 typedef std::vector<Contact_t> Contacts_t;
61
62 /// Constructor
63 /// \param robot the robot the constraints is applied to,
64 /// \param com COM of the object in the joint frame.
65 StaticStability(const std::string& name, const DevicePtr_t& robot,
66 const Contacts_t& contacts,
67 const CenterOfMassComputationPtr_t& com);
68
69 static StaticStabilityPtr_t create(const std::string& name,
70 const DevicePtr_t& robot,
71 const Contacts_t& contacts,
72 const CenterOfMassComputationPtr_t& com);
73
74 static StaticStabilityPtr_t create(const DevicePtr_t& robot,
75 const Contacts_t& contacts,
76 const CenterOfMassComputationPtr_t& com);
77
78 MatrixOfExpressions<>& phi() { return phi_; }
79
80 protected:
81 bool isEqual(const DifferentiableFunction& other) const {
82 const StaticStability& castother =
83 dynamic_cast<const StaticStability&>(other);
84 if (!DifferentiableFunction::isEqual(other)) return false;
85
86 if (robot_ != castother.robot_) return false;
87 if (contacts_ != castother.contacts_) return false;
88 if (com_ != castother.com_) return false;
89
90 return true;
91 }
92
93 private:
94 void impl_compute(LiegroupElementRef result,
95 ConfigurationIn_t argument) const;
96
97 void impl_jacobian(matrixOut_t jacobian, ConfigurationIn_t argument) const;
98
99 static void findBoundIndex(vectorIn_t u, vectorIn_t v, value_type& lambdaMin,
100 size_type* iMin, value_type& lambdaMax,
101 size_type* iMax);
102
103 /// Return false if uMinus.isZero(), i which case v also zero (not computed).
104 bool computeUminusAndV(vectorIn_t u, vectorOut_t uMinus, vectorOut_t v) const;
105
106 void computeVDot(const ConfigurationIn_t arg, vectorIn_t uMinus, vectorIn_t S,
107 matrixIn_t uDot, matrixOut_t uMinusDot,
108 matrixOut_t vDot) const;
109
110 void computeLambdaDot(vectorIn_t u, vectorIn_t v, const std::size_t i0,
111 matrixIn_t uDot, matrixIn_t vDot,
112 vectorOut_t lambdaDot) const;
113
114 DevicePtr_t robot_;
115 Contacts_t contacts_;
116 CenterOfMassComputationPtr_t com_;
117
118 typedef MatrixOfExpressions<eigen::vector3_t, JacobianMatrix> MoE_t;
119
120 mutable MoE_t phi_;
121 mutable vector_t u_, uMinus_, v_;
122 mutable matrix_t uDot_, uMinusDot_, vDot_;
123 mutable vector_t lambdaDot_;
124 };
125 /// \}
126 } // namespace constraints
127 } // namespace hpp
128
129 #endif // HPP_CONSTRAINTS_STATIC_STABILITY_HH
130