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 #include "descartes_core/trajectory_pt.h"
00020 #include "descartes_trajectory/cart_trajectory_pt.h"
00021 #include "descartes_trajectory/joint_trajectory_pt.h"
00022 #include "descartes_trajectory/axial_symmetric_pt.h"
00023 #include "ros/console.h"
00024 #include <gtest/gtest.h>
00025
00026 using namespace descartes_core;
00027 using namespace descartes_trajectory;
00028
00029
00030 bool equal(const descartes_core::TimingConstraint& a,
00031 const descartes_core::TimingConstraint& b)
00032 {
00033 return std::abs(a.upper - b.upper) < 0.001;
00034 }
00035
00036
00037 template <class T>
00038 TrajectoryPt* CreateTrajectoryPt();
00039
00040 template <>
00041 TrajectoryPt* CreateTrajectoryPt<CartTrajectoryPt>()
00042 {
00043 return new CartTrajectoryPt();
00044 }
00045
00046 template <>
00047 TrajectoryPt* CreateTrajectoryPt<JointTrajectoryPt>()
00048 {
00049 return new JointTrajectoryPt();
00050 }
00051
00052 template <>
00053 TrajectoryPt* CreateTrajectoryPt<AxialSymmetricPt>()
00054 {
00055 return new AxialSymmetricPt();
00056 }
00057
00058 template <class T>
00059 class TrajectoryPtTest : public testing::Test {
00060 protected:
00061
00062 TrajectoryPtTest()
00063 : lhs_(CreateTrajectoryPt<T>())
00064 , rhs_(CreateTrajectoryPt<T>())
00065 , lhs_copy_(CreateTrajectoryPt<T>())
00066 , lhs_clone_(CreateTrajectoryPt<T>())
00067 {
00068 lhs_->setTiming(descartes_core::TimingConstraint(10.0));
00069
00070 lhs_copy_ = lhs_->copy();
00071 lhs_clone_ = lhs_->clone();
00072 lhs_same_ = lhs_;
00073 }
00074
00075 TrajectoryPtPtr lhs_;
00076 TrajectoryPtPtr rhs_;
00077 TrajectoryPtPtr lhs_copy_;
00078 TrajectoryPtPtr lhs_clone_;
00079 TrajectoryPtPtr lhs_same_;
00080 };
00081
00082 using testing::Types;
00083
00084
00085 typedef Types<CartTrajectoryPt, JointTrajectoryPt, AxialSymmetricPt> Implementations;
00086
00087 TYPED_TEST_CASE(TrajectoryPtTest, Implementations);
00088
00089 TYPED_TEST(TrajectoryPtTest, construction) {
00090
00091 EXPECT_FALSE(this->lhs_->getID().is_nil());
00092 EXPECT_FALSE(this->lhs_copy_->getID().is_nil());
00093 EXPECT_FALSE(this->lhs_clone_->getID().is_nil());
00094 EXPECT_FALSE(this->rhs_->getID().is_nil());
00095
00096
00097
00098
00099
00100
00101
00102
00103 EXPECT_NE(this->lhs_->getID(), this->rhs_->getID());
00104
00105
00106
00107 EXPECT_EQ(this->lhs_->getID(), this->lhs_copy_->getID());
00108
00109
00110
00111 EXPECT_NE(this->lhs_->getID(), this->lhs_clone_->getID());
00112
00113
00114
00115 EXPECT_EQ(this->lhs_->getID(), this->lhs_same_->getID());
00116
00117
00118 EXPECT_TRUE(equal(this->lhs_->getTiming(), this->lhs_copy_->getTiming()));
00119 EXPECT_TRUE(equal(this->lhs_->getTiming(), this->lhs_clone_->getTiming()));
00120 EXPECT_FALSE(equal(this->lhs_->getTiming(), this->rhs_->getTiming()));
00121 }