Debian Codegraph @

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