src/tasks/task-joint-bounds.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2017 CNRS
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 
20 
21 namespace tsid {
22 namespace tasks {
23 using namespace math;
24 using namespace trajectories;
25 using namespace pinocchio;
26 
28  double dt)
29  : TaskMotion(name, robot),
30  m_constraint(name, robot.nv()),
31  m_dt(dt),
32  m_nv(robot.nv()),
33  m_na(robot.na()) {
34  PINOCCHIO_CHECK_INPUT_ARGUMENT(dt > 0.0, "dt needs to be positive");
35  m_v_lb = -1e10 * Vector::Ones(m_na);
36  m_v_ub = +1e10 * Vector::Ones(m_na);
37  m_a_lb = -1e10 * Vector::Ones(m_na);
38  m_a_ub = +1e10 * Vector::Ones(m_na);
39  m_ddq_max_due_to_vel.setZero(m_na);
40  m_ddq_max_due_to_vel.setZero(m_na);
41 
42  int offset = m_nv - m_na;
43  for (int i = 0; i < offset; i++) {
44  m_constraint.upperBound()(i) = 1e10;
45  m_constraint.lowerBound()(i) = -1e10;
46  }
47 }
48 
49 int TaskJointBounds::dim() const { return m_nv; }
50 
52  return m_a_lb;
53 }
54 
56  return m_a_ub;
57 }
58 
60 
62 
64  PINOCCHIO_CHECK_INPUT_ARGUMENT(dt > 0.0, "dt needs to be positive");
65  m_dt = dt;
66 }
67 
69  ConstRefVector upper) {
71  lower.size() == m_na,
72  "The size of the lower velocity bounds vector needs to equal " +
73  std::to_string(m_na));
75  upper.size() == m_na,
76  "The size of the upper velocity bounds vector needs to equal " +
77  std::to_string(m_na));
78  m_v_lb = lower;
79  m_v_ub = upper;
80 }
81 
83  ConstRefVector upper) {
85  lower.size() == m_na,
86  "The size of the lower acceleration bounds vector needs to equal " +
87  std::to_string(m_na));
89  upper.size() == m_na,
90  "The size of the upper acceleration bounds vector needs to equal " +
91  std::to_string(m_na));
92  m_a_lb = lower;
93  m_a_ub = upper;
94 }
95 
97  return m_constraint;
98 }
99 
101 
103  ConstRefVector v, Data&) {
104  // compute min/max joint acc imposed by velocity limits
105  m_ddq_max_due_to_vel = (m_v_ub - v.tail(m_na)) / m_dt;
106  m_ddq_min_due_to_vel = (m_v_lb - v.tail(m_na)) / m_dt;
107 
108  // take most conservative limit between vel and acc
109  int offset = m_nv - m_na;
110  for (int i = 0; i < m_na; i++) {
111  // TODO: use mask here
112  m_constraint.upperBound()(offset + i) =
113  std::min(m_ddq_max_due_to_vel(i), m_a_ub(i));
114  m_constraint.lowerBound()(offset + i) =
115  std::max(m_ddq_min_due_to_vel(i), m_a_lb(i));
116  }
117  return m_constraint;
118 }
119 
120 } // namespace tasks
121 } // namespace tsid
TaskJointBounds(const std::string &name, RobotWrapper &robot, double dt)
void setVelocityBounds(ConstRefVector lower, ConstRefVector upper)
int i
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: math/fwd.hpp:35
const ConstraintBase & getConstraint() const
const Vector & getAccelerationUpperBounds() const
void setAccelerationBounds(ConstRefVector lower, ConstRefVector upper)
virtual void setMask(math::ConstRefVector mask)
math::ConstRefVector ConstRefVector
Definition: task-base.hpp:39
int nv
Definition: ex_4_conf.py:25
const ConstraintBase & compute(const double t, ConstRefVector q, ConstRefVector v, Data &data)
Wrapper for a robot based on pinocchio.
const Vector & getAccelerationLowerBounds() const
int dim() const
Return the dimension of the task. should be overloaded in the child class.
#define PINOCCHIO_CHECK_INPUT_ARGUMENT(...)


tsid
Author(s): Andrea Del Prete, Justin Carpentier
autogenerated on Sun Jul 2 2023 02:21:51