5 #include <gtest/gtest.h> 37 EXPECT_EQ(fva.x(), v1.
wx());
38 EXPECT_EQ(fva.y(), v1.
wy());
39 EXPECT_EQ(fva.z(), v1.
wz());
41 EXPECT_EQ(fvl.x(), v1.
vx());
42 EXPECT_EQ(fvl.y(), v1.
vy());
43 EXPECT_EQ(fvl.z(), v1.
vz());
48 EXPECT_EQ(v1.
wx(), 0.1);
49 EXPECT_EQ(v1.
wy(), -0.1);
50 EXPECT_EQ(v1.
wz(), 0.2);
52 EXPECT_EQ(v1.
vx(), -0.2);
53 EXPECT_EQ(v1.
vy(), 0.3);
54 EXPECT_EQ(v1.
vz(), -0.3);
59 EXPECT_EQ(v1.
wx(), 3.);
60 EXPECT_EQ(v1.
wy(), 4.);
61 EXPECT_EQ(v1.
wz(), 5.);
63 EXPECT_EQ(v1.
vx(), 6.);
64 EXPECT_EQ(v1.
vy(), 7.);
65 EXPECT_EQ(v1.
vz(), 8.);
78 EXPECT_FALSE(v2.
wx() == v1.
wx());
79 EXPECT_TRUE(v2.
wy() == v1.
wy());
80 EXPECT_FALSE(v2.
wz() == v1.
wz());
81 EXPECT_FALSE(v2.
vx() == v1.
vx());
82 EXPECT_FALSE(v2.
vy() == v1.
vy());
83 EXPECT_FALSE(v2.
vz() == v1.
vz());
87 EXPECT_TRUE(v2.
wx() == v1.
wx());
88 EXPECT_TRUE(v2.
wy() == v1.
wy());
89 EXPECT_TRUE(v2.
wz() == v1.
wz());
90 EXPECT_TRUE(v2.
vx() == v1.
vx());
91 EXPECT_TRUE(v2.
vy() == v1.
vy());
92 EXPECT_TRUE(v2.
vz() == v1.
vz());
99 EXPECT_FALSE(v3.wx() == v4.
wx());
100 EXPECT_TRUE(v3.wy() == v4.
wy());
101 EXPECT_FALSE(v3.wz() == v4.
wz());
102 EXPECT_FALSE(v3.vx() == v4.
vx());
103 EXPECT_FALSE(v3.vy() == v4.
vy());
104 EXPECT_FALSE(v3.vz() == v4.
vz());
108 EXPECT_TRUE(v3.wx() == v4.
wx());
109 EXPECT_TRUE(v3.wy() == v4.
wy());
110 EXPECT_TRUE(v3.wz() == v4.
wz());
111 EXPECT_TRUE(v3.vx() == v4.
vx());
112 EXPECT_TRUE(v3.vy() == v4.
vy());
113 EXPECT_TRUE(v3.vz() == v4.
vz());
130 EXPECT_STREQ(
"Reference frames do not match!", e.
what());
143 EXPECT_STREQ(
"Reference frames do not match!", e.
what());
146 SpatialMotion v4(model->getReferenceFrame(
"body_c"), model->getReferenceFrame(
"body_b"), model->getReferenceFrame(
"body_b"), 0., 1., 0., 0., 0., 0.);
156 SpatialMotion v7(model->getReferenceFrame(
"body_c"), model->getReferenceFrame(
"body_b"), model->getReferenceFrame(
"body_b"), -0.2, 0.3, -0.4, 0.5, -0.6, 0.7);
157 SpatialMotion v8(model->getReferenceFrame(
"body_a"), model->getReferenceFrame(
"body_c"), model->getReferenceFrame(
"body_b"), -0.5, -0.3, 0.1, 0.1, -4.6, 1.7);
159 EXPECT_EQ(v7.
wx(), -0.2);
160 EXPECT_EQ(v7.
wy(), 0.3);
161 EXPECT_EQ(v7.
wz(), -0.4);
162 EXPECT_EQ(v7.
vx(), 0.5);
163 EXPECT_EQ(v7.
vy(), -0.6);
164 EXPECT_EQ(v7.
vz(), 0.7);
168 EXPECT_STREQ(v9.
getReferenceFrame()->getName().c_str(), v8.getReferenceFrame()->getName().c_str());
194 EXPECT_STREQ(e.
what(),
"Cannot perform -= operation on spatial motion vectors due to a reference frame mismatch!");
197 v7.setBodyFrame(model->getReferenceFrame(
"body_a"));
198 v7.setBaseFrame(model->getReferenceFrame(
"body_b"));
199 EXPECT_TRUE(v7.getBodyFrame() == model->getReferenceFrame(
"body_a"));
200 EXPECT_TRUE(v7.getBaseFrame() == model->getReferenceFrame(
"body_b"));
201 EXPECT_TRUE(v7.getReferenceFrame() == model->getReferenceFrame(
"body_b"));
214 X_st.
E = X_66_matrix.block<3, 3>(0, 0);
238 X_st.
E = X_66_matrix.block<3, 3>(0, 0);
259 EXPECT_STREQ(e.
what(),
"Either this reference frame or desired reference frame is nullptr!");
263 int main(
int argc,
char** argv)
265 ::testing::InitGoogleTest(&argc, argv);
266 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.
EIGEN_STRONG_INLINE double & vz()
Get a reference to the linear-z component.
void transform(const SpatialTransform &X)
Transforms a motion vector. Performs .
SpatialMatrix Xtrans_mat(const Vector3d &displacement)
Creates a transformation of a linear displacement.
FrameVector getFramedAngularPart() const
Get angular part of spatial motion as a frame vector.
EIGEN_STRONG_INLINE double & wx()
Get a reference to the angular-x component.
static ReferenceFramePtr getWorldFrame()
Get a pointer to the world frame.
EIGEN_STRONG_INLINE double & wy()
Get a reference to the angular-y component.
virtual const char * what() const
FrameVector getFramedLinearPart() const
Get linear part of spatial motion as a frame vector.
int main(int argc, char **argv)
EIGEN_STRONG_INLINE double & vx()
Get a reference to the linear-x 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...
A SpatialMotion vector is a MotionVector with a RobotDynamics::ReferenceFrame it is expressed in...
ReferenceFrame object used to tell what frame objects are expressed in. Every ReferenceFrame has a po...
ReferenceFramePtr getBaseFrame() const
Get a SpatialMotions SpatialMotion::baseFrame.
EIGEN_STRONG_INLINE double & wz()
Get a reference to the angular-z component.
EIGEN_STRONG_INLINE double & vy()
Get a reference to the linear-y component.
SpatialMatrix Xroty_mat(const double &yrot)
Creates a rotational transformation around the Y-axis.
TEST_F(FixedBase3DoFPlanar, get_frame_vectors)
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)
SpatialMotion changeFrameAndCopy(ReferenceFramePtr referenceFrame) const
Copy and change frame.
MotionVector transform_copy(const SpatialTransform &X) const
Copies, transforms, and returns a MotionVector. Performs .
SpatialMatrix Xrotz_mat(const double &zrot)
Creates a rotational transformation around the Z-axis.