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
113  std::min(m_ddq_max_due_to_vel(i), m_a_ub(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
demo_quadruped.v
v
Definition: demo_quadruped.py:80
tsid::tasks::TaskJointBounds::m_constraint
ConstraintBound m_constraint
Definition: tasks/task-joint-bounds.hpp:58
tsid::math::ConstraintBound::lowerBound
const Vector & lowerBound() const override
Definition: src/math/constraint-bound.cpp:66
tsid::tasks::TaskJointBounds::compute
const ConstraintBase & compute(const double t, ConstRefVector q, ConstRefVector v, Data &data) override
Definition: src/tasks/task-joint-bounds.cpp:102
pinocchio::DataTpl
PINOCCHIO_CHECK_INPUT_ARGUMENT
#define PINOCCHIO_CHECK_INPUT_ARGUMENT(...)
tsid::tasks::TaskJointBounds::m_a_ub
Vector m_a_ub
Definition: tasks/task-joint-bounds.hpp:56
tsid::tasks::TaskJointBounds::getAccelerationUpperBounds
const Vector & getAccelerationUpperBounds() const
Definition: src/tasks/task-joint-bounds.cpp:55
tsid::math::ConstraintBase
Abstract class representing a linear equality/inequality constraint. Equality constraints are represe...
Definition: constraint-base.hpp:35
tsid::tasks::TaskJointBounds::setTimeStep
void setTimeStep(double dt)
Definition: src/tasks/task-joint-bounds.cpp:63
i
int i
task-joint-bounds.hpp
tsid::tasks::TaskJointBounds::getAccelerationLowerBounds
const Vector & getAccelerationLowerBounds() const
Definition: src/tasks/task-joint-bounds.cpp:51
demo_quadruped.robot
robot
Definition: demo_quadruped.py:51
tsid::tasks::TaskJointBounds::TaskJointBounds
TaskJointBounds(const std::string &name, RobotWrapper &robot, double dt)
Definition: src/tasks/task-joint-bounds.cpp:27
tsid::tasks::TaskMotion::m_mask
Vector m_mask
Definition: task-motion.hpp:53
tsid::tasks::TaskJointBounds::m_a_lb
Vector m_a_lb
Definition: tasks/task-joint-bounds.hpp:56
tsid::tasks::TaskJointBounds::m_nv
int m_nv
Definition: tasks/task-joint-bounds.hpp:60
ex_4_conf.nv
int nv
Definition: ex_4_conf.py:23
tsid::tasks::TaskJointBounds::m_dt
double m_dt
Definition: tasks/task-joint-bounds.hpp:59
tsid::tasks::TaskJointBounds::setVelocityBounds
void setVelocityBounds(ConstRefVector lower, ConstRefVector upper)
Definition: src/tasks/task-joint-bounds.cpp:68
tsid::tasks::TaskJointBounds::dim
int dim() const override
Return the dimension of the task. \info should be overloaded in the child class.
Definition: src/tasks/task-joint-bounds.cpp:49
robot-wrapper.hpp
tsid::tasks::TaskJointBounds::m_na
int m_na
Definition: tasks/task-joint-bounds.hpp:60
demo_quadruped.dt
float dt
Definition: demo_quadruped.py:41
tsid::tasks::TaskJointBounds::getVelocityLowerBounds
const Vector & getVelocityLowerBounds() const
Definition: src/tasks/task-joint-bounds.cpp:59
setup.name
name
Definition: setup.in.py:179
tsid::tasks::TaskMotion
Definition: task-motion.hpp:26
tsid::math::Vector
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: math/fwd.hpp:35
tsid::tasks::TaskJointBounds::m_v_lb
Vector m_v_lb
Definition: tasks/task-joint-bounds.hpp:55
demo_quadruped.offset
offset
Definition: demo_quadruped.py:148
tsid
Definition: bindings/python/constraint/constraint-bound.cpp:21
tsid::tasks::TaskJointBounds::getVelocityUpperBounds
const Vector & getVelocityUpperBounds() const
Definition: src/tasks/task-joint-bounds.cpp:61
tsid::robots::RobotWrapper
Wrapper for a robot based on pinocchio.
Definition: robots/robot-wrapper.hpp:37
tsid::tasks::TaskJointBounds::setAccelerationBounds
void setAccelerationBounds(ConstRefVector lower, ConstRefVector upper)
Definition: src/tasks/task-joint-bounds.cpp:82
test_Tasks.na
int na
Definition: test_Tasks.py:95
tsid::tasks::TaskJointBounds::getConstraint
const ConstraintBase & getConstraint() const override
Definition: src/tasks/task-joint-bounds.cpp:96
tsid::tasks::TaskJointBounds::m_ddq_min_due_to_vel
Vector m_ddq_min_due_to_vel
Definition: tasks/task-joint-bounds.hpp:57
tsid::tasks::TaskJointBounds::m_ddq_max_due_to_vel
Vector m_ddq_max_due_to_vel
Definition: tasks/task-joint-bounds.hpp:57
tsid::tasks::TaskBase::ConstRefVector
math::ConstRefVector ConstRefVector
Definition: task-base.hpp:39
pinocchio
tsid::tasks::TaskJointBounds::setMask
virtual void setMask(math::ConstRefVector mask) override
Definition: src/tasks/task-joint-bounds.cpp:100
tsid::math::ConstraintBound::upperBound
const Vector & upperBound() const override
Definition: src/math/constraint-bound.cpp:67
tsid::tasks::TaskJointBounds::m_v_ub
Vector m_v_ub
Definition: tasks/task-joint-bounds.hpp:55


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