GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/tsid/contacts/contact-two-frame-positions.hpp Lines: 0 1 0.0 %
Date: 2024-02-02 08:47:34 Branches: 0 0 - %

Line Branch Exec Source
1
//
2
// Copyright (c) 2023 MIPT
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_two_frame_positions_hpp__
19
#define __invdyn_contact_two_frame_positions_hpp__
20
21
#include "tsid/contacts/contact-base.hpp"
22
#include "tsid/tasks/task-se3-equality.hpp"
23
#include "tsid/tasks/task-two-frames-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 ContactTwoFramePositions : 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::TaskTwoFramesEquality TaskTwoFramesEquality;
40
  typedef tasks::TaskSE3Equality TaskSE3Equality;
41
  typedef math::ConstraintInequality ConstraintInequality;
42
  typedef math::ConstraintEquality ConstraintEquality;
43
  typedef pinocchio::SE3 SE3;
44
45
  ContactTwoFramePositions(const std::string& name, RobotWrapper& robot,
46
                           const std::string& frameName1,
47
                           const std::string& frameName2,
48
                           const double minNormalForce,
49
                           const double maxNormalForce);
50
51
  /// Return the number of motion constraints
52
  virtual unsigned int n_motion() const;
53
54
  /// Return the number of force variables
55
  virtual unsigned int n_force() const;
56
57
  virtual const ConstraintBase& computeMotionTask(const double t,
58
                                                  ConstRefVector q,
59
                                                  ConstRefVector v, Data& data);
60
61
  virtual const ConstraintInequality& computeForceTask(const double t,
62
                                                       ConstRefVector q,
63
                                                       ConstRefVector v,
64
                                                       const Data& data);
65
66
  virtual const Matrix& getForceGeneratorMatrix();
67
68
  virtual const ConstraintEquality& computeForceRegularizationTask(
69
      const double t, ConstRefVector q, ConstRefVector v, const Data& data);
70
71
  const TaskTwoFramesEquality& getMotionTask() const;
72
  const ConstraintBase& getMotionConstraint() const;
73
  const ConstraintInequality& getForceConstraint() const;
74
  const ConstraintEquality& getForceRegularizationTask() const;
75
  double getMotionTaskWeight() const;
76
  const Matrix3x& getContactPoints() const;
77
78
  double getNormalForce(ConstRefVector f) const;
79
  double getMinNormalForce() const;
80
  double getMaxNormalForce() const;
81
82
  const Vector&
83
  Kp();  // cannot be const because it set a member variable inside
84
  const Vector&
85
  Kd();  // cannot be const because it set a member variable inside
86
  void Kp(ConstRefVector Kp);
87
  void Kd(ConstRefVector Kp);
88
89
  bool setContactNormal(ConstRefVector contactNormal);
90
91
  bool setFrictionCoefficient(const double frictionCoefficient);
92
  bool setMinNormalForce(const double minNormalForce);
93
  bool setMaxNormalForce(const double maxNormalForce);
94
  bool setMotionTaskWeight(const double w);
95
  void setForceReference(ConstRefVector& f_ref);
96
  void setRegularizationTaskWeightVector(ConstRefVector& w);
97
98
 protected:
99
  void updateForceInequalityConstraints();
100
  void updateForceRegularizationTask();
101
  void updateForceGeneratorMatrix();
102
103
  TaskTwoFramesEquality m_motionTask;
104
  ConstraintInequality m_forceInequality;
105
  ConstraintEquality m_forceRegTask;
106
  Vector3 m_fRef;
107
  Vector3 m_weightForceRegTask;
108
  Matrix3x m_contactPoints;
109
  Vector m_Kp3, m_Kd3;  // gain vectors to be returned by reference
110
  double m_fMin;
111
  double m_fMax;
112
  double m_regularizationTaskWeight;
113
  double m_motionTaskWeight;
114
  Matrix m_forceGenMat;
115
};
116
}  // namespace contacts
117
}  // namespace tsid
118
119
#endif  // ifndef __invdyn_contact_two_frame_positions_hpp__