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