src
tasks
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
18
#include <
tsid/tasks/task-actuation-bounds.hpp
>
19
#include "
tsid/robots/robot-wrapper.hpp
"
20
21
namespace
tsid
{
22
namespace
tasks {
23
using namespace
math;
24
using namespace
trajectories;
25
using namespace
pinocchio
;
26
27
TaskActuationBounds::TaskActuationBounds
(
const
std::string&
name
,
28
RobotWrapper
&
robot
)
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
36
void
TaskActuationBounds::mask
(
const
Vector
&
m
) {
37
PINOCCHIO_CHECK_INPUT_ARGUMENT
(
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) {
47
PINOCCHIO_CHECK_INPUT_ARGUMENT
(
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
());
54
m_constraint
.
setMatrix
(
S
);
55
}
56
57
int
TaskActuationBounds::dim
()
const
{
return
(
int
)
m_mask
.sum(); }
58
59
const
Vector
&
TaskActuationBounds::getLowerBounds
()
const
{
60
return
m_constraint
.
lowerBound
();
61
}
62
63
const
Vector
&
TaskActuationBounds::getUpperBounds
()
const
{
64
return
m_constraint
.
upperBound
();
65
}
66
67
void
TaskActuationBounds::setBounds
(
ConstRefVector
lower,
68
ConstRefVector
upper) {
69
PINOCCHIO_CHECK_INPUT_ARGUMENT
(
70
lower.size() ==
dim
(),
71
"The size of the lower joint bounds vector needs to equal "
+
72
std::to_string(
dim
()));
73
PINOCCHIO_CHECK_INPUT_ARGUMENT
(
74
upper.size() ==
dim
(),
75
"The size of the upper joint bounds vector needs to equal "
+
76
std::to_string(
dim
()));
77
m_constraint
.
setLowerBound
(lower);
78
m_constraint
.
setUpperBound
(upper);
79
}
80
81
const
ConstraintBase
&
TaskActuationBounds::getConstraint
()
const
{
82
return
m_constraint
;
83
}
84
85
const
ConstraintBase
&
TaskActuationBounds::compute
(
const
double
,
ConstRefVector
,
86
ConstRefVector
,
Data
&) {
87
return
m_constraint
;
88
}
89
90
}
// namespace tasks
91
}
// namespace tsid
pinocchio::DataTpl
PINOCCHIO_CHECK_INPUT_ARGUMENT
#define PINOCCHIO_CHECK_INPUT_ARGUMENT(...)
tsid::tasks::TaskActuationBounds::dim
int dim() const override
Return the dimension of the task. \info should be overloaded in the child class.
Definition:
src/tasks/task-actuation-bounds.cpp:57
tsid::math::ConstraintBase
Abstract class representing a linear equality/inequality constraint. Equality constraints are represe...
Definition:
constraint-base.hpp:35
i
int i
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
tsid::tasks::TaskActuationBounds::m_activeAxes
VectorXi m_activeAxes
Definition:
tasks/task-actuation-bounds.hpp:57
tsid::tasks::TaskActuationBounds::m_mask
Vector m_mask
Definition:
tasks/task-actuation-bounds.hpp:56
tsid::tasks::TaskActuationBounds::getUpperBounds
const Vector & getUpperBounds() const
Definition:
src/tasks/task-actuation-bounds.cpp:63
Index
PINOCCHIO_COMPILER_DIAGNOSTIC_POP typedef std::size_t Index
S
S
tsid::tasks::TaskActuationBounds::Vector
math::Vector Vector
Definition:
tasks/task-actuation-bounds.hpp:34
tsid::math::ConstraintInequality::setUpperBound
bool setUpperBound(ConstRefVector ub) override
Definition:
src/math/constraint-inequality.cpp:84
tsid::math::ConstraintInequality::setLowerBound
bool setLowerBound(ConstRefVector lb) override
Definition:
src/math/constraint-inequality.cpp:80
tsid::tasks::TaskActuationBounds::getLowerBounds
const Vector & getLowerBounds() const
Definition:
src/tasks/task-actuation-bounds.cpp:59
robot-wrapper.hpp
tsid::math::ConstraintInequality::resize
void resize(unsigned int r, unsigned int c) override
Definition:
src/math/constraint-inequality.cpp:52
tsid::tasks::TaskActuationBounds::getConstraint
const ConstraintBase & getConstraint() const override
Definition:
src/tasks/task-actuation-bounds.cpp:81
tsid::math::Matrix
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
Definition:
math/fwd.hpp:36
setup.name
name
Definition:
setup.in.py:179
tsid::tasks::TaskActuationBounds::compute
const ConstraintBase & compute(double t, ConstRefVector q, ConstRefVector v, Data &data) override
Definition:
src/tasks/task-actuation-bounds.cpp:85
tsid::tasks::TaskActuationBounds::m_constraint
ConstraintInequality m_constraint
Definition:
tasks/task-actuation-bounds.hpp:58
task-actuation-bounds.hpp
tsid::tasks::TaskActuationBounds::TaskActuationBounds
TaskActuationBounds(const std::string &name, RobotWrapper &robot)
Definition:
src/tasks/task-actuation-bounds.cpp:27
tsid
Definition:
bindings/python/constraint/constraint-bound.cpp:21
test_Constraint.m
int m
Definition:
test_Constraint.py:41
tsid::tasks::TaskActuation
Definition:
task-actuation.hpp:25
tsid::robots::RobotWrapper
Wrapper for a robot based on pinocchio.
Definition:
robots/robot-wrapper.hpp:37
test_Tasks.na
int na
Definition:
test_Tasks.py:95
tsid::math::ConstraintInequality::upperBound
const Vector & upperBound() const override
Definition:
src/math/constraint-inequality.cpp:67
tsid::tasks::TaskBase::m_robot
RobotWrapper & m_robot
Reference on the robot model.
Definition:
task-base.hpp:64
tsid::tasks::TaskActuationBounds::setBounds
void setBounds(ConstRefVector lower, ConstRefVector upper)
Definition:
src/tasks/task-actuation-bounds.cpp:67
tsid::tasks::TaskActuationBounds::mask
const Vector & mask() const
Definition:
src/tasks/task-actuation-bounds.cpp:34
tsid::tasks::TaskBase::ConstRefVector
math::ConstRefVector ConstRefVector
Definition:
task-base.hpp:39
tsid::robots::RobotWrapper::na
virtual int na() const
Definition:
src/robots/robot-wrapper.cpp:98
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 Sat May 3 2025 02:48:17