tsid  1.8.0
Efficient Task Space Inverse Dynamics for Multi-body Systems based on Pinocchio
task-joint-posVelAcc-bounds.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2022 INRIA
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 #ifndef __tsid_python_task_joint_posVelAcc_bounds_hpp__
19 #define __tsid_python_task_joint_posVelAcc_bounds_hpp__
20 
22 
27 
28 namespace tsid {
29 namespace python {
30 namespace bp = boost::python;
32 
33 template <typename Task>
35  : public boost::python::def_visitor<
36  TaskJointPosVelAccBoundsPythonVisitor<Task>> {
37  template <class PyClass>
38 
39  void visit(PyClass& cl) const {
40  cl.def(bp::init<std::string, robots::RobotWrapper&, double,
41  bp::optional<bool>>(
42  (bp::arg("name"), bp::arg("robot"), bp::arg("Time step"),
43  bp::arg("verbose")),
44  "Default Constructor"))
45  .add_property("dim", &Task::dim, "return dimension size")
47  bp::args("dt"))
48  .def("setPositionBounds",
50  bp::args("lower", "upper"))
51  .def("setVelocityBounds",
53  bp::args("upper"))
54  .def("setAccelerationBounds",
56  bp::args("upper"))
58  bp::args("t", "q", "v", "data"))
59  .def("getConstraint",
62  bp::args("verbose"))
63  .def("setImposeBounds",
65  bp::args("impose_position_bounds", "impose_velocity_bounds",
66  "impose_viability_bounds", "impose_acceleration_bounds"))
67  .def("isStateViable",
69  (bp::arg("q"), bp::arg("dq"), bp::arg("verbose") = true))
70  .def("computeAccLimitsFromPosLimits",
73  (bp::arg("q"), bp::arg("dq"), bp::arg("verbose") = true))
74  .def("computeAccLimitsFromViability",
77  (bp::arg("q"), bp::arg("dq"), bp::arg("verbose") = true))
78  .def("computeAccLimits",
80  (bp::arg("q"), bp::arg("dq"), bp::arg("verbose") = true))
82  bp::args("mask"))
83  .add_property(
84  "getAccelerationBounds",
85  bp::make_function(
87  bp::return_value_policy<bp::copy_const_reference>()))
88  .add_property(
89  "getVelocityBounds",
90  bp::make_function(
92  bp::return_value_policy<bp::copy_const_reference>()))
93  .add_property(
94  "getPositionLowerBounds",
95  bp::make_function(
97  bp::return_value_policy<bp::copy_const_reference>()))
98  .add_property(
99  "getPositionUpperBounds",
100  bp::make_function(
102  bp::return_value_policy<bp::copy_const_reference>()))
103  .add_property("name", &TaskJointPosVelAccBoundsPythonVisitor::name);
104  }
105  static std::string name(Task& self) {
106  std::string name = self.name();
107  return name;
108  }
109  static math::ConstraintBound compute(Task& self, const double t,
110  const Eigen::VectorXd& q,
111  const Eigen::VectorXd& v,
112  pinocchio::Data& data) {
113  self.compute(t, q, v, data);
115  self.getConstraint().lowerBound(),
116  self.getConstraint().upperBound());
117  return cons;
118  }
119  static math::ConstraintBound getConstraint(const Task& self) {
121  self.getConstraint().lowerBound(),
122  self.getConstraint().upperBound());
123  return cons;
124  }
125  static const Eigen::VectorXd& getAccelerationBounds(const Task& self) {
126  return self.getAccelerationBounds();
127  }
128  static const Eigen::VectorXd& getVelocityBounds(const Task& self) {
129  return self.getVelocityBounds();
130  }
131  static const Eigen::VectorXd& getPositionLowerBounds(const Task& self) {
132  return self.getPositionLowerBounds();
133  }
134  static const Eigen::VectorXd& getPositionUpperBounds(const Task& self) {
135  return self.getPositionUpperBounds();
136  }
137  static void setTimeStep(Task& self, const double dt) {
138  return self.setTimeStep(dt);
139  }
140  static void setPositionBounds(Task& self, const Eigen::VectorXd lower,
141  const Eigen::VectorXd upper) {
142  return self.setPositionBounds(lower, upper);
143  }
144  static void setVelocityBounds(Task& self, const Eigen::VectorXd upper) {
145  return self.setVelocityBounds(upper);
146  }
147  static void setAccelerationBounds(Task& self, const Eigen::VectorXd upper) {
148  return self.setAccelerationBounds(upper);
149  }
150  static void expose(const std::string& class_name) {
151  std::string doc = "Task info.";
152  bp::class_<Task>(class_name.c_str(), doc.c_str(), bp::no_init)
154  }
155  static void setVerbose(Task& self, bool verbose) {
156  return self.setVerbose(verbose);
157  }
158  static void setImposeBounds(Task& self, bool impose_position_bounds,
159  bool impose_velocity_bounds,
160  bool impose_viability_bounds,
161  bool impose_acceleration_bounds) {
162  return self.setImposeBounds(impose_position_bounds, impose_velocity_bounds,
163  impose_viability_bounds,
164  impose_acceleration_bounds);
165  }
166 
167  static void isStateViable(Task& self, ConstRefVector q, ConstRefVector dq,
168  bool verbose = true) {
169  return self.isStateViable(q, dq, verbose);
170  }
172  ConstRefVector dq,
173  bool verbose = true) {
174  return self.computeAccLimitsFromPosLimits(q, dq, verbose);
175  }
177  ConstRefVector dq,
178  bool verbose = true) {
179  return self.computeAccLimitsFromViability(q, dq, verbose);
180  }
181  static void computeAccLimits(Task& self, ConstRefVector q, ConstRefVector dq,
182  bool verbose = true) {
183  return self.computeAccLimits(q, dq, verbose);
184  }
185  static void setMask(Task& self, math::ConstRefVector mask) {
186  return self.setMask(mask);
187  }
188 };
189 } // namespace python
190 } // namespace tsid
191 
192 #endif // ifndef __tsid_python_task_actuation_bounds_hpp__
Definition: constraint-bound.hpp:26
Wrapper for a robot based on pinocchio.
Definition: robot-wrapper.hpp:37
pinocchio::Data Data
Definition: inverse-dynamics-formulation-acc-force.cpp:30
const Eigen::Ref< const Vector > ConstRefVector
Definition: fwd.hpp:48
math::ConstRefVector ConstRefVector
Definition: task-joint-posVelAcc-bounds.hpp:31
Definition: constraint-bound.hpp:25
Definition: task-joint-posVelAcc-bounds.hpp:36
static math::ConstraintBound compute(Task &self, const double t, const Eigen::VectorXd &q, const Eigen::VectorXd &v, pinocchio::Data &data)
Definition: task-joint-posVelAcc-bounds.hpp:109
static void computeAccLimitsFromViability(Task &self, ConstRefVector q, ConstRefVector dq, bool verbose=true)
Definition: task-joint-posVelAcc-bounds.hpp:176
static const Eigen::VectorXd & getPositionUpperBounds(const Task &self)
Definition: task-joint-posVelAcc-bounds.hpp:134
static math::ConstraintBound getConstraint(const Task &self)
Definition: task-joint-posVelAcc-bounds.hpp:119
static void setImposeBounds(Task &self, bool impose_position_bounds, bool impose_velocity_bounds, bool impose_viability_bounds, bool impose_acceleration_bounds)
Definition: task-joint-posVelAcc-bounds.hpp:158
static const Eigen::VectorXd & getPositionLowerBounds(const Task &self)
Definition: task-joint-posVelAcc-bounds.hpp:131
static void expose(const std::string &class_name)
Definition: task-joint-posVelAcc-bounds.hpp:150
static void setVerbose(Task &self, bool verbose)
Definition: task-joint-posVelAcc-bounds.hpp:155
static void isStateViable(Task &self, ConstRefVector q, ConstRefVector dq, bool verbose=true)
Definition: task-joint-posVelAcc-bounds.hpp:167
static std::string name(Task &self)
Definition: task-joint-posVelAcc-bounds.hpp:105
static void computeAccLimitsFromPosLimits(Task &self, ConstRefVector q, ConstRefVector dq, bool verbose=true)
Definition: task-joint-posVelAcc-bounds.hpp:171
static void setAccelerationBounds(Task &self, const Eigen::VectorXd upper)
Definition: task-joint-posVelAcc-bounds.hpp:147
static const Eigen::VectorXd & getAccelerationBounds(const Task &self)
Definition: task-joint-posVelAcc-bounds.hpp:125
static void setVelocityBounds(Task &self, const Eigen::VectorXd upper)
Definition: task-joint-posVelAcc-bounds.hpp:144
static void setMask(Task &self, math::ConstRefVector mask)
Definition: task-joint-posVelAcc-bounds.hpp:185
static void setPositionBounds(Task &self, const Eigen::VectorXd lower, const Eigen::VectorXd upper)
Definition: task-joint-posVelAcc-bounds.hpp:140
static const Eigen::VectorXd & getVelocityBounds(const Task &self)
Definition: task-joint-posVelAcc-bounds.hpp:128
void visit(PyClass &cl) const
Definition: task-joint-posVelAcc-bounds.hpp:39
static void setTimeStep(Task &self, const double dt)
Definition: task-joint-posVelAcc-bounds.hpp:137
static void computeAccLimits(Task &self, ConstRefVector q, ConstRefVector dq, bool verbose=true)
Definition: task-joint-posVelAcc-bounds.hpp:181