Parallel Execution of Joint Motions

Normally when you make a robot, you don't want it to move one joint at a time. Usually you want something more fluid where several joints are moving in tandem.

While it is impossible to have parallel execution on the arduino, the illusion of parallel execution can be achieved.

It is done by moving each joint only a few degrees and then moving the next joint a few degrees. Since the delays between the movements are milliseconds it appears as if all the joints are moving at once.

This code was tested using the Training Program created in the last post.  The user control the arm to some position they want it to be at and then records that position. Then when there are several positions the arm will move directly to each point.

For those familiar with engineering, what we have created is a very basic PD controller.

What is great about this parallel movement is that while before when we did training we may have had to record single joint movements to ensure that the arm didn't collide with the table. Now that is not as much of a worry since all the joints can move to their desired positions simultaneously.

Code for this post for Parallel Joint Movement

//Primary Function for Simultaneous Servo Motion
int servoParallelControl (int thePos, Servo theServo ){
 
    int startPos = theServo.read();        //read the current pos
    int newPos = startPos;
    int theSpeed = 9;
   
    //define where the pos is with respect to the command
    // if the current position is less that the actual move up
    if (startPos < (thePos-5)){
         
       newPos = newPos + 1;
       theServo.write(newPos);
       delay(theSpeed);
       return 0;
         
    }
 
   else if (newPos > (thePos + 5)){
 
      newPos = newPos - 1;
      theServo.write(newPos);
      delay(theSpeed);
      return 0;
         
    }
   
    else {
        return 1;
    }
   
 
}

No comments:

Post a Comment