Controlling AL5D arm with x,y,z coordinates

Hi everybody,

I’m planning to buy a Lynxmotion AL5D SSC-32U. I found a lot of infos on the forum, on how to communicate with the board via USB port.
My idea is to have a sensor connected to my machine, giving me 3D point coordinates (X,Y,Z)

In all sample codes i’ve found, the arm is driven by giving each servo a target angle-value.

Is there any way of transforming a space-position value (x,y,z) to degree/radians values so the arm will follow a position in space … ?
Or is there another way to do that ??

Thanks in advance!
Antoine

“Inverse kinematics” would be what you need, where the angle of each joint is determined based on the Cartesian coordinate. Since the SSC-32U itself is not meant to be programmed, but rather simply respond to input commands for each angle, a separate software / controller needs to do the calculations in order to determine the angle of each joint for the end effector to reach a specific coordinate. We offer basic equations in the guide on the third to last page under "calculating angles based on x,y,z:
robotshop.com/media/files/pd … -guide.pdf
You will be calculating angles a, b, c and d.

Thank you CBenson, i’m gonna read the guide and will come back to you if i have questions implementing the inverse kinematics in C++ !

Hi CBenson,

I get troubles trying to implement the inverse Kinematics in c++.
i get “nan” (not a number) for the three first angles …

here is my code :


const double cm_to_inch = 2.54;


//--------------------------------------------------------------
void inverseKinematics(float x, float y, float z)
{
  cout << "input coordinates : x=" << x << "  y=" << y << "  z="<<z<<endl;
  
  float L,M,N,R;
  
  L = 5.75*cm_to_inch;
  M = 7.375*cm_to_inch;
  N = 3.375*cm_to_inch;
  
  R = sqrt((x*x) + (y*y));
  
  cout
  << "  L:" << L
  << "  M:" << M
  << "  N:" << N
  << "  R:" << R
  << endl;
  
  
  float S = R - N;
  cout << "S: " << S << endl;
  
  float Q = sqrt((S*S) + (z*z));
  cout << "Q: " << Q << endl;
  
  float f = atan2(z, S) ;
  cout << "f: " << f << endl;
  
  float g = acos( ((L*L)+(Q*Q)-(M*M)) / (2*L*Q));
  cout << "g: " << g << endl;
  
  //final angles values
  float a = f + g;
  cout << "a = " << a << endl;
  
  float b = acos( ((M*M)+(L*L)-(Q*Q)) / (2*L*M) );
  cout << "b = " << b << endl;
  
  float c = -b - a + 2*pi;
  float d = atan2(x, y);    
  
}

x, y and z are the coordinate i want the arm to go to. (they are in centimeters, so i converted L,M and N in centimeters too.

Can you see something wrong ??

Here is what i get in the console :

input coordinates : x=29.2987  y=16.3637  z=26.4698
L: 14.605  M:18.7325  N:8.5725  R:33.5586
S: 24.9861
Q: 36.4
f: 0.814224   
g: nan
a =  nan
b = nan

Unfortunately we cannot troubleshoot custom code. Calculate each line by hand to see what you should get.
You caught the error in that the radius should be the square root of x^2 + y^2.

Ok, i checked the code again and calculate each line by hand : it works :slight_smile:
My error was due to my inputs (the values i was passing to this method were “out of range”)

I let the code here if someone needs to implement inverseKinematics in c++. :wink:

Thanks for your time.