1 #include <gtest/gtest.h> 11 std::srand(time(NULL));
26 allFrames.push_back(root1);
27 allFrames.push_back(frame1);
28 allFrames.push_back(frame2);
29 allFrames.push_back(frame3);
31 allFrames.push_back(root2);
32 allFrames.push_back(frame4);
33 allFrames.push_back(frame5);
34 allFrames.push_back(frame6);
35 allFrames.push_back(frame7);
36 allFrames.push_back(frame8);
38 frames1.push_back(root1);
39 frames1.push_back(frame1);
40 frames1.push_back(frame2);
41 frames1.push_back(frame3);
43 frames2.push_back(root2);
44 frames2.push_back(frame4);
45 frames2.push_back(frame5);
46 frames2.push_back(frame6);
47 frames2.push_back(frame7);
48 frames2.push_back(frame8);
87 EXPECT_STREQ(testFrame.
getName().c_str(), frame1->getName().c_str());
94 EXPECT_TRUE(root1->getParentFrame() ==
nullptr);
95 EXPECT_TRUE(root2->getParentFrame() ==
nullptr);
103 EXPECT_STREQ(e.
what(),
"You are not allowed to create a frame with parentFrame=nullptr. Only a root frame and the world frame may have parentFrame=nullptr");
112 EXPECT_EQ(worldFrame1, worldFrame2);
117 EXPECT_FALSE(root1 == root2);
122 EXPECT_TRUE(frame2->getRootFrame() == root1.get());
123 EXPECT_TRUE(frame7->getRootFrame() == frame5->getRootFrame());
125 frame7->verifyFramesHaveSameRoot(frame6);
129 frame7->verifyFramesHaveSameRoot(frame1);
133 EXPECT_STREQ(
"Frames frame1 and frame7 have mismatched roots!", e.
what());
141 frame2->checkReferenceFramesMatch(
nullptr);
145 EXPECT_STREQ(e.
what(),
"Reference frame is nullptr!");
150 frame2->checkReferenceFramesMatch(frame7);
154 EXPECT_STREQ(e.
what(),
"Reference frames do not match!");
160 for (
int i = 0; i < nTests; i++)
176 for (
int i = 0; i < nTests; i++)
195 for (
int i = 1; i < allFrames.size(); i++)
201 if (parentFrame !=
nullptr)
203 Eigen::Matrix4d m1, m2;
213 for (
int j = 0; j < nTests; j++)
217 for (
int i = 0; i < allFrames.size(); i++)
229 for (
int i = 0; i < nTests; i++)
233 for (
int j = 0; j < allFrames.size(); j++)
244 int main(
int argc,
char** argv)
246 ::testing::InitGoogleTest(&argc, argv);
247 ::testing::FLAGS_gtest_death_test_style =
"threadsafe";
248 return RUN_ALL_TESTS();
std::string getName() const
Get the frame name.
static ReferenceFramePtr createRandomUnchangingFrame(const std::string &frameName, ReferenceFramePtr parentFrame, const unsigned int movableBodyId)
A custom exception for frame operations.
static ReferenceFramePtr createARootFrame(const std::string &frameName)
Creates a root frame with ReferenceFrame::parentFrame=nullptr.
bool getIsBodyFrame() const
Get boolean telling if this frame is a body frame or not. If it is a body frame, A pointer to this fr...
static ReferenceFramePtr getARandomFrame(std::vector< ReferenceFramePtr > frames)
std::vector< ReferenceFramePtr > allFrames
static ReferenceFramePtr getWorldFrame()
Get a pointer to the world frame.
virtual const char * what() const
bool getIsWorldFrame() const
Get a boolean telling if this frame is the world frame.
std::vector< ReferenceFramePtr > frames1
TEST_F(ReferenceFrameTest, constructors)
std::shared_ptr< ReferenceFrame > ReferenceFramePtr
int main(int argc, char **argv)
virtual RobotDynamics::Math::SpatialTransform getTransformToRoot()
Get this frames ReferenceFrame::transformToRoot.
static RobotDynamics::Math::SpatialTransform getTransformToRootByClimbingTree(ReferenceFramePtr frame)
virtual RobotDynamics::Math::SpatialTransform getInverseTransformToRoot()
Get this frames ReferenceFrame::inverseTransformToRoot.
ReferenceFrame object used to tell what frame objects are expressed in. Every ReferenceFrame has a po...
static bool checkSpatialMatrixEpsilonClose(const RobotDynamics::Math::SpatialMatrix &t1, const RobotDynamics::Math::SpatialMatrix &t2, const double epsilon)
SpatialMatrix SpatialMatrixIdentity
std::vector< ReferenceFramePtr > frames2
static void updateAllFrames(std::vector< ReferenceFramePtr > frames)
Namespace for all structures of the RobotDynamics library.