 # Robotic Arm Project

Hey guys, I'm doing a robotic arm project with several other engineering majors in our college, but I am in charge of the software/math division of the project. I was wondering if anybody has any suggestions on where I should start for the the programming. We are using servo motors for the base and the joints and we were thinking of using Galago, but ended up with Arduino since Galago doesn't have forums and source like arduino does. Any help/input will be appreciated, thanks!

I was wondering if anybody has any suggestions on where I should start for the the programming.

I'd suggest that start by defining some requirements. Unless choosing random angles and flailing the arm around is what you want. If it is, by all means go ahead and do that.

Take a look at this

To PaulS,

We don't know exact angles yet but we do know the dimensions of all the parts of the arm, we are using arduinos for every joint and a raspberry pi linux computer to control these arduinos. We essentially want the arm to pick up something small, preferably under 5 lbs, like a small mug or something.

To justone,

I've seen that , but it seems a bit complex for someone that hasn't programmed using arduino before.

I've seen that , but it seems a bit complex for someone that hasn't programmed using arduino before.

But, that is what is needed to determine the path that an open loop kinematic system needs to follow to reach point A (which is presumably where the object to be picked up is) or point B (where to put it).

I don't know what stage of your studies you're at, but if you're going to be an engineer you need to be able to solve problems- that's what engineering is.

To that end, you need to accept that the problem is to move the 5lb mug from A to B. (Unless you simply want to wave it around, as suggested above.)

Assuming your team's hardware guys-n-gals have figured out their side- and sounds like they have since you say you know the dimensions- yours is to provide the intelligence. Inverse kinematics is that intelligence, and you don't dive into code. You understand what inverse kinematics is, look at different ways of implementing it in various algorithms- and then look at ways of coding the algorithm.

It's a fact of life that inverse kinematics is complicated, but you took that complication on when you accepted the job of math guy. You have to understand the math first.... and if that's complicated, well that's tough on you. Get your mind round how to do the math first, then only flowchart the solution (perhaps with pseudo code) and only then figure out the coding.

And of course before all of that, learn to program your Arduinos! There are loads of tutorials on that....

Edit.... sorry if that came across as a bit of a rant, didn't mean it to

To JimboZA,

yea that makes sense to get the math down before the programming, I mean I just finished taking my first semester of linear algebra, and through research I came across the fact that i am going to need knowledge of isomorphisms between the joints and their rotations, DH parameters (which seems a bit complicated), and inverse kinematics (which I am still researching and doing my best to learn about). My main concern was the programming in arduino, and not as much the mathematics, but I guess my logic was reversed and I should start the other way around based on your advice.

Good man....

Have you no calculus though?- my (admittedly limited) knowledge of IK is that it's differential equations. I guess you can get some off-the-shelf algorithms at least, without necessarily having a deep understanding of the calculus? Then implement those in code....

While you're researching the math, also learn to program the Arduino. There are two servo tutorials on this site, here and here, which will get you going. But get something like Blink going first 8)

We are using servo motors for the base and the joints and ... We essentially want the arm to pick up something small, preferably under 5 lbs, like a small mug or something.

Servos are generally limited to moving small weights unless \$\$\$ servos are used. Search on youtube for "robot arm" to see what others are doing.

I have finished an alike project----a 4-freedom arm, using joystick(made by 4 pots) to control it.
Servos as driving unit.
Here is another resourses:Endurance R/C - Analog Reader
Here is the code(just copy and paste):
#include <Servo.h>

Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;// create servo object to control a servo

int potpin1 = 0; // analog pin used to connect the potentiometer
int potpin2 = 1;
int potpin3 = 2;
int potpin4 = 3;
int val1; // variable to read the value from the analog pin
int val2;
int val3;
int val4;

void setup()
{
myservo1.attach(9); // attaches the servo on pin 9 to the servo object
myservo2.attach(10);
myservo3.attach(11);
myservo4.attach(13);
}

