Directory: | ./ |
---|---|
File: | include/tsid/bindings/python/trajectories/trajectory-euclidian.hpp |
Date: | 2024-11-10 01:12:44 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 28 | 30 | 93.3% |
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 |
2/4✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
|
7 | cl.def(bp::init<std::string>((bp::arg("name")), |
36 | "Default Constructor with name")) | ||
37 |
3/6✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
|
7 | .def(bp::init<std::string, Eigen::VectorXd>( |
38 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | (bp::arg("name"), bp::arg("reference")), |
39 | "Default Constructor with name and ref_vec")) | ||
40 | |||
41 | 14 | .add_property("size", &Traj::size) | |
42 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setReference", |
43 | &TrajectoryEuclidianConstantPythonVisitor::setReference, | ||
44 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | bp::arg("ref_vec")) |
45 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def("computeNext", |
46 | &TrajectoryEuclidianConstantPythonVisitor::computeNext) | ||
47 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def("getLastSample", |
48 | &TrajectoryEuclidianConstantPythonVisitor::getLastSample, | ||
49 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | bp::arg("sample")) |
50 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def("has_trajectory_ended", |
51 | &TrajectoryEuclidianConstantPythonVisitor::has_trajectory_ended) | ||
52 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def("getSample", &TrajectoryEuclidianConstantPythonVisitor::getSample, |
53 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | 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 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::string doc = "Trajectory Euclidian Constant info."; |
74 |
1/2✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
|
7 | bp::class_<Traj>(class_name.c_str(), doc.c_str(), bp::no_init) |
75 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def(TrajectoryEuclidianConstantPythonVisitor<Traj>()); |
76 | 7 | } | |
77 | }; | ||
78 | } // namespace python | ||
79 | } // namespace tsid | ||
80 | |||
81 | #endif // ifndef __tsid_python_traj_euclidian_hpp__ | ||
82 |