RefValJS_PTP_Trajectory.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #ifndef _REFVALJS_PTP_TRAJECTORY_H_
19 #define _REFVALJS_PTP_TRAJECTORY_H_
20 #include <ros/console.h>
22 #include <vector>
24 #include <trajectory_msgs/JointTrajectory.h>
25 
26 
28 {
29  public:
30  /* smooth = false:
31  additional knots between the trajectory points will be generated to make the spline follow straight lines
32  and just have the corners rounded (default)
33  smooth = true:
34  no additional points will be generated, path will be lot smoother, but will have significant differences
35  between a path were the trajectory points are connected by straight lines. Do not use in conjunction with
36  a path planner!
37  */
38  RefValJS_PTP_Trajectory(const trajectory_msgs::JointTrajectory& trajectory, double v_rad_s, double a_rad_s2, bool smooth=false);
39  //RefValJS_PTP_Trajectory(const std::vector<Jointd>& trajectory, Jointd start, Jointd startvel, double v_rad_s, double a_rad_s2, bool smooth=false);
40 
41  std::vector<double> r(double s) const;
42  double s(double t) const;
43 
44  std::vector<double> dr_ds(double s) const;
45  double ds_dt(double t) const;
46 
47  double getTotalTime() const { return m_T1 + m_T2 + m_T3; }
48 
49  std::vector<double> getLengthParts() const { return m_length_parts; }
50 
51  protected:
52  double norm(const std::vector<double>& j);
53  double norm_max(const std::vector<double>& j);
54  double norm_sqr(const std::vector<double>& j);
55  double norm_weighted(const std::vector<double>& j);
56  trajectory_msgs::JointTrajectory m_trajectory;
57 
58  typedef std::vector<double> vecd;
59  typedef std::vector<double>::const_iterator vecd_it;
62  vecd m_s_parts;
63 
65  std::vector< std::vector<double> > m_SplinePoints;
66 
67 
68  double m_stepSize;
69  double m_length;
71 
72  double m_v_rad_s;
73  double m_a_rad_s2;
74 
75  double m_T1; // Dauer der Phase konst. Beschl.
76  double m_T2; // Dauer der Phase konst. Geschw.
77  double m_T3; // Dauer der Phase konst. Verzög.
78 
79  double m_sa1; // "Beschl." des Wegparameters s in Phase 1
80  double m_sv2; // "Geschw." des Wegparameters s in Phase 2
81  double m_sa3; // "Verzög." des Wegparameters s in Phase 3
82 
83  static const double weigths[];
84 };
85 
86 
87 inline double RefValJS_PTP_Trajectory::norm(const std::vector<double>& j)
88 {
89  // which norm should be used?
90  return norm_weighted(j);
91 }
92 
93 inline double RefValJS_PTP_Trajectory::norm_max(const std::vector<double>& j)
94 {
95  double max = j.at(0);
96  for (unsigned int i = 0; i<j.size(); i++)
97  {
98  if(j.at(i) < max)
99  max = j.at(i);
100  }
101  return max;
102 }
103 
104 inline double RefValJS_PTP_Trajectory::norm_sqr(const std::vector<double>& j)
105 {
106  double l = 0;
107  for (unsigned int i = 0; i < j.size(); i++)
108  {
109  l += j[i] * j[i];
110  }
111  return sqrt(l);
112 }
113 
114 inline double RefValJS_PTP_Trajectory::norm_weighted(const std::vector<double>& j)
115 {
116  double l = 0;
117  if ( j.size() == 7 )
118  {
119  for (unsigned int i = 0; i < j.size(); i++)
120  {
121  l += j[i]* weigths[i] * j[i] * weigths[i];
122  }
123  }
124  else
125  {
126  for (unsigned int i = 0; i < j.size(); i++)
127  {
128  l += j[i] * j[i];
129  }
130  }
131  return sqrt(l);
132 }
133 
134 
135 
136 #endif
137 
RefValJS_PTP_Trajectory(const trajectory_msgs::JointTrajectory &trajectory, double v_rad_s, double a_rad_s2, bool smooth=false)
double norm_weighted(const std::vector< double > &j)
BSplineND< std::vector< double > > m_TrajectorySpline
double norm(const std::vector< double > &j)
std::vector< double >::const_iterator vecd_it
double norm_sqr(const std::vector< double > &j)
trajectory_msgs::JointTrajectory m_trajectory
double ds_dt(double t) const
std::vector< double > getLengthParts() const
static const double weigths[]
std::vector< double > r(double s) const
std::vector< double > dr_ds(double s) const
std::vector< std::vector< double > > m_SplinePoints
double norm_max(const std::vector< double > &j)
std::vector< double > vecd


cob_trajectory_controller
Author(s): Alexander Bubeck
autogenerated on Thu Apr 8 2021 02:39:55