trajectory_maker.cpp
Go to the documentation of this file.
00001 #include "trajectory_maker.h"
00002 
00003 // Makes a linear trajectory with a given tool speed
00004 std::vector<descartes_core::TrajectoryPtPtr> descartes_tests::makeConstantVelocityTrajectory(
00005     const Eigen::Vector3d& start, const Eigen::Vector3d& stop, double tool_vel, size_t n_steps)
00006 {
00007   Eigen::Vector3d delta = stop - start;
00008   Eigen::Vector3d step = delta / n_steps;
00009   double dt = delta.norm() / tool_vel;
00010   double time_step = dt / n_steps;
00011   // We know our dt, all points should have it
00012   descartes_core::TimingConstraint tm(time_step);
00013 
00014   std::vector<descartes_core::TrajectoryPtPtr> result;
00015   for (size_t i = 0; i <= n_steps; ++i)
00016   {
00017     Eigen::Affine3d pose;
00018     pose = Eigen::Translation3d(start + i * step);
00019     descartes_core::TrajectoryPtPtr pt(new descartes_trajectory::CartTrajectoryPt(pose, tm));
00020     result.push_back(pt);
00021   }
00022   return result;
00023 }
00024 
00025 std::vector<descartes_core::TrajectoryPtPtr> descartes_tests::makeZigZagTrajectory(double x_start, double x_stop,
00026                                                                                    double y_amplitude, double tool_vel,
00027                                                                                    size_t n_steps)
00028 {
00029   using namespace Eigen;
00030   Vector3d start(x_start, 0, 0);
00031   Vector3d stop(x_stop, 0, 0);
00032 
00033   Eigen::Vector3d delta = stop - start;
00034   Eigen::Vector3d step = delta / n_steps;
00035   double dt = delta.norm() / tool_vel;
00036   double time_step = dt / n_steps;
00037   // We know our dt, all points should have it
00038   descartes_core::TimingConstraint tm(time_step);
00039 
00040   std::vector<descartes_core::TrajectoryPtPtr> result;
00041   for (size_t i = 0; i <= n_steps; ++i)
00042   {
00043     Eigen::Affine3d pose;
00044     pose = Eigen::Translation3d(start + i * step);
00045     if (i & 1)
00046     {
00047       pose *= Translation3d(0, y_amplitude, 0);
00048     }
00049     else
00050     {
00051       pose *= Translation3d(0, -y_amplitude, 0);
00052     }
00053     descartes_core::TrajectoryPtPtr pt(new descartes_trajectory::CartTrajectoryPt(pose, tm));
00054     result.push_back(pt);
00055   }
00056   return result;
00057 }


descartes_planner
Author(s): Jorge Nicho
autogenerated on Thu Jun 6 2019 21:36:12