PowerCubeSim.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 __POWER_CUBE_SIM_H_
19 #define __POWER_CUBE_SIM_H_
20 
23 #include <iostream>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <vector>
27 
28 using namespace std;
29 #include <pthread.h>
30 
31 //-------------------------------------------------------------------------
32 // Defines
33 // -------------------------------------------------------------------------
34 
35 #define MAX_VEL 0.5
36 #define MAX_ACC 0.5
37 #define K13 0.5
38 #define K14 0.5
39 #define K15 3
40 #define DAEMPFUNG 0.5
41 
42 //#define __LINUX__
43 
44 #ifdef SWIG
45 %module PowerCubeSim
46 %include "Source/Manipulation/Interfaces/armInterface.h"
47 %{
48  #include "PowerCubeSim.h"
49 %}
50 #endif
51 
52 class PowerCubeSim;
53 
54 /* Thread arguments for simulation threads*/
55 typedef struct
56 {
58  int cubeID;
59  double targetAngle;
61 
63 {
64 public:
65  PowerCubeSim();
66  ~PowerCubeSim();
67 
68  bool Init(PowerCubeCtrlParams* params);
69 
70  bool isInitialized() const
71  {
72  return m_Initialized;
73  }
74 
75  std::string getErrorMessage() const
76  {
77  return m_ErrorMessage;
78  }
79 
80  int Close()
81  {
82  return true;
83  }
84  // Arm-Ansteuerung:
85 
88  bool MoveJointSpaceSync(const std::vector<double>& Angle);
89 
91  bool MoveVel(const std::vector<double>& vel);
92 
94  bool Stop();
95 
97  // Funktionen zum setzen von Parametern: //
99 
102  bool setMaxVelocity(double radpersec);
103 
104  bool setMaxVelocity(const std::vector<double>& radpersec);
105 
108  bool setMaxAcceleration(double radPerSecSquared);
109  bool setMaxAcceleration(const std::vector<double>& radPerSecSquared);
110 
112  // hier die Funktionen zur Statusabfrage: //
114 
116  bool getConfig(std::vector<double>& result);
117 
119  bool getJointVelocities(std::vector<double>& result);
120 
121  void setCurrentAngles(std::vector<double> Angles);
122 
123  void setCurrentJointVelocities(std::vector<double> Angles);
124 
127  bool statusMoving();
128  bool statusMoving(int cubeNo);
129 
131  bool statusDec();
132 
134  bool statusAcc();
135 
137  // vector<int> getModuleMap(int dev);
138 
140  // void HomingDone();
141 
142  typedef enum
143  {
144  PC_CTRL_OK = 0,
145  PC_CTRL_NOT_REFERENCED = -1,
146  PC_CTRL_ERR = -2,
147  PC_CTRL_POW_VOLT_ERR = -3
148  } PC_CTRL_STATE;
149  // int getStatus(){return PC_CTRL_OK;}
150  double maxVel;
151 
152  void setStatusMoving(int cubeNo, bool moving);
153  bool getStatusMoving(int cubeNo) const
154  {
155  return m_MovementInProgress[cubeNo];
156  }
157 
158  vector<int> getModuleMap() const
159  {
160  return m_IdModules;
161  }
162  std::vector<double> getCurrentAngularMaxVel()
163  {
164  return m_CurrentAngularMaxVel;
165  }
166  std::vector<double> getCurrentAngularMaxAccel()
167  {
168  return m_CurrentAngularMaxAccel;
169  }
170  void millisleep(unsigned int milliseconds) const;
171 
172 protected:
174  // void waitForSync();
176  // void dontWaitForSync();
179  double timeRampMove(double dtheta, double vnow, double v, double a);
180 
181  int startSimulatedMovement(std::vector<double> target);
182 
183 // void* SimThreadRoutine (void*);
184 
185 #ifdef COB3
186  Manipulator* m_Obj_Manipulator;
187 #endif
188 
189  int m_DOF;
192  int m_Dev;
193  vector<int> m_IdModules;
194 
195  std::vector<double> m_maxVel;
196  std::vector<double> m_maxAcc;
197 
199 
200  std::vector<bool> m_MovementInProgress;
201 
202  std::vector<double> m_CurrentAngles;
203  std::vector<double> m_CurrentAngularVel;
204  std::vector<double> m_CurrentAngularMaxVel;
205  std::vector<double> m_CurrentAngularMaxAccel;
206 
207  // vector<unsigned long> startConf;
208 
209  std::string m_ErrorMessage;
210 
211  float maxAcc;
212 
213  pthread_mutex_t m_Angles_Mutex;
214  pthread_mutex_t m_AngularVel_Mutex;
215  pthread_mutex_t m_Movement_Mutex;
216  pthread_t* m_SimThreadID;
218 };
219 
220 #endif
pthread_mutex_t m_AngularVel_Mutex
Definition: PowerCubeSim.h:214
std::vector< double > m_maxAcc
Definition: PowerCubeSim.h:196
std::vector< double > m_maxVel
Definition: PowerCubeSim.h:195
SimThreadArgs ** m_SimThreadArgs
Definition: PowerCubeSim.h:217
pthread_mutex_t m_Movement_Mutex
Definition: PowerCubeSim.h:215
double targetAngle
Definition: PowerCubeSim.h:59
std::vector< double > m_CurrentAngularMaxVel
Definition: PowerCubeSim.h:204
std::string m_ErrorMessage
Definition: PowerCubeSim.h:209
std::vector< bool > m_MovementInProgress
Definition: PowerCubeSim.h:200
vector< int > getModuleMap() const
Definition: PowerCubeSim.h:158
std::vector< double > m_CurrentAngularVel
Definition: PowerCubeSim.h:203
std::string getErrorMessage() const
Definition: PowerCubeSim.h:75
vector< int > m_IdModules
Definition: PowerCubeSim.h:193
std::vector< double > getCurrentAngularMaxAccel()
Definition: PowerCubeSim.h:166
pthread_mutex_t m_Angles_Mutex
Definition: PowerCubeSim.h:213
std::vector< double > m_CurrentAngles
Definition: PowerCubeSim.h:202
pthread_t * m_SimThreadID
Definition: PowerCubeSim.h:216
std::vector< double > getCurrentAngularMaxVel()
Definition: PowerCubeSim.h:162
PC_CTRL_STATE
Looks for connected Modules and returns their Ids in a vector.
Definition: PowerCubeSim.h:142
PowerCubeSim * cubeSimPtr
Definition: PowerCubeSim.h:57
bool isInitialized() const
Definition: PowerCubeSim.h:70
Jointd m_AngleOffsets
Definition: PowerCubeSim.h:198
std::vector< double > m_CurrentAngularMaxAccel
Definition: PowerCubeSim.h:205
Parameters for cob_powercube_chain.
bool getStatusMoving(int cubeNo) const
Definition: PowerCubeSim.h:153


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