|
@ -33,12 +33,14 @@ class BangBangJointTrajectory : public Trajectory<SIZE> |
|
|
// calculate number of movement steps |
|
|
// calculate number of movement steps |
|
|
// one joint has to reach maxvelocity the others are stepped down to |
|
|
// one joint has to reach maxvelocity the others are stepped down to |
|
|
// calculate time if acceleration is enouth to reach max speed |
|
|
// calculate time if acceleration is enouth to reach max speed |
|
|
|
|
|
// s = a * t^2 / 2 |
|
|
Vec<float,SIZE> minBangBangTime = maxJointLocalVelocity.celldivide(maxJointLocalAcceleration) / sampleTime; |
|
|
Vec<float,SIZE> minBangBangTime = maxJointLocalVelocity.celldivide(maxJointLocalAcceleration) / sampleTime; |
|
|
//TODO check if mintime is neceesary |
|
|
//TODO check if mintime is neceesary |
|
|
|
|
|
Vec<float,SIZE> time = ((jointMovementAbs/2.0f).celldivide(maxJointAcceleration) * 2.0f).sqrt() * 2.0f / sampleTime; |
|
|
|
|
|
std::cout << time << "time \n "; |
|
|
std::cout << minBangBangTime << "minBangBangTime \n "; |
|
|
std::cout << minBangBangTime << "minBangBangTime \n "; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vec<float,SIZE> minStepsPerJoint = jointMovementAbs.celldivide(maxJointLocalVelocity)*2.0f; |
|
|
|
|
|
|
|
|
Vec<float,SIZE> minStepsPerJoint = time;//jointMovementAbs.celldivide(maxJointLocalVelocity)*2.0f; |
|
|
minStepsPerJoint = minStepsPerJoint.ceil(); |
|
|
minStepsPerJoint = minStepsPerJoint.ceil(); |
|
|
std::cout << minStepsPerJoint << "minStepsPerJoint \n"; |
|
|
std::cout << minStepsPerJoint << "minStepsPerJoint \n"; |
|
|
|
|
|
|
|
@ -54,15 +56,14 @@ class BangBangJointTrajectory : public Trajectory<SIZE> |
|
|
// percentage of max velocity |
|
|
// percentage of max velocity |
|
|
//Vec<float,SIZE> currJointMovementOfMax = minStepsPerJoint / minStepsPerJoint.max() ; |
|
|
//Vec<float,SIZE> currJointMovementOfMax = minStepsPerJoint / minStepsPerJoint.max() ; |
|
|
// s = a* t^2 / 2 => a = s* 2 / t^2 |
|
|
// s = a* t^2 / 2 => a = s* 2 / t^2 |
|
|
float floaterror = 1.0f; |
|
|
|
|
|
Vec<float,SIZE> currMaxAcceleration = (jointMovementAbs * 2.0f ).celldivide(this->steps).celldivide(this->steps)*2.0f*floaterror; |
|
|
|
|
|
|
|
|
Vec<float,SIZE> currMaxAcceleration = (jointMovementAbs * 2.0f ).celldivide(this->steps).celldivide(this->steps)*2.0f; |
|
|
std::cout << "currMaxAcceleration : " << currMaxAcceleration << "\n"; |
|
|
std::cout << "currMaxAcceleration : " << currMaxAcceleration << "\n"; |
|
|
|
|
|
|
|
|
float count = 0.0f; |
|
|
float count = 0.0f; |
|
|
for( int i = 0 ; i < this->steps; ++i) |
|
|
for( int i = 0 ; i < this->steps; ++i) |
|
|
{ |
|
|
{ |
|
|
// acceleration phase |
|
|
// acceleration phase |
|
|
if (i < this->steps /2 ) |
|
|
|
|
|
|
|
|
if (i <= this->steps /2 ) |
|
|
{ |
|
|
{ |
|
|
this->nodes[i].acceleration = currMaxAcceleration ; |
|
|
this->nodes[i].acceleration = currMaxAcceleration ; |
|
|
count +=1.0f; |
|
|
count +=1.0f; |
|
|