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.
 
 
 
 
 
 

132 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 {
Robot::VecJoint jointPos;
MatCarthesian cartPos;
VecTorque forceAndTorque;
float jacobian[FRI_CART_VEC * Robot::joints];
} messured;
struct {
Robot::VecJoint jointPos;
MatCarthesian cartPos;
} commanded;
struct {
Robot* robotClass;
float currentVelocityPercentage;
float currentAccelerationPercentage;
} robot;
struct {
float sampleTimeMs;
bool cancel;
bool done;
std::queue< Trajectory<Robot::joints>* > 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 updateMeasurementData(
Robot::VecJoint newJointPos,
MatCarthesian newCartPos,
VecTorque newForceAndTorque
);
public:
~SvrData(void);
static SvrData* getInstance();
friRemote* getFriRemote();
void updateMeasurement();
Robot::VecJoint getMeasuredJointPos();
MatCarthesian getMeasuredCartPos();
int getMessuredJacobian(float* data, size_t size);
VecTorque getMessuredForceTorque();
Robot::VecJoint getMessuredJointPos();
MatCarthesian getMessuredCartPos();
Robot::VecJoint getCommandedJointPos();
void setCommandedJointPos(Robot::VecJoint newJointPos);
MatCarthesian getCommandedCartPos();
void setCommandedCartPos(MatCarthesian newCartPos);
Robot::VecJoint getMaxTorque();
Robot::VecJoint getMaxVelocity();
Robot::VecJoint getMaxAcceleration();
Robot::VecJoint getMaxRange();
bool checkJointRange(Robot::VecJoint vectorToCheck);
Robot::VecJoint getRobotVelocity();
float getRobotVelocityPercentage();
int setRobotVelocityPercentage(float newVelocityPercentage);
Robot::VecJoint getRobotAcceleration();
float getRobotAccelerationPercentage();
int setRobotAccelerationPercentage(float newAccelerationPercentage);
unsigned int getJoints();
// trajectory functions
float getSampleTimeMs();
int setSampleTimeMs(float newSampleTime);
bool getTrajectoryCancel();
class Trajectory<Robot::joints>* popTrajectory();
int pushTrajectory(class Trajectory<Robot::joints>* newFrajectory);
bool cancelCurrentTrajectory();
void trajectoryCancelDone();
bool getTrajectoryDone();
enum TrajectoryType getTrajectoryType();
void setTrajectoryType(enum TrajectoryType newType);
class Trajectory<Robot::joints>* createTrajectory(Robot::VecJoint newJointPos);
class Trajectory<Robot::joints>* createTrajectory(MatCarthesian newJointPos);
class Trajectory<Robot::joints>* calculateTrajectory(
Robot::VecJoint maxJointVelocity,
Robot::VecJoint maxJointAcceleration,
Robot::VecJoint jointStart,
Robot::VecJoint jointEnd
);
int calculateAndAddNewTrajectory(Robot::VecJoint jointEnd);
void setTrajectoryPotfieldMode(bool newstate);
bool getTrajectoryPotfieldMode();
};
#endif