Debian Codegraph @

python/dartpy/constraint/DynamicJointConstraint.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 <pybind11/eigen.h>
35 #include <pybind11/pybind11.h>
36
37 namespace py = pybind11;
38
39 namespace dart {
40 namespace python {
41
42 void DynamicJointConstraint(py::module& m)
43 {
44 ::py::class_<
45 dart::constraint::DynamicJointConstraint,
46 dart::constraint::ConstraintBase,
47 std::shared_ptr<dart::constraint::DynamicJointConstraint>>(
48 m, "DynamicJointConstraint")
49 .def_static(
50 "setErrorAllowance",
51 +[](double allowance) {
52 dart::constraint::DynamicJointConstraint::setErrorAllowance(
53 allowance);
54 },
55 ::py::arg("allowance"))
56 .def_static(
57 "getErrorAllowance",
58 +[]() -> double {
59 return dart::constraint::DynamicJointConstraint::
60 getErrorAllowance();
61 })
62 .def_static(
63 "setErrorReductionParameter",
64 +[](double erp) {
65 dart::constraint::DynamicJointConstraint::
66 setErrorReductionParameter(erp);
67 },
68 ::py::arg("erp"))
69 .def_static(
70 "getErrorReductionParameter",
71 +[]() -> double {
72 return dart::constraint::DynamicJointConstraint::
73 getErrorReductionParameter();
74 })
75 .def_static(
76 "setMaxErrorReductionVelocity",
77 +[](double erv) {
78 dart::constraint::DynamicJointConstraint::
79 setMaxErrorReductionVelocity(erv);
80 },
81 ::py::arg("erv"))
82 .def_static(
83 "getMaxErrorReductionVelocity",
84 +[]() -> double {
85 return dart::constraint::DynamicJointConstraint::
86 getMaxErrorReductionVelocity();
87 })
88 .def_static(
89 "setConstraintForceMixing",
90 +[](double cfm) {
91 dart::constraint::DynamicJointConstraint::setConstraintForceMixing(
92 cfm);
93 },
94 ::py::arg("cfm"))
95 .def_static(
96 "getConstraintForceMixing", +[]() -> double {
97 return dart::constraint::DynamicJointConstraint::
98 getConstraintForceMixing();
99 });
100
101 ::py::class_<
102 dart::constraint::BallJointConstraint,
103 dart::constraint::DynamicJointConstraint,
104 std::shared_ptr<dart::constraint::BallJointConstraint>>(
105 m, "BallJointConstraint")
106 .def(
107 ::py::init<dart::dynamics::BodyNode*, const Eigen::Vector3d&>(),
108 ::py::arg("body"),
109 ::py::arg("jointPos"))
110 .def(
111 ::py::init<
112 dart::dynamics::BodyNode*,
113 dart::dynamics::BodyNode*,
114 const Eigen::Vector3d&>(),
115 ::py::arg("body1"),
116 ::py::arg("body2"),
117 ::py::arg("jointPos"))
118 .def_static(
119 "getStaticType", +[]() -> std::string {
120 return dart::constraint::BallJointConstraint::getStaticType();
121 });
122
123 ::py::class_<
124 dart::constraint::WeldJointConstraint,
125 dart::constraint::DynamicJointConstraint,
126 std::shared_ptr<dart::constraint::WeldJointConstraint>>(
127 m, "WeldJointConstraint")
128 .def(::py::init<dart::dynamics::BodyNode*>(), ::py::arg("body"))
129 .def(
130 ::py::init<dart::dynamics::BodyNode*, dart::dynamics::BodyNode*>(),
131 ::py::arg("body1"),
132 ::py::arg("body2"))
133 .def_static(
134 "getStaticType",
135 +[]() -> std::string {
136 return dart::constraint::WeldJointConstraint::getStaticType();
137 })
138 .def(
139 "setRelativeTransform",
140 +[](dart::constraint::WeldJointConstraint* self,
141 const Eigen::Isometry3d& tf) { self->setRelativeTransform(tf); },
142 ::py::arg("tf"));
143 }
144
145 } // namespace python
146 } // namespace dart