Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <gtest/gtest.h>
00032 #include <robot_controllers/trajectory.h>
00033
00034 TEST(TrajectoryTests, test_unwind)
00035 {
00036 robot_controllers::Trajectory t;
00037 t.points.resize(3);
00038 t.points[0].q.resize(3);
00039 t.points[0].q[0] = 3.0;
00040 t.points[0].q[1] = -3.0;
00041 t.points[0].q[2] = -3.0;
00042 t.points[1].q.resize(3);
00043 t.points[1].q[0] = -3.0;
00044 t.points[1].q[1] = 3.0;
00045 t.points[1].q[2] = 3.0;
00046 t.points[2].q.resize(3);
00047 t.points[2].q[0] = 3.0;
00048 t.points[2].q[1] = -3.0;
00049 t.points[2].q[2] = -3.0;
00050
00051 std::vector<bool> continuous(3, false);
00052 continuous[0] = true;
00053 continuous[1] = true;
00054
00055
00056 EXPECT_TRUE(windupTrajectory(continuous, t));
00057
00058 EXPECT_EQ(3.0, t.points[0].q[0]);
00059 EXPECT_EQ(3.2831853071795862, t.points[1].q[0]);
00060 EXPECT_EQ(3.0, t.points[2].q[0]);
00061
00062 EXPECT_EQ(-3.0, t.points[0].q[1]);
00063 EXPECT_EQ(-3.2831853071795862, t.points[1].q[1]);
00064 EXPECT_EQ(-3.0, t.points[2].q[1]);
00065
00066 EXPECT_EQ(-3.0, t.points[0].q[2]);
00067 EXPECT_EQ(3.0, t.points[1].q[2]);
00068 EXPECT_EQ(-3.0, t.points[2].q[2]);
00069
00070
00071 EXPECT_TRUE(unwindTrajectoryPoint(continuous, t.points[0]));
00072 EXPECT_EQ(3.0, t.points[0].q[0]);
00073 EXPECT_EQ(-3.0, t.points[0].q[1]);
00074 EXPECT_EQ(-3.0, t.points[0].q[2]);
00075 EXPECT_TRUE(unwindTrajectoryPoint(continuous, t.points[1]));
00076 EXPECT_EQ(-3.0, t.points[1].q[0]);
00077 EXPECT_EQ(3.0, t.points[1].q[1]);
00078 EXPECT_EQ(3.0, t.points[1].q[2]);
00079 EXPECT_TRUE(unwindTrajectoryPoint(continuous, t.points[2]));
00080 EXPECT_EQ(3.0, t.points[2].q[0]);
00081 EXPECT_EQ(-3.0, t.points[2].q[1]);
00082 EXPECT_EQ(-3.0, t.points[2].q[2]);
00083
00084
00085
00086 t.points[1].q.resize(2);
00087 EXPECT_FALSE(windupTrajectory(continuous, t));
00088
00089 continuous.resize(4);
00090 t.points[1].q.resize(3);
00091 EXPECT_FALSE(windupTrajectory(continuous, t));
00092 }
00093
00094 TEST(TrajectoryTests, test_multiple_unwinds)
00095 {
00096 robot_controllers::Trajectory t;
00097 t.points.resize(10);
00098 t.points[0].q.push_back(-3.0);
00099 t.points[1].q.push_back(3.0);
00100 t.points[2].q.push_back(1.0);
00101 t.points[3].q.push_back(-1.0);
00102 t.points[4].q.push_back(-3.0);
00103 t.points[5].q.push_back(3.0);
00104 t.points[6].q.push_back(1.0);
00105 t.points[7].q.push_back(-1.0);
00106 t.points[8].q.push_back(-3.0);
00107 t.points[9].q.push_back(3.0);
00108
00109 std::vector<bool> continuous(1, true);
00110
00111
00112 EXPECT_TRUE(windupTrajectory(continuous, t));
00113
00114 EXPECT_EQ(-3.0, t.points[0].q[0]);
00115 EXPECT_EQ(-3.2831853071795862, t.points[1].q[0]);
00116 EXPECT_EQ(-5.2831853071795862, t.points[2].q[0]);
00117 EXPECT_EQ(-7.2831853071795862, t.points[3].q[0]);
00118 EXPECT_EQ(-9.2831853071795862, t.points[4].q[0]);
00119 EXPECT_EQ(-9.566370614359172, t.points[5].q[0]);
00120 EXPECT_EQ(-11.566370614359172, t.points[6].q[0]);
00121 EXPECT_EQ(-13.566370614359172, t.points[7].q[0]);
00122 EXPECT_EQ(-15.566370614359172, t.points[8].q[0]);
00123 EXPECT_EQ(-15.849555921538759, t.points[9].q[0]);
00124 }
00125
00126
00127 int main(int argc, char **argv)
00128 {
00129 testing::InitGoogleTest(&argc, argv);
00130 return RUN_ALL_TESTS();
00131 }