31 #include <kdl/path.hpp>
32 #include <kdl/path_line.hpp>
33 #include <kdl/rotational_interpolation.hpp>
34 #include <kdl/rotational_interpolation_sa.hpp>
35 #include <kdl/trajectory.hpp>
36 #include <kdl/trajectory_segment.hpp>
37 #include <kdl/trajectory_stationary.hpp>
38 #include <kdl/velocityprofile.hpp>
39 #include <kdl/velocityprofile_spline.hpp>
53 std::istringstream ss(data);
60 for (
int i = 0; i <
n; ++i)
62 for (
int j = 0; j < m; ++j)
109 std::ostringstream ss;
111 ss <<
data_.rows() <<
" " <<
data_.cols() <<
"\n";
118 if (!(data.cols() == 4 || data.cols() == 7 || data.cols() == 8) || data.rows() < 2)
ThrowPretty(
"Invalid trajectory data size!\nNeeds to contain 4, 7, or 8 columns and at least 2 rows.");
119 trajectory_.reset(
new KDL::Trajectory_Composite());
120 for (
int i = 0; i < data.rows() - 1; ++i)
122 KDL::Frame f1 =
GetFrame(data.row(i).tail(data.cols() - 1).transpose());
123 KDL::Frame f2 =
GetFrame(data.row(i + 1).tail(data.cols() - 1).transpose());
124 double dt = data(i + 1, 0) - data(i, 0);
125 if (dt <= 0)
ThrowPretty(
"Time indices must be monotonically increasing! " << i <<
" (" << dt <<
")");
126 if (KDL::Equal(f1, f2, 1e-6))
128 trajectory_->Add(
new KDL::Trajectory_Stationary(dt, f1));
132 KDL::RotationalInterpolation_SingleAxis* rot =
new KDL::RotationalInterpolation_SingleAxis();
133 KDL::Path_Line* path =
new KDL::Path_Line(f1, f2, rot, radius);
134 KDL::VelocityProfile_Spline* vel =
new KDL::VelocityProfile_Spline();
135 KDL::Trajectory_Segment* seg =
new KDL::Trajectory_Segment(path, vel, dt);