GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/tsid/bindings/python/trajectories/trajectory-se3.hpp Lines: 26 26 100.0 %
Date: 2024-02-02 08:47:34 Branches: 19 38 50.0 %

Line Branch Exec Source
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_se3_hpp__
19
#define __tsid_python_traj_se3_hpp__
20
21
#include "tsid/bindings/python/fwd.hpp"
22
23
#include "tsid/trajectories/trajectory-se3.hpp"
24
namespace tsid {
25
namespace python {
26
namespace bp = boost::python;
27
28
template <typename TrajSE3>
29
struct TrajectorySE3ConstantPythonVisitor
30
    : public boost::python::def_visitor<
31
          TrajectorySE3ConstantPythonVisitor<TrajSE3> > {
32
  template <class PyClass>
33
34
7
  void visit(PyClass& cl) const {
35
7
    cl.def(bp::init<std::string>((bp::arg("name")),
36
                                 "Default Constructor with name"))
37

7
        .def(bp::init<std::string, pinocchio::SE3>(
38
            (bp::arg("name"), bp::arg("reference")),
39
            "Default Constructor with name and ref_vec"))
40
41


14
        .add_property("size", &TrajSE3::size)
42
14
        .def("setReference", &TrajectorySE3ConstantPythonVisitor::setReference,
43
             bp::arg("M_ref"))
44

14
        .def("computeNext", &TrajectorySE3ConstantPythonVisitor::computeNext)
45
7
        .def("getLastSample",
46
             &TrajectorySE3ConstantPythonVisitor::getLastSample,
47
             bp::arg("sample"))
48

14
        .def("has_trajectory_ended",
49
             &TrajectorySE3ConstantPythonVisitor::has_trajectory_ended)
50

7
        .def("getSample", &TrajectorySE3ConstantPythonVisitor::getSample,
51
             bp::arg("time"));
52
7
  }
53
1
  static void setReference(TrajSE3& self, const pinocchio::SE3& ref) {
54
1
    self.setReference(ref);
55
1
  }
56
1001
  static trajectories::TrajectorySample computeNext(TrajSE3& self) {
57
1001
    return self.computeNext();
58
  }
59
1
  static void getLastSample(const TrajSE3& self,
60
                            trajectories::TrajectorySample& sample) {
61
1
    self.getLastSample(sample);
62
1
  }
63
1
  static bool has_trajectory_ended(const TrajSE3& self) {
64
1
    return self.has_trajectory_ended();
65
  }
66
1
  static trajectories::TrajectorySample getSample(TrajSE3& self, double time) {
67
1
    return self.operator()(time);
68
  }
69
70
7
  static void expose(const std::string& class_name) {
71
7
    std::string doc = "Trajectory SE3 Constant info.";
72

7
    bp::class_<TrajSE3>(class_name.c_str(), doc.c_str(), bp::no_init)
73
        .def(TrajectorySE3ConstantPythonVisitor<TrajSE3>());
74
7
  }
75
};
76
}  // namespace python
77
}  // namespace tsid
78
79
#endif  // ifndef __tsid_python_traj_se3_hpp__