Calculations for a Dual-Arm SCARA robot Computes the shoulder angles to make the robot move to an XY position Also the reverse calculation - mainly useful as a cross-check

Description of a Dual-Arm SCARA robot (more info at http://robdobson.com/scara-arm-calculations)

The two arms of the robot are akin to two human arms with the hands permanently clasped together The arms are always in the same plane (generally horizontal) and the hands hold a stick (also in the same plane) On the end of the stick is the tool (pen/actuayor/nozzle/laser etc)

* The measurements required to describe a Dual-Arm SCARA robot of the kind described above are:
* 1) Distance between shoulders
* 2) Distance from shoulder to elbow
* 3) Distance from elbow to hand
* 4) Distance from hand to tool (length of stick holding the tool)*

Example Usage

* Setup calculation
double betweenShouldersMM = 320;
double shoulderToElbowMM = 138;
double elbowToHandMM = 307;
double handToToolMM = 22.5;
ScaraArms scaraArms(betweenShouldersMM, shoulderToElbowMM, elbowToHandMM, handToToolMM);*

* Compute the angles at the shoulders given the required XY position of the tool in radians
double requiredX = 200;
double requiredY = 180;
double theta1, theta2;
scaraArms.ConvertXYtoScara(requiredX, requiredY, theta1, theta2);*

* Show result
printf("Angles required: left (from 3 O'Clock counter-clockwise) %f and right (from 9 O'Clock clockwise) %f", theta1, theta2);*

## ScaraArms.h@0:9a3fc5ff8de3, 2015-05-15 (annotated)

- Committer:
- Bobty
- Date:
- Fri May 15 08:50:58 2015 +0000
- Revision:
- 0:9a3fc5ff8de3

Initial revision

### Who changed what in which revision?

User | Revision | Line number | New contents of line |
---|---|---|---|

Bobty | 0:9a3fc5ff8de3 | 1 | // SCARA_Arms library |

Bobty | 0:9a3fc5ff8de3 | 2 | // Code to compute the shoulder angles required to move a Dual-Arm SCARA robot to required x,y position |

Bobty | 0:9a3fc5ff8de3 | 3 | // More information at http://robdobson.com/scara-arm-calculations |

Bobty | 0:9a3fc5ff8de3 | 4 | // Copyright (C) Rob Dobson 2013-2015, MIT License |

Bobty | 0:9a3fc5ff8de3 | 5 | |

Bobty | 0:9a3fc5ff8de3 | 6 | #ifndef SCARAARMS_H |

Bobty | 0:9a3fc5ff8de3 | 7 | #define SCARAARMS_H |

Bobty | 0:9a3fc5ff8de3 | 8 | |

Bobty | 0:9a3fc5ff8de3 | 9 | // Description of a Dual-Arm SCARA robot |

Bobty | 0:9a3fc5ff8de3 | 10 | // The two arms of the robot are akin to two human arms with the hands permanently clasped together |

Bobty | 0:9a3fc5ff8de3 | 11 | // The arms are always in the same plane (generally horizontal) and the hands hold a stick (also in the same plane) |

Bobty | 0:9a3fc5ff8de3 | 12 | // On the end of the stick is the tool (pen/actuayor/nozzle/laser etc) |

Bobty | 0:9a3fc5ff8de3 | 13 | |

Bobty | 0:9a3fc5ff8de3 | 14 | class ScaraArms |

Bobty | 0:9a3fc5ff8de3 | 15 | { |

Bobty | 0:9a3fc5ff8de3 | 16 | public: |

Bobty | 0:9a3fc5ff8de3 | 17 | // Constructor |

Bobty | 0:9a3fc5ff8de3 | 18 | // The measurements required to describe a Dual-Arm SCARA robot of the kind described above are: |

Bobty | 0:9a3fc5ff8de3 | 19 | // 1) Distance between shoulders |

Bobty | 0:9a3fc5ff8de3 | 20 | // 2) Distance from shoulder to elbow |

Bobty | 0:9a3fc5ff8de3 | 21 | // 3) Distance from elbow to hand |

Bobty | 0:9a3fc5ff8de3 | 22 | // 4) Distance from hand to tool (length of stick holding the tool) |

Bobty | 0:9a3fc5ff8de3 | 23 | ScaraArms(double betweenShouldersMM, double shoulderToElbowMM, double elbowToHandMM, double handToToolMM); |

Bobty | 0:9a3fc5ff8de3 | 24 | |

Bobty | 0:9a3fc5ff8de3 | 25 | // Compute the angles at the shoulders given the required XY position of the tool in radians |

Bobty | 0:9a3fc5ff8de3 | 26 | // Note that the way the angles are measured is that theta1 (the left arm angle) is measured counter-clockwise from 3 O'Clock |

Bobty | 0:9a3fc5ff8de3 | 27 | // theta2 (the right arm angle) is measured clockwise from 9 O'Clock |

Bobty | 0:9a3fc5ff8de3 | 28 | // To calculate both clockwise from 9 O'Clock use PI-theta2 |

Bobty | 0:9a3fc5ff8de3 | 29 | // To convert the angles to degrees multiply by 180/PI |

Bobty | 0:9a3fc5ff8de3 | 30 | // The XY position has it's origin (0,0) at the left shoulder |

Bobty | 0:9a3fc5ff8de3 | 31 | void ConvertXYtoScara(double x, double y, double &theta1, double &theta2); |

Bobty | 0:9a3fc5ff8de3 | 32 | |

Bobty | 0:9a3fc5ff8de3 | 33 | // Compute the XY position of the tool given the angles at the shoulders |

Bobty | 0:9a3fc5ff8de3 | 34 | // See the comments above for the reverse calculation concerning the way the angles are measured and the origin |

Bobty | 0:9a3fc5ff8de3 | 35 | // of the XY coordinates |

Bobty | 0:9a3fc5ff8de3 | 36 | // These calculations use a different mathematical model as the conversion in this direction is simpler and |

Bobty | 0:9a3fc5ff8de3 | 37 | // it provides a useful cross check |

Bobty | 0:9a3fc5ff8de3 | 38 | void ConvertScaratoXY(double theta1, double theta2, double &x, double &y); |

Bobty | 0:9a3fc5ff8de3 | 39 | |

Bobty | 0:9a3fc5ff8de3 | 40 | private: |

Bobty | 0:9a3fc5ff8de3 | 41 | double _betweenShouldersMM; |

Bobty | 0:9a3fc5ff8de3 | 42 | double _shoulderToElbowMM; |

Bobty | 0:9a3fc5ff8de3 | 43 | double _elbowToHandMM; |

Bobty | 0:9a3fc5ff8de3 | 44 | double _handToToolMM; |

Bobty | 0:9a3fc5ff8de3 | 45 | }; |

Bobty | 0:9a3fc5ff8de3 | 46 | |

Bobty | 0:9a3fc5ff8de3 | 47 | #endif |