RefValJS_PTP_Trajectory.h
Go to the documentation of this file.
00001 /********************************************************************
00002  *                                                                  *
00003  *                   RefValJS_PTP_Trajectory                        *
00004  *                                                                  *
00005  ********************************************************************/
00006  
00007 #ifndef _REFVALJS_PTP_TRAJECTORY_H_
00008 #define _REFVALJS_PTP_TRAJECTORY_H_
00009 #include <ros/console.h>
00010 #include <cob_trajectory_controller/RefVal_JS.h>
00011 #include <vector>
00012 #include <cob_trajectory_controller/BSplineND.h>
00013 #include <trajectory_msgs/JointTrajectory.h>
00014 
00015 
00016 class RefValJS_PTP_Trajectory : public RefVal_JS
00017 {
00018         public:
00019                 /* smooth = false:
00020                         additional knots between the trajectory points will be generated to make the spline follow straight lines
00021                         and just have the corners rounded (default)
00022                    smooth = true:
00023                         no additional points will be generated, path will be lot smoother, but will have significant differences
00024                         between a path were the trajectory points are connected by straight lines. Do not use in conjunction with
00025                         a path planner!
00026                 */
00027                 RefValJS_PTP_Trajectory(const trajectory_msgs::JointTrajectory& trajectory, double v_rad_s, double a_rad_s2, bool smooth=false);
00028                 //RefValJS_PTP_Trajectory(const std::vector<Jointd>& trajectory, Jointd start, Jointd startvel, double v_rad_s, double a_rad_s2, bool smooth=false);
00029                 
00030                 std::vector<double> r(double s) const;
00031                 double s(double t) const;
00032 
00033                 std::vector<double> dr_ds(double s) const;
00034                 double ds_dt(double t) const;
00035                 
00036                 double getTotalTime() const { return m_T1 + m_T2 + m_T3; }
00037                 
00038                 std::vector<double> getLengthParts() const { return m_length_parts; }
00039                 
00040         protected:
00041                 double norm(const std::vector<double>& j);
00042                 double norm_max(const std::vector<double>& j);
00043                 double norm_sqr(const std::vector<double>& j);
00044                 double norm_weighted(const std::vector<double>& j);
00045                 trajectory_msgs::JointTrajectory m_trajectory;
00046                 
00047                 typedef std::vector<double> vecd;
00048                 typedef std::vector<double>::const_iterator vecd_it;
00049                 vecd m_length_parts;
00050                 vecd m_length_cumulated;
00051                 vecd m_s_parts;
00052                 
00053                 BSplineND< std::vector<double> > m_TrajectorySpline;
00054                 std::vector< std::vector<double> > m_SplinePoints;
00055                 
00056 
00057                 double m_stepSize;
00058                 double m_length;
00059                 double m_param_length;
00060                 
00061                 double m_v_rad_s;
00062                 double m_a_rad_s2;
00063                 
00064                 double m_T1;    // Dauer der Phase konst. Beschl.
00065                 double m_T2;    // Dauer der Phase konst. Geschw.
00066                 double m_T3;    // Dauer der Phase konst. Verzög.
00067                 
00068                 double m_sa1;   // "Beschl." des Wegparameters s in Phase 1
00069                 double m_sv2;   // "Geschw." des Wegparameters s in Phase 2
00070                 double m_sa3;   // "Verzög." des Wegparameters s in Phase 3
00071                 
00072                 static const double weigths[];
00073                 
00074 };
00075 
00076 
00077 inline double RefValJS_PTP_Trajectory::norm(const std::vector<double>& j)
00078 {
00079         // which norm should be used?
00080         return norm_weighted(j);
00081 }
00082 
00083 inline double RefValJS_PTP_Trajectory::norm_max(const std::vector<double>& j)
00084 {
00085         double max = j.at(0);
00086         for     (unsigned int i = 0; i<j.size(); i++)
00087         {
00088                 if(j.at(i) < max)
00089                         max = j.at(i);
00090         }
00091         return max;
00092 }
00093 
00094 inline double RefValJS_PTP_Trajectory::norm_sqr(const std::vector<double>& j)
00095 {
00096         double l = 0;
00097         for (unsigned int i = 0; i < j.size(); i++)
00098         {
00099                 l += j[i] * j[i];
00100         }
00101         return sqrt(l);
00102 }
00103 
00104 inline double RefValJS_PTP_Trajectory::norm_weighted(const std::vector<double>& j)
00105 {
00106         double l = 0;
00107         if ( j.size() == 7 )
00108         {
00109                 for (unsigned int i = 0; i < j.size(); i++)
00110                 {
00111                         l += j[i]* weigths[i] * j[i] * weigths[i];
00112                 }
00113         }
00114         else
00115         {
00116                 for (unsigned int i = 0; i < j.size(); i++)
00117                 {
00118                         l += j[i] * j[i];
00119                 }
00120         }
00121         return sqrt(l);
00122 }
00123 
00124 
00125 
00126 #endif
00127 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


cob_trajectory_controller
Author(s): Alexander Bubeck
autogenerated on Fri Mar 1 2013 17:49:16