You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

140 lines
3.5 KiB

#ifndef _SVRDATA_H_
#define _SVRDATA_H_
#include <new>
#include <iostream>
#include <pthread.h>
#include <queue>
#include "Singleton.h"
#include "Trajectroy.h"
#include "friComm.h"
#include "friremote.h"
#include "Mat.h"
#include "Vec.h"
#include "Robot.h"
class SvrData: public Singleton
{
private:
struct {
VecJoint jointPos;
MatCarthesian cartPos;
VecTorque forceAndTorque;
float jacobian[FRI_CART_VEC * jointNumber];
} messured;
struct {
VecJoint jointPos;
MatCarthesian cartPos;
} commanded;
struct {
struct {
VecJoint velocity;
VecJoint accelaration;
VecJoint torque;
VecJoint range;
} max;
float currentVelocityPercentage;
float currentAccelerationPercentage;
} robot;
struct {
float sampleTimeMs;
bool cancel;
bool done;
std::queue< Trajectory<jointNumber>* > list;
enum TrajectoryType type;
bool potfieldmode;
}trajectory;
friRemote* friInst;
pthread_mutex_t dataLock;
/// private constructor, because the database is a singleton
SvrData();
static bool instanceFlag;
static SvrData* single;
void updateMessurementData(
VecJoint newJointPos,
MatCarthesian newCartPos,
VecTorque newForceAndTorque
);
public:
~SvrData(void);
static SvrData* getInstance();
friRemote* getFriRemote();
void updateMessurement();
void lock();
void unlock();
VecJoint getMeasuredJointPos();
MatCarthesian getMeasuredCartPos();
int getMessuredJacobian(float* data, size_t size);
VecTorque getMessuredForceTorque();
VecJoint getMessuredJointPos();
MatCarthesian getMessuredCartPos();
VecJoint getCommandedJointPos();
void setCommandedJointPos(VecJoint newJointPos);
MatCarthesian getCommandedCartPos();
void setCommandedCartPos(MatCarthesian newCartPos);
VecJoint getMaxTorque();
VecJoint getMaxVelocity();
VecJoint getMaxAcceleration();
VecJoint getMaxRange();
bool checkJointRange(VecJoint vectorToCheck);
VecJoint getRobotVelocity();
float getRobotVelocityPercentage();
int setRobotVelocityPercentage(float newVelocityPercentage);
VecJoint getRobotAcceleration();
float getRobotAccelerationPercentage();
int setRobotAccelerationPercentage(float newAccelerationPercentage);
unsigned int getJoints();
// trajectory functions
float getSampleTimeMs();
int setSampleTimeMs(float newSampleTime);
bool getTrajectoryCancel();
class Trajectory<jointNumber>* popTrajectory();
int pushTrajectory(class Trajectory<jointNumber>* newFrajectory);
bool cancelCurrentTrajectory();
void trajectoryCancelDone();
bool getTrajectoryDone();
enum TrajectoryType getTrajectoryType();
void setTrajectoryType(enum TrajectoryType newType);
class Trajectory<jointNumber>* createTrajectory(VecJoint newJointPos);
class Trajectory<jointNumber>* createTrajectory(MatCarthesian newJointPos);
class Trajectory<jointNumber>* calculateTrajectory(
VecJoint maxJointVelocity,
VecJoint maxJointAcceleration,
VecJoint jointStart,
VecJoint jointEnd
);
int calculateAndAddNewTrajectory(VecJoint jointEnd);
void setTrajectoryPotfieldMode(bool newstate);
bool getTrajectoryPotfieldMode();
};
#endif