Debian Codegraph @

python/dartpy/dynamics/FreeJoint.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 <pybind11/pybind11.h>
35
36 #include "eigen_geometry_pybind.h"
37 #include "eigen_pybind.h"
38
39 namespace py = pybind11;
40
41 namespace dart {
42 namespace python {
43
44 void FreeJoint(py::module& m)
45 {
46 ::py::class_<
47 dart::dynamics::FreeJoint::Properties,
48 dart::dynamics::GenericJoint<math::SE3Space>::Properties>(
49 m, "FreeJointProperties")
50 .def(::py::init<>())
51 .def(
52 ::py::init<const dart::dynamics::GenericJoint<
53 dart::math::SE3Space>::Properties&>(),
54 ::py::arg("properties"));
55
56 ::py::class_<
57 dart::dynamics::FreeJoint,
58 dart::dynamics::GenericJoint<dart::math::SE3Space>,
59 std::shared_ptr<dart::dynamics::FreeJoint>>(m, "FreeJoint")
60 .def(
61 "getFreeJointProperties",
62 +[](const dart::dynamics::FreeJoint* self)
63 -> dart::dynamics::FreeJoint::Properties {
64 return self->getFreeJointProperties();
65 })
66 .def(
67 "getType",
68 +[](const dart::dynamics::FreeJoint* self) -> const std::string& {
69 return self->getType();
70 },
71 ::py::return_value_policy::reference_internal)
72 .def(
73 "isCyclic",
74 +[](const dart::dynamics::FreeJoint* self,
75 std::size_t _index) -> bool { return self->isCyclic(_index); },
76 ::py::arg("index"))
77 .def(
78 "setSpatialMotion",
79 +[](dart::dynamics::FreeJoint* self,
80 const Eigen::Isometry3d* newTransform,
81 const dart::dynamics::Frame* withRespectTo,
82 const Eigen::Vector6d* newSpatialVelocity,
83 const dart::dynamics::Frame* velRelativeTo,
84 const dart::dynamics::Frame* velInCoordinatesOf,
85 const Eigen::Vector6d* newSpatialAcceleration,
86 const dart::dynamics::Frame* accRelativeTo,
87 const dart::dynamics::Frame* accInCoordinatesOf) {
88 self->setSpatialMotion(
89 newTransform,
90 withRespectTo,
91 newSpatialVelocity,
92 velRelativeTo,
93 velInCoordinatesOf,
94 newSpatialAcceleration,
95 accRelativeTo,
96 accInCoordinatesOf);
97 },
98 ::py::arg("newTransform"),
99 ::py::arg("withRespectTo"),
100 ::py::arg("newSpatialVelocity"),
101 ::py::arg("velRelativeTo"),
102 ::py::arg("velInCoordinatesOf"),
103 ::py::arg("newSpatialAcceleration"),
104 ::py::arg("accRelativeTo"),
105 ::py::arg("accInCoordinatesOf"))
106 .def(
107 "setRelativeTransform",
108 +[](dart::dynamics::FreeJoint* self,
109 const Eigen::Isometry3d& newTransform) {
110 self->setRelativeTransform(newTransform);
111 },
112 ::py::arg("newTransform"))
113 .def(
114 "setTransform",
115 +[](dart::dynamics::FreeJoint* self,
116 const Eigen::Isometry3d& newTransform) {
117 self->setTransform(newTransform);
118 },
119 ::py::arg("newTransform"))
120 .def(
121 "setTransform",
122 +[](dart::dynamics::FreeJoint* self,
123 const Eigen::Isometry3d& newTransform,
124 const dart::dynamics::Frame* withRespectTo) {
125 self->setTransform(newTransform, withRespectTo);
126 },
127 ::py::arg("newTransform"),
128 ::py::arg("withRespectTo"))
129 .def(
130 "setRelativeSpatialVelocity",
131 +[](dart::dynamics::FreeJoint* self,
132 const Eigen::Vector6d& newSpatialVelocity) {
133 self->setRelativeSpatialVelocity(newSpatialVelocity);
134 },
135 ::py::arg("newSpatialVelocity"))
136 .def(
137 "setRelativeSpatialVelocity",
138 +[](dart::dynamics::FreeJoint* self,
139 const Eigen::Vector6d& newSpatialVelocity,
140 const dart::dynamics::Frame* inCoordinatesOf) {
141 self->setRelativeSpatialVelocity(
142 newSpatialVelocity, inCoordinatesOf);
143 },
144 ::py::arg("newSpatialVelocity"),
145 ::py::arg("inCoordinatesOf"))
146 .def(
147 "setSpatialVelocity",
148 +[](dart::dynamics::FreeJoint* self,
149 const Eigen::Vector6d& newSpatialVelocity,
150 const dart::dynamics::Frame* relativeTo,
151 const dart::dynamics::Frame* inCoordinatesOf) {
152 self->setSpatialVelocity(
153 newSpatialVelocity, relativeTo, inCoordinatesOf);
154 },
155 ::py::arg("newSpatialVelocity"),
156 ::py::arg("relativeTo"),
157 ::py::arg("inCoordinatesOf"))
158 .def(
159 "setLinearVelocity",
160 +[](dart::dynamics::FreeJoint* self,
161 const Eigen::Vector3d& newLinearVelocity) {
162 self->setLinearVelocity(newLinearVelocity);
163 },
164 ::py::arg("newLinearVelocity"))
165 .def(
166 "setLinearVelocity",
167 +[](dart::dynamics::FreeJoint* self,
168 const Eigen::Vector3d& newLinearVelocity,
169 const dart::dynamics::Frame* relativeTo) {
170 self->setLinearVelocity(newLinearVelocity, relativeTo);
171 },
172 ::py::arg("newLinearVelocity"),
173 ::py::arg("relativeTo"))
174 .def(
175 "setLinearVelocity",
176 +[](dart::dynamics::FreeJoint* self,
177 const Eigen::Vector3d& newLinearVelocity,
178 const dart::dynamics::Frame* relativeTo,
179 const dart::dynamics::Frame* inCoordinatesOf) {
180 self->setLinearVelocity(
181 newLinearVelocity, relativeTo, inCoordinatesOf);
182 },
183 ::py::arg("newLinearVelocity"),
184 ::py::arg("relativeTo"),
185 ::py::arg("inCoordinatesOf"))
186 .def(
187 "setAngularVelocity",
188 +[](dart::dynamics::FreeJoint* self,
189 const Eigen::Vector3d& newAngularVelocity) {
190 self->setAngularVelocity(newAngularVelocity);
191 },
192 ::py::arg("newAngularVelocity"))
193 .def(
194 "setAngularVelocity",
195 +[](dart::dynamics::FreeJoint* self,
196 const Eigen::Vector3d& newAngularVelocity,
197 const dart::dynamics::Frame* relativeTo) {
198 self->setAngularVelocity(newAngularVelocity, relativeTo);
199 },
200 ::py::arg("newAngularVelocity"),
201 ::py::arg("relativeTo"))
202 .def(
203 "setAngularVelocity",
204 +[](dart::dynamics::FreeJoint* self,
205 const Eigen::Vector3d& newAngularVelocity,
206 const dart::dynamics::Frame* relativeTo,
207 const dart::dynamics::Frame* inCoordinatesOf) {
208 self->setAngularVelocity(
209 newAngularVelocity, relativeTo, inCoordinatesOf);
210 },
211 ::py::arg("newAngularVelocity"),
212 ::py::arg("relativeTo"),
213 ::py::arg("inCoordinatesOf"))
214 .def(
215 "setRelativeSpatialAcceleration",
216 +[](dart::dynamics::FreeJoint* self,
217 const Eigen::Vector6d& newSpatialAcceleration) {
218 self->setRelativeSpatialAcceleration(newSpatialAcceleration);
219 },
220 ::py::arg("newSpatialAcceleration"))
221 .def(
222 "setRelativeSpatialAcceleration",
223 +[](dart::dynamics::FreeJoint* self,
224 const Eigen::Vector6d& newSpatialAcceleration,
225 const dart::dynamics::Frame* inCoordinatesOf) {
226 self->setRelativeSpatialAcceleration(
227 newSpatialAcceleration, inCoordinatesOf);
228 },
229 ::py::arg("newSpatialAcceleration"),
230 ::py::arg("inCoordinatesOf"))
231 .def(
232 "setSpatialAcceleration",
233 +[](dart::dynamics::FreeJoint* self,
234 const Eigen::Vector6d& newSpatialAcceleration,
235 const dart::dynamics::Frame* relativeTo,
236 const dart::dynamics::Frame* inCoordinatesOf) {
237 self->setSpatialAcceleration(
238 newSpatialAcceleration, relativeTo, inCoordinatesOf);
239 },
240 ::py::arg("newSpatialAcceleration"),
241 ::py::arg("relativeTo"),
242 ::py::arg("inCoordinatesOf"))
243 .def(
244 "setLinearAcceleration",
245 +[](dart::dynamics::FreeJoint* self,
246 const Eigen::Vector3d& newLinearAcceleration) {
247 self->setLinearAcceleration(newLinearAcceleration);
248 },
249 ::py::arg("newLinearAcceleration"))
250 .def(
251 "setLinearAcceleration",
252 +[](dart::dynamics::FreeJoint* self,
253 const Eigen::Vector3d& newLinearAcceleration,
254 const dart::dynamics::Frame* relativeTo) {
255 self->setLinearAcceleration(newLinearAcceleration, relativeTo);
256 },
257 ::py::arg("newLinearAcceleration"),
258 ::py::arg("relativeTo"))
259 .def(
260 "setLinearAcceleration",
261 +[](dart::dynamics::FreeJoint* self,
262 const Eigen::Vector3d& newLinearAcceleration,
263 const dart::dynamics::Frame* relativeTo,
264 const dart::dynamics::Frame* inCoordinatesOf) {
265 self->setLinearAcceleration(
266 newLinearAcceleration, relativeTo, inCoordinatesOf);
267 },
268 ::py::arg("newLinearAcceleration"),
269 ::py::arg("relativeTo"),
270 ::py::arg("inCoordinatesOf"))
271 .def(
272 "setAngularAcceleration",
273 +[](dart::dynamics::FreeJoint* self,
274 const Eigen::Vector3d& newAngularAcceleration) {
275 self->setAngularAcceleration(newAngularAcceleration);
276 },
277 ::py::arg("newAngularAcceleration"))
278 .def(
279 "setAngularAcceleration",
280 +[](dart::dynamics::FreeJoint* self,
281 const Eigen::Vector3d& newAngularAcceleration,
282 const dart::dynamics::Frame* relativeTo) {
283 self->setAngularAcceleration(newAngularAcceleration, relativeTo);
284 },
285 ::py::arg("newAngularAcceleration"),
286 ::py::arg("relativeTo"))
287 .def(
288 "setAngularAcceleration",
289 +[](dart::dynamics::FreeJoint* self,
290 const Eigen::Vector3d& newAngularAcceleration,
291 const dart::dynamics::Frame* relativeTo,
292 const dart::dynamics::Frame* inCoordinatesOf) {
293 self->setAngularAcceleration(
294 newAngularAcceleration, relativeTo, inCoordinatesOf);
295 },
296 ::py::arg("newAngularAcceleration"),
297 ::py::arg("relativeTo"),
298 ::py::arg("inCoordinatesOf"))
299 .def(
300 "getRelativeJacobianStatic",
301 +[](const dart::dynamics::FreeJoint* self,
302 const Eigen::Vector6d& _positions) -> Eigen::Matrix6d {
303 return self->getRelativeJacobianStatic(_positions);
304 },
305 ::py::arg("positions"))
306 .def(
307 "getPositionDifferencesStatic",
308 +[](const dart::dynamics::FreeJoint* self,
309 const Eigen::Vector6d& _q2,
310 const Eigen::Vector6d& _q1) -> Eigen::Vector6d {
311 return self->getPositionDifferencesStatic(_q2, _q1);
312 },
313 ::py::arg("q2"),
314 ::py::arg("q1"))
315 .def_static(
316 "getStaticType",
317 +[]() -> const std::string& {
318 return dart::dynamics::FreeJoint::getStaticType();
319 },
320 ::py::return_value_policy::reference_internal)
321 .def_static(
322 "convertToPositions",
323 +[](const Eigen::Isometry3d& _tf) -> Eigen::Vector6d {
324 return dart::dynamics::FreeJoint::convertToPositions(_tf);
325 },
326 ::py::arg("tf"))
327 .def_static(
328 "convertToTransform",
329 +[](const Eigen::Vector6d& _positions) -> Eigen::Isometry3d {
330 return dart::dynamics::FreeJoint::convertToTransform(_positions);
331 },
332 ::py::arg("positions"))
333 .def_static(
334 "setTransformOf",
335 +[](dart::dynamics::Joint* joint, const Eigen::Isometry3d& tf) {
336 dart::dynamics::FreeJoint::setTransformOf(joint, tf);
337 },
338 ::py::arg("joint"),
339 ::py::arg("tf"))
340 .def_static(
341 "setTransformOf",
342 +[](dart::dynamics::Joint* joint,
343 const Eigen::Isometry3d& tf,
344 const dart::dynamics::Frame* withRespectTo) {
345 dart::dynamics::FreeJoint::setTransformOf(joint, tf, withRespectTo);
346 },
347 ::py::arg("joint"),
348 ::py::arg("tf"),
349 ::py::arg("withRespectTo"))
350 .def_static(
351 "setTransformOf",
352 +[](dart::dynamics::BodyNode* bodyNode, const Eigen::Isometry3d& tf) {
353 dart::dynamics::FreeJoint::setTransformOf(bodyNode, tf);
354 },
355 ::py::arg("bodyNode"),
356 ::py::arg("tf"))
357 .def_static(
358 "setTransformOf",
359 +[](dart::dynamics::BodyNode* bodyNode,
360 const Eigen::Isometry3d& tf,
361 const dart::dynamics::Frame* withRespectTo) {
362 dart::dynamics::FreeJoint::setTransformOf(
363 bodyNode, tf, withRespectTo);
364 },
365 ::py::arg("bodyNode"),
366 ::py::arg("tf"),
367 ::py::arg("withRespectTo"))
368 .def_static(
369 "setTransformOf",
370 +[](dart::dynamics::Skeleton* skeleton, const Eigen::Isometry3d& tf) {
371 dart::dynamics::FreeJoint::setTransformOf(skeleton, tf);
372 },
373 ::py::arg("skeleton"),
374 ::py::arg("tf"))
375 .def_static(
376 "setTransformOf",
377 +[](dart::dynamics::Skeleton* skeleton,
378 const Eigen::Isometry3d& tf,
379 const dart::dynamics::Frame* withRespectTo) {
380 dart::dynamics::FreeJoint::setTransformOf(
381 skeleton, tf, withRespectTo);
382 },
383 ::py::arg("skeleton"),
384 ::py::arg("tf"),
385 ::py::arg("withRespectTo"))
386 .def_static(
387 "setTransformOf",
388 +[](dart::dynamics::Skeleton* skeleton,
389 const Eigen::Isometry3d& tf,
390 const dart::dynamics::Frame* withRespectTo,
391 bool applyToAllRootBodies) {
392 dart::dynamics::FreeJoint::setTransformOf(
393 skeleton, tf, withRespectTo, applyToAllRootBodies);
394 },
395 ::py::arg("skeleton"),
396 ::py::arg("tf"),
397 ::py::arg("withRespectTo"),
398 ::py::arg("applyToAllRootBodies"));
399 }
400
401 } // namespace python
402 } // namespace dart