Debian Codegraph @

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