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
8using namespace armarx;
9
11{
12 // consturct a UserWaypoint and tests getter
13
14 PoseBasePtr pose1 = PoseBasePtr(new Pose());
15 UserWaypoint w1 = UserWaypoint(pose1);
16 std::vector<double> jointAngles = {1.0, 2.0, 3.0};
17
18 //check constructor
19 BOOST_CHECK_EQUAL(w1.getTimeOptimalTimestamp(), 0);
20 BOOST_CHECK_EQUAL(w1.getUserTimestamp(), 0);
21 BOOST_CHECK_EQUAL(w1.getIKSelection(), VirtualRobot::IKSolver::CartesianSelection::All);
22 BOOST_CHECK_EQUAL(w1.getIsTimeOptimalBreakpoint(), false);
23
24
25 //check getPose
26 BOOST_CHECK_EQUAL(w1.getPose(), pose1);
27
28 //check setJointAngles and getJointAngles
29 w1.setJointAngles(jointAngles);
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
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
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}
BOOST_AUTO_TEST_CASE(basicTest)
static QuaternionBasePtr toQuaternion(const double roll, const double pitch, const double yaw)
The Pose class.
Definition Pose.h:243
The UserWaypoint class represents a waypoint of the trajectory.
PoseBasePtr getPose()
Returns the PoseBasePtr of the UserWaypoint.
double getTimeOptimalTimestamp() const
Returns the timeOptimalTimestamp of the UserWaypoint which is calculate by the TrajectoryCalculation.
std::vector< double > getJointAngles() const
Returns the jointAngles of the UserWaypoint.
void setUserTimestamp(double value)
Set the new UserDuration and tests if its greater than timeOptimalTimestamp.
double getUserTimestamp() const
Returns the UserTimestamp.
void setJointAngles(const std::vector< double > &value)
Set the new JointAngles of the UserWaypoint.
void setTimeOptimalTimestamp(double value)
Set the time optimal timestamp of the UserWaypoint calculate by TrajectoryCalculation.
void setPose(const PoseBasePtr &value)
Set the new PoseBase of the UserWaypoint.
bool getIsTimeOptimalBreakpoint() const
Returns if the UserWaypoint is breakpoint.
IKSelection getIKSelection() const
Returns the VirtualRobot::IKSolver::CartesianSelection of the UserWaypoint.
void setIsTimeOptimalBreakpoint(bool value)
Set isTimeOptimalBreakpoint.
The Vector3 class.
Definition Pose.h:113
This file offers overloads of toIce() and fromIce() functions for STL container types.