|
@ -305,87 +305,96 @@ void *threadFriDataExchange(void *arg) |
|
|
// PTP Joint Movement
|
|
|
// PTP Joint Movement
|
|
|
if (__MSRCMDJNTPOS) |
|
|
if (__MSRCMDJNTPOS) |
|
|
{ |
|
|
{ |
|
|
double maxVelJntLocal[LBR_MNJ]; |
|
|
|
|
|
double maxAccJntLocal[LBR_MNJ]; |
|
|
|
|
|
double delta[LBR_MNJ]; |
|
|
|
|
|
double sampleTime = (double)0.005; |
|
|
|
|
|
double deltaAbs[LBR_MNJ]; |
|
|
|
|
|
double dMaxSpeed[LBR_MNJ]; |
|
|
|
|
|
double lMaxSpeed[LBR_MNJ]; |
|
|
|
|
|
double dGesamt[LBR_MNJ]; |
|
|
|
|
|
|
|
|
|
|
|
double currentInk[LBR_MNJ] = {0}; |
|
|
|
|
|
double currentInkLast[LBR_MNJ] = {0}; |
|
|
|
|
|
double currentDist [LBR_MNJ] = {0}; |
|
|
|
|
|
double currentDistLast [LBR_MNJ] = {0}; |
|
|
|
|
|
|
|
|
|
|
|
Vec<float,LBR_MNJ> maxVelocity = SvrData::getInstance()->getMaxVelocity(); |
|
|
|
|
|
Vec<float,LBR_MNJ> maxAccelaration = SvrData::getInstance()->getMaxAcceleration(); |
|
|
|
|
|
|
|
|
Vec<float,LBR_MNJ> maxJointLocalVelocity; |
|
|
|
|
|
Vec<float,LBR_MNJ> maxJointLocalAcceleration; |
|
|
|
|
|
Vec<float,LBR_MNJ> delta; |
|
|
|
|
|
Vec<float,LBR_MNJ> deltaAbs; |
|
|
|
|
|
Vec<float,LBR_MNJ> dMaxSpeed; |
|
|
|
|
|
Vec<float,LBR_MNJ> lMaxSpeed; |
|
|
|
|
|
Vec<float,LBR_MNJ> dGesamt; |
|
|
|
|
|
float sampleTime = 0.005f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get current robot constraints
|
|
|
|
|
|
Vec<float,LBR_MNJ> maxVelocityJoint = SvrData::getInstance()->getMaxVelocity(); |
|
|
|
|
|
Vec<float,LBR_MNJ> maxAccelarationJoint = SvrData::getInstance()->getMaxAcceleration(); |
|
|
|
|
|
Vec<float,LBR_MNJ> messuredJointPos = SvrData::getInstance()->getMessuredJointPos(); |
|
|
|
|
|
Vec<float,LBR_MNJ> commandedJointPos = SvrData::getInstance()->getCommandedJointPos(); |
|
|
|
|
|
|
|
|
|
|
|
float velocity = SvrData::getInstance()->getRobotVelocity(); |
|
|
|
|
|
float accelaration = SvrData::getInstance()->getRobotAcceleration(); |
|
|
|
|
|
|
|
|
// calculate delta positions of movement
|
|
|
// calculate delta positions of movement
|
|
|
for ( int i= 0; i < LBR_MNJ; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
delta[i] = MSRCMDJNTPOS[i]-(MSRMSRJNTPOS[i]*180/M_PI); |
|
|
|
|
|
deltaAbs[i] = fabs(MSRCMDJNTPOS[i]-(MSRMSRJNTPOS[i]*180/M_PI)); |
|
|
|
|
|
maxVelJntLocal[i] = maxVelJnt[i]*sampleTime*(VELOCITY/100.0); |
|
|
|
|
|
maxAccJntLocal[i] = maxAccJnt[i]*sampleTime*(ACCELARATION/100.0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
delta = commandedJointPos - messuredJointPos; |
|
|
|
|
|
deltaAbs = delta.abs(); |
|
|
|
|
|
maxJointLocalVelocity = maxVelocityJoint * sampleTime * (velocity/100.0f); |
|
|
|
|
|
maxJointLocalAcceleration = maxAccelarationJoint * sampleTime * (accelaration/100.0f); |
|
|
|
|
|
|
|
|
|
|
|
// calculate number of movement steps
|
|
|
|
|
|
dMaxSpeed = maxJointLocalVelocity.celldivide(maxJointLocalAcceleration); |
|
|
|
|
|
lMaxSpeed = dMaxSpeed.cellmultiply(dMaxSpeed).cellmultiply(maxJointLocalAcceleration) * 0.5f; |
|
|
|
|
|
|
|
|
// calculate movement steps
|
|
|
|
|
|
for (int j=0; j<LBR_MNJ; j++) |
|
|
for (int j=0; j<LBR_MNJ; j++) |
|
|
{ |
|
|
{ |
|
|
dMaxSpeed[j] = maxVelJntLocal[j]/maxAccJntLocal[j]; |
|
|
|
|
|
lMaxSpeed[j] = dMaxSpeed[j]*dMaxSpeed[j]*maxAccJntLocal[j]*0.5; |
|
|
|
|
|
if (lMaxSpeed[j] > deltaAbs[j]/(double)2.0) |
|
|
|
|
|
|
|
|
if (lMaxSpeed(j) > deltaAbs(j)/(double)2.0) |
|
|
{ |
|
|
{ |
|
|
dGesamt[j] = sqrt(deltaAbs[j]/maxAccJntLocal[j])*2.0; |
|
|
|
|
|
|
|
|
dGesamt(j) = sqrt(deltaAbs(j) / maxJointLocalAcceleration (j))*2.0; |
|
|
} else |
|
|
} else |
|
|
{ |
|
|
{ |
|
|
dGesamt[j] = dMaxSpeed[j]*2 + (deltaAbs[j]-lMaxSpeed[j]*2.0)/maxVelJntLocal[j]; |
|
|
|
|
|
|
|
|
dGesamt(j) = dMaxSpeed(j)*2 + (deltaAbs(j)-lMaxSpeed(j)*2.0)/maxJointLocalVelocity(j); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
int maxSteps =ceil(*max_element(dGesamt,(dGesamt+LBR_MNJ-1))); |
|
|
|
|
|
|
|
|
int maxSteps = ceil(dGesamt.max()); |
|
|
|
|
|
|
|
|
|
|
|
// there are atleast 2 steps otherwise it is no trajectory
|
|
|
if (maxSteps == 0 || maxSteps == 1) |
|
|
if (maxSteps == 0 || maxSteps == 1) |
|
|
goto end; |
|
|
goto end; |
|
|
|
|
|
|
|
|
for (int j=0; j<LBR_MNJ; j++) |
|
|
for (int j=0; j<LBR_MNJ; j++) |
|
|
{ |
|
|
{ |
|
|
dMaxSpeed[j] = ceil(maxSteps/(double)2 - sqrt((maxSteps/(double)2)*(maxSteps/(double)2) - deltaAbs[j]/maxAccJntLocal[j])); |
|
|
|
|
|
double temp = maxSteps/(double)2 - sqrt((maxSteps/(double)2)*(maxSteps/(double)2) - deltaAbs[j]/maxAccJntLocal[j]); |
|
|
|
|
|
if (dMaxSpeed[j]==0) |
|
|
|
|
|
|
|
|
dMaxSpeed(j) = ceil( maxSteps /2.0f - sqrt((maxSteps/2.0f)*(maxSteps/2.0f) - deltaAbs(j)/maxAccelarationJoint(j))); |
|
|
|
|
|
if (dMaxSpeed(j) == 0.0f) |
|
|
{ |
|
|
{ |
|
|
maxAccJntLocal[j] = 0; |
|
|
|
|
|
|
|
|
maxJointLocalAcceleration(j) = 0.0f; |
|
|
} else |
|
|
} else |
|
|
{ |
|
|
{ |
|
|
maxAccJntLocal[j] = -deltaAbs[j]/(dMaxSpeed[j]*dMaxSpeed[j]-maxSteps*dMaxSpeed[j]); |
|
|
|
|
|
|
|
|
maxJointLocalAcceleration(j) = -deltaAbs(j)/(dMaxSpeed(j)*dMaxSpeed(j)-maxSteps*dMaxSpeed(j)); |
|
|
} |
|
|
} |
|
|
maxVelJntLocal[j] = dMaxSpeed[j]*maxAccJntLocal[j]; |
|
|
|
|
|
|
|
|
maxJointLocalVelocity(j) = dMaxSpeed(j)*maxJointLocalAcceleration(j); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// do the trajectory
|
|
|
|
|
|
{ |
|
|
|
|
|
Vec<float,LBR_MNJ> currentInk; |
|
|
|
|
|
Vec<float,LBR_MNJ> currentInkLast; |
|
|
|
|
|
Vec<float,LBR_MNJ> currentDist; |
|
|
|
|
|
Vec<float,LBR_MNJ> currentDistLast; |
|
|
for (int i=0;i<maxSteps;i++) |
|
|
for (int i=0;i<maxSteps;i++) |
|
|
{ |
|
|
{ |
|
|
for (int j=0;j<LBR_MNJ;j++) |
|
|
for (int j=0;j<LBR_MNJ;j++) |
|
|
{ |
|
|
{ |
|
|
if (i+1 <= maxSteps/(double)2) |
|
|
|
|
|
|
|
|
if (i+1 <= maxSteps/2.0f) |
|
|
{ |
|
|
{ |
|
|
currentInk[j] = min(currentInkLast[j]+maxAccJntLocal[j],maxVelJntLocal[j]); |
|
|
|
|
|
}else if (i+1 > maxSteps-dMaxSpeed[j]) |
|
|
|
|
|
|
|
|
currentInk(j) = min(currentInkLast(j)+maxJointLocalAcceleration(j),maxJointLocalVelocity(j)); |
|
|
|
|
|
}else if (i+1 > maxSteps-dMaxSpeed(j)) |
|
|
{ |
|
|
{ |
|
|
currentInk[j] = max(currentInkLast[j]-maxAccJntLocal[j],(double)0); |
|
|
|
|
|
|
|
|
currentInk(j) = max(currentInkLast(j)-maxJointLocalAcceleration(j),0.0f); |
|
|
}else |
|
|
}else |
|
|
{ |
|
|
{ |
|
|
currentInk[j] = currentInkLast[j]; |
|
|
|
|
|
|
|
|
currentInk(j) = currentInkLast(j); |
|
|
} |
|
|
} |
|
|
currentDist[j] = currentDistLast[j] + sgn(delta[j])*currentInk[j]; |
|
|
|
|
|
currentInkLast[j] = currentInk[j]; |
|
|
|
|
|
currentDistLast[j] = currentDist[j]; |
|
|
|
|
|
MSRMSRJNTPOS[j]+= sgn(delta[j])*currentInk[j]*(1./180*M_PI); |
|
|
|
|
|
|
|
|
currentDist(j) = currentDistLast(j) + sgn(delta(j))*currentInk(j); |
|
|
|
|
|
currentInkLast(j) = currentInk(j); |
|
|
|
|
|
currentDistLast(j) = currentDist(j); |
|
|
|
|
|
MSRMSRJNTPOS[j]+= sgn(delta(j))*currentInk(j)*(1./180*M_PI); |
|
|
} |
|
|
} |
|
|
|
|
|
// set new position
|
|
|
friInst.doPositionControl(MSRMSRJNTPOS); |
|
|
friInst.doPositionControl(MSRMSRJNTPOS); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
end: |
|
|
end: |
|
|
|
|
|
// mark state to be done
|
|
|
__MSRCMDJNTPOS = false; |
|
|
__MSRCMDJNTPOS = false; |
|
|
|
|
|
|
|
|
} else if (__CARTMOVE) |
|
|
} else if (__CARTMOVE) |
|
|