UserWaypointTests.cpp
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE ArmarX::RobotTrajectoryDesigner::UserWaypoint
2 #define ARMARX_BOOST_TEST
3 
4 
5 #include <RobotComponents/Test.h>
6 
7 #include "../UserWaypoint.h"
8 #include "../Util/OrientationConversion.h"
9 
10 using namespace armarx;
12 {
13  // consturct a UserWaypoint and tests getter
14 
15  PoseBasePtr pose1 = PoseBasePtr(new Pose());
16  UserWaypoint w1 = UserWaypoint(pose1);
17  std::vector<double> jointAngles = {1.0, 2.0, 3.0};
18 
19  //check constructor
20  BOOST_CHECK_EQUAL(w1.getTimeOptimalTimestamp(), 0);
21  BOOST_CHECK_EQUAL(w1.getUserTimestamp(), 0);
22  BOOST_CHECK_EQUAL(w1.getIKSelection(), VirtualRobot::IKSolver::CartesianSelection::All);
23  BOOST_CHECK_EQUAL(w1.getIsTimeOptimalBreakpoint(), false);
24 
25 
26 
27  //check getPose
28  BOOST_CHECK_EQUAL(w1.getPose(), pose1);
29 
30  //check setJointAngles and getJointAngles
32  BOOST_CHECK_EQUAL(w1.getJointAngles(), jointAngles);
33 
34  //check setIKSelection and getIKSelection
35 
36  //check getIsTimeOptimalBreakpoint
38  BOOST_CHECK_EQUAL(w1.getIsTimeOptimalBreakpoint(), true);
39 
40  //check get/set TimeOptimalTimestamp/UserTimestamp
41  w1.setUserTimestamp(10);
42  BOOST_CHECK_EQUAL(w1.getUserTimestamp(), 10);
44  BOOST_CHECK_EQUAL(w1.getTimeOptimalTimestamp(), 20);
45  BOOST_CHECK_EQUAL(w1.getUserTimestamp(), 20);
46  w1.setUserTimestamp(30);
47  BOOST_CHECK_EQUAL(w1.getUserTimestamp(), 30);
48  BOOST_CHECK_EQUAL(w1.getTimeOptimalTimestamp(), 20);
49  //UserTime lower than timeoptimal
50  BOOST_CHECK_THROW(w1.setUserTimestamp(10), InvalidArgumentException);
51 
52 
53  //wrong usage of setter
54  BOOST_CHECK_THROW(w1.setUserTimestamp(-10), InvalidArgumentException);
55  BOOST_CHECK_THROW(w1.setTimeOptimalTimestamp(-10), InvalidArgumentException);
56  BOOST_CHECK_THROW(w1.setJointAngles(std::vector<double>()), InvalidArgumentException);
57 }
58 
59 BOOST_AUTO_TEST_CASE(deepCopyTest)
60 {
61  Vector3BasePtr pos1 = Vector3BasePtr(new Vector3(1, 2, 3));
62  QuaternionBasePtr ori1 = OrientationConversion::toQuaternion(1, 2, 3);
63  PoseBasePtr pose1 = PoseBasePtr(new Pose(pos1, ori1));
64 
65  Vector3BasePtr pos2 = Vector3BasePtr(new Vector3(4, 5, 6));
66  QuaternionBasePtr ori2 = OrientationConversion::toQuaternion(4, 5, 6);
67  PoseBasePtr pose2 = PoseBasePtr(new Pose(pos2, ori2));
68 
69 
70  UserWaypoint w1 = UserWaypoint(pose1);
71  std::vector<double> jointAngles1 = {1.0, 2.0, 3.0};
72  std::vector<double> jointAngles2 = {4.0, 5.0, 6.0};
73  double userT1 = 10;
74  double userT2 = 20;
75  double optimalT1 = 5;
76  double optimalT2 = 10;
77 
78  w1.setJointAngles(jointAngles1);
80  w1.setUserTimestamp(userT1);
81  w1.setTimeOptimalTimestamp(optimalT1);
82 
83  //copy of w1
84  UserWaypoint w2 = UserWaypoint(w1);
85 
86  BOOST_CHECK_EQUAL(w2.getJointAngles(), jointAngles1);
87  BOOST_CHECK_EQUAL(w2.getIsTimeOptimalBreakpoint(), true);
88  BOOST_CHECK_EQUAL(w2.getUserTimestamp(), userT1);
89  BOOST_CHECK_EQUAL(w2.getTimeOptimalTimestamp(), optimalT1);
90  //BOOST_CHECK_EQUAL(*w2.getPose(), *pose1);
91 
92  //change w2
93  w2.setJointAngles(jointAngles2);
95  w2.setUserTimestamp(userT2);
96  w2.setTimeOptimalTimestamp(optimalT2);
97  w2.setPose(pose2);
98 
99  //check w1 and w2
100  BOOST_CHECK_EQUAL(w2.getJointAngles(), jointAngles2);
101  BOOST_CHECK_EQUAL(w2.getIsTimeOptimalBreakpoint(), false);
102  BOOST_CHECK_EQUAL(w2.getUserTimestamp(), userT2);
103  BOOST_CHECK_EQUAL(w2.getTimeOptimalTimestamp(), optimalT2);
104  BOOST_CHECK_EQUAL(w2.getPose(), pose2);
105 
106  BOOST_CHECK_EQUAL(w1.getJointAngles(), jointAngles1);
107  BOOST_CHECK_EQUAL(w1.getIsTimeOptimalBreakpoint(), true);
108  BOOST_CHECK_EQUAL(w1.getUserTimestamp(), userT1);
109  BOOST_CHECK_EQUAL(w1.getTimeOptimalTimestamp(), optimalT1);
110  BOOST_CHECK_EQUAL(w1.getPose(), pose1);
111 }
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