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.
 
 
 
 
 
 

142 lines
3.9 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:
/// measured units from the robot
struct {
/// current measured joint position in [ degree ]
Robot::VecJoint jointPos;
/// current measured homogeneous cartesian position
MatCarthesian cartPos;
/// current measured force and torque for the end effector in [ Nm ]
VecTorque forceAndTorque;
/// current measured Jacobian matrix for the robot
float jacobian[FRI_CART_VEC * Robot::joints];
} measured;
// commanded position for the robot
struct {
// the last commanded position for the joint angles
Robot::VecJoint jointPos;
// the last commanded position for the homogeneous cartesian position
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();
int getMeasuredJacobian(float* data, size_t size);
VecTorque getMeasuredForceTorque();
Robot::VecJoint getMeasuredJointPos();
MatCarthesian getMeasuredCartPos();
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();
Robot::VecJoint getMinRange();
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();
class Robot* getRobot();
// 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