GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
// |
||
2 |
// Copyright (c) 2016-2021 CNRS INRIA |
||
3 |
// |
||
4 |
|||
5 |
#ifndef __pinocchio_python_frame_hpp__ |
||
6 |
#define __pinocchio_python_frame_hpp__ |
||
7 |
|||
8 |
#include "pinocchio/multibody/fwd.hpp" |
||
9 |
#include "pinocchio/multibody/frame.hpp" |
||
10 |
#include "pinocchio/bindings/python/utils/copyable.hpp" |
||
11 |
#include "pinocchio/bindings/python/utils/printable.hpp" |
||
12 |
|||
13 |
namespace pinocchio |
||
14 |
{ |
||
15 |
namespace python |
||
16 |
{ |
||
17 |
namespace bp = boost::python; |
||
18 |
|||
19 |
struct FramePythonVisitor |
||
20 |
: public bp::def_visitor< FramePythonVisitor > |
||
21 |
{ |
||
22 |
template<class PyClass> |
||
23 |
19 |
void visit(PyClass& cl) const |
|
24 |
{ |
||
25 |
✓✗ | 19 |
cl |
26 |
.def(bp::init<>(bp::arg("self"),"Default constructor")) |
||
27 |
✓✗✓✗ |
19 |
.def(bp::init<const Frame &>(bp::args("self","other"),"Copy constructor")) |
28 |
✓✗✓✗ ✓✗ |
38 |
.def(bp::init< const std::string&,const JointIndex, const FrameIndex, const SE3&, FrameType, bp::optional<const Inertia&> > ((bp::arg("name"),bp::arg("parent_joint"), bp::args("parent_frame"), bp::arg("placement"), bp::arg("type"), bp::arg("inertia")), |
29 |
"Initialize from a given name, type, parent joint index, parent frame index and placement wrt parent joint and an spatial inertia object.")) |
||
30 |
|||
31 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
38 |
.def_readwrite("name", &Frame::name, "name of the frame") |
32 |
✓✗ | 19 |
.def_readwrite("parent", &Frame::parent, "id of the parent joint") |
33 |
✓✗ | 19 |
.def_readwrite("previousFrame", &Frame::previousFrame, "id of the previous frame") |
34 |
✓✗ | 19 |
.def_readwrite("placement", |
35 |
&Frame::placement, |
||
36 |
"placement in the parent joint local frame") |
||
37 |
✓✗ | 19 |
.def_readwrite("type", &Frame::type, "Type of the frame") |
38 |
✓✗ | 19 |
.def_readwrite("inertia", &Frame::inertia,"Inertia information attached to the frame.") |
39 |
|||
40 |
✓✗ | 19 |
.def(bp::self == bp::self) |
41 |
✓✗ | 38 |
.def(bp::self != bp::self) |
42 |
; |
||
43 |
19 |
} |
|
44 |
|||
45 |
19 |
static void expose() |
|
46 |
{ |
||
47 |
38 |
bp::enum_<FrameType>("FrameType") |
|
48 |
✓✗ | 19 |
.value("OP_FRAME",OP_FRAME) |
49 |
✓✗ | 19 |
.value("JOINT",JOINT) |
50 |
✓✗ | 19 |
.value("FIXED_JOINT",FIXED_JOINT) |
51 |
✓✗ | 19 |
.value("BODY",BODY) |
52 |
✓✗ | 19 |
.value("SENSOR",SENSOR) |
53 |
✓✗ | 19 |
.export_values() |
54 |
; |
||
55 |
|||
56 |
19 |
bp::class_<Frame>("Frame", |
|
57 |
"A Plucker coordinate frame related to a parent joint inside a kinematic tree.\n\n", |
||
58 |
bp::no_init |
||
59 |
) |
||
60 |
✓✗ | 19 |
.def(FramePythonVisitor()) |
61 |
✓✗ | 19 |
.def(CopyableVisitor<Frame>()) |
62 |
✓✗ | 19 |
.def(PrintableVisitor<Frame>()) |
63 |
✓✗ | 19 |
.def_pickle(Pickle()) |
64 |
; |
||
65 |
19 |
} |
|
66 |
|||
67 |
private: |
||
68 |
struct Pickle : bp::pickle_suite |
||
69 |
{ |
||
70 |
static bp::tuple getinitargs(const Frame &) |
||
71 |
{ |
||
72 |
return bp::make_tuple(); |
||
73 |
} |
||
74 |
|||
75 |
static bp::tuple getstate(const Frame & f) |
||
76 |
{ |
||
77 |
return bp::make_tuple(f.name, f.parent, f.previousFrame, f.placement, (int)f.type, f.inertia); |
||
78 |
} |
||
79 |
|||
80 |
static void setstate(Frame & f, bp::tuple tup) |
||
81 |
{ |
||
82 |
f.name = bp::extract<std::string>(tup[0]); |
||
83 |
f.parent = bp::extract<JointIndex>(tup[1]); |
||
84 |
f.previousFrame = bp::extract<JointIndex>(tup[2]); |
||
85 |
f.placement = bp::extract<SE3&>(tup[3]); |
||
86 |
f.type = (FrameType)(int)bp::extract<int>(tup[4]); |
||
87 |
if(bp::len(tup) > 5) |
||
88 |
f.inertia = bp::extract<Inertia&>(tup[5]); |
||
89 |
} |
||
90 |
|||
91 |
19 |
static bool getstate_manages_dict() { return true; } |
|
92 |
}; |
||
93 |
}; |
||
94 |
|||
95 |
|||
96 |
} // namespace python |
||
97 |
} // namespace pinocchio |
||
98 |
|||
99 |
#endif // ifndef __pinocchio_python_frame_hpp__ |
Generated by: GCOVR (Version 4.2) |