4 #include <gtest/gtest.h> 29 SpatialForce v1(model->getReferenceFrame(
"body_b"), 1., 2., 3., 4., 5., 6.);
37 EXPECT_FALSE(v2.
mx() == v1.
mx());
38 EXPECT_FALSE(v2.
my() == v1.
my());
39 EXPECT_FALSE(v2.
mz() == v1.
mz());
40 EXPECT_FALSE(v2.
fx() == v1.
fx());
42 EXPECT_FALSE(v2.
fz() == v1.
fz());
46 EXPECT_TRUE(v2.
mx() == v1.
mx());
47 EXPECT_TRUE(v2.
my() == v1.
my());
48 EXPECT_TRUE(v2.
mz() == v1.
mz());
49 EXPECT_TRUE(v2.
fx() == v1.
fx());
50 EXPECT_TRUE(v2.
fy() == v1.
fy());
51 EXPECT_TRUE(v2.
fz() == v1.
fz());
53 SpatialForce v3(model->getReferenceFrame(
"body_b"), 1., 2., 3., 4., 5., 6.);
58 EXPECT_FALSE(v3.mx() == v4.
mx());
59 EXPECT_FALSE(v3.my() == v4.
my());
60 EXPECT_FALSE(v3.mz() == v4.
mz());
61 EXPECT_FALSE(v3.fx() == v4.
fx());
63 EXPECT_FALSE(v3.fz() == v4.
fz());
67 EXPECT_TRUE(v3.mx() == v4.
mx());
68 EXPECT_TRUE(v3.my() == v4.
my());
69 EXPECT_TRUE(v3.mz() == v4.
mz());
70 EXPECT_TRUE(v3.fx() == v4.
fx());
71 EXPECT_TRUE(v3.fy() == v4.
fy());
72 EXPECT_TRUE(v3.fz() == v4.
fz());
77 SpatialForce v1(model->getReferenceFrame(
"body_a"), 1., 2., 3., 4., 5., 6.);
84 EXPECT_EQ(fva.x(), v1.
mx());
85 EXPECT_EQ(fva.y(), v1.
my());
86 EXPECT_EQ(fva.z(), v1.
mz());
88 EXPECT_EQ(fvl.x(), v1.
fx());
89 EXPECT_EQ(fvl.y(), v1.
fy());
90 EXPECT_EQ(fvl.z(), v1.
fz());
95 EXPECT_EQ(v1.
mx(), 0.1);
96 EXPECT_EQ(v1.
my(), -0.1);
97 EXPECT_EQ(v1.
mz(), 0.2);
99 EXPECT_EQ(v1.
fx(), -0.2);
100 EXPECT_EQ(v1.
fy(), 0.3);
101 EXPECT_EQ(v1.
fz(), -0.3);
103 v1.
setIncludingFrame(model->getReferenceFrame(
"body_c"), 3., 4., 5., 6., 7., 8.);
106 EXPECT_EQ(v1.
mx(), 3.);
107 EXPECT_EQ(v1.
my(), 4.);
108 EXPECT_EQ(v1.
mz(), 5.);
110 EXPECT_EQ(v1.
fx(), 6.);
111 EXPECT_EQ(v1.
fy(), 7.);
112 EXPECT_EQ(v1.
fz(), 8.);
117 SpatialForce v1(model->getReferenceFrame(
"body_a"), 0., 1., 0., 0., 0., 0.);
118 SpatialForce v2(model->getReferenceFrame(
"body_b"), 0., 1., 0., 0., 0., 0.);
127 EXPECT_STREQ(
"Reference frames do not match!", e.
what());
130 SpatialForce v4(model->getReferenceFrame(
"body_b"), 0., 1., 0., 0., 0., 0.);
140 SpatialForce v7(model->getReferenceFrame(
"body_b"), -0.2, 0.3, -0.4, 0.5, -0.6, 0.7);
142 EXPECT_EQ(v7.
mx(), -0.2);
143 EXPECT_EQ(v7.
my(), 0.3);
144 EXPECT_EQ(v7.
mz(), -0.4);
145 EXPECT_EQ(v7.
fx(), 0.5);
146 EXPECT_EQ(v7.
fy(), -0.6);
147 EXPECT_EQ(v7.
fz(), 0.7);
164 X_st.
E = X_66_matrix.block<3, 3>(0, 0);
201 int main(
int argc,
char** argv)
203 ::testing::InitGoogleTest(&argc, argv);
204 return RUN_ALL_TESTS();
ReferenceFramePtr getReferenceFrame() const
Get a pointer to the reference frame this FrameObject is expressed in.
void setIncludingFrame(ReferenceFramePtr referenceFrame, const SpatialVector &v)
SpatialMatrix Xrotx_mat(const double &xrot)
Creates a rotational transformation around the X-axis.
A custom exception for frame operations.
FrameVector getFramedLinearPart() const
Get linear part of spatial force as a frame vector.
SpatialMatrix Xtrans_mat(const Vector3d &displacement)
Creates a transformation of a linear displacement.
A ForceVector is a SpatialVector containing 3 moments and 3 linear forces.
EIGEN_STRONG_INLINE double & fy()
Get reference to y-linear component.
static ReferenceFramePtr getWorldFrame()
Get a pointer to the world frame.
virtual const char * what() const
void transform(const SpatialTransform &X)
Performs the following in place transform .
EIGEN_STRONG_INLINE double & fx()
Get reference to x-linear component.
EIGEN_STRONG_INLINE double & fz()
Get reference to z-linear component.
SpatialTransform Xrotz(const double &zrot)
Get transform with zero translation and pure rotation about z axis.
FrameVector getFramedAngularPart() const
Get angular part of spatial force as a frame vector.
EIGEN_STRONG_INLINE double & my()
Get reference to y-angular component.
virtual void changeFrame(ReferenceFramePtr desiredFrame)
Change the ReferenceFrame this FrameObject is expressed in.
A FrameVector is a 3D vector with a ReferenceFrame, and all operations between FrameVectors and other...
ReferenceFrame object used to tell what frame objects are expressed in. Every ReferenceFrame has a po...
EIGEN_STRONG_INLINE double & mz()
Get reference to z-angular component.
SpatialMatrix Xroty_mat(const double &yrot)
Creates a rotational transformation around the Y-axis.
TEST_F(FixedBase3DoFPlanar, changeFrameAndCopy)
void updateKinematicsCustom(Model &model, const Math::VectorNd *Q, const Math::VectorNd *QDot=nullptr, const Math::VectorNd *QDDot=nullptr)
Selectively updates model internal states of body positions, velocities and/or accelerations.
Math types such as vectors and matrices and utility functions.
static bool checkSpatialVectorsEpsilonClose(const RobotDynamics::Math::SpatialVector &v1, const RobotDynamics::Math::SpatialVector &v2, const double epsilon)
A SpatialForce is a spatial vector with the angular part being three moments and the linear part bein...
EIGEN_STRONG_INLINE double & mx()
Get reference to x-angular component.
int main(int argc, char **argv)
SpatialMatrix Xrotz_mat(const double &zrot)
Creates a rotational transformation around the Z-axis.
SpatialForce changeFrameAndCopy(ReferenceFramePtr referenceFrame) const
Copy and change frame.
ForceVector transform_copy(const SpatialTransform &X) const
Copy then transform a ForceVector by .