#ifndef _LINEAR_TRAJECTORY_H_ #define _LINEAR_TRAJECTORY_H_ #include "vec.h" #include "Trajectroy.h" #include "stdlib.h" template class LinearJointTrajectory : public Trajectory { public: LinearJointTrajectory( float sampleTimeMs, Vec maxJointVelocity, Vec maxJointAcceleration, Vec jointStart, Vec jointEnd ) { // calculate maximum velocity and acceleration Vec maxJointLocalVelocity = maxJointVelocity * sampleTimeMs; Vec maxJointLocalAcceleration = maxJointAcceleration * sampleTimeMs; // calculate delta movement Vec jointMovement = jointEnd - jointStart; Vec jointMovementAbs = jointMovement.abs(); // calculate sample count // calculate number of movement steps Vec minStepsPerJoint = jointMovementAbs.celldivide(maxJointLocalVelocity); this->steps = ceil(minStepsPerJoint.max()); this->nodes = (struct Trajectory::trajectoryNode* ) malloc(sizeof(struct Trajectory::trajectoryNode)*this->steps); Vec jointLast = jointStart; for( int i = 0 ; i < this->steps; ++i) { jointLast = jointLast + jointMovement.celldivide((float) this->steps ); this->nodes[0].jointPos = jointLast; this->nodes[0].velocity = maxJointLocalVelocity; this->nodes[0].acceleration; } } ~LinearJointTrajectory() { free (this->nodes); } private: protected: }; template class LinearCartTrajectory : public Trajectory { }; #endif