Debian Codegraph @

python/dartpy/dynamics/ScrewJoint.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 ScrewJoint(py::module& m)
46 {
47 ::py::class_<dart::dynamics::ScrewJoint::UniqueProperties>(
48 m, "ScrewJointUniqueProperties")
49 .def(::py::init<>())
50 .def(::py::init<const Eigen::Vector3d&>(), ::py::arg("axis"))
51 .def(
52 ::py::init<const Eigen::Vector3d&, double>(),
53 ::py::arg("axis"),
54 ::py::arg("pitch"));
55
56 ::py::class_<
57 dart::dynamics::ScrewJoint::Properties,
58 dart::dynamics::GenericJoint<math::R1Space>::Properties,
59 dart::dynamics::ScrewJoint::UniqueProperties>(m, "ScrewJointProperties")
60 .def(::py::init<>())
61 .def(
62 ::py::init<const dart::dynamics::GenericJoint<
63 dart::math::R1Space>::Properties&>(),
64 ::py::arg("genericJointProperties"))
65 .def(
66 ::py::init<
67 const dart::dynamics::GenericJoint<
68 dart::math::R1Space>::Properties&,
69 const dart::dynamics::ScrewJoint::UniqueProperties&>(),
70 ::py::arg("genericJointProperties"),
71 ::py::arg("revoluteProperties"))
72 .def_readwrite(
73 "mAxis", &dart::dynamics::detail::ScrewJointUniqueProperties::mAxis)
74 .def_readwrite(
75 "mPitch",
76 &dart::dynamics::detail::ScrewJointUniqueProperties::mPitch);
77
78 DARTPY_DEFINE_JOINT_COMMON_BASE(ScrewJoint, R1Space)
79
80 ::py::class_<
81 dart::dynamics::ScrewJoint,
82 dart::common::EmbedPropertiesOnTopOf<
83 dart::dynamics::ScrewJoint,
84 dart::dynamics::detail::ScrewJointUniqueProperties,
85 dart::dynamics::GenericJoint<dart::math::RealVectorSpace<1>>>,
86 std::shared_ptr<dart::dynamics::ScrewJoint>>(m, "ScrewJoint")
87 .def(
88 "hasScrewJointAspect",
89 +[](const dart::dynamics::ScrewJoint* self) -> bool {
90 return self->hasScrewJointAspect();
91 })
92 .def(
93 "setScrewJointAspect",
94 +[](dart::dynamics::ScrewJoint* self,
95 const dart::common::EmbedPropertiesOnTopOf<
96 dart::dynamics::ScrewJoint,
97 dart::dynamics::detail::ScrewJointUniqueProperties,
98 dart::dynamics::GenericJoint<
99 dart::math::RealVectorSpace<1>>>::Aspect* aspect) {
100 self->setScrewJointAspect(aspect);
101 },
102 ::py::arg("aspect"))
103 .def(
104 "removeScrewJointAspect",
105 +[](dart::dynamics::ScrewJoint* self) {
106 self->removeScrewJointAspect();
107 })
108 .def(
109 "releaseScrewJointAspect",
110 +[](dart::dynamics::ScrewJoint* self)
111 -> std::unique_ptr<dart::common::EmbedPropertiesOnTopOf<
112 dart::dynamics::ScrewJoint,
113 dart::dynamics::detail::ScrewJointUniqueProperties,
114 dart::dynamics::GenericJoint<
115 dart::math::RealVectorSpace<1>>>::Aspect> {
116 return self->releaseScrewJointAspect();
117 })
118 .def(
119 "setProperties",
120 +[](dart::dynamics::ScrewJoint* self,
121 const dart::dynamics::ScrewJoint::Properties& _properties) {
122 self->setProperties(_properties);
123 },
124 ::py::arg("properties"))
125 .def(
126 "setProperties",
127 +[](dart::dynamics::ScrewJoint* self,
128 const dart::dynamics::ScrewJoint::UniqueProperties& _properties) {
129 self->setProperties(_properties);
130 },
131 ::py::arg("properties"))
132 .def(
133 "setAspectProperties",
134 +[](dart::dynamics::ScrewJoint* self,
135 const dart::common::EmbedPropertiesOnTopOf<
136 dart::dynamics::ScrewJoint,
137 dart::dynamics::detail::ScrewJointUniqueProperties,
138 dart::dynamics::GenericJoint<
139 dart::math::RealVectorSpace<1>>>::AspectProperties&
140 properties) { self->setAspectProperties(properties); },
141 ::py::arg("properties"))
142 .def(
143 "getScrewJointProperties",
144 +[](const dart::dynamics::ScrewJoint* self)
145 -> dart::dynamics::ScrewJoint::Properties {
146 return self->getScrewJointProperties();
147 })
148 .def(
149 "copy",
150 +[](dart::dynamics::ScrewJoint* self,
151 const dart::dynamics::ScrewJoint* _otherJoint) {
152 self->copy(_otherJoint);
153 },
154 ::py::arg("otherJoint"))
155 .def(
156 "getType",
157 +[](const dart::dynamics::ScrewJoint* self) -> const std::string& {
158 return self->getType();
159 },
160 ::py::return_value_policy::reference_internal)
161 .def(
162 "isCyclic",
163 +[](const dart::dynamics::ScrewJoint* self,
164 std::size_t _index) -> bool { return self->isCyclic(_index); },
165 ::py::arg("index"))
166 .def(
167 "setAxis",
168 +[](dart::dynamics::ScrewJoint* self, const Eigen::Vector3d& _axis) {
169 self->setAxis(_axis);
170 },
171 ::py::arg("axis"))
172 .def(
173 "getAxis",
174 +[](const dart::dynamics::ScrewJoint* self)
175 -> const Eigen::Vector3d& { return self->getAxis(); },
176 ::py::return_value_policy::reference_internal)
177 .def(
178 "setPitch",
179 +[](dart::dynamics::ScrewJoint* self, double _pitch) {
180 self->setPitch(_pitch);
181 },
182 ::py::arg("pitch"))
183 .def(
184 "getPitch",
185 +[](const dart::dynamics::ScrewJoint* self) -> double {
186 return self->getPitch();
187 })
188 .def(
189 "getRelativeJacobianStatic",
190 +[](const dart::dynamics::ScrewJoint* self,
191 const dart::dynamics::GenericJoint<
192 dart::math::RealVectorSpace<1>>::Vector& positions)
193 -> dart::dynamics::GenericJoint<
194 dart::math::RealVectorSpace<1>>::JacobianMatrix {
195 return self->getRelativeJacobianStatic(positions);
196 },
197 ::py::arg("positions"))
198 .def_static(
199 "getStaticType",
200 +[]() -> const std::
201 string& {
202 return dart::dynamics::ScrewJoint::getStaticType();
203 },
204 ::py::return_value_policy::reference_internal);
205 }
206
207 } // namespace python
208 } // namespace dart