trajectory_profile_generator_ramp.cpp
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 #include <vector>
19 #include <ros/ros.h>
21 
22 /* BEGIN TrajectoryProfileRamp ********************************************************************************************/
24 {
26  double tv, tb = 0.0;
27  double vel = params_.profile.vel;
28  double accl = params_.profile.accl;
29 
30  // Calculate the Sinoid Profile Parameters
31  if (vel > sqrt(std::fabs(Se) * accl))
32  {
33  vel = sqrt(std::fabs(Se) * accl);
34  }
35 
36  if (vel > MIN_VELOCITY_THRESHOLD)
37  {
38  tb = utils.roundUpToMultiplier(vel / accl, params_.profile.t_ipo);
39  if (calcMaxTe)
40  {
41  te = utils.roundUpToMultiplier((std::fabs(Se) / vel) + tb, params_.profile.t_ipo);
42  }
43  tv = te - tb;
44 
45  // Interpolationsteps for every timesequence
46  pt.tb = tb;
47  pt.tv = tv;
48  pt.te = te;
49 
51  pt.steps_tv = (pt.tv-pt.tb)/params_.profile.t_ipo;
52  pt.steps_te = (pt.te-pt.tv)/params_.profile.t_ipo;
53 
54  pt.vel = vel;
55  return true;
56  }
57 
58  return false;
59 }
60 
62 {
63  std::vector<double> array;
64  unsigned int i = 1;
65  double direction = se/std::fabs(se);
66  double accl = params_.profile.accl;
67  double t_ipo = params_.profile.t_ipo;
68 
69  // Calculate the ramp profile path
70  // 0 <= t <= tb
71  for (; i <= pt.steps_tb; i++)
72  {
73  array.push_back(direction * (0.5*accl*pow((t_ipo*i), 2)));
74  }
75  // tb <= t <= tv
76  for (; i <= (pt.steps_tb + pt.steps_tv); i++)
77  {
78  array.push_back(direction *(pt.vel*(t_ipo*i) - 0.5*pow(pt.vel, 2)/accl));
79  }
80  // tv <= t <= te
81  for (; i <= (pt.steps_tb + pt.steps_tv + pt.steps_te + 1); i++)
82  {
83  array.push_back(direction * (pt.vel * pt.tv - 0.5 * accl * pow(pt.te-(t_ipo*i), 2)));
84  }
85 
86  return array;
87 }
88 /* END TrajectoryProfileRamp **********************************************************************************************/
const cob_cartesian_controller::CartesianActionStruct & params_
#define MIN_VELOCITY_THRESHOLD
virtual bool getProfileTimings(double Se, double te, bool calcMaxTe, cob_cartesian_controller::ProfileTimings &pt)
virtual std::vector< double > getTrajectory(double se, cob_cartesian_controller::ProfileTimings pt)
double roundUpToMultiplier(const double numberToRound, const double multiplier)
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > pow(const Rall1d< T, V, S > &arg, double m)


cob_cartesian_controller
Author(s): Christoph Mark
autogenerated on Thu Apr 8 2021 02:40:13