3 changed files with 137 additions and 0 deletions
@ -0,0 +1,9 @@ |
|||
class Singleton |
|||
{ |
|||
public: |
|||
Singleton* getInstance(void); |
|||
Singleton() {}; |
|||
~Singleton() {}; |
|||
private: |
|||
static Singleton* single; |
|||
}; |
@ -0,0 +1,58 @@ |
|||
#include "SvrData.h"
|
|||
bool SvrData::instanceFlag = false; |
|||
SvrData* SvrData::single = 0; |
|||
|
|||
SvrData::SvrData(void) |
|||
{ |
|||
velocity = 20; |
|||
accelaration = 10; |
|||
robot.joints = LBR_MNJ; |
|||
|
|||
robot.max.velocity = new float[robot.joints]; |
|||
robot.max.accelaration = new float[robot.joints]; |
|||
robot.max.torque = new float[robot.joints]; |
|||
robot.max.range = new float[robot.joints]; |
|||
|
|||
double maxVelJnt[] = {110.0,110.0,128.0,128.0,204.0,184.0,184.0}; |
|||
double maxAccJnt[] = {1.0,1.0,1.0,1.0,2.0,1.0,1.0}; |
|||
double maxTrqJnt[] = {176.0,176.0,100.0,100.0,100.0,38.0,38.0}; |
|||
double maxRangeJnt[] = {170.0,120.0,170.0,120.0,170.0,120.0,170.0}; |
|||
|
|||
|
|||
for (int i = 0; i < robot.joints; ++i) |
|||
{ |
|||
robot.max.velocity[i] = maxVelJnt[i]; |
|||
robot.max.accelaration[i] = maxAccJnt[i]; |
|||
robot.max.torque[i] = maxTrqJnt[i]; |
|||
robot.max.range[i] = maxRangeJnt[i]; |
|||
} |
|||
} |
|||
SvrData::~SvrData() |
|||
{ |
|||
if (robot.max.velocity != 0) |
|||
delete[] robot.max.velocity; |
|||
|
|||
if (robot.max.accelaration != 0) |
|||
delete[] robot.max.accelaration; |
|||
|
|||
if (robot.max.torque != 0) |
|||
delete[] robot.max.torque; |
|||
|
|||
if (robot.max.velocity != 0) |
|||
delete[] robot.max.range; |
|||
|
|||
robot.max.velocity = 0; |
|||
robot.max.accelaration = 0; |
|||
robot.max.torque = 0; |
|||
robot.max.range = 0; |
|||
} |
|||
|
|||
SvrData* SvrData::getInstance () |
|||
{ |
|||
if (instanceFlag) |
|||
return single; |
|||
|
|||
single = new SvrData(); |
|||
instanceFlag = true; |
|||
return single; |
|||
} |
@ -0,0 +1,70 @@ |
|||
|
|||
#ifndef _SVRDATA_H_ |
|||
#define _SVRDATA_H_ |
|||
|
|||
#include <new> |
|||
#include <iostream> |
|||
#include <pthread.h> |
|||
|
|||
#include "Singleton.h" |
|||
#include "friComm.h" |
|||
|
|||
|
|||
class SvrData: public Singleton |
|||
{ |
|||
private: |
|||
struct { |
|||
float jointPos[LBR_MNJ]; |
|||
float cartPos[FRI_CART_FRM_DIM]; |
|||
float jacobian[FRI_CART_VEC * LBR_MNJ]; |
|||
float forceAndTorque[FRI_CART_VEC]; |
|||
} messured; |
|||
struct { |
|||
float jointPos[LBR_MNJ]; |
|||
float cartPos[FRI_CART_FRM_DIM]; |
|||
float pose[3][4]; //TODO what is this for |
|||
} commanded; |
|||
|
|||
float velocity; |
|||
float accelaration; |
|||
|
|||
struct { |
|||
struct { |
|||
float* velocity; |
|||
float* accelaration; |
|||
float* torque; |
|||
float* range; |
|||
} max; |
|||
unsigned int joints; |
|||
} robot; |
|||
|
|||
pthread_mutex_t mutexsum; |
|||
|
|||
/// private constructor, because the database is a singleton |
|||
SvrData(); |
|||
|
|||
static bool instanceFlag; |
|||
static SvrData* single; |
|||
|
|||
public: |
|||
~SvrData(void); |
|||
SvrData* getInstance(); |
|||
|
|||
float getMaxTorque(unsigned int pos); |
|||
int getMaxTorque(float* data, size_t size); |
|||
|
|||
float getMaxAccelaration(unsigned int pos); |
|||
int getMaxAccelaration(float* data, size_t size); |
|||
|
|||
float getMaxRange(unsigned int pos); |
|||
int getMaxRange(float* data, size_t size); |
|||
|
|||
unsigned int getJoints(); |
|||
|
|||
float getTrajectoryVelocity(); |
|||
int setTrajectoryVelocity(float); |
|||
|
|||
float getTrajectoryAccelaration(); |
|||
float setTrajectoryAccelaration(float); |
|||
}; |
|||
#endif |
Write
Preview
Loading…
Cancel
Save
Reference in new issue