| 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 <iostream> |
| 34 |
|
| 35 |
#include <gtest/gtest.h> |
| 36 |
|
| 37 |
#include "dart/dart.hpp" |
| 38 |
|
| 39 |
#include "TestHelpers.hpp" |
| 40 |
|
| 41 |
using namespace dart; |
| 42 |
using namespace dynamics; |
| 43 |
|
| 44 |
// class ZeroDofJointTest : public GenericJoint<NullSpace> |
| 45 |
//{ |
| 46 |
// public: |
| 47 |
// /// Constructor called by Skeleton class |
| 48 |
// ZeroDofJointTest(const Properties& properties = Properties()) |
| 49 |
// : GenericJoint<NullSpace>(properties) {} |
| 50 |
|
| 51 |
// virtual ~ZeroDofJointTest() {} |
| 52 |
|
| 53 |
// /// Gets a string representing the joint type |
| 54 |
// const std::string& getType() const override { return getStaticType(); } |
| 55 |
|
| 56 |
// const std::string& getStaticType() const |
| 57 |
// { |
| 58 |
// static const std::string name = "TestWeldJoint"; |
| 59 |
// return name; |
| 60 |
// } |
| 61 |
|
| 62 |
// // Documentation inherited |
| 63 |
// bool isCyclic(size_t index) const override { return false; } |
| 64 |
|
| 65 |
// const JacobianMatrix getRelativeJacobianStatic( |
| 66 |
// const Vector& positions) const override |
| 67 |
// { return JacobianMatrix(); } |
| 68 |
|
| 69 |
// protected: |
| 70 |
// // Documentation inherited |
| 71 |
// Joint* clone() const override { return nullptr; } |
| 72 |
|
| 73 |
// // Documentation inherited |
| 74 |
// void updateDegreeOfFreedomNames() override {} |
| 75 |
|
| 76 |
// // Documentation inherited |
| 77 |
// void updateRelativeTransform() const override {} |
| 78 |
|
| 79 |
// // Documentation inherited |
| 80 |
// void updateRelativeJacobian(bool mandatory = true) const override {} |
| 81 |
|
| 82 |
// // Documentation inherited |
| 83 |
// void updateRelativeJacobianTimeDeriv() const override {} |
| 84 |
//}; |
| 85 |
|
| 86 |
class SingleDofJointTest : public GenericJoint<R1Space> |
| 87 |
{ |
| 88 |
public: |
| 89 |
/// Constructor called by Skeleton class |
| 90 |
SingleDofJointTest(const Properties& properties = Properties()) |
| 91 |
: GenericJoint<R1Space>(properties) |
| 92 |
{ |
| 93 |
} |
| 94 |
|
| 95 |
virtual ~SingleDofJointTest() {} |
| 96 |
|
| 97 |
/// Gets a string representing the joint type |
| 98 |
const std::string& getType() const override |
| 99 |
{ |
| 100 |
return getStaticType(); |
| 101 |
} |
| 102 |
|
| 103 |
const std::string& getStaticType() const |
| 104 |
{ |
| 105 |
static const std::string name = "TestSingleDofJoint"; |
| 106 |
return name; |
| 107 |
} |
| 108 |
|
| 109 |
// Documentation inherited |
| 110 |
bool isCyclic(size_t /*index*/) const override |
| 111 |
{ |
| 112 |
return false; |
| 113 |
} |
| 114 |
|
| 115 |
JacobianMatrix getRelativeJacobianStatic( |
| 116 |
const Vector& /*positions*/) const override |
| 117 |
{ |
| 118 |
return JacobianMatrix(); |
| 119 |
} |
| 120 |
|
| 121 |
protected: |
| 122 |
// Documentation inherited |
| 123 |
Joint* clone() const override |
| 124 |
{ |
| 125 |
return nullptr; |
| 126 |
} |
| 127 |
|
| 128 |
// Documentation inherited |
| 129 |
void updateDegreeOfFreedomNames() override {} |
| 130 |
|
| 131 |
// Documentation inherited |
| 132 |
void updateRelativeTransform() const override {} |
| 133 |
|
| 134 |
// Documentation inherited |
| 135 |
void updateRelativeJacobian(bool /*mandatory = true*/) const override {} |
| 136 |
|
| 137 |
// Documentation inherited |
| 138 |
void updateRelativeJacobianTimeDeriv() const override {} |
| 139 |
}; |
| 140 |
|
| 141 |
class MultiDofJointTest : public GenericJoint<RealVectorSpace<6>> |
| 142 |
{ |
| 143 |
public: |
| 144 |
/// Constructor called by Skeleton class |
| 145 |
MultiDofJointTest(const Properties& properties = Properties()) |
| 146 |
: GenericJoint<RealVectorSpace<6>>(properties) |
| 147 |
{ |
| 148 |
} |
| 149 |
|
| 150 |
virtual ~MultiDofJointTest() {} |
| 151 |
|
| 152 |
/// Gets a string representing the joint type |
| 153 |
const std::string& getType() const override |
| 154 |
{ |
| 155 |
return getStaticType(); |
| 156 |
} |
| 157 |
|
| 158 |
const std::string& getStaticType() const |
| 159 |
{ |
| 160 |
static const std::string name = "TestMultiDofJoint"; |
| 161 |
return name; |
| 162 |
} |
| 163 |
|
| 164 |
// Documentation inherited |
| 165 |
bool isCyclic(size_t /*index*/) const override |
| 166 |
{ |
| 167 |
return false; |
| 168 |
} |
| 169 |
|
| 170 |
JacobianMatrix getRelativeJacobianStatic( |
| 171 |
const Vector& /*positions*/) const override |
| 172 |
{ |
| 173 |
return JacobianMatrix(); |
| 174 |
} |
| 175 |
|
| 176 |
protected: |
| 177 |
// Documentation inherited |
| 178 |
Joint* clone() const override |
| 179 |
{ |
| 180 |
return nullptr; |
| 181 |
} |
| 182 |
|
| 183 |
// Documentation inherited |
| 184 |
void updateDegreeOfFreedomNames() override {} |
| 185 |
|
| 186 |
// Documentation inherited |
| 187 |
void updateRelativeTransform() const override {} |
| 188 |
|
| 189 |
// Documentation inherited |
| 190 |
void updateRelativeJacobian(bool /*mandatory = true*/) const override {} |
| 191 |
|
| 192 |
// Documentation inherited |
| 193 |
void updateRelativeJacobianTimeDeriv() const override {} |
| 194 |
}; |
| 195 |
|
| 196 |
class SO3JointTest : public GenericJoint<SO3Space> |
| 197 |
{ |
| 198 |
public: |
| 199 |
/// Constructor called by Skeleton class |
| 200 |
SO3JointTest(const Properties& properties = Properties()) |
| 201 |
: GenericJoint<SO3Space>(properties) |
| 202 |
{ |
| 203 |
} |
| 204 |
|
| 205 |
virtual ~SO3JointTest() {} |
| 206 |
|
| 207 |
/// Gets a string representing the joint type |
| 208 |
const std::string& getType() const override |
| 209 |
{ |
| 210 |
return getStaticType(); |
| 211 |
} |
| 212 |
|
| 213 |
const std::string& getStaticType() const |
| 214 |
{ |
| 215 |
static const std::string name = "TestMultiDofJoint"; |
| 216 |
return name; |
| 217 |
} |
| 218 |
|
| 219 |
// Documentation inherited |
| 220 |
bool isCyclic(size_t /*index*/) const override |
| 221 |
{ |
| 222 |
return false; |
| 223 |
} |
| 224 |
|
| 225 |
JacobianMatrix getRelativeJacobianStatic( |
| 226 |
const Vector& /*positions*/) const override |
| 227 |
{ |
| 228 |
return JacobianMatrix(); |
| 229 |
} |
| 230 |
|
| 231 |
protected: |
| 232 |
// Documentation inherited |
| 233 |
Joint* clone() const override |
| 234 |
{ |
| 235 |
return nullptr; |
| 236 |
} |
| 237 |
|
| 238 |
// Documentation inherited |
| 239 |
void updateDegreeOfFreedomNames() override {} |
| 240 |
|
| 241 |
// Documentation inherited |
| 242 |
void updateRelativeTransform() const override {} |
| 243 |
|
| 244 |
// Documentation inherited |
| 245 |
void updateRelativeJacobian(bool /*mandatory = true*/) const override {} |
| 246 |
|
| 247 |
// Documentation inherited |
| 248 |
void updateRelativeJacobianTimeDeriv() const override {} |
| 249 |
}; |
| 250 |
|
| 251 |
//============================================================================== |
| 252 |
TEST(GenericJoint, Basic) |
| 253 |
{ |
| 254 |
// ZeroDofJointTest zeroDofJoint; |
| 255 |
SingleDofJointTest singleDofJoint; |
| 256 |
MultiDofJointTest genericJoint; |
| 257 |
SO3JointTest so3Joint; |
| 258 |
} |