PowerCubeSim.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 
00018 #ifndef __POWER_CUBE_SIM_H_
00019 #define __POWER_CUBE_SIM_H_
00020 
00021 #include <schunk_powercube_chain/PowerCubeCtrl.h>
00022 #include <schunk_powercube_chain/Joint.h>
00023 #include <iostream>
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include <vector>
00027 
00028 using namespace std;
00029 #include <pthread.h>
00030 
00031 //-------------------------------------------------------------------------
00032 //                              Defines
00033 // -------------------------------------------------------------------------
00034 
00035 #define MAX_VEL 0.5
00036 #define MAX_ACC 0.5
00037 #define K13 0.5
00038 #define K14 0.5
00039 #define K15 3
00040 #define DAEMPFUNG 0.5
00041 
00042 //#define __LINUX__
00043 
00044 #ifdef SWIG
00045 %module PowerCubeSim
00046 %include "Source/Manipulation/Interfaces/armInterface.h"
00047 %{
00048   #include "PowerCubeSim.h"
00049 %}
00050 #endif
00051 
00052 class PowerCubeSim;
00053 
00054 /* Thread arguments for simulation threads*/
00055 typedef struct
00056 {
00057   PowerCubeSim* cubeSimPtr;
00058   int cubeID;
00059   double targetAngle;
00060 } SimThreadArgs;
00061 
00062 class PowerCubeSim
00063 {
00064 public:
00065   PowerCubeSim();
00066   ~PowerCubeSim();
00067 
00068   bool Init(PowerCubeCtrlParams* params);
00069 
00070   bool isInitialized() const
00071   {
00072     return m_Initialized;
00073   }
00074 
00075   std::string getErrorMessage() const
00076   {
00077     return m_ErrorMessage;
00078   }
00079 
00080   int Close()
00081   {
00082     return true;
00083   }
00084   // Arm-Ansteuerung:
00085 
00088   bool MoveJointSpaceSync(const std::vector<double>& Angle);
00089 
00091   bool MoveVel(const std::vector<double>& vel);
00092 
00094   bool Stop();
00095 
00097   // Funktionen zum setzen von Parametern: //
00099 
00102   bool setMaxVelocity(double radpersec);
00103 
00104   bool setMaxVelocity(const std::vector<double>& radpersec);
00105 
00108   bool setMaxAcceleration(double radPerSecSquared);
00109   bool setMaxAcceleration(const std::vector<double>& radPerSecSquared);
00110 
00112   // hier die Funktionen zur Statusabfrage: //
00114 
00116   bool getConfig(std::vector<double>& result);
00117 
00119   bool getJointVelocities(std::vector<double>& result);
00120 
00121   void setCurrentAngles(std::vector<double> Angles);
00122 
00123   void setCurrentJointVelocities(std::vector<double> Angles);
00124 
00127   bool statusMoving();
00128   bool statusMoving(int cubeNo);
00129 
00131   bool statusDec();
00132 
00134   bool statusAcc();
00135 
00137   // vector<int> getModuleMap(int dev);
00138 
00140   // void HomingDone();
00141 
00142   typedef enum
00143   {
00144     PC_CTRL_OK = 0,
00145     PC_CTRL_NOT_REFERENCED = -1,
00146     PC_CTRL_ERR = -2,
00147     PC_CTRL_POW_VOLT_ERR = -3
00148   } PC_CTRL_STATE;
00149   // int getStatus(){return PC_CTRL_OK;}
00150   double maxVel;
00151 
00152   void setStatusMoving(int cubeNo, bool moving);
00153   bool getStatusMoving(int cubeNo) const
00154   {
00155     return m_MovementInProgress[cubeNo];
00156   }
00157 
00158   vector<int> getModuleMap() const
00159   {
00160     return m_IdModules;
00161   }
00162   std::vector<double> getCurrentAngularMaxVel()
00163   {
00164     return m_CurrentAngularMaxVel;
00165   }
00166   std::vector<double> getCurrentAngularMaxAccel()
00167   {
00168     return m_CurrentAngularMaxAccel;
00169   }
00170   void millisleep(unsigned int milliseconds) const;
00171 
00172 protected:
00174   // void waitForSync();
00176   // void dontWaitForSync();
00179   double timeRampMove(double dtheta, double vnow, double v, double a);
00180 
00181   int startSimulatedMovement(std::vector<double> target);
00182 
00183 // void* SimThreadRoutine (void*);
00184 
00185 #ifdef COB3
00186   Manipulator* m_Obj_Manipulator;
00187 #endif
00188 
00189   int m_DOF;
00190   int m_Initialized;
00191   int m_NumOfModules;
00192   int m_Dev;
00193   vector<int> m_IdModules;
00194 
00195   std::vector<double> m_maxVel;
00196   std::vector<double> m_maxAcc;
00197 
00198   Jointd m_AngleOffsets;
00199 
00200   std::vector<bool> m_MovementInProgress;
00201 
00202   std::vector<double> m_CurrentAngles;
00203   std::vector<double> m_CurrentAngularVel;
00204   std::vector<double> m_CurrentAngularMaxVel;
00205   std::vector<double> m_CurrentAngularMaxAccel;
00206 
00207   // vector<unsigned long> startConf;
00208 
00209   std::string m_ErrorMessage;
00210 
00211   float maxAcc;
00212 
00213   pthread_mutex_t m_Angles_Mutex;
00214   pthread_mutex_t m_AngularVel_Mutex;
00215   pthread_mutex_t m_Movement_Mutex;
00216   pthread_t* m_SimThreadID;
00217   SimThreadArgs** m_SimThreadArgs;
00218 };
00219 
00220 #endif


schunk_powercube_chain
Author(s): Florian Weisshardt
autogenerated on Sat Jun 8 2019 20:25:18