GCC Code Coverage Report


Directory: ./
File: include/tsid/contacts/contact-6d.hpp
Date: 2024-08-26 20:29:39
Exec Total Coverage
Lines: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //
2 // Copyright (c) 2017 CNRS, NYU, MPI Tübingen
3 //
4 // This file is part of tsid
5 // tsid is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 // tsid is distributed in the hope that it will be
10 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Lesser Public License for more details. You should have
13 // received a copy of the GNU Lesser General Public License along with
14 // tsid If not, see
15 // <http://www.gnu.org/licenses/>.
16 //
17
18 #ifndef __invdyn_contact_6d_hpp__
19 #define __invdyn_contact_6d_hpp__
20
21 #include "tsid/deprecated.hh"
22 #include "tsid/contacts/contact-base.hpp"
23 #include "tsid/tasks/task-se3-equality.hpp"
24 #include "tsid/math/constraint-inequality.hpp"
25 #include "tsid/math/constraint-equality.hpp"
26
27 namespace tsid {
28 namespace contacts {
29 class Contact6d : public ContactBase {
30 public:
31 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
32
33 typedef math::ConstRefMatrix ConstRefMatrix;
34 typedef math::ConstRefVector ConstRefVector;
35 typedef math::Matrix3x Matrix3x;
36 typedef math::Vector6 Vector6;
37 typedef math::Vector3 Vector3;
38 typedef math::Vector Vector;
39 typedef tasks::TaskSE3Equality TaskSE3Equality;
40 typedef math::ConstraintInequality ConstraintInequality;
41 typedef math::ConstraintEquality ConstraintEquality;
42 typedef pinocchio::SE3 SE3;
43
44 Contact6d(const std::string& name, RobotWrapper& robot,
45 const std::string& frameName, ConstRefMatrix contactPoints,
46 ConstRefVector contactNormal, const double frictionCoefficient,
47 const double minNormalForce, const double maxNormalForce);
48
49 TSID_DEPRECATED Contact6d(const std::string& name, RobotWrapper& robot,
50 const std::string& frameName,
51 ConstRefMatrix contactPoints,
52 ConstRefVector contactNormal,
53 const double frictionCoefficient,
54 const double minNormalForce,
55 const double maxNormalForce,
56 const double forceRegWeight);
57
58 6 virtual ~Contact6d() {}
59
60 /// Return the number of motion constraints
61 virtual unsigned int n_motion() const;
62
63 /// Return the number of force variables
64 virtual unsigned int n_force() const;
65
66 virtual const ConstraintBase& computeMotionTask(const double t,
67 ConstRefVector q,
68 ConstRefVector v, Data& data);
69
70 virtual const ConstraintInequality& computeForceTask(const double t,
71 ConstRefVector q,
72 ConstRefVector v,
73 const Data& data);
74
75 virtual const Matrix& getForceGeneratorMatrix();
76
77 virtual const ConstraintEquality& computeForceRegularizationTask(
78 const double t, ConstRefVector q, ConstRefVector v, const Data& data);
79
80 const TaskSE3Equality& getMotionTask() const;
81 const ConstraintBase& getMotionConstraint() const;
82 const ConstraintInequality& getForceConstraint() const;
83 const ConstraintEquality& getForceRegularizationTask() const;
84
85 double getNormalForce(ConstRefVector f) const;
86 double getMinNormalForce() const;
87 double getMaxNormalForce() const;
88 const Matrix3x& getContactPoints() const;
89
90 const Vector& Kp() const;
91 const Vector& Kd() const;
92 void Kp(ConstRefVector Kp);
93 void Kd(ConstRefVector Kp);
94
95 bool setContactPoints(ConstRefMatrix contactPoints);
96 bool setContactNormal(ConstRefVector contactNormal);
97
98 bool setFrictionCoefficient(const double frictionCoefficient);
99 bool setMinNormalForce(const double minNormalForce);
100 bool setMaxNormalForce(const double maxNormalForce);
101 void setReference(const SE3& ref);
102 void setForceReference(ConstRefVector& f_ref);
103 void setRegularizationTaskWeightVector(ConstRefVector& w);
104
105 private:
106 void init();
107
108 protected:
109 void updateForceInequalityConstraints();
110 void updateForceRegularizationTask();
111 void updateForceGeneratorMatrix();
112
113 TaskSE3Equality m_motionTask;
114 ConstraintInequality m_forceInequality;
115 ConstraintEquality m_forceRegTask;
116 Matrix3x m_contactPoints;
117 Vector3 m_contactNormal;
118 Vector6 m_fRef;
119 Vector6 m_weightForceRegTask;
120 double m_mu;
121 double m_fMin;
122 double m_fMax;
123 Matrix m_forceGenMat;
124 };
125 } // namespace contacts
126 } // namespace tsid
127
128 #endif // ifndef __invdyn_contact_6d_hpp__
129