void loop()
{
val1 = analogRead(potpin1); // reads the value of the potentiometer (value between 0 and 1023)
val1 = map(val1, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
val2 = map(val2, 0, 1023, 0, 179);
val3 = map(val3, 0, 1023, 0, 179);
val4 = map(val4, 0, 1023, 0, 179);
myservo1.write(val1); // sets the servo position according to the scaled value
myservo2.write(val2);
myservo3.write(val3);
myservo4.write(val4);
delay(5); // waits for the servo to get there
}

I have finished an alike project----a 4-freedom arm, using joystick(made by 4 pots) to control it.

With all due respect, Stargazer, moving the end of a servo with four pots is not an "alike project". It's simply 4 knob programs in one and is simple in comparison to inverse kinematics in 3D and real time.

But it might be enough for the OP, who went silent after January 14th.

As a compromise though, I recently experimented a bit with using the potentiometer (knob) approach and using a push button on an interrupt to store the current settings of the pots into EEPROM as the servos move.That was a very ( very)basic way of programming the actuator path, by recording waypoints as it was driven by the pot (pot singular, for my testing.) Then I had another program that read the EEPROM values back and moved the actuator on its pre-programmed path. Timing is an issue.....

JimboZA: It's simply 4 knob programs in one and is simple in comparison to inverse kinematics in 3D and real time.

Frankly speaking, it is truely simple :%, but at least it worked. Considering on the scale of the robotic arm, this kind of code would satisfy when the arm is small(You won't feel the difference between using function "map" and using function "PID"). However the problem about response time did exist. So I think if want to make the arm larger like human arm, this problem can't be ignored. In that case negtive feedback and PID algorithm may be indispensable. And the driving unite would probably be switched into DC gear motors. So I wrote down this code below, I call it single-neuroned self-adapting NN PID algorithm(Whatever it is...never mind, It is the simplest NN algorithm). Actually it is only test version and anyone can adapt it to his own device if needed. By the way, the code is not perfect yet...and I will be pretty appreciate if you can find mistakes. XD Here is the code(for only one motor),

``````const int analogInPin1 = A0;
const int analogOutPin = 9;

int y_in = 0;
int r_in = 0;
int u_k = 0;
int u_k_old = 0;
int e_k;
int e_k_old = 0;
int e_k_old2 = 0;
double xite_i = 0.35;
double xite_p = 0.40;
double xite_d = 0.40;
double wk1 = 0.1;
double wk2 = 0.1;
double wk3 = 0.1;
double wk1_old = 0;
double wk2_old = 0;
double wk3_old = 0;
double wk11;
double wk22;
double wk33;
double w;
double k = 0.12;
double x1;
double x2;
double x3;

void setup() {
Serial.begin(9600);
}

void loop() {
e_k = y_in - r_in;
x1 = e_k;
x2 = e_k - e_k_old;
x3 = e_k - 2*e_k_old + e_k_old2;
w = abs(wk1)+abs(wk2)+abs(wk3);
wk11 = wk1/w;
wk22 = wk2/w;
wk33 = wk3/w;
u_k = u_k_old + k*(wk11*x1 + wk22*x2 + wk33*x3);
wk1_old = wk1;
wk2_old = wk2;
wk3_old = wk3;
wk1 = wk1_old + xite_i*e_k*u_k*(2*e_k - e_k_old);
wk2 = wk2_old + xite_p*e_k*u_k*(2*e_k - e_k_old);
wk3 = wk3_old + xite_d*e_k*u_k*(2*e_k - e_k_old);

analogWrite(analogOutPin, u_k);

Serial.print("r_in = " );
Serial.print(r_in);
Serial.print("\t y_in = ");
Serial.println(y_in);
Serial.print("\t u_k = ");
Serial.println(u_k);

e_k_old2 = e_k_old;
e_k_old = e_k;
u_k_old = u_k;

delay(2);

}
``````

A0 is attached to controlling pot; A1 is attached to feed-back pot which shares the same shaft with the arthrosis of the arm.