TransitionTests.cpp
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE ArmarX::RobotTrajectoryDesigner::Transition
2 #define ARMARX_BOOST_TEST
3 
4 #include "../../../../../build/testing/RobotTrajectoryDesigner/Test.h"
5 #include "../Transition.h"
6 #include "../Util/OrientationConversion.h"
7 
8 using namespace armarx;
10 {
11  //Init
12  Vector3BasePtr pos1 = Vector3BasePtr(new Vector3(1, 2, 3));
13  QuaternionBasePtr ori1 = OrientationConversion::toQuaternion(1, 2, 3);
14  PoseBasePtr pose1 = PoseBasePtr(new Pose(pos1, ori1));
15 
16  Vector3BasePtr pos2 = Vector3BasePtr(new Vector3(4, 5, 6));
17  QuaternionBasePtr ori2 = OrientationConversion::toQuaternion(4, 5, 6);
18  PoseBasePtr pose2 = PoseBasePtr(new Pose(pos2, ori2));
19 
22 
23 
24  //Consturctor test
25  Transition t1 = Transition(w1, w2);
26  BOOST_CHECK_EQUAL(t1.getStart(), w1);
27  BOOST_CHECK_EQUAL(t1.getEnd(), w2);
28  BOOST_CHECK_EQUAL(t1.getInterpolationType(), eLinearInterpolation);
29  BOOST_CHECK_EQUAL(t1.getTimeOptimalDuration(), 0);
30  BOOST_CHECK_EQUAL(t1.getUserDuration(), 0);
31 
32  //check user/timeOptimal duration
33  t1.setUserDuration(5);
34  BOOST_CHECK_EQUAL(t1.getUserDuration(), 5);
36  BOOST_CHECK_EQUAL(t1.getTimeOptimalDuration(), 10);
37  BOOST_CHECK_EQUAL(t1.getUserDuration(), 10);
38  //UserDuration lower Than timeOptimal
39  BOOST_CHECK_THROW(t1.setUserDuration(5), InvalidArgumentException);
40 
41  //wrong usage
42  BOOST_CHECK_THROW(t1.setUserDuration(-1), InvalidArgumentException);
43  BOOST_CHECK_THROW(t1.setTimeOptimalDuration(-1), InvalidArgumentException);
44 }
45 
46 
47 BOOST_AUTO_TEST_CASE(deepCopyTest)
48 {
49  //Init
50  Vector3BasePtr pos1 = Vector3BasePtr(new Vector3(1, 2, 3));
51  QuaternionBasePtr ori1 = OrientationConversion::toQuaternion(1, 2, 3);
52  PoseBasePtr pose1 = PoseBasePtr(new Pose(pos1, ori1));
53 
54  Vector3BasePtr pos2 = Vector3BasePtr(new Vector3(4, 5, 6));
55  QuaternionBasePtr ori2 = OrientationConversion::toQuaternion(4, 5, 6);
56  PoseBasePtr pose2 = PoseBasePtr(new Pose(pos2, ori2));
57 
60 
61  Vector3BasePtr pos3 = Vector3BasePtr(new Vector3(7, 8, 9));
62  QuaternionBasePtr ori3 = OrientationConversion::toQuaternion(7, 8, 9);
63  PoseBasePtr pose3 = PoseBasePtr(new Pose(pos3, ori3));
64 
65  Vector3BasePtr pos4 = Vector3BasePtr(new Vector3(10, 11, 12));
66  QuaternionBasePtr ori4 = OrientationConversion::toQuaternion(10, 11, 12);
67  PoseBasePtr pose4 = PoseBasePtr(new Pose(pos4, ori4));
68 
71 
72 
73  Transition t1 = Transition(w1, w2);
75  t1.setUserDuration(20);
76 
77  t1.getStart()->setTimeOptimalTimestamp(1);
78  t1.getStart()->setUserTimestamp(2);
79  t1.getEnd()->setTimeOptimalTimestamp(10);
80  t1.getEnd()->setUserTimestamp(20);
81  Transition t2 = Transition(t1);
82 
83 
84  BOOST_CHECK_EQUAL(t2.getTimeOptimalDuration(), 10);
85  BOOST_CHECK_EQUAL(t2.getUserDuration(), 20);
86  BOOST_CHECK_EQUAL(t2.getStart()->getUserTimestamp(), 2);
87  BOOST_CHECK_EQUAL(t2.getStart()->getTimeOptimalTimestamp(), 1);
88  BOOST_CHECK_EQUAL(t2.getEnd()->getUserTimestamp(), 20);
89  BOOST_CHECK_EQUAL(t2.getEnd()->getTimeOptimalTimestamp(), 10);
90 
91 
93  t1.setUserDuration(40);
94  t1.getStart()->setTimeOptimalTimestamp(3);
95  t1.getStart()->setUserTimestamp(4);
96  t1.getEnd()->setTimeOptimalTimestamp(30);
97  t1.getEnd()->setUserTimestamp(40);
98 
99  BOOST_CHECK_EQUAL(t2.getTimeOptimalDuration(), 10);
100  BOOST_CHECK_EQUAL(t2.getUserDuration(), 20);
101  BOOST_CHECK_EQUAL(t2.getStart()->getUserTimestamp(), 2);
102  BOOST_CHECK_EQUAL(t2.getStart()->getTimeOptimalTimestamp(), 1);
103  BOOST_CHECK_EQUAL(t2.getEnd()->getUserTimestamp(), 20);
104  BOOST_CHECK_EQUAL(t2.getEnd()->getTimeOptimalTimestamp(), 10);
105 
106 
107  BOOST_CHECK_EQUAL(t1.getTimeOptimalDuration(), 30);
108  BOOST_CHECK_EQUAL(t1.getUserDuration(), 40);
109  BOOST_CHECK_EQUAL(t1.getStart()->getUserTimestamp(), 4);
110  BOOST_CHECK_EQUAL(t1.getStart()->getTimeOptimalTimestamp(), 3);
111  BOOST_CHECK_EQUAL(t1.getEnd()->getUserTimestamp(), 40);
112  BOOST_CHECK_EQUAL(t1.getEnd()->getTimeOptimalTimestamp(), 30);
113 }
114 
armarx::UserWaypointPtr
std::shared_ptr< UserWaypoint > UserWaypointPtr
Definition: UserWaypoint.h:137
armarx::Transition::setTimeOptimalDuration
void setTimeOptimalDuration(double value)
set the time optimal duration and set the userDuration if its less than time optimal duration
Definition: Transition.cpp:35
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
armarx::UserWaypoint
The UserWaypoint class represents a waypoint of the trajectory.
Definition: UserWaypoint.h:42
armarx::Transition::getEnd
UserWaypointPtr getEnd()
Returns the end UserWaypoint of the transition.
Definition: Transition.cpp:90
armarx::Transition::getTimeOptimalDuration
double getTimeOptimalDuration() const
Returns the time optimal duration calculated by TrajectoryCalculation.
Definition: Transition.cpp:30
armarx::OrientationConversion::toQuaternion
static QuaternionBasePtr toQuaternion(const double roll, const double pitch, const double yaw)
Definition: OrientationConversion.cpp:57
armarx::Transition
Definition: Transition.h:36
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:41
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(basicTest)
Definition: TransitionTests.cpp:11
armarx::eLinearInterpolation
@ eLinearInterpolation
Definition: InterpolationType.h:34
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::Transition::getInterpolationType
InterpolationType getInterpolationType() const
Returns the interpolation type of the transition.
Definition: Transition.cpp:53
armarx::Transition::getUserDuration
double getUserDuration() const
Returns the user duration of the transition.
Definition: Transition.cpp:5
armarx::Transition::setUserDuration
void setUserDuration(double value)
Set the user duration of the transition and tests if it is greater than the time optimal duration.
Definition: Transition.cpp:10
armarx::Transition::getStart
UserWaypointPtr getStart()
Returns the start UserWaypoint of the transition.
Definition: Transition.cpp:73