Hello, I need to implement inverse kinematics in a windows program I am writing, using an AL5D arm. Unfortunately, I am not an expert programmer, and DEFINITELY not an expert mathematician, so I cannot write it myself and must use existing code. I managed to find some arduino code for controlling the arm. However, I will not be using the Arduino in my project, and will instead be interfacing directly with the SSC-32U servo controlled. The controlled is controlled by ascii commands transmitted over a serial connection. The commands are found HERE.
If I knew C++, I would not have this problem (arduino code is compiled in C++, i believe), but I dont. I know some arduino programming, but not how to write a real windows application in C++. Therefore I need your help converting this code into Visual Basic.NET.
int Arm(float x, float y, float z, int g, float wa, int wr) //Here's all the Inverse Kinematics to control the arm
{
float M = sqrt((y*y)+(x*x));
if(M <= 0)
return 1;
float A1 = atan(y/x);
if(x <= 0)
return 1;
float A2 = acos((A*A-B*B+M*M)/((A*2)*M));
float Elbow = acos((A*A+B*B-M*M)/((A*2)*B));
float Shoulder = A1 + A2;
Elbow = Elbow * rtod;
Shoulder = Shoulder * rtod;
if((int)Elbow <= 0 || (int)Shoulder <= 0)
return 1;
float Wris = abs(wa - Elbow - Shoulder) - 90;
#ifdef DIGITAL_RANGE
Elb.writeMicroseconds(map(180 - Elbow, 0, 180, 900, 2100 ));
Shldr.writeMicroseconds(map(Shoulder, 0, 180, 900, 2100));
#else
Elb.write(180 - Elbow);
Shldr.write(Shoulder);
#endif
Wrist.write(180 - Wris);
Base.write(z);
WristR.write(wr);
#ifndef FSRG
Gripper.write(g);
#endif
Y = tmpy;
X = tmpx;
Z = tmpz;
WA = tmpwa;
#ifndef FSRG
G = tmpg;
#endif
WR = tmpwr;
return 0;
}
- How do I implement the statements that begin with # in VB?
- How would I implement the commands that move the arm in ASCII? (syntax is detailed in the link)
- What other adjustments do I have to make?