Debian Codegraph @

python/dartpy/dynamics/RevoluteJoint.cpp

raw
1 /*
2 * Copyright (c) 2011-2022, 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 <eigen_geometry_pybind.h>
35 #include <pybind11/eigen.h>
36 #include <pybind11/pybind11.h>
37
38 #include "Joint.hpp"
39
40 namespace py = pybind11;
41
42 namespace dart {
43 namespace python {
44
45 void RevoluteJoint(py::module& m)
46 {
47 ::py::class_<dart::dynamics::RevoluteJoint::UniqueProperties>(
48 m, "RevoluteJointUniqueProperties")
49 .def(::py::init<>())
50 .def(::py::init<const Eigen::Vector3d&>(), ::py::arg("axis"));
51
52 ::py::class_<
53 dart::dynamics::RevoluteJoint::Properties,
54 dart::dynamics::GenericJoint<math::R1Space>::Properties,
55 dart::dynamics::RevoluteJoint::UniqueProperties>(
56 m, "RevoluteJointProperties")
57 .def(::py::init<>())
58 .def(
59 ::py::init<const dart::dynamics::GenericJoint<
60 dart::math::R1Space>::Properties&>(),
61 ::py::arg("genericJointProperties"))
62 .def(
63 ::py::init<
64 const dart::dynamics::GenericJoint<
65 dart::math::R1Space>::Properties&,
66 const dart::dynamics::RevoluteJoint::UniqueProperties&>(),
67 ::py::arg("genericJointProperties"),
68 ::py::arg("uniqueProperties"))
69 .def_readwrite(
70 "mAxis",
71 &dart::dynamics::detail::RevoluteJointUniqueProperties::mAxis);
72
73 DARTPY_DEFINE_JOINT_COMMON_BASE(RevoluteJoint, R1Space)
74
75 ::py::class_<
76 dart::dynamics::RevoluteJoint,
77 dart::dynamics::detail::RevoluteJointBase,
78 std::shared_ptr<dart::dynamics::RevoluteJoint>>(m, "RevoluteJoint")
79 .def(
80 "hasRevoluteJointAspect",
81 +[](const dart::dynamics::RevoluteJoint* self) -> bool {
82 return self->hasRevoluteJointAspect();
83 })
84 .def(
85 "setRevoluteJointAspect",
86 +[](dart::dynamics::RevoluteJoint* self,
87 const dart::common::EmbedPropertiesOnTopOf<
88 dart::dynamics::RevoluteJoint,
89 dart::dynamics::detail::RevoluteJointUniqueProperties,
90 dart::dynamics::GenericJoint<
91 dart::math::RealVectorSpace<1>>>::Aspect* aspect) {
92 self->setRevoluteJointAspect(aspect);
93 },
94 ::py::arg("aspect"))
95 .def(
96 "removeRevoluteJointAspect",
97 +[](dart::dynamics::RevoluteJoint* self) {
98 self->removeRevoluteJointAspect();
99 })
100 .def(
101 "releaseRevoluteJointAspect",
102 +[](dart::dynamics::RevoluteJoint* self)
103 -> std::unique_ptr<dart::common::EmbedPropertiesOnTopOf<
104 dart::dynamics::RevoluteJoint,
105 dart::dynamics::detail::RevoluteJointUniqueProperties,
106 dart::dynamics::GenericJoint<
107 dart::math::RealVectorSpace<1>>>::Aspect> {
108 return self->releaseRevoluteJointAspect();
109 })
110 .def(
111 "setProperties",
112 +[](dart::dynamics::RevoluteJoint* self,
113 const dart::dynamics::RevoluteJoint::Properties& _properties) {
114 self->setProperties(_properties);
115 },
116 ::py::arg("properties"))
117 .def(
118 "setProperties",
119 +[](dart::dynamics::RevoluteJoint* self,
120 const dart::dynamics::RevoluteJoint::UniqueProperties&
121 _properties) { self->setProperties(_properties); },
122 ::py::arg("properties"))
123 .def(
124 "setAspectProperties",
125 +[](dart::dynamics::RevoluteJoint* self,
126 const dart::common::EmbedPropertiesOnTopOf<
127 dart::dynamics::RevoluteJoint,
128 dart::dynamics::detail::RevoluteJointUniqueProperties,
129 dart::dynamics::GenericJoint<
130 dart::math::RealVectorSpace<1>>>::AspectProperties&
131 properties) { self->setAspectProperties(properties); },
132 ::py::arg("properties"))
133 .def(
134 "getRevoluteJointProperties",
135 +[](const dart::dynamics::RevoluteJoint* self)
136 -> dart::dynamics::RevoluteJoint::Properties {
137 return self->getRevoluteJointProperties();
138 })
139 .def(
140 "copy",
141 +[](dart::dynamics::RevoluteJoint* self,
142 const dart::dynamics::RevoluteJoint* _otherJoint) {
143 self->copy(_otherJoint);
144 },
145 ::py::arg("otherJoint"))
146 .def(
147 "getType",
148 +[](const dart::dynamics::RevoluteJoint* self) -> const std::string& {
149 return self->getType();
150 },
151 ::py::return_value_policy::reference_internal)
152 .def(
153 "isCyclic",
154 +[](const dart::dynamics::RevoluteJoint* self,
155 std::size_t _index) -> bool { return self->isCyclic(_index); },
156 ::py::arg("index"))
157 .def(
158 "setAxis",
159 +[](dart::dynamics::RevoluteJoint* self,
160 const Eigen::Vector3d& _axis) { self->setAxis(_axis); },
161 ::py::arg("axis"))
162 .def(
163 "getAxis",
164 +[](const dart::dynamics::RevoluteJoint* self)
165 -> const Eigen::Vector3d& { return self->getAxis(); },
166 ::py::return_value_policy::reference_internal)
167 .def(
168 "getRelativeJacobianStatic",
169 +[](const dart::dynamics::RevoluteJoint* self,
170 const dart::dynamics::GenericJoint<
171 dart::math::RealVectorSpace<1>>::Vector& positions)
172 -> dart::dynamics::GenericJoint<
173 dart::math::RealVectorSpace<1>>::JacobianMatrix {
174 return self->getRelativeJacobianStatic(positions);
175 },
176 ::py::arg("positions"))
177 .def_static(
178 "getStaticType",
179 +[]() -> const std::string& {
180 return dart::dynamics::RevoluteJoint::getStaticType();
181 },
182 ::py::return_value_policy::reference_internal);
183 }
184
185 } // namespace python
186 } // namespace dart