1 #include <gtest/gtest.h> 21 std::srand(time(NULL));
48 ASSERT_TRUE(pair.
linear().isApprox(v1, 1e-12));
49 ASSERT_TRUE(pair.
angular().isApprox(v2, 1e-12));
53 ASSERT_FALSE(pair.
linear().isApprox(v1, 1e-12));
54 ASSERT_FALSE(pair.
angular().isApprox(v2, 1e-12));
59 ASSERT_TRUE(pair.
linear().isApprox(v1, 1e-12));
60 ASSERT_TRUE(pair.
angular().isApprox(v2, 1e-12));
64 ASSERT_TRUE(pair.
linear().isApprox(pair2.linear(), 1e-12));
65 ASSERT_TRUE(pair.
angular().isApprox(pair2.angular(), 1e-12));
72 ASSERT_TRUE(pair3.
linear().isApprox(v1, 1e-12));
73 ASSERT_TRUE(pair3.
angular().isApprox(v2, 1e-12));
75 ASSERT_FALSE(pair.
linear().isApprox(pair3.
linear(), 1e-12));
78 ASSERT_FALSE(pair2.linear().isApprox(pair3.
linear(), 1e-12));
79 ASSERT_FALSE(pair2.angular().isApprox(pair3.
angular(), 1e-12));
89 ASSERT_TRUE(pair.linear().isApprox(v1, 1e-12));
90 ASSERT_TRUE(pair.angular().isApprox(v2, 1e-12));
94 ASSERT_FALSE(pair.linear().isApprox(v1, 1e-12));
95 ASSERT_FALSE(pair.angular().isApprox(v2, 1e-12));
100 ASSERT_TRUE(pair.linear().isApprox(v1, 1e-12));
101 ASSERT_TRUE(pair.angular().isApprox(v2, 1e-12));
105 ASSERT_TRUE(pair.linear().isApprox(pair2.linear(), 1e-12));
106 ASSERT_TRUE(pair.angular().isApprox(pair2.angular(), 1e-12));
113 ASSERT_TRUE(pair3.
linear().isApprox(v1, 1e-12));
114 ASSERT_TRUE(pair3.
angular().isApprox(v2, 1e-12));
116 ASSERT_FALSE(pair.linear().isApprox(pair3.
linear(), 1e-12));
117 ASSERT_FALSE(pair.angular().isApprox(pair3.
angular(), 1e-12));
119 ASSERT_FALSE(pair2.linear().isApprox(pair3.
linear(), 1e-12));
120 ASSERT_FALSE(pair2.angular().isApprox(pair3.
angular(), 1e-12));
131 ASSERT_TRUE(pair.
linear().isApprox(v1, 1e-12));
132 ASSERT_TRUE(pair.
angular().isApprox(v2, 1e-12));
136 ASSERT_FALSE(pair.
linear().isApprox(v1, 1e-12));
137 ASSERT_FALSE(pair.
angular().isApprox(v2, 1e-12));
142 ASSERT_TRUE(pair.
linear().isApprox(v1, 1e-12));
143 ASSERT_TRUE(pair.
angular().isApprox(v2, 1e-12));
147 ASSERT_TRUE(pair.
linear().isApprox(pair2.linear(), 1e-12));
148 ASSERT_TRUE(pair.
angular().isApprox(pair2.angular(), 1e-12));
155 ASSERT_TRUE(pair3.
linear().isApprox(v1, 1e-12));
156 ASSERT_TRUE(pair3.
angular().isApprox(v2, 1e-12));
158 ASSERT_FALSE(pair.
linear().isApprox(pair3.
linear(), 1e-12));
161 ASSERT_FALSE(pair2.linear().isApprox(pair3.
linear(), 1e-12));
162 ASSERT_FALSE(pair2.angular().isApprox(pair3.
angular(), 1e-12));
173 ASSERT_TRUE(pair.
linear().isApprox(v1, 1e-12));
174 ASSERT_TRUE(pair.
angular().isApprox(v2, 1e-12));
178 ASSERT_FALSE(pair.
linear().isApprox(v1, 1e-12));
179 ASSERT_FALSE(pair.
angular().isApprox(v2, 1e-12));
184 ASSERT_TRUE(pair.
linear().isApprox(v1, 1e-12));
185 ASSERT_TRUE(pair.
angular().isApprox(v2, 1e-12));
189 ASSERT_TRUE(pair.
linear().isApprox(pair2.linear(), 1e-12));
190 ASSERT_TRUE(pair.
angular().isApprox(pair2.angular(), 1e-12));
197 ASSERT_TRUE(pair3.
linear().isApprox(v1, 1e-12));
198 ASSERT_TRUE(pair3.
angular().isApprox(v2, 1e-12));
200 ASSERT_FALSE(pair.
linear().isApprox(pair3.
linear(), 1e-12));
203 ASSERT_FALSE(pair2.linear().isApprox(pair3.
linear(), 1e-12));
204 ASSERT_FALSE(pair2.angular().isApprox(pair3.
angular(), 1e-12));
209 ASSERT_TRUE(lin_ptr->isApprox(pair3.
linear(), 1e-12));
210 ASSERT_TRUE(ang_ptr->isApprox(pair3.
angular(), 1e-12));
213 int main(
int argc,
char** argv)
215 ::testing::InitGoogleTest(&argc, argv);
216 return RUN_ALL_TESTS();
ReferenceFramePtr getReferenceFrame() const
Get a pointer to the reference frame this FrameObject is expressed in.
static ReferenceFramePtr createRandomUnchangingFrame(const std::string &frameName, ReferenceFramePtr parentFrame, const unsigned int movableBodyId)
static ReferenceFramePtr createARootFrame(const std::string &frameName)
Creates a root frame with ReferenceFrame::parentFrame=nullptr.
FrameVector linear() const
Get copy of linear component.
FrameVector angular() const
Get copy of angular component.
TEST_F(FrameVectorPairTest, simple1)
std::shared_ptr< ReferenceFrame > ReferenceFramePtr
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...
int main(int argc, char **argv)
void changeFrame(ReferenceFramePtr referenceFrame)
Change the frame of the two 3d vectors. Equivalent to the following math expression ...
FrameVector * angularPtr()
Get pointer to angular vector.
FrameVectorPair changeFrameAndCopy(ReferenceFramePtr referenceFrame) const
copy into new frame vector and change the frame of that
A FrameVector is a pair of 3D vector with a ReferenceFrame.
void setIncludingFrame(ReferenceFramePtr referenceFrame, const Vector3d &linear, const Vector3d &angular)
Set the components and the ReferenceFrame these components are expressed in.
Namespace for all structures of the RobotDynamics library.
FrameVector * linearPtr()
Get pointer to linear vector.