|
@ -2,7 +2,11 @@ |
|
|
#include <errno.h>
|
|
|
#include <errno.h>
|
|
|
#include <stdio.h>
|
|
|
#include <stdio.h>
|
|
|
#include <string.h>
|
|
|
#include <string.h>
|
|
|
|
|
|
#include "Trajectroy.h"
|
|
|
#include "SvrData.h"
|
|
|
#include "SvrData.h"
|
|
|
|
|
|
#include "friComm.h"
|
|
|
|
|
|
#include "friremote.h"
|
|
|
|
|
|
#include <boost/thread/thread.hpp>
|
|
|
|
|
|
|
|
|
bool SvrData::instanceFlag = false; |
|
|
bool SvrData::instanceFlag = false; |
|
|
SvrData* SvrData::single = 0; |
|
|
SvrData* SvrData::single = 0; |
|
@ -18,19 +22,23 @@ SvrData::SvrData(void) |
|
|
|
|
|
|
|
|
robot.currentVelocity = 20; |
|
|
robot.currentVelocity = 20; |
|
|
robot.currentAcceleration = 10; |
|
|
robot.currentAcceleration = 10; |
|
|
robot.joints = LBR_MNJ; |
|
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < robot.joints; ++i) |
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < JOINT_NUMBER; ++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]; |
|
|
|
|
|
|
|
|
robot.max.velocity(i) = maxVelJnt[i]; |
|
|
|
|
|
robot.max.accelaration(i) = maxAccJnt[i]; |
|
|
|
|
|
robot.max.torque(i) = maxTrqJnt[i]; |
|
|
|
|
|
robot.max.range(i) = maxRangeJnt[i]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
trajectory.sampleTimeMs = 5.0f; |
|
|
|
|
|
trajectory.cancel = false; |
|
|
|
|
|
|
|
|
// init mutex for database
|
|
|
// init mutex for database
|
|
|
if (pthread_mutex_init(&dataLock, NULL) != 0) |
|
|
if (pthread_mutex_init(&dataLock, NULL) != 0) |
|
|
printf("mutex init failed\n"); |
|
|
printf("mutex init failed\n"); |
|
|
|
|
|
|
|
|
|
|
|
this->friInst = new friRemote; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
SvrData::~SvrData() |
|
|
SvrData::~SvrData() |
|
@ -48,57 +56,83 @@ SvrData* SvrData::getInstance () |
|
|
return single; |
|
|
return single; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SvrData::lock() |
|
|
|
|
|
|
|
|
friRemote* SvrData::getFriRemote() |
|
|
{ |
|
|
{ |
|
|
|
|
|
friRemote* retval = NULL; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
|
|
|
retval = this->friInst; |
|
|
|
|
|
pthread_mutex_unlock(&dataLock); |
|
|
|
|
|
return retval; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrData::unlock() |
|
|
|
|
|
|
|
|
void SvrData::updateMessurementData( |
|
|
|
|
|
VecJoint newJointPos, |
|
|
|
|
|
MatCarthesian newCartPos, |
|
|
|
|
|
VecTorque newForceAndTorque |
|
|
|
|
|
) |
|
|
{ |
|
|
{ |
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
|
|
|
this->messured.jointPos = newJointPos; |
|
|
|
|
|
this->messured.cartPos = newCartPos; |
|
|
|
|
|
this->messured.forceAndTorque = newForceAndTorque; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int SvrData::getMessuredJointPos(float* data, size_t size) |
|
|
|
|
|
|
|
|
void SvrData::updateMessurement() |
|
|
{ |
|
|
{ |
|
|
if (data == NULL) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
if (size != sizeof(messured.jointPos)) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
VecJoint newJointPos(0.0f); |
|
|
|
|
|
MatCarthesian newCartPos(0.0f,1.0f); |
|
|
|
|
|
VecTorque newForceAndTorque(0.0f); |
|
|
|
|
|
|
|
|
|
|
|
/// do the update using fri
|
|
|
|
|
|
/// update current joint positions
|
|
|
|
|
|
VecJoint newJointPosComanded(friInst->getMsrCmdJntPosition()); |
|
|
|
|
|
VecJoint newJointPosOffset(friInst->getMsrCmdJntPositionOffset()); |
|
|
|
|
|
newJointPos = newJointPosComanded + newJointPosOffset; |
|
|
|
|
|
|
|
|
|
|
|
/// update current cart position
|
|
|
|
|
|
newCartPos = friInst->getMsrCartPosition(); |
|
|
|
|
|
|
|
|
|
|
|
/// update current force and torque
|
|
|
|
|
|
newForceAndTorque = friInst->getFTTcp(); |
|
|
|
|
|
|
|
|
|
|
|
updateMessurementData(newJointPos,newCartPos,newForceAndTorque); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SvrData::lock() |
|
|
|
|
|
{ |
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
memcpy(data,messured.jointPos,size); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SvrData::unlock() |
|
|
|
|
|
{ |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return 0; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Vec<float,LBR_MNJ> SvrData::getMessuredJointPos() |
|
|
|
|
|
|
|
|
VecJoint SvrData::getMessuredJointPos() |
|
|
{ |
|
|
{ |
|
|
Vec<float,LBR_MNJ> buf ; |
|
|
|
|
|
|
|
|
VecJoint buf; |
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
buf = messured.jointPos; |
|
|
buf = messured.jointPos; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return buf; |
|
|
return buf; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int SvrData::getMessuredCartPos (float* data, size_t size) |
|
|
|
|
|
|
|
|
MatCarthesian SvrData::getMessuredCartPos() |
|
|
{ |
|
|
{ |
|
|
if (data == NULL) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
if (size != sizeof(messured.cartPos)) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MatCarthesian buf; |
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
memcpy(data,messured.cartPos,size); |
|
|
|
|
|
|
|
|
buf = messured.cartPos; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return 0 ; |
|
|
|
|
|
|
|
|
return buf; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Mat<float,LBR_MNJ> SvrData::getMessuredCartPos() |
|
|
|
|
|
|
|
|
VecTorque SvrData::getMessuredForceTorque() |
|
|
{ |
|
|
{ |
|
|
Mat<float,LBR_MNJ> buf ; |
|
|
|
|
|
|
|
|
VecTorque buf; |
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
buf = messured.cartPos; |
|
|
|
|
|
|
|
|
buf = messured.forceAndTorque; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return buf; |
|
|
return buf; |
|
|
} |
|
|
} |
|
@ -116,226 +150,225 @@ int SvrData::getMessuredJacobian(float* data, size_t size) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int SvrData::getMessuredForceTorque(float* data, size_t size) |
|
|
|
|
|
|
|
|
VecJoint SvrData::getCommandedJointPos() |
|
|
{ |
|
|
{ |
|
|
if (data == NULL) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
if (size != sizeof(messured.forceAndTorque)) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VecJoint buff; |
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
memcpy(data,messured.forceAndTorque,size); |
|
|
|
|
|
|
|
|
buff = commanded.jointPos; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return 0; |
|
|
|
|
|
|
|
|
return buff; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int SvrData::getCommandedJointPos(float* data, size_t size) |
|
|
|
|
|
|
|
|
void SvrData::setCommandedJointPos(VecJoint newJointPos) |
|
|
{ |
|
|
{ |
|
|
if (data == NULL) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
if (size != sizeof(commanded.jointPos)) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
memcpy(data,commanded.jointPos,size); |
|
|
|
|
|
|
|
|
commanded.jointPos = newJointPos; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
} |
|
|
Vec<float, LBR_MNJ> SvrData::getCommandedJointPos() |
|
|
|
|
|
|
|
|
MatCarthesian SvrData::getCommandedCartPos () |
|
|
{ |
|
|
{ |
|
|
Vec<float, LBR_MNJ> buff; |
|
|
|
|
|
|
|
|
MatCarthesian buff; |
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
buff = commanded.jointPos; |
|
|
|
|
|
|
|
|
buff = commanded.cartPos; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return buff; |
|
|
return buff; |
|
|
} |
|
|
} |
|
|
int SvrData::getCommandedCartPos (float* data, size_t size) |
|
|
|
|
|
|
|
|
void SvrData::setCommandedCartPos(MatCarthesian newCartPos) |
|
|
{ |
|
|
{ |
|
|
if (data == NULL) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
if (size != sizeof(commanded.cartPos)) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
memcpy(data,commanded.cartPos,size); |
|
|
|
|
|
|
|
|
commanded.cartPos = newCartPos; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
} |
|
|
Mat<float, LBR_MNJ> SvrData::getCommandedCartPos () |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VecJoint SvrData::getMaxTorque() |
|
|
{ |
|
|
{ |
|
|
Mat<float, LBR_MNJ> buff; |
|
|
|
|
|
|
|
|
VecJoint buff; |
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
buff = commanded.cartPos; |
|
|
|
|
|
|
|
|
buff = robot.max.torque; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return buff; |
|
|
return buff; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
float SvrData::getMaxTorque(unsigned int pos) |
|
|
|
|
|
|
|
|
VecJoint SvrData::getMaxAcceleration() |
|
|
{ |
|
|
{ |
|
|
float retval = -1.0f; |
|
|
|
|
|
if (pos >= robot.joints) |
|
|
|
|
|
return retval; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VecJoint buff; |
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
retval = robot.max.torque[pos-1]; |
|
|
|
|
|
|
|
|
buff = robot.max.accelaration; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return retval; |
|
|
|
|
|
|
|
|
return buff; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int SvrData::getMaxTorque(float* data, size_t size) |
|
|
|
|
|
|
|
|
VecJoint SvrData::getMaxVelocity() |
|
|
{ |
|
|
{ |
|
|
if (data == NULL) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
if (size != sizeof(float)* robot.joints) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
VecJoint buff; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
memcpy(data,robot.max.torque,size); |
|
|
|
|
|
|
|
|
buff = robot.max.velocity; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return 0; |
|
|
|
|
|
|
|
|
return buff; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
float SvrData::getMaxAcceleration(unsigned int pos) |
|
|
|
|
|
|
|
|
VecJoint SvrData::getMaxRange() |
|
|
{ |
|
|
{ |
|
|
float retval = -1.0f; |
|
|
|
|
|
if (pos >= robot.joints) |
|
|
|
|
|
return retval; |
|
|
|
|
|
|
|
|
VecJoint buff; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
retval = robot.max.accelaration[pos-1]; |
|
|
|
|
|
|
|
|
buff = robot.max.range; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return retval; |
|
|
|
|
|
|
|
|
return buff; |
|
|
} |
|
|
} |
|
|
int SvrData::getMaxAcceleration(float* data, size_t size) |
|
|
|
|
|
|
|
|
bool SvrData::checkJointRange(VecJoint vectorToCheck) |
|
|
{ |
|
|
{ |
|
|
if (data == NULL) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
if (size != sizeof(float)* robot.joints) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
bool retval = false; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
memcpy(data,robot.max.accelaration,size); |
|
|
|
|
|
|
|
|
Vec<float,LBR_MNJ> maxJointRange; |
|
|
|
|
|
maxJointRange = robot.max.range; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i<JOINT_NUMBER; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
if (abs(vectorToCheck(i)) > abs(maxJointRange(i))) |
|
|
|
|
|
{ |
|
|
|
|
|
// join angle is too big
|
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// no join angle is too big
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
Vec<float,LBR_MNJ> SvrData::getMaxAcceleration() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int SvrData::setRobotVelocity(float newVelocity) |
|
|
{ |
|
|
{ |
|
|
Vec<float,LBR_MNJ> buff; |
|
|
|
|
|
|
|
|
unsigned int retval = 0; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
buff = robot.max.accelaration; |
|
|
|
|
|
|
|
|
robot.currentVelocity = newVelocity; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return buff; |
|
|
|
|
|
|
|
|
return retval; |
|
|
} |
|
|
} |
|
|
float SvrData::getMaxVelocity(unsigned int pos) |
|
|
|
|
|
|
|
|
float SvrData::getRobotVelocity() |
|
|
{ |
|
|
{ |
|
|
float retval = -1.0f; |
|
|
|
|
|
if (pos >= robot.joints) |
|
|
|
|
|
return retval; |
|
|
|
|
|
|
|
|
float retval = 0; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
retval = robot.max.velocity[pos-1]; |
|
|
|
|
|
|
|
|
retval = robot.currentVelocity; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return retval; |
|
|
return retval; |
|
|
} |
|
|
} |
|
|
int SvrData::getMaxVelocity(float* data, size_t size) |
|
|
|
|
|
|
|
|
int SvrData::setRobotAcceleration(float newAcceleration) |
|
|
{ |
|
|
{ |
|
|
if (data == NULL) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
if (size != sizeof(float)* robot.joints) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
unsigned int retval = 0; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
memcpy(data,robot.max.velocity,size); |
|
|
|
|
|
|
|
|
robot.currentAcceleration = newAcceleration; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return 0; |
|
|
|
|
|
|
|
|
return retval; |
|
|
} |
|
|
} |
|
|
Vec<float,LBR_MNJ> SvrData::getMaxVelocity() |
|
|
|
|
|
|
|
|
float SvrData::getRobotAcceleration() |
|
|
{ |
|
|
{ |
|
|
Vec<float,LBR_MNJ> buff; |
|
|
|
|
|
|
|
|
float retval = 0; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
buff = robot.max.velocity; |
|
|
|
|
|
|
|
|
retval = robot.currentAcceleration; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return buff; |
|
|
|
|
|
|
|
|
return retval; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
float SvrData::getMaxRange(unsigned int pos) |
|
|
|
|
|
|
|
|
unsigned int SvrData::getJoints() |
|
|
{ |
|
|
{ |
|
|
float retval = -1.0f; |
|
|
|
|
|
if (pos >= robot.joints) |
|
|
|
|
|
return retval; |
|
|
|
|
|
|
|
|
unsigned int retval = 0; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
retval = robot.max.range[pos-1]; |
|
|
|
|
|
|
|
|
retval = JOINT_NUMBER; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return retval; |
|
|
return retval; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int SvrData::getMaxRange(float* data, size_t size) |
|
|
|
|
|
|
|
|
/// Trajectory function
|
|
|
|
|
|
float SvrData::getSampleTimeMs() |
|
|
{ |
|
|
{ |
|
|
if (data == NULL) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
if (size != sizeof(float)* robot.joints) |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
float retval = 0; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
memcpy(data,robot.max.range,size); |
|
|
|
|
|
|
|
|
retval = trajectory.sampleTimeMs; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return 0; |
|
|
|
|
|
|
|
|
return retval; |
|
|
} |
|
|
} |
|
|
Vec<float, LBR_MNJ> SvrData::getMaxRange() |
|
|
|
|
|
|
|
|
int SvrData::setSampleTimeMs(float newSampleTimeMs) |
|
|
{ |
|
|
{ |
|
|
Vec<float, LBR_MNJ> retval ; |
|
|
|
|
|
|
|
|
int retval = 0; |
|
|
|
|
|
|
|
|
|
|
|
// sample time can not be negative or 0
|
|
|
|
|
|
if (newSampleTimeMs <= 0.0f) |
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
retval = robot.max.range; |
|
|
|
|
|
|
|
|
trajectory.sampleTimeMs = newSampleTimeMs; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return retval; |
|
|
return retval; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int SvrData::setRobotVelocity(float newVelocity) |
|
|
|
|
|
|
|
|
class Trajectory<JOINT_NUMBER>* SvrData::popTrajectory() |
|
|
{ |
|
|
{ |
|
|
unsigned int retval = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Trajectory<JOINT_NUMBER>* retval = NULL; |
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
robot.currentVelocity = newVelocity; |
|
|
|
|
|
|
|
|
retval = trajectory.list.front(); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return retval; |
|
|
return retval; |
|
|
} |
|
|
} |
|
|
float SvrData::getRobotVelocity() |
|
|
|
|
|
|
|
|
int SvrData::pushTrajectory(class Trajectory<JOINT_NUMBER>* newTrajectory) |
|
|
{ |
|
|
{ |
|
|
float retval = 0; |
|
|
|
|
|
|
|
|
if (newTrajectory == NULL) |
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
retval = robot.currentVelocity; |
|
|
|
|
|
|
|
|
trajectory.list.push(newTrajectory); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return retval; |
|
|
|
|
|
|
|
|
return 0; |
|
|
} |
|
|
} |
|
|
int SvrData::setRobotAcceleration(float newAcceleration) |
|
|
|
|
|
|
|
|
bool SvrData::getTrajectoryCancel() |
|
|
{ |
|
|
{ |
|
|
unsigned int retval = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool retval = false; |
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
robot.currentAcceleration = newAcceleration; |
|
|
|
|
|
|
|
|
retval = trajectory.cancel; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return retval; |
|
|
return retval; |
|
|
} |
|
|
} |
|
|
float SvrData::getRobotAcceleration() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool SvrData::cancelCurrentTrajectory() |
|
|
{ |
|
|
{ |
|
|
float retval = 0; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
|
|
|
// set cancel state
|
|
|
|
|
|
trajectory.cancel = true; |
|
|
|
|
|
|
|
|
|
|
|
// clear trajectory list
|
|
|
|
|
|
while(!trajectory.list.empty()) |
|
|
|
|
|
{ |
|
|
|
|
|
class Trajectory<JOINT_NUMBER>* currentTrajectory = trajectory.list.front(); |
|
|
|
|
|
if(currentTrajectory != NULL) |
|
|
|
|
|
delete currentTrajectory; |
|
|
|
|
|
trajectory.list.pop(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&dataLock); |
|
|
|
|
|
|
|
|
|
|
|
// wait for stop signaled by calling cancel done
|
|
|
|
|
|
bool run = true; |
|
|
|
|
|
while (run) |
|
|
|
|
|
{ |
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
retval = robot.currentAcceleration; |
|
|
|
|
|
|
|
|
if (trajectory.cancel == false) |
|
|
|
|
|
{ |
|
|
|
|
|
run = false; |
|
|
|
|
|
} |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return retval; |
|
|
|
|
|
|
|
|
boost::this_thread::sleep( boost::posix_time::milliseconds(trajectory.sampleTimeMs) ); |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
} |
|
|
} |
|
|
unsigned int SvrData::getJoints() |
|
|
|
|
|
|
|
|
void SvrData::trajectoryCancelDone() |
|
|
{ |
|
|
{ |
|
|
unsigned int retval = 0; |
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_lock(&dataLock); |
|
|
pthread_mutex_lock(&dataLock); |
|
|
retval = robot.joints; |
|
|
|
|
|
|
|
|
trajectory.cancel = false; |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
pthread_mutex_unlock(&dataLock); |
|
|
return retval; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|