src/tasks/task-actuation-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 
29  : TaskActuation(name, robot), m_constraint(name, robot.na(), robot.na()) {
30  Vector m = Vector::Ones(robot.na());
31  mask(m);
32 }
33 
34 const Vector& TaskActuationBounds::mask() const { return m_mask; }
35 
38  m.size() == m_robot.na(),
39  "The size of the mask needs to equal " + std::to_string(m_robot.na()));
40  m_mask = m;
41  const Vector::Index dim = static_cast<Vector::Index>(m.sum());
42  Matrix S = Matrix::Zero(dim, m_robot.na());
43  m_activeAxes.resize(dim);
44  unsigned int j = 0;
45  for (unsigned int i = 0; i < m.size(); i++)
46  if (m(i) != 0.0) {
48  m(i) == 1.0, "The mask entries need to equal either 0.0 or 1.0");
49  S(j, i) = 1.0;
50  m_activeAxes(j) = i;
51  j++;
52  }
53  m_constraint.resize((unsigned int)dim, m_robot.na());
55 }
56 
57 int TaskActuationBounds::dim() const { return (int)m_mask.sum(); }
58 
60  return m_constraint.lowerBound();
61 }
62 
64  return m_constraint.upperBound();
65 }
66 
68  ConstRefVector upper) {
70  lower.size() == dim(),
71  "The size of the lower joint bounds vector needs to equal " +
72  std::to_string(dim()));
74  upper.size() == dim(),
75  "The size of the upper joint bounds vector needs to equal " +
76  std::to_string(dim()));
79 }
80 
82  return m_constraint;
83 }
84 
86  ConstRefVector, Data&) {
87  return m_constraint;
88 }
89 
90 } // namespace tasks
91 } // namespace tsid
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
Definition: math/fwd.hpp:36
int i
RobotWrapper & m_robot
Reference on the robot model.
Definition: task-base.hpp:64
TaskActuationBounds(const std::string &name, RobotWrapper &robot)
virtual bool setMatrix(ConstRefMatrix A)
int dim() const
Return the dimension of the task. should be overloaded in the child class.
void setBounds(ConstRefVector lower, ConstRefVector upper)
math::ConstRefVector ConstRefVector
Definition: task-base.hpp:39
void resize(const unsigned int r, const unsigned int c)
const ConstraintBase & compute(const double t, ConstRefVector q, ConstRefVector v, Data &data)
Wrapper for a robot based on pinocchio.
std::size_t Index
#define PINOCCHIO_CHECK_INPUT_ARGUMENT(...)


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