UserWaypointTests.cpp
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE ArmarX::RobotTrajectoryDesigner::UserWaypoint
2 #define ARMARX_BOOST_TEST
3 
4 #include "../../../../../build/testing/RobotTrajectoryDesigner/Test.h"
5 #include "../UserWaypoint.h"
6 #include "../Util/OrientationConversion.h"
7 
8 using namespace armarx;
10 {
11  // consturct a UserWaypoint and tests getter
12 
13  PoseBasePtr pose1 = PoseBasePtr(new Pose());
14  UserWaypoint w1 = UserWaypoint(pose1);
15  std::vector<double> jointAngles = {1.0, 2.0, 3.0};
16 
17  //check constructor
18  BOOST_CHECK_EQUAL(w1.getTimeOptimalTimestamp(), 0);
19  BOOST_CHECK_EQUAL(w1.getUserTimestamp(), 0);
20  BOOST_CHECK_EQUAL(w1.getIKSelection(), VirtualRobot::IKSolver::CartesianSelection::All);
21  BOOST_CHECK_EQUAL(w1.getIsTimeOptimalBreakpoint(), false);
22 
23 
24 
25  //check getPose
26  BOOST_CHECK_EQUAL(w1.getPose(), pose1);
27 
28  //check setJointAngles and getJointAngles
30  BOOST_CHECK_EQUAL(w1.getJointAngles(), jointAngles);
31 
32  //check setIKSelection and getIKSelection
33 
34  //check getIsTimeOptimalBreakpoint
36  BOOST_CHECK_EQUAL(w1.getIsTimeOptimalBreakpoint(), true);
37 
38  //check get/set TimeOptimalTimestamp/UserTimestamp
39  w1.setUserTimestamp(10);
40  BOOST_CHECK_EQUAL(w1.getUserTimestamp(), 10);
42  BOOST_CHECK_EQUAL(w1.getTimeOptimalTimestamp(), 20);
43  BOOST_CHECK_EQUAL(w1.getUserTimestamp(), 20);
44  w1.setUserTimestamp(30);
45  BOOST_CHECK_EQUAL(w1.getUserTimestamp(), 30);
46  BOOST_CHECK_EQUAL(w1.getTimeOptimalTimestamp(), 20);
47  //UserTime lower than timeoptimal
48  BOOST_CHECK_THROW(w1.setUserTimestamp(10), InvalidArgumentException);
49 
50 
51  //wrong usage of setter
52  BOOST_CHECK_THROW(w1.setUserTimestamp(-10), InvalidArgumentException);
53  BOOST_CHECK_THROW(w1.setTimeOptimalTimestamp(-10), InvalidArgumentException);
54  BOOST_CHECK_THROW(w1.setJointAngles(std::vector<double>()), InvalidArgumentException);
55 }
56 
57 BOOST_AUTO_TEST_CASE(deepCopyTest)
58 {
59  Vector3BasePtr pos1 = Vector3BasePtr(new Vector3(1, 2, 3));
60  QuaternionBasePtr ori1 = OrientationConversion::toQuaternion(1, 2, 3);
61  PoseBasePtr pose1 = PoseBasePtr(new Pose(pos1, ori1));
62 
63  Vector3BasePtr pos2 = Vector3BasePtr(new Vector3(4, 5, 6));
64  QuaternionBasePtr ori2 = OrientationConversion::toQuaternion(4, 5, 6);
65  PoseBasePtr pose2 = PoseBasePtr(new Pose(pos2, ori2));
66 
67 
68  UserWaypoint w1 = UserWaypoint(pose1);
69  std::vector<double> jointAngles1 = {1.0, 2.0, 3.0};
70  std::vector<double> jointAngles2 = {4.0, 5.0, 6.0};
71  double userT1 = 10;
72  double userT2 = 20;
73  double optimalT1 = 5;
74  double optimalT2 = 10;
75 
76  w1.setJointAngles(jointAngles1);
78  w1.setUserTimestamp(userT1);
79  w1.setTimeOptimalTimestamp(optimalT1);
80 
81  //copy of w1
82  UserWaypoint w2 = UserWaypoint(w1);
83 
84  BOOST_CHECK_EQUAL(w2.getJointAngles(), jointAngles1);
85  BOOST_CHECK_EQUAL(w2.getIsTimeOptimalBreakpoint(), true);
86  BOOST_CHECK_EQUAL(w2.getUserTimestamp(), userT1);
87  BOOST_CHECK_EQUAL(w2.getTimeOptimalTimestamp(), optimalT1);
88  //BOOST_CHECK_EQUAL(*w2.getPose(), *pose1);
89 
90  //change w2
91  w2.setJointAngles(jointAngles2);
93  w2.setUserTimestamp(userT2);
94  w2.setTimeOptimalTimestamp(optimalT2);
95  w2.setPose(pose2);
96 
97  //check w1 and w2
98  BOOST_CHECK_EQUAL(w2.getJointAngles(), jointAngles2);
99  BOOST_CHECK_EQUAL(w2.getIsTimeOptimalBreakpoint(), false);
100  BOOST_CHECK_EQUAL(w2.getUserTimestamp(), userT2);
101  BOOST_CHECK_EQUAL(w2.getTimeOptimalTimestamp(), optimalT2);
102  BOOST_CHECK_EQUAL(w2.getPose(), pose2);
103 
104  BOOST_CHECK_EQUAL(w1.getJointAngles(), jointAngles1);
105  BOOST_CHECK_EQUAL(w1.getIsTimeOptimalBreakpoint(), true);
106  BOOST_CHECK_EQUAL(w1.getUserTimestamp(), userT1);
107  BOOST_CHECK_EQUAL(w1.getTimeOptimalTimestamp(), optimalT1);
108  BOOST_CHECK_EQUAL(w1.getPose(), pose1);
109 }
armarx::UserWaypoint::getUserTimestamp
double getUserTimestamp() const
Returns the UserTimestamp.
Definition: UserWaypoint.cpp:63
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
armarx::UserWaypoint::setUserTimestamp
void setUserTimestamp(double value)
Set the new UserDuration and tests if its greater than timeOptimalTimestamp.
Definition: UserWaypoint.cpp:68
armarx::UserWaypoint
The UserWaypoint class represents a waypoint of the trajectory.
Definition: UserWaypoint.h:42
armarx::UserWaypoint::getTimeOptimalTimestamp
double getTimeOptimalTimestamp() const
Returns the timeOptimalTimestamp of the UserWaypoint which is calculate by the TrajectoryCalculation.
Definition: UserWaypoint.cpp:42
armarx::UserWaypoint::setTimeOptimalTimestamp
void setTimeOptimalTimestamp(double value)
Set the time optimal timestamp of the UserWaypoint calculate by TrajectoryCalculation.
Definition: UserWaypoint.cpp:47
armarx::UserWaypoint::getIsTimeOptimalBreakpoint
bool getIsTimeOptimalBreakpoint() const
Returns if the UserWaypoint is breakpoint.
Definition: UserWaypoint.cpp:32
armarx::UserWaypoint::setIsTimeOptimalBreakpoint
void setIsTimeOptimalBreakpoint(bool value)
Set isTimeOptimalBreakpoint.
Definition: UserWaypoint.cpp:37
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(basicTest)
Definition: UserWaypointTests.cpp:11
armarx::UserWaypoint::getJointAngles
std::vector< double > getJointAngles() const
Returns the jointAngles of the UserWaypoint.
Definition: UserWaypoint.cpp:5
armarx::UserWaypoint::setJointAngles
void setJointAngles(const std::vector< double > &value)
Set the new JointAngles of the UserWaypoint.
Definition: UserWaypoint.cpp:10
armarx::OrientationConversion::toQuaternion
static QuaternionBasePtr toQuaternion(const double roll, const double pitch, const double yaw)
Definition: OrientationConversion.cpp:57
armarx::UserWaypoint::getIKSelection
IKSelection getIKSelection() const
Returns the VirtualRobot::IKSolver::CartesianSelection of the UserWaypoint.
Definition: UserWaypoint.cpp:22
armarx::channels::KinematicUnitObserver::jointAngles
const KinematicUnitDatafieldCreator jointAngles("jointAngles")
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:41
armarx::UserWaypoint::getPose
PoseBasePtr getPose()
Returns the PoseBasePtr of the UserWaypoint.
Definition: UserWaypoint.cpp:80
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::UserWaypoint::setPose
void setPose(const PoseBasePtr &value)
Set the new PoseBase of the UserWaypoint.
Definition: UserWaypoint.cpp:85