15 #include <gtest/gtest.h> 21 #include "../../include/ecl/manipulators/waypoint.hpp" 22 #include "../../include/ecl/manipulators/trajectory.hpp" 46 TEST(TrajectoryTests,allEggsInOneBasket) {
55 int main(
int argc,
char **argv) {
57 Format<string> string_format; string_format.width(8); string_format.align(RightAlign);
58 Format<double> format; format.width(8); format.precision(2); format.align(RightAlign);
61 std::ofstream tension_file_output, linear_file_output;
62 tension_file_output.open(
"tension_interpolation.dat");
63 linear_file_output.open(
"linear_interpolation.dat");
64 tension_file_output <<
"# Created by trajectories_output_to_file test." << endl;
65 tension_file_output <<
"# name: tension_interpolation" << endl;
66 tension_file_output <<
"# type: matrix" << endl;
67 tension_file_output <<
"# rows: " << (n + 1) * 3 << endl;
68 tension_file_output <<
"# columns: " << 1 + 2 * 3 << endl;
69 tension_file_output << endl;
70 linear_file_output <<
"# Created by trajectories_output_to_file test." << endl;
71 linear_file_output <<
"# name: linear_interpolation" << endl;
72 linear_file_output <<
"# type: matrix" << endl;
73 linear_file_output <<
"# rows: " << (n + 1) * 3 << endl;
74 linear_file_output <<
"# columns: " << 1 + 2 * 3 << endl;
75 linear_file_output << endl;
77 std::cout << std::endl;
78 std::cout <<
"***********************************************************" << std::endl;
79 std::cout <<
" Constructor" << std::endl;
80 std::cout <<
"***********************************************************" << std::endl;
81 std::cout << std::endl;
90 initial_waypoint.name(
"Initial Position");
91 initial_waypoint.angles() << 1.0, 1.0;
92 initial_waypoint.rates() << 0.0, 2.0;
93 initial_waypoint.nominalRates(0.5);
94 trajectory.append(initial_waypoint);
96 waypoint.name(
"Second Waypoint");
97 waypoint.angles() << 2.0, 0.0;
98 waypoint.nominalRates(1.0);
99 trajectory.append(waypoint);
101 waypoint.name(
"Mid Waypoint");
102 waypoint.angles() << 1.0, 5.0;
103 waypoint.nominalRates(1.2);
104 trajectory.append(waypoint);
106 waypoint.name(
"Fourth Waypoint");
107 waypoint.angles() << 3.0, 3.0;
108 waypoint.nominalRates(0.5);
109 trajectory.append(waypoint);
111 final_waypoint.name(
"End Position");
112 final_waypoint.angles() << 4.0, 2.0;
113 final_waypoint.nominalRates(0.5);
114 final_waypoint.rates() << 0.0, 1.0;
115 trajectory.append(final_waypoint);
117 std::cout << trajectory << std::endl;
119 trajectory.maxAccelerations(5);
121 std::cout << std::endl;
122 std::cout <<
"***********************************************************" << std::endl;
123 std::cout <<
" Tension Spline Interpolation" << std::endl;
124 std::cout <<
"***********************************************************" << std::endl;
125 std::cout << std::endl;
127 trajectory.tensionSplineInterpolation(4.0);
137 for (
int i = 0; i <= n; ++i ) {
140 x = i*(trajectory.duration())/n;
142 x = trajectory.duration();
153 tension_file_output << format(x);
154 tension_file_output << format(trajectory(0,x));
155 tension_file_output << format(trajectory.derivative(0,x));
156 tension_file_output << format(trajectory.dderivative(0,x));
157 tension_file_output << format(trajectory(1,x));
158 tension_file_output << format(trajectory.derivative(1,x));
159 tension_file_output << format(trajectory.dderivative(1,x));
160 tension_file_output << endl;
164 std::cout << std::endl;
165 std::cout <<
"***********************************************************" << std::endl;
166 std::cout <<
" Smooth Linear Spline Interpolation" << std::endl;
167 std::cout <<
"***********************************************************" << std::endl;
168 std::cout << std::endl;
170 trajectory.maxAccelerations(5);
171 trajectory.linearSplineInterpolation();
181 for (
int i = 0; i <= n; ++i ) {
184 x = i*(trajectory.duration())/n;
186 x = trajectory.duration();
197 linear_file_output << format(x);
198 linear_file_output << format(trajectory(0,x));
199 linear_file_output << format(trajectory.derivative(0,x));
200 linear_file_output << format(trajectory.dderivative(0,x));
201 linear_file_output << format(trajectory(1,x));
202 linear_file_output << format(trajectory.derivative(1,x));
203 linear_file_output << format(trajectory.dderivative(1,x));
204 linear_file_output << endl;
208 std::cout << std::endl;
209 std::cout <<
"***********************************************************" << std::endl;
210 std::cout <<
" Passed" << std::endl;
211 std::cout <<
"***********************************************************" << std::endl;
212 std::cout << std::endl;
214 tension_file_output.close();
215 linear_file_output.close();
216 std::cout <<
"Trajectories written to files 'linear_interpolation.dat', 'tension_interpolation.dat'." << std::endl;
218 testing::InitGoogleTest(&argc,argv);
219 return RUN_ALL_TESTS();
Primary template for waypoints.
int main(int argc, char **argv)
TEST(TrajectoryTests, allEggsInOneBasket)
Primary template for manipulator trajectories.
Joint angle representations are being used.
Polynomial< 3 > CubicPolynomial