1 /*
2  * Copyright (c) 2011-2021, 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 namespace dart {
39 namespace python {
40 
41 #define DARTPY_DEFINE_JOINT_COMMON_BASE(type, space)                           \
42   ::pybind11::class_<                                                          \
43       dart::common::SpecializedForAspect<                                      \
44           dart::common::EmbeddedPropertiesAspect<                              \
45               dart::dynamics::type,                                            \
46               dart::dynamics::detail::type##UniqueProperties>>,                \
47       dart::common::Composite,                                                 \
48       std::shared_ptr<dart::common::SpecializedForAspect<                      \
49           dart::common::EmbeddedPropertiesAspect<                              \
50               dart::dynamics::type,                                            \
51               dart::dynamics::detail::type##UniqueProperties>>>>(              \
52       m,                                                                       \
53       "SpecializedForAspect_EmbeddedPropertiesAspect_" #type "_" #type         \
54       "UniqueProperties")                                                      \
55       .def(::pybind11::init<>());                                              \
56                                                                                \
57   ::pybind11::class_<                                                          \
58       dart::common::RequiresAspect<dart::common::EmbeddedPropertiesAspect<     \
59           dart::dynamics::type,                                                \
60           dart::dynamics::detail::type##UniqueProperties>>,                    \
61       dart::common::SpecializedForAspect<                                      \
62           dart::common::EmbeddedPropertiesAspect<                              \
63               dart::dynamics::type,                                            \
64               dart::dynamics::detail::type##UniqueProperties>>,                \
65       std::shared_ptr<                                                         \
66           dart::common::RequiresAspect<dart::common::EmbeddedPropertiesAspect< \
67               dart::dynamics::type,                                            \
68               dart::dynamics::detail::type##UniqueProperties>>>>(              \
69       m,                                                                       \
70       "RequiresAspect_EmbeddedPropertiesAspect_" #type "_" #type               \
71       "UniqueProperties")                                                      \
72       .def(::pybind11::init<>());                                              \
73                                                                                \
74   ::pybind11::class_<                                                          \
75       dart::common::EmbedProperties<                                           \
76           dart::dynamics::type,                                                \
77           dart::dynamics::detail::type##UniqueProperties>,                     \
78       dart::common::RequiresAspect<dart::common::EmbeddedPropertiesAspect<     \
79           dart::dynamics::type,                                                \
80           dart::dynamics::detail::type##UniqueProperties>>,                    \
81       std::shared_ptr<dart::common::EmbedProperties<                           \
82           dart::dynamics::type,                                                \
83           dart::dynamics::detail::type##UniqueProperties>>>(                   \
84       m, "EmbedProperties_" #type "_" #type "UniqueProperties");               \
85                                                                                \
86   ::pybind11::class_<                                                          \
87       dart::common::CompositeJoiner<                                           \
88           dart::common::EmbedProperties<                                       \
89               dart::dynamics::type,                                            \
90               dart::dynamics::detail::type##UniqueProperties>,                 \
91           dart::dynamics::GenericJoint<dart::math::space>>,                    \
92       dart::common::EmbedProperties<                                           \
93           dart::dynamics::type,                                                \
94           dart::dynamics::detail::type##UniqueProperties>,                     \
95       dart::dynamics::GenericJoint<dart::math::space>,                         \
96       std::shared_ptr<dart::common::CompositeJoiner<                           \
97           dart::common::EmbedProperties<                                       \
98               dart::dynamics::type,                                            \
99               dart::dynamics::detail::type##UniqueProperties>,                 \
100           dart::dynamics::GenericJoint<dart::math::space>>>>(                  \
101       m,                                                                       \
102       "CompositeJoiner_EmbedProperties_" #type "_" #type                       \
103       "UniqueProperties_GenericJoint_" #space);                                \
104                                                                                \
105   ::pybind11::class_<                                                          \
106       dart::common::EmbedPropertiesOnTopOf<                                    \
107           dart::dynamics::type,                                                \
108           dart::dynamics::detail::type##UniqueProperties,                      \
109           dart::dynamics::GenericJoint<dart::math::space>>,                    \
110       dart::common::CompositeJoiner<                                           \
111           dart::common::EmbedProperties<                                       \
112               dart::dynamics::type,                                            \
113               dart::dynamics::detail::type##UniqueProperties>,                 \
114           dart::dynamics::GenericJoint<dart::math::space>>,                    \
115       std::shared_ptr<dart::common::EmbedPropertiesOnTopOf<                    \
116           dart::dynamics::type,                                                \
117           dart::dynamics::detail::type##UniqueProperties,                      \
118           dart::dynamics::GenericJoint<dart::math::space>>>>(                  \
119       m,                                                                       \
120       "EmbedPropertiesOnTopOf_" #type "_" #type                                \
121       "UniqueProperties_GenericJoint_" #space);
122 
123 } // namespace python
124 } // namespace dart
125