1 /*
2  * Copyright (c) 2011-2021, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  *   https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  *   Redistribution and use in source and binary forms, with or
10  *   without modification, are permitted provided that the following
11  *   conditions are met:
12  *   * Redistributions of source code must retain the above copyright
13  *     notice, this list of conditions and the following disclaimer.
14  *   * Redistributions in binary form must reproduce the above
15  *     copyright notice, this list of conditions and the following
16  *     disclaimer in the documentation and/or other materials provided
17  *     with the distribution.
18  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  *   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  *   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  *   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  *   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  *   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  *   AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  *   ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  *   POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #include <dart/dart.hpp>
34 #include <pybind11/pybind11.h>
35 #include "eigen_geometry_pybind.h"
36 #include "eigen_pybind.h"
37 
38 namespace py = pybind11;
39 
40 namespace dart {
41 namespace python {
42 
Entity(py::module & m)43 void Entity(py::module& m)
44 {
45   ::py::class_<
46       dart::dynamics::Entity,
47       dart::common::Subject,
48       std::shared_ptr<dart::dynamics::Entity>>(m, "Entity")
49       .def(
50           "setName",
51           +[](dart::dynamics::Entity* self, const std::string& name)
52               -> const std::string& { return self->setName(name); },
53           ::py::return_value_policy::reference_internal,
54           ::py::arg("name"))
55       .def(
56           "getName",
57           +[](const dart::dynamics::Entity* self) -> const std::string& {
58             return self->getName();
59           },
60           ::py::return_value_policy::reference_internal)
61       .def(
62           "getParentFrame",
63           +[](const dart::dynamics::Entity* self)
64               -> const dart::dynamics::Frame* {
65             return self->getParentFrame();
66           },
67           ::py::return_value_policy::reference_internal)
68       .def(
69           "descendsFrom",
70           +[](const dart::dynamics::Entity* self,
71               const dart::dynamics::Frame* someFrame) -> bool {
72             return self->descendsFrom(someFrame);
73           },
74           ::py::arg("someFrame"))
75       .def(
76           "isFrame",
77           +[](const dart::dynamics::Entity* self) -> bool {
78             return self->isFrame();
79           })
80       .def(
81           "isQuiet",
82           +[](const dart::dynamics::Entity* self) -> bool {
83             return self->isQuiet();
84           })
85       .def(
86           "dirtyTransform",
87           +[](dart::dynamics::Entity* self) { self->dirtyTransform(); })
88       .def(
89           "needsTransformUpdate",
90           +[](const dart::dynamics::Entity* self) -> bool {
91             return self->needsTransformUpdate();
92           })
93       .def(
94           "dirtyVelocity",
95           +[](dart::dynamics::Entity* self) { self->dirtyVelocity(); })
96       .def(
97           "needsVelocityUpdate",
98           +[](const dart::dynamics::Entity* self) -> bool {
99             return self->needsVelocityUpdate();
100           })
101       .def(
102           "dirtyAcceleration",
103           +[](dart::dynamics::Entity* self) { self->dirtyAcceleration(); })
104       .def(
105           "needsAccelerationUpdate",
106           +[](const dart::dynamics::Entity* self) -> bool {
107             return self->needsAccelerationUpdate();
108           });
109 
110   ::py::class_<
111       dart::dynamics::Detachable,
112       dart::dynamics::Entity,
113       std::shared_ptr<dart::dynamics::Detachable>>(m, "Detachable")
114       .def(
115           "setParentFrame",
116           +[](dart::dynamics::Detachable* self,
117               dart::dynamics::Frame* _newParentFrame) {
118             self->setParentFrame(_newParentFrame);
119           },
120           ::py::arg("newParentFrame"));
121 }
122 
123 } // namespace python
124 } // namespace dart
125