ForceVectorTests.cpp
Go to the documentation of this file.
1 //
2 // Created by jordan on 9/25/16.
3 //
4 
5 #include "UnitTestUtils.hpp"
6 #include <gtest/gtest.h>
7 
8 using namespace RobotDynamics::Math;
9 
10 class ForceVectorTests : public testing::Test
11 {
12  public:
14  {
15  }
16 
17  void SetUp()
18  {
19  }
20 
21  void TearDown()
22  {
23  }
24 };
25 
26 TEST_F(ForceVectorTests, testConstructorsAndAccessors)
27 {
28  ForceVector f(1.1, 2.2, 3.3, 4.4, 5.5, 6.6);
29 
30  EXPECT_EQ(f.mx(), 1.1);
31  EXPECT_EQ(f.my(), 2.2);
32  EXPECT_EQ(f.mz(), 3.3);
33  EXPECT_EQ(f.fx(), 4.4);
34  EXPECT_EQ(f.fy(), 5.5);
35  EXPECT_EQ(f.fz(), 6.6);
36 
37  f.mx() = -1.1;
38  f.my() = -2.2;
39  f.mz() = -3.3;
40  f.fx() = -4.4;
41  f.fy() = -5.5;
42  f.fz() = -6.6;
43 
44  EXPECT_EQ(f.mx(), -1.1);
45  EXPECT_EQ(f.my(), -2.2);
46  EXPECT_EQ(f.mz(), -3.3);
47  EXPECT_EQ(f.fx(), -4.4);
48  EXPECT_EQ(f.fy(), -5.5);
49  EXPECT_EQ(f.fz(), -6.6);
50 }
51 
52 TEST_F(ForceVectorTests, testTransform)
53 {
54  SpatialVector v(1.1, 2.1, 3.1, 4.1, 5.1, 6.1);
55  ForceVector f(v);
56  ForceVector f2(v), f3(v);
57 
58  SpatialTransform X = Xrotx(0.1) * Xtrans(Vector3d(0.1, 0.2, -0.3));
59  f2 = X * f2;
60 
61  ForceVector f_tr = f.transform_copy(X);
62  ForceVector f_exp;
63 
64  f_exp = X.toMatrixAdjoint() * ForceVector(v);
67 }
68 
69 TEST_F(ForceVectorTests, testOperatorOverloads)
70 {
71  ForceVector f1(0.1, 0.2, -0.3, -0.1, 1.0, -3.);
72  ForceVector f2(-0.1, -0.2, 0.3, 0.1, -1.0, 3.);
73 
74  f1 += f2;
76 }
77 
78 int main(int argc, char** argv)
79 {
80  ::testing::InitGoogleTest(&argc, argv);
81  return RUN_ALL_TESTS();
82 }
SpatialVector SpatialVectorZero
TEST_F(ForceVectorTests, testConstructorsAndAccessors)
const double TEST_PREC
SpatialTransform Xtrans(const Vector3d &r)
Get pure translation transform.
A ForceVector is a SpatialVector containing 3 moments and 3 linear forces.
Definition: ForceVector.hpp:27
EIGEN_STRONG_INLINE double & fy()
Get reference to y-linear component.
EIGEN_STRONG_INLINE double & fx()
Get reference to x-linear component.
EIGEN_STRONG_INLINE double & fz()
Get reference to z-linear component.
EIGEN_STRONG_INLINE double & my()
Get reference to y-angular component.
Compact representation of spatial transformations.
SpatialTransform Xrotx(const double &xrot)
Get transform with zero translation and pure rotation about x axis.
EIGEN_STRONG_INLINE double & mz()
Get reference to z-angular component.
int main(int argc, char **argv)
SpatialMatrix toMatrixAdjoint() const
Returns Spatial transform that transforms spatial force vectors.
Math types such as vectors and matrices and utility functions.
Definition: ForceVector.hpp:21
static bool checkSpatialVectorsEpsilonClose(const RobotDynamics::Math::SpatialVector &v1, const RobotDynamics::Math::SpatialVector &v2, const double epsilon)
EIGEN_STRONG_INLINE double & mx()
Get reference to x-angular component.
Definition: ForceVector.hpp:96
ForceVector transform_copy(const SpatialTransform &X) const
Copy then transform a ForceVector by .


rdl_dynamics
Author(s):
autogenerated on Tue Apr 20 2021 02:25:27