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
10using namespace armarx;
11
13{
14 // consturct a UserWaypoint and tests getter
15
16 PoseBasePtr pose1 = PoseBasePtr(new Pose());
17 UserWaypoint w1 = UserWaypoint(pose1);
18 std::vector<double> jointAngles = {1.0, 2.0, 3.0};
19
20 //check constructor
21 BOOST_CHECK_EQUAL(w1.getTimeOptimalTimestamp(), 0);
22 BOOST_CHECK_EQUAL(w1.getUserTimestamp(), 0);
23 BOOST_CHECK_EQUAL(w1.getIKSelection(), VirtualRobot::IKSolver::CartesianSelection::All);
24 BOOST_CHECK_EQUAL(w1.getIsTimeOptimalBreakpoint(), false);
25
26
27 //check getPose
28 BOOST_CHECK_EQUAL(w1.getPose(), pose1);
29
30 //check setJointAngles and getJointAngles
31 w1.setJointAngles(jointAngles);
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
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
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}
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.