Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef COB_CARTESIAN_CONTROLLER_TRAJECTORY_PROFILE_GENERATOR_TRAJECTORY_PROFILE_GENERATOR_BASE_H
00019 #define COB_CARTESIAN_CONTROLLER_TRAJECTORY_PROFILE_GENERATOR_TRAJECTORY_PROFILE_GENERATOR_BASE_H
00020
00021 #include <vector>
00022 #include <ros/ros.h>
00023 #include <cob_cartesian_controller/cartesian_controller_data_types.h>
00024 #include <cob_cartesian_controller/cartesian_controller_utils.h>
00025
00026
00027 #define MIN_VELOCITY_THRESHOLD 0.001
00028
00029 class TrajectoryProfileBase
00030 {
00031 public:
00032 explicit TrajectoryProfileBase(const cob_cartesian_controller::CartesianActionStruct& params)
00033 : params_(params)
00034 {}
00035
00036 virtual ~TrajectoryProfileBase()
00037 {}
00038
00039 virtual bool calculateProfile(std::vector<double>* path_matrix,
00040 const double Se_lin, const double Se_rot)
00041 {
00042 CartesianControllerUtils ccu;
00043 std::vector<double> linear_path, angular_path;
00044
00045 cob_cartesian_controller::PathArray lin(Se_lin, linear_path);
00046 cob_cartesian_controller::PathArray rot(Se_rot, angular_path);
00047
00048 cob_cartesian_controller::PathMatrix pm(lin, rot);
00049
00050
00051 bool success = getProfileTimings(pm.getMaxSe(), 0, true, pt_max_);
00052
00053
00054 for (unsigned int i = 0; i < pm.pm_.size(); i++)
00055 {
00056 generatePath(pm.pm_[i]);
00057 }
00058
00059
00060
00061
00062 ccu.adjustArrayLength(pm.pm_);
00063
00064 ccu.copyMatrix(path_matrix, pm.pm_);
00065
00066 return true;
00067 }
00068
00069 protected:
00070 virtual bool generatePath(cob_cartesian_controller::PathArray& pa)
00071 {
00072 std::vector<double> array;
00073 cob_cartesian_controller::ProfileTimings pt;
00074
00075
00076 if (getProfileTimings(pa.Se_, pt_max_.te, false, pt))
00077 {
00078 array = getTrajectory(pa.Se_, pt);
00079 }
00080 else
00081 {
00082 array.push_back(0);
00083 }
00084
00085 pa.array_ = array;
00086 return true;
00087 }
00088
00089 virtual bool getProfileTimings(double Se, double te, bool calcMaxTe, cob_cartesian_controller::ProfileTimings& pt) = 0;
00090 virtual std::vector<double> getTrajectory(double se, cob_cartesian_controller::ProfileTimings pt) = 0;
00091
00092 const cob_cartesian_controller::CartesianActionStruct& params_;
00093 cob_cartesian_controller::ProfileTimings pt_max_;
00094 };
00095
00096 #endif // COB_CARTESIAN_CONTROLLER_TRAJECTORY_PROFILE_GENERATOR_TRAJECTORY_PROFILE_GENERATOR_BASE_H