Debian Codegraph @

python/dartpy/dynamics/EulerJoint.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 EulerJoint(py::module& m)
46 {
47 ::py::class_<dart::dynamics::EulerJoint::UniqueProperties>(
48 m, "EulerJointUniqueProperties")
49 .def(::py::init<>())
50 .def(
51 ::py::init<dart::dynamics::detail::AxisOrder>(),
52 ::py::arg("axisOrder"));
53
54 ::py::class_<
55 dart::dynamics::EulerJoint::Properties,
56 dart::dynamics::GenericJoint<math::R3Space>::Properties,
57 dart::dynamics::EulerJoint::UniqueProperties>(m, "EulerJointProperties")
58 .def(::py::init<>())
59 .def(
60 ::py::init<const dart::dynamics::GenericJoint<
61 dart::math::R3Space>::Properties&>(),
62 ::py::arg("genericJointProperties"))
63 .def(
64 ::py::init<
65 const dart::dynamics::GenericJoint<
66 dart::math::R3Space>::Properties&,
67 const dart::dynamics::EulerJoint::UniqueProperties&>(),
68 ::py::arg("genericJointProperties"),
69 ::py::arg("uniqueProperties"))
70 .def_readwrite(
71 "mAxisOrder",
72 &dart::dynamics::detail::EulerJointUniqueProperties::mAxisOrder);
73
74 DARTPY_DEFINE_JOINT_COMMON_BASE(EulerJoint, R3Space)
75
76 ::py::class_<
77 dart::dynamics::EulerJoint,
78 dart::common::EmbedPropertiesOnTopOf<
79 dart::dynamics::EulerJoint,
80 dart::dynamics::detail::EulerJointUniqueProperties,
81 dart::dynamics::GenericJoint<dart::math::RealVectorSpace<3>>>,
82 std::shared_ptr<dart::dynamics::EulerJoint>>(m, "EulerJoint")
83 .def(
84 "hasEulerJointAspect",
85 +[](const dart::dynamics::EulerJoint* self) -> bool {
86 return self->hasEulerJointAspect();
87 })
88 .def(
89 "setEulerJointAspect",
90 +[](dart::dynamics::EulerJoint* self,
91 const dart::common::EmbedPropertiesOnTopOf<
92 dart::dynamics::EulerJoint,
93 dart::dynamics::detail::EulerJointUniqueProperties,
94 dart::dynamics::GenericJoint<
95 dart::math::RealVectorSpace<3>>>::Aspect* aspect) {
96 self->setEulerJointAspect(aspect);
97 },
98 ::py::arg("aspect"))
99 .def(
100 "removeEulerJointAspect",
101 +[](dart::dynamics::EulerJoint* self) {
102 self->removeEulerJointAspect();
103 })
104 .def(
105 "releaseEulerJointAspect",
106 +[](dart::dynamics::EulerJoint* self)
107 -> std::unique_ptr<dart::common::EmbedPropertiesOnTopOf<
108 dart::dynamics::EulerJoint,
109 dart::dynamics::detail::EulerJointUniqueProperties,
110 dart::dynamics::GenericJoint<
111 dart::math::RealVectorSpace<3>>>::Aspect> {
112 return self->releaseEulerJointAspect();
113 })
114 .def(
115 "setProperties",
116 +[](dart::dynamics::EulerJoint* self,
117 const dart::dynamics::EulerJoint::Properties& _properties) {
118 self->setProperties(_properties);
119 },
120 ::py::arg("properties"))
121 .def(
122 "setProperties",
123 +[](dart::dynamics::EulerJoint* self,
124 const dart::dynamics::EulerJoint::UniqueProperties& _properties) {
125 self->setProperties(_properties);
126 },
127 ::py::arg("properties"))
128 .def(
129 "setAspectProperties",
130 +[](dart::dynamics::EulerJoint* self,
131 const dart::common::EmbedPropertiesOnTopOf<
132 dart::dynamics::EulerJoint,
133 dart::dynamics::detail::EulerJointUniqueProperties,
134 dart::dynamics::GenericJoint<
135 dart::math::RealVectorSpace<3>>>::AspectProperties&
136 properties) { self->setAspectProperties(properties); },
137 ::py::arg("properties"))
138 .def(
139 "getEulerJointProperties",
140 +[](const dart::dynamics::EulerJoint* self)
141 -> dart::dynamics::EulerJoint::Properties {
142 return self->getEulerJointProperties();
143 })
144 .def(
145 "copy",
146 +[](dart::dynamics::EulerJoint* self,
147 const dart::dynamics::EulerJoint* _otherJoint) {
148 self->copy(_otherJoint);
149 },
150 ::py::arg("otherJoint"))
151 .def(
152 "getType",
153 +[](const dart::dynamics::EulerJoint* self) -> const std::string& {
154 return self->getType();
155 },
156 ::py::return_value_policy::reference_internal)
157 .def(
158 "isCyclic",
159 +[](const dart::dynamics::EulerJoint* self,
160 std::size_t _index) -> bool { return self->isCyclic(_index); },
161 ::py::arg("index"))
162 .def(
163 "setAxisOrder",
164 +[](dart::dynamics::EulerJoint* self,
165 dart::dynamics::EulerJoint::AxisOrder _order) {
166 self->setAxisOrder(_order);
167 },
168 ::py::arg("order"))
169 .def(
170 "setAxisOrder",
171 +[](dart::dynamics::EulerJoint* self,
172 dart::dynamics::EulerJoint::AxisOrder _order,
173 bool _renameDofs) { self->setAxisOrder(_order, _renameDofs); },
174 ::py::arg("order"),
175 ::py::arg("renameDofs"))
176 .def(
177 "getAxisOrder",
178 +[](const dart::dynamics::EulerJoint* self)
179 -> dart::dynamics::EulerJoint::AxisOrder {
180 return self->getAxisOrder();
181 })
182 .def(
183 "convertToTransform",
184 +[](const dart::dynamics::EulerJoint* self,
185 const Eigen::Vector3d& _positions) -> Eigen::Isometry3d {
186 return self->convertToTransform(_positions);
187 },
188 ::py::arg("positions"))
189 .def(
190 "convertToRotation",
191 +[](const dart::dynamics::EulerJoint* self,
192 const Eigen::Vector3d& _positions) -> Eigen::Matrix3d {
193 return self->convertToRotation(_positions);
194 },
195 ::py::arg("positions"))
196 .def(
197 "getRelativeJacobianStatic",
198 +[](const dart::dynamics::EulerJoint* self,
199 const Eigen::Vector3d& _positions)
200 -> Eigen::Matrix<double, 6, 3> {
201 return self->getRelativeJacobianStatic(_positions);
202 },
203 ::py::arg("positions"))
204 .def_static(
205 "getStaticType",
206 +[]() -> const std::
207 string& {
208 return dart::dynamics::EulerJoint::getStaticType();
209 },
210 ::py::return_value_policy::reference_internal)
211 .def_static(
212 "convertToTransformOf",
213 +[](const Eigen::Vector3d& _positions,
214 dart::dynamics::EulerJoint::AxisOrder _ordering)
215 -> Eigen::Isometry3d {
216 return dart::dynamics::EulerJoint::convertToTransform(
217 _positions, _ordering);
218 },
219 ::py::arg("positions"),
220 ::py::arg("ordering"))
221 .def_static(
222 "convertToRotationOf",
223 +[](const Eigen::Vector3d& _positions,
224 dart::dynamics::EulerJoint::AxisOrder _ordering)
225 -> Eigen::Matrix3d {
226 return dart::dynamics::EulerJoint::convertToRotation(
227 _positions, _ordering);
228 },
229 ::py::arg("positions"),
230 ::py::arg("ordering"));
231 }
232
233 } // namespace python
234 } // namespace dart