moveCommand.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 __MOVE_COMMAND_H__
19 #define __MOVE_COMMAND_H__
20 
23 
25 {
26 public:
28  virtual ~moveCommand() {;}
29 
31  // Child Classes have to define these: //
33 
37  virtual double getPos(double TimeElapsed) = 0;
38 
42  virtual double getVel(double TimeElapsed) = 0;
43 
47  virtual double getTotalTime() = 0;
48 
50  // Functions useful for simulation: //
51  // start() has to be called before the other functions //
53 
57  virtual void start()
58  {
59  m_timeStarted.SetNow();
60  }
61 
65  virtual bool isActive()
66  {
67  m_now.SetNow();
68  return (m_now - m_timeStarted > getTotalTime()) ? false : true;
69  std::cerr << "========Total Time: " << getTotalTime() << "\n";
70  }
71 
75  virtual double pos()
76  {
77  m_now.SetNow();
78  return getPos(m_now - m_timeStarted);
79  }
80 
84  virtual double vel()
85  {
86  m_now.SetNow();
87  return getVel(m_now - m_timeStarted);
88  }
89 
93  virtual double timeRemaining()
94  {
95  m_now.SetNow();
96  return (m_timeStarted - m_now) + getTotalTime();
97  }
98 
99 protected:
100  TimeStamp m_timeStarted;
101  TimeStamp m_now;
102 };
103 
104 class RampCommand : public moveCommand
105 {
106 public:
107  RampCommand(double x0, double v0, double xtarget, double amax, double vmax);
108  RampCommand(const RampCommand& rc);
109 
110  virtual RampCommand& operator=(const RampCommand& rc);
111 
112  virtual ~RampCommand()
113  {
114  if (m_nachumkehr)
115  delete m_nachumkehr;
116  }
117 
121  virtual double getPos(double TimeElapsed);
122  double getPos()
123  {
124  return moveCommand::pos();
125  }
126 
130  virtual double getVel(double TimeElapsed);
131  double getVel()
132  {
133  return moveCommand::vel();
134  }
135 
139  virtual double getTotalTime();
140 
141  virtual bool inPhase1()
142  {
143  m_now.SetNow();
144  return (m_now - m_timeStarted <= m_T1) ? true : false;
145  }
146  virtual bool inPhase3()
147  {
148  m_now.SetNow();
149  return (m_now - m_timeStarted > m_T1 + m_T2 && m_now - m_timeStarted < m_T1 + m_T2 + m_T3) ? true : false;
150  }
151 
155  virtual double T1()
156  {
157  return (m_umkehr) ? (m_T1 + m_nachumkehr->T1()) : m_T1;
158  }
159  virtual double T2()
160  {
161  return (m_umkehr) ? m_nachumkehr->T2() : m_T2;
162  }
163  virtual double T3()
164  {
165  return (m_umkehr) ? m_nachumkehr->T3() : m_T3;
166  }
167 
171  static void calculateAV(double x0, double v0, double xtarget, double time, double T3, double amax, double vmax,
172  double& a, double& v);
173 
174 private:
175  static std::ofstream debug;
176 
177  double m_x0, m_v0;
178  double m_xtarget;
179  double m_amax, m_vmax;
180 
181  double m_T1, m_T2, m_T3;
182  double m_a1, m_v2, m_a3;
183  bool m_umkehr;
185 };
186 
187 #endif
TimeStamp m_now
Definition: moveCommand.h:101
virtual double getPos(double TimeElapsed)=0
returns the planned position for TimeElapsed (seconds)
RampCommand * m_nachumkehr
Definition: moveCommand.h:184
double m_vmax
Definition: moveCommand.h:179
virtual double T3()
Definition: moveCommand.h:163
virtual bool isActive()
returns true if the the end of the movement is not reached yet
Definition: moveCommand.h:65
static std::ofstream debug
Definition: moveCommand.h:175
virtual double timeRemaining()
returns remaining time
Definition: moveCommand.h:93
virtual double getTotalTime()=0
returns the planned total time for the movement (in seconds)
double getVel()
Definition: moveCommand.h:131
virtual double getVel(double TimeElapsed)=0
returns the planned velocity for TimeElapsed (seconds)
virtual bool inPhase1()
Definition: moveCommand.h:141
double m_T3
Definition: moveCommand.h:181
double getPos()
Definition: moveCommand.h:122
TimeStamp m_timeStarted
Definition: moveCommand.h:100
virtual ~moveCommand()
Definition: moveCommand.h:28
virtual double pos()
returns the planned position at time of function call (desired position)
Definition: moveCommand.h:75
double m_x0
Definition: moveCommand.h:177
virtual double vel()
returns the planned velocity at time of function call (desired velocitys)
Definition: moveCommand.h:84
double m_xtarget
Definition: moveCommand.h:178
virtual void start()
sets the starttime for the movement to the current time
Definition: moveCommand.h:57
virtual double T1()
Return the times of the different phases of the ramp move.
Definition: moveCommand.h:155
virtual ~RampCommand()
Definition: moveCommand.h:112
virtual double T2()
Definition: moveCommand.h:159
virtual bool inPhase3()
Definition: moveCommand.h:146
double m_v2
Definition: moveCommand.h:182


schunk_powercube_chain
Author(s): Florian Weisshardt
autogenerated on Mon Nov 25 2019 03:48:21