GCC Code Coverage Report


Directory: ./
File: include/tsid/contacts/contact-point.hpp
Date: 2024-08-26 20:29:39
Exec Total Coverage
Lines: 0 1 0.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_point_hpp__
19 #define __invdyn_contact_point_hpp__
20
21 #include "tsid/contacts/contact-base.hpp"
22 #include "tsid/tasks/task-se3-equality.hpp"
23 #include "tsid/math/constraint-inequality.hpp"
24 #include "tsid/math/constraint-equality.hpp"
25
26 namespace tsid {
27 namespace contacts {
28 class ContactPoint : public ContactBase {
29 public:
30 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
31
32 typedef math::ConstRefMatrix ConstRefMatrix;
33 typedef math::ConstRefVector ConstRefVector;
34 typedef math::Matrix3x Matrix3x;
35 typedef math::Vector6 Vector6;
36 typedef math::Vector3 Vector3;
37 typedef math::Vector Vector;
38 typedef tasks::TaskSE3Equality TaskSE3Equality;
39 typedef math::ConstraintInequality ConstraintInequality;
40 typedef math::ConstraintEquality ConstraintEquality;
41 typedef pinocchio::SE3 SE3;
42
43 ContactPoint(const std::string& name, RobotWrapper& robot,
44 const std::string& frameName, ConstRefVector contactNormal,
45 const double frictionCoefficient, const double minNormalForce,
46 const double maxNormalForce);
47
48 virtual ~ContactPoint() {}
49
50 /// Return the number of motion constraints
51 virtual unsigned int n_motion() const;
52
53 /// Return the number of force variables
54 virtual unsigned int n_force() const;
55
56 virtual const ConstraintBase& computeMotionTask(const double t,
57 ConstRefVector q,
58 ConstRefVector v, Data& data);
59
60 virtual const ConstraintInequality& computeForceTask(const double t,
61 ConstRefVector q,
62 ConstRefVector v,
63 const Data& data);
64
65 virtual const Matrix& getForceGeneratorMatrix();
66
67 virtual const ConstraintEquality& computeForceRegularizationTask(
68 const double t, ConstRefVector q, ConstRefVector v, const Data& data);
69
70 const TaskSE3Equality& getMotionTask() const;
71 const ConstraintBase& getMotionConstraint() const;
72 const ConstraintInequality& getForceConstraint() const;
73 const ConstraintEquality& getForceRegularizationTask() const;
74 double getMotionTaskWeight() const;
75 const Matrix3x& getContactPoints() const;
76
77 double getNormalForce(ConstRefVector f) const;
78 double getMinNormalForce() const;
79 double getMaxNormalForce() const;
80
81 const Vector&
82 Kp(); // cannot be const because it set a member variable inside
83 const Vector&
84 Kd(); // cannot be const because it set a member variable inside
85 void Kp(ConstRefVector Kp);
86 void Kd(ConstRefVector Kp);
87
88 bool setContactNormal(ConstRefVector contactNormal);
89
90 bool setFrictionCoefficient(const double frictionCoefficient);
91 bool setMinNormalForce(const double minNormalForce);
92 bool setMaxNormalForce(const double maxNormalForce);
93 bool setMotionTaskWeight(const double w);
94 void setReference(const SE3& ref);
95 void setForceReference(ConstRefVector& f_ref);
96 void setRegularizationTaskWeightVector(ConstRefVector& w);
97
98 /**
99 * @brief Specifies if properties of the contact point and motion task
100 * are expressed in the local or local world oriented frame. The contact
101 * forces, contact normal and contact coefficients are interpreted in
102 * the specified frame.
103 *
104 * @param local_frame If true, use the local frame, otherwise use the
105 * local world oriented
106 */
107 void useLocalFrame(bool local_frame);
108
109 protected:
110 void updateForceInequalityConstraints();
111 void updateForceRegularizationTask();
112 void updateForceGeneratorMatrix();
113
114 TaskSE3Equality m_motionTask;
115 ConstraintInequality m_forceInequality;
116 ConstraintEquality m_forceRegTask;
117 Vector3 m_contactNormal;
118 Vector3 m_fRef;
119 Vector3 m_weightForceRegTask;
120 Matrix3x m_contactPoints;
121 Vector m_Kp3, m_Kd3; // gain vectors to be returned by reference
122 double m_mu;
123 double m_fMin;
124 double m_fMax;
125 double m_regularizationTaskWeight;
126 double m_motionTaskWeight;
127 Matrix m_forceGenMat;
128 };
129 } // namespace contacts
130 } // namespace tsid
131
132 #endif // ifndef __invdyn_contact_6d_hpp__
133