This is a continuation of the Robotic arm that draws with light.
Robotic Arm part 1
This time we wanted to improve on the motion of the first weeks and hone in the accuracy and motion
With many ways to get to the same position, it was quite interesting playing around with he inverse kinematics, as sometimes the equations would break down with some values, or attempt to do some strange actions such as taking the long way around to a position.
def position(x,y):
L1 = 2.5
L2 = 2.5
L3 = math.sqrt((x**2)+(y**2))
B1 = (L2**2 - L1**2 -L3**2)/(-2*L1*L3)
A1 = math.acos(B1)
Th1 = (y/x)- math.tan(A1)
Ang1 = Th1 * (180/math.pi)
B2 = (L3**2 - L2**2 - L1**2)/(-2*L1*L2)
A2 = math.acos(B2)
Th2 = math.pi - A2
Ang2 = Th2 * (180/math.pi)
print(Ang1)
print(Ang2)
posneg(0,Ang1)
time.sleep_ms(20)
posneg(1,Ang2)
time.sleep_ms(20)
We created a position function that took in an (x,y) input and found the angles to translate it into motor angles. There were different variation of this position function using both Cosine and atan2 function to try each but there was a bit of a strange effect with each at some of the angles that we were testing.
The downfall of position is understanding global position with the robots position and how once we input for instance (1.25, 1.25) on than (2.5, 2.5), in order to move to 2.5, we should be starting at 1.25,1.25 not the origin 0,0 point.
Which is why we came up with a start function that constantly took input and sort of subtracted previous value to give us a new value through which we must move.
def start(m,n):
while True:
position(m,n)
m = float(input()) - m
print("m is", m)
n = float(input()) - n
print("n is", n)
The flaw in that logic is that position function is trying to get us to that point and not necessarily what increment that it is moving at.