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
moveCommand::moveCommand
moveCommand()
Definition: moveCommand.h:27
RampCommand::m_T2
double m_T2
Definition: moveCommand.h:181
RampCommand::m_nachumkehr
RampCommand * m_nachumkehr
Definition: moveCommand.h:184
RampCommand::m_T1
double m_T1
Definition: moveCommand.h:181
moveCommand::start
virtual void start()
sets the starttime for the movement to the current time
Definition: moveCommand.h:57
RampCommand::m_umkehr
bool m_umkehr
Definition: moveCommand.h:183
moveCommand::getVel
virtual double getVel(double TimeElapsed)=0
returns the planned velocity for TimeElapsed (seconds)
RampCommand::m_vmax
double m_vmax
Definition: moveCommand.h:179
RampCommand::T3
virtual double T3()
Definition: moveCommand.h:163
RampCommand
Definition: moveCommand.h:104
moveCommand::getPos
virtual double getPos(double TimeElapsed)=0
returns the planned position for TimeElapsed (seconds)
RampCommand::getTotalTime
virtual double getTotalTime()
returns the planned total time for the movement (in seconds)
Definition: moveCommand.cpp:282
RampCommand::RampCommand
RampCommand(double x0, double v0, double xtarget, double amax, double vmax)
Definition: moveCommand.cpp:26
moveCommand::pos
virtual double pos()
returns the planned position at time of function call (desired position)
Definition: moveCommand.h:75
moveCommand
Definition: moveCommand.h:24
RampCommand::debug
static std::ofstream debug
Definition: moveCommand.h:175
moveCommand::~moveCommand
virtual ~moveCommand()
Definition: moveCommand.h:28
RampCommand::m_T3
double m_T3
Definition: moveCommand.h:181
moveCommand::m_now
TimeStamp m_now
Definition: moveCommand.h:101
moveCommand::vel
virtual double vel()
returns the planned velocity at time of function call (desired velocitys)
Definition: moveCommand.h:84
RampCommand::calculateAV
static void calculateAV(double x0, double v0, double xtarget, double time, double T3, double amax, double vmax, double &a, double &v)
Calculate the necessary a and v of a rampmove, so that the move will take the desired time.
Definition: moveCommand.cpp:296
RampCommand::inPhase1
virtual bool inPhase1()
Definition: moveCommand.h:141
RampCommand::getVel
double getVel()
Definition: moveCommand.h:131
RampCommand::m_a3
double m_a3
Definition: moveCommand.h:182
RampCommand::getPos
double getPos()
Definition: moveCommand.h:122
RampCommand::m_amax
double m_amax
Definition: moveCommand.h:179
moveCommand::isActive
virtual bool isActive()
returns true if the the end of the movement is not reached yet
Definition: moveCommand.h:65
RampCommand::T1
virtual double T1()
Return the times of the different phases of the ramp move.
Definition: moveCommand.h:155
RampCommand::m_v0
double m_v0
Definition: moveCommand.h:177
RampCommand::~RampCommand
virtual ~RampCommand()
Definition: moveCommand.h:112
RampCommand::m_x0
double m_x0
Definition: moveCommand.h:177
moveCommand::timeRemaining
virtual double timeRemaining()
returns remaining time
Definition: moveCommand.h:93
RampCommand::T2
virtual double T2()
Definition: moveCommand.h:159
RampCommand::m_xtarget
double m_xtarget
Definition: moveCommand.h:178
datastructsManipulator.h
RampCommand::inPhase3
virtual bool inPhase3()
Definition: moveCommand.h:146
RampCommand::operator=
virtual RampCommand & operator=(const RampCommand &rc)
Definition: moveCommand.cpp:174
RampCommand::m_v2
double m_v2
Definition: moveCommand.h:182
RampCommand::m_a1
double m_a1
Definition: moveCommand.h:182
moveCommand::getTotalTime
virtual double getTotalTime()=0
returns the planned total time for the movement (in seconds)
TimeStamp.h
moveCommand::m_timeStarted
TimeStamp m_timeStarted
Definition: moveCommand.h:100


schunk_powercube_chain
Author(s): Florian Weisshardt
autogenerated on Sat May 7 2022 02:17:15