The SCARA pancake printer is taking shape. I’ve recently been reworking the basic arm calculations because the classic ones work when the pen (or nozzle) is at the centre of the fore-arm joint but aren’t quite correct for me as I’ve added an extra piece.

To explain further, we’re talking here about a dual-arm SCARA robot. 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). It’s this stick which is my addition to the design and calculation – and at the end of the stick is the tool (pen/actuator/nozzle/laser etc).

### Library for MBED

To make this easier to work with I’ve written a simple C++ library which is available here:

https://developer.mbed.org/users/Bobty/code/SCARA_Arms/

Here’s an overview of the library:

```
```ScaraArms(double betweenShouldersMM, double shoulderToElbowMM, double elbowToHandMM, double handToToolMM)

Constructor – set the measurements required to describe a Dual-Arm SCARA robot of the kind described above:

- Distance between shoulders
- Distance from shoulder to elbow
- Distance from elbow to hand
- Distance from hand to tool (length of stick holding the tool)

```
```ConvertXYtoScara(double x, double y, double &theta1, double &theta2)

Compute the angles at the shoulders given the required XY position of the tool in radians, note that:

- the way the angles are measured is that theta1 (the left arm angle) is measured counter-clockwise from 3 O’Clock
- theta2 (the right arm angle) is measured clockwise from 9 O’Clock
- so to calculate both clockwise from 9 O’Clock use PI-theta2
- and to convert the angles to degrees multiply by 180/PI
- the XY position has it’s origin (0,0) at the left shoulder

```
```ConvertScaratoXY(double theta1, double theta2, double &x, double &y)

Reverse the above calculation – the same notes apply.

These calculations use a different mathematical model as conversion in this direction is simpler and provides a useful cross check.

### 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 = 180;

double requiredY = 300;

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);

This results in the following printout:

Angles required: left (from 3 O’Clock counter-clockwise) 2.164312 and right (from 9 O’Clock clockwise) 2.437823