| 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 <pybind11/pybind11.h> |
| 35 |
|
| 36 |
namespace py = pybind11; |
| 37 |
|
| 38 |
namespace dart { |
| 39 |
namespace python { |
| 40 |
|
| 41 |
void ConstraintBase(py::module& m) |
| 42 |
{ |
| 43 |
::py::class_< |
| 44 |
dart::constraint::ConstraintBase, |
| 45 |
std::shared_ptr<dart::constraint::ConstraintBase> >(m, "ConstraintBase") |
| 46 |
.def( |
| 47 |
"getType", |
| 48 |
+[](const dart::constraint::ConstraintBase* self) -> std::string { |
| 49 |
return self->getType(); |
| 50 |
}) |
| 51 |
.def( |
| 52 |
"getDimension", |
| 53 |
+[](const dart::constraint::ConstraintBase* self) -> std::size_t { |
| 54 |
return self->getDimension(); |
| 55 |
}) |
| 56 |
.def( |
| 57 |
"update", |
| 58 |
+[](dart::constraint::ConstraintBase* self) { self->update(); }) |
| 59 |
.def( |
| 60 |
"getInformation", |
| 61 |
+[](dart::constraint::ConstraintBase* self, |
| 62 |
dart::constraint::ConstraintInfo* info) { |
| 63 |
self->getInformation(info); |
| 64 |
}, |
| 65 |
::py::arg("info")) |
| 66 |
.def( |
| 67 |
"applyUnitImpulse", |
| 68 |
+[](dart::constraint::ConstraintBase* self, std::size_t index) { |
| 69 |
self->applyUnitImpulse(index); |
| 70 |
}, |
| 71 |
::py::arg("index")) |
| 72 |
.def( |
| 73 |
"getVelocityChange", |
| 74 |
+[](dart::constraint::ConstraintBase* self, |
| 75 |
double* vel, |
| 76 |
bool withCfm) { self->getVelocityChange(vel, withCfm); }, |
| 77 |
::py::arg("vel"), |
| 78 |
::py::arg("withCfm")) |
| 79 |
.def( |
| 80 |
"excite", |
| 81 |
+[](dart::constraint::ConstraintBase* self) { self->excite(); }) |
| 82 |
.def( |
| 83 |
"unexcite", |
| 84 |
+[](dart::constraint::ConstraintBase* self) { self->unexcite(); }) |
| 85 |
.def( |
| 86 |
"applyImpulse", |
| 87 |
+[](dart::constraint::ConstraintBase* self, double* lambda) { |
| 88 |
self->applyImpulse(lambda); |
| 89 |
}, |
| 90 |
::py::arg("lambda")) |
| 91 |
.def( |
| 92 |
"isActive", |
| 93 |
+[](const dart::constraint::ConstraintBase* self) -> bool { |
| 94 |
return self->isActive(); |
| 95 |
}) |
| 96 |
.def( |
| 97 |
"getRootSkeleton", |
| 98 |
+[](const dart::constraint::ConstraintBase* self) |
| 99 |
-> dart::dynamics::SkeletonPtr { |
| 100 |
return self->getRootSkeleton(); |
| 101 |
}) |
| 102 |
.def( |
| 103 |
"uniteSkeletons", |
| 104 |
+[](dart::constraint::ConstraintBase* self) { |
| 105 |
self->uniteSkeletons(); |
| 106 |
}) |
| 107 |
.def_static( |
| 108 |
"compressPath", |
| 109 |
+[](dart::dynamics::SkeletonPtr skeleton) |
| 110 |
-> dart::dynamics::SkeletonPtr { |
| 111 |
return dart::constraint::ConstraintBase::compressPath(skeleton); |
| 112 |
}, |
| 113 |
::py::arg("skeleton")) |
| 114 |
.def_static( |
| 115 |
"getRootSkeletonOf", |
| 116 |
+[](dart::dynamics::SkeletonPtr skeleton) |
| 117 |
-> dart::dynamics::SkeletonPtr { |
| 118 |
return dart::constraint::ConstraintBase::getRootSkeleton(skeleton); |
| 119 |
}, |
| 120 |
::py::arg("skeleton")); |
| 121 |
} |
| 122 |
|
| 123 |
} // namespace python |
| 124 |
} // namespace dart |