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