task-capture-point-inequality.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 CNRS, NYU, MPI Tübingen, PAL Robotics
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 //
18 #include "tsid/math/utils.hpp"
20 
27 namespace tsid {
28 namespace tasks {
29 using namespace math;
30 using namespace trajectories;
31 using namespace pinocchio;
32 
35  const double timeStep)
36  : TaskMotion(name, robot),
37  m_constraint(name, 2, robot.nv()),
38  m_nv(robot.nv()),
39  m_delta_t(timeStep) {
40  m_dim = 2;
41  m_p_com.setZero(3);
42  m_v_com.setZero(3);
43 
44  m_safety_margin.setZero(m_dim);
45 
46  m_support_limits_x.setZero(m_dim);
47  m_support_limits_y.setZero(m_dim);
48 
49  m_rp_max.setZero(m_dim);
50  m_rp_min.setZero(m_dim);
51 
52  b_lower.setZero(m_dim);
53  b_upper.setZero(m_dim);
54 
55  m_g = robot.model().gravity.linear().norm();
56  m_w = 0;
57  m_ka = 0;
58 }
59 
60 int TaskCapturePointInequality::dim() const { return m_dim; }
61 
63  return m_constraint.matrix() * dv - m_drift;
64 }
65 
68  return m_constraint;
69 }
70 
72  const double x_max) {
73  PINOCCHIO_CHECK_INPUT_ARGUMENT(x_min >= x_max,
74  "The minimum limit for x needs to be greater "
75  "or equal to the maximum limit");
76  m_support_limits_x(0) = x_min;
77  m_support_limits_x(1) = x_max;
78 }
79 
81  const double y_max) {
82  PINOCCHIO_CHECK_INPUT_ARGUMENT(y_min >= y_max,
83  "The minimum limit for y needs to be greater "
84  "or equal to the maximum limit");
85  m_support_limits_y(0) = y_min;
86  m_support_limits_y(1) = y_max;
87 }
88 
90  const double y_margin) {
91  m_safety_margin(0) = x_margin;
92  m_safety_margin(1) = y_margin;
93 }
94 
98  Data& data) {
100 
101  const Matrix3x& Jcom = m_robot.Jcom(data);
102 
103  m_w = sqrt(m_g / m_p_com(2));
104  m_ka = (2 * m_w) / ((m_w * m_delta_t + 2) * m_delta_t);
105 
106  m_rp_min(0) =
107  m_support_limits_x(0) + m_safety_margin(0); // x min support polygon
108  m_rp_min(1) =
109  m_support_limits_y(0) + m_safety_margin(1); // y min support polygon
110 
111  m_rp_max(0) =
112  m_support_limits_x(1) - m_safety_margin(0); // x max support polygon
113  m_rp_max(1) =
114  m_support_limits_y(1) - m_safety_margin(1); // y max support polygon
115 
116  for (int i = 0; i < m_dim; i++) {
117  b_lower(i) =
118  m_ka * (m_rp_min(i) - m_p_com(i) - m_v_com(i) * (m_delta_t + 1 / m_w));
119  b_upper(i) =
120  m_ka * (m_rp_max(i) - m_p_com(i) - m_v_com(i) * (m_delta_t + 1 / m_w));
121  }
122 
125 
126  m_constraint.setMatrix(Jcom.block(0, 0, m_dim, m_nv));
127 
128  return m_constraint;
129 }
130 
131 } // namespace tasks
132 } // namespace tsid
tsid::tasks::TaskCapturePointInequality::compute
const ConstraintBase & compute(double t, ConstRefVector q, ConstRefVector v, Data &data) override
Definition: task-capture-point-inequality.cpp:95
tsid::tasks::TaskCapturePointInequality::m_delta_t
double m_delta_t
Definition: task-capture-point-inequality.hpp:77
pinocchio::DataTpl
PINOCCHIO_CHECK_INPUT_ARGUMENT
#define PINOCCHIO_CHECK_INPUT_ARGUMENT(...)
tsid::tasks::TaskCapturePointInequality::m_support_limits_y
Vector m_support_limits_y
Definition: task-capture-point-inequality.hpp:74
dv
dv
tsid::math::ConstraintBase
Abstract class representing a linear equality/inequality constraint. Equality constraints are represe...
Definition: constraint-base.hpp:35
tsid::tasks::TaskCapturePointInequality::m_g
double m_g
Definition: task-capture-point-inequality.hpp:78
i
int i
setup.data
data
Definition: setup.in.py:48
demo_quadruped.robot
robot
Definition: demo_quadruped.py:51
tsid::math::ConstraintInequality::lowerBound
const Vector & lowerBound() const override
Definition: src/math/constraint-inequality.cpp:66
utils.hpp
tsid::tasks::TaskCapturePointInequality::m_support_limits_x
Vector m_support_limits_x
Definition: task-capture-point-inequality.hpp:73
tsid::math::Matrix3x
Eigen::Matrix< Scalar, 3, Eigen::Dynamic > Matrix3x
Definition: math/fwd.hpp:42
tsid::tasks::TaskCapturePointInequality::m_drift
Vector3 m_drift
Definition: task-capture-point-inequality.hpp:65
tsid::tasks::TaskCapturePointInequality::dim
int dim() const override
Return the dimension of the task. \info should be overloaded in the child class.
Definition: task-capture-point-inequality.cpp:60
tsid::tasks::TaskCapturePointInequality::m_safety_margin
Vector m_safety_margin
Definition: task-capture-point-inequality.hpp:72
ex_4_conf.nv
int nv
Definition: ex_4_conf.py:23
tsid::tasks::TaskCapturePointInequality::m_constraint
ConstraintInequality m_constraint
Definition: task-capture-point-inequality.hpp:70
tsid::tasks::TaskCapturePointInequality::getAcceleration
Vector getAcceleration(ConstRefVector dv) const override
Definition: task-capture-point-inequality.cpp:62
tsid::math::ConstraintBase::matrix
virtual const Matrix & matrix() const
Definition: constraint-base.cpp:35
tsid::tasks::TaskCapturePointInequality::m_rp_max
Vector m_rp_max
Definition: task-capture-point-inequality.hpp:68
robot-wrapper.hpp
tsid::robots::RobotWrapper::com
void com(const Data &data, RefVector com_pos, RefVector com_vel, RefVector com_acc) const
Definition: src/robots/robot-wrapper.cpp:145
tsid::tasks::TaskCapturePointInequality::TaskCapturePointInequality
TaskCapturePointInequality(const std::string &name, RobotWrapper &robot, const double timeStep)
Definition: task-capture-point-inequality.cpp:33
tsid::tasks::TaskCapturePointInequality::position
const Vector & position() const override
Definition: task-capture-point-inequality.cpp:66
tsid::tasks::TaskCapturePointInequality::setSafetyMargin
void setSafetyMargin(const double x_margin, const double y_margin)
Definition: task-capture-point-inequality.cpp:89
tsid::tasks::TaskCapturePointInequality::m_v_com
Vector m_v_com
Definition: task-capture-point-inequality.hpp:66
tsid::tasks::TaskCapturePointInequality::setSupportLimitsXAxis
void setSupportLimitsXAxis(const double x_min, const double x_max)
Definition: task-capture-point-inequality.cpp:71
setup.name
name
Definition: setup.in.py:179
tsid::tasks::TaskCapturePointInequality::m_dim
int m_dim
Definition: task-capture-point-inequality.hpp:81
tsid::tasks::TaskMotion
Definition: task-motion.hpp:26
tsid::tasks::TaskCapturePointInequality::m_ka
double m_ka
Definition: task-capture-point-inequality.hpp:80
task-capture-point-inequality.hpp
tsid
Definition: bindings/python/constraint/constraint-bound.cpp:21
tsid::robots::RobotWrapper
Wrapper for a robot based on pinocchio.
Definition: robots/robot-wrapper.hpp:37
tsid::tasks::TaskCapturePointInequality::setSupportLimitsYAxis
void setSupportLimitsYAxis(const double y_min, const double y_max)
Definition: task-capture-point-inequality.cpp:80
tsid::tasks::TaskCapturePointInequality::m_p_com
Vector m_p_com
Definition: task-capture-point-inequality.hpp:66
tsid::robots::RobotWrapper::Jcom
const Matrix3x & Jcom(const Data &data) const
Definition: src/robots/robot-wrapper.cpp:162
tsid::tasks::TaskCapturePointInequality::Vector
math::Vector Vector
Definition: task-capture-point-inequality.hpp:36
tsid::math::ConstraintInequality::upperBound
const Vector & upperBound() const override
Definition: src/math/constraint-inequality.cpp:67
tsid::tasks::TaskCapturePointInequality::b_upper
Vector b_upper
Definition: task-capture-point-inequality.hpp:84
tsid::tasks::TaskCapturePointInequality::m_nv
Eigen::Index m_nv
Definition: task-capture-point-inequality.hpp:76
tsid::tasks::TaskCapturePointInequality::b_lower
Vector b_lower
Definition: task-capture-point-inequality.hpp:83
tsid::tasks::TaskBase::m_robot
RobotWrapper & m_robot
Reference on the robot model.
Definition: task-base.hpp:64
tsid::tasks::TaskCapturePointInequality::m_rp_min
Vector m_rp_min
Definition: task-capture-point-inequality.hpp:67
tsid::tasks::TaskCapturePointInequality::m_w
double m_w
Definition: task-capture-point-inequality.hpp:79
tsid::tasks::TaskBase::ConstRefVector
math::ConstRefVector ConstRefVector
Definition: task-base.hpp:39
tsid::tasks::TaskCapturePointInequality::getConstraint
const ConstraintBase & getConstraint() const override
Definition: task-capture-point-inequality.cpp:67
tsid::math::ConstraintBase::setMatrix
virtual bool setMatrix(ConstRefMatrix A)
Definition: constraint-base.cpp:39
pinocchio


tsid
Author(s): Andrea Del Prete, Justin Carpentier
autogenerated on Thu Apr 3 2025 02:47:16