tsid  1.8.0
Efficient Task Space Inverse Dynamics for Multi-body Systems based on Pinocchio
trajectory-base.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2018 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 #ifndef __tsid_python_traj_sample_hpp__
19 #define __tsid_python_traj_sample_hpp__
20 
22 
23 #include <tsid/math/utils.hpp>
25 
26 #include <pinocchio/bindings/python/utils/deprecation.hpp>
27 #include <assert.h>
28 namespace tsid {
29 namespace python {
30 namespace bp = boost::python;
32 
33 template <typename TrajSample>
35  : public boost::python::def_visitor<
36  TrajectorySamplePythonVisitor<TrajSample> > {
37  template <class PyClass>
38 
39  void visit(PyClass& cl) const {
40  cl.def(bp::init<unsigned int>((bp::arg("size")),
41  "Default Constructor with size"))
42  .def(bp::init<unsigned int, unsigned int>(
43  (bp::arg("value_size"), bp::arg("derivative_size")),
44  "Default Constructor with value and derivative size"))
45 
46  .def("resize", &TrajectorySamplePythonVisitor::resize, bp::arg("size"))
48  bp::args("value_size", "derivative_size"))
49 
52  .def("second_derivative",
54 
58  .def("second_derivative",
60 
61  // Deprecated methods:
63  pinocchio::python::deprecated_function<>(
64  "This method is now deprecated. Please use .value"))
66  pinocchio::python::deprecated_function<>(
67  "This method is now deprecated. Please use .derivative"))
68  .def(
70  pinocchio::python::deprecated_function<>(
71  "This method is now deprecated. Please use .second_derivative"))
72 
74  pinocchio::python::deprecated_function<>(
75  "This method is now deprecated. Please use .value"))
77  pinocchio::python::deprecated_function<>(
78  "This method is now deprecated. Please use .value"))
80  pinocchio::python::deprecated_function<>(
81  "This method is now deprecated. Please use .derivative"))
83  pinocchio::python::deprecated_function<>(
84  "This method is now deprecated. Please use "
85  ".second_derivative"));
86  }
87 
88  static void setvalue_vec(TrajSample& self, const Eigen::VectorXd value) {
89  assert(self.getValue().size() == value.size());
90  self.setValue(value);
91  }
92  static void setvalue_se3(TrajSample& self, const pinocchio::SE3& value) {
93  assert(self.getValue().size() == 12);
96  tsid::math::SE3ToVector(value, self.pos);
98  }
99  static void setderivative(TrajSample& self,
100  const Eigen::VectorXd derivative) {
101  assert(self.getDerivative().size() == derivative.size());
102  self.setDerivative(derivative);
103  }
104  static void setsecond_derivative(TrajSample& self,
105  const Eigen::VectorXd second_derivative) {
106  assert(self.getSecondDerivative().size() == second_derivative.size());
107  self.setSecondDerivative(second_derivative);
108  }
109  static void resize(TrajSample& self, const unsigned int& size) {
110  self.resize(size, size);
111  }
112  static void resize2(TrajSample& self, const unsigned int& value_size,
113  const unsigned int& derivative_size) {
114  self.resize(value_size, derivative_size);
115  }
116  static Eigen::VectorXd value(const TrajSample& self) {
117  return self.getValue();
118  }
119  static Eigen::VectorXd derivative(const TrajSample& self) {
120  return self.getDerivative();
121  }
122  static Eigen::VectorXd second_derivative(const TrajSample& self) {
123  return self.getSecondDerivative();
124  }
125 
126  static void expose(const std::string& class_name) {
127  std::string doc = "Trajectory Sample info.";
128  bp::class_<TrajSample>(class_name.c_str(), doc.c_str(), bp::no_init)
130  }
131 };
132 } // namespace python
133 } // namespace tsid
134 
135 #endif // ifndef __tsid_python_traj_euclidian_hpp__
#define TSID_DISABLE_WARNING_PUSH
Definition: macros.hpp:27
#define TSID_DISABLE_WARNING_DEPRECATED
Definition: macros.hpp:29
#define TSID_DISABLE_WARNING_POP
Definition: macros.hpp:28
void SE3ToVector(const pinocchio::SE3 &M, RefVector vec)
Definition: utils.cpp:30
pinocchio::SE3 SE3
Definition: trajectory-base.hpp:31
Definition: constraint-bound.hpp:25
Definition: trajectory-base.hpp:36
static void expose(const std::string &class_name)
Definition: trajectory-base.hpp:126
static Eigen::VectorXd value(const TrajSample &self)
Definition: trajectory-base.hpp:116
static void resize2(TrajSample &self, const unsigned int &value_size, const unsigned int &derivative_size)
Definition: trajectory-base.hpp:112
static void setderivative(TrajSample &self, const Eigen::VectorXd derivative)
Definition: trajectory-base.hpp:99
static Eigen::VectorXd derivative(const TrajSample &self)
Definition: trajectory-base.hpp:119
static void resize(TrajSample &self, const unsigned int &size)
Definition: trajectory-base.hpp:109
static void setvalue_se3(TrajSample &self, const pinocchio::SE3 &value)
Definition: trajectory-base.hpp:92
void visit(PyClass &cl) const
Definition: trajectory-base.hpp:39
static void setvalue_vec(TrajSample &self, const Eigen::VectorXd value)
Definition: trajectory-base.hpp:88
static void setsecond_derivative(TrajSample &self, const Eigen::VectorXd second_derivative)
Definition: trajectory-base.hpp:104
static Eigen::VectorXd second_derivative(const TrajSample &self)
Definition: trajectory-base.hpp:122