GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/tsid/bindings/python/trajectories/trajectory-euclidian.hpp Lines: 23 25 92.0 %
Date: 2024-02-02 08:47:34 Branches: 19 40 47.5 %

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_euclidian_hpp__
19
#define __tsid_python_traj_euclidian_hpp__
20
21
#include "tsid/bindings/python/fwd.hpp"
22
23
#include "tsid/trajectories/trajectory-euclidian.hpp"
24
namespace tsid {
25
namespace python {
26
namespace bp = boost::python;
27
28
template <typename Traj>
29
struct TrajectoryEuclidianConstantPythonVisitor
30
    : public boost::python::def_visitor<
31
          TrajectoryEuclidianConstantPythonVisitor<Traj> > {
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, Eigen::VectorXd>(
38
            (bp::arg("name"), bp::arg("reference")),
39
            "Default Constructor with name and ref_vec"))
40
41


14
        .add_property("size", &Traj::size)
42
14
        .def("setReference",
43
             &TrajectoryEuclidianConstantPythonVisitor::setReference,
44
             bp::arg("ref_vec"))
45

14
        .def("computeNext",
46
             &TrajectoryEuclidianConstantPythonVisitor::computeNext)
47
7
        .def("getLastSample",
48
             &TrajectoryEuclidianConstantPythonVisitor::getLastSample,
49
             bp::arg("sample"))
50

14
        .def("has_trajectory_ended",
51
             &TrajectoryEuclidianConstantPythonVisitor::has_trajectory_ended)
52

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

7
    bp::class_<Traj>(class_name.c_str(), doc.c_str(), bp::no_init)
75
        .def(TrajectoryEuclidianConstantPythonVisitor<Traj>());
76
7
  }
77
};
78
}  // namespace python
79
}  // namespace tsid
80
81
#endif  // ifndef __tsid_python_traj_euclidian_hpp__