Team Super Laser Robot
For our final project, we decided to build and program a robot laser arm pointer. We built this using our knowledge of robot arms and matlab based on lab 8 (the mini robot arm project). We began by building the physical model with two servo motors, one on top of the other. The laser barrel was then attached to the second servo model. While building this model we were careful to zero the motors using matlab to ensure that the starting position of robot arm was aligned. We then moved to the matlab script. We began with much of the same script as lab 8. Even the calibration was generally kept. The one major change was the inverse kinematics. To account for the movement in three dimensions, the invKin function had to be changed according to the math that Professor Cheever shared with us.
Our goal was to use the information and knowledge we had from Lab 8 to create a robotic arm that would draw a circle on a surface using a laser. The idea of a laser was interesting because it required us to use different planes in a three dimensional context, while the previous lab had "simple" x and y planes. We were motivated by the idea of applying previously learned knowledge in a creative way to create a new, more challenging type of robot arm.
Our project is an adaptation of the previous robot arm that could draw on a piece of paper with a pencil. We built Matlab code that could take Cartesian coordinate points and translate them, through a series of Matlab functions, into pulse counts. Pulse Counts are the length of the signal that the servo motor uses to turn to a specific angle. The script entitled MoveLaser.m calculates and creates a matrix with the coordinates of the circle that the laser draws on the wall. The laser does not actually move in a circle; it moves in 360 small lines that create the appearance of moving in a circle. Because the laser rotates the three dimensions, a different inverse kinematics was used to calculate the angles for which the robot arms needed at in order to achieve setting the robot arm to a certain coordinate point. Below is the inversekin function used for our lab:
r = sqrt(x^2+y^2+z^2-rho^2); %defines the variable r
thetaA = asin(z/r)*180/pi; %defines theta, the angle for servo 1
thetaB = (asin(rho/(sqrt(x^2+y^2)))-atan2(y,x))*180/pi; %defines thetaB, the angle for servo 2
Completed Project Design
Our Robot Arm Design had two servo motors. On that moved in the horizontal x-axis plane and one that moved in the vertical y-axis plane. X-axis servo motor is mounted above the base and held up the mount for the y-axis servo motor. The y-axis servo motor is directly connected to the laser pointer itself. The battery powered laser pointer is embedded inside the metal holder that allows the laser to remain on. When these two servo motors move together, they are able to achieve pointing the laser on a vertical plane with a wide spectrum.
In our matlab code we used 4 different functions. One function defined the coordinate points for a circle. (found in results section of lab). The next most important function translated these points, along with two constants (the distance to the vertical plan and the distance from the moment of rotation to the laser) to determine the angle at which the two segments of the robot arm should be placed. Then the GetPCs function translates these angles into pulse counts. This part of the code was the same as the previous lab (robot arm lab) and is found below. And the Goto Angles function writes the pulse counts to the servo motors. In order to calibrate our motors, we used the ServoCalibrate function to measure the degrees of change using 5 different pulse counts. This allowed our robot arm to move with accuracy.
mA=0.4127; bA=-52.0028; mB=0.3999; bB=-50.3903;
pcA = round((thetaA-bA)/mA) - 1; pcB = round((thetaB-bB)/mB) - 1;
The results of our project were as expected. We where able to make the Robot Laser arm to move in a circle on a horizontal plane "x" distance away from the robot. This was demonstrated in the project presentation on Tuesday, December 11th. Below is the code used in order to make the rotation take place.
r = 2; % Radius of the circle is 1. y = ones(1,360); % Create a matrix of ones to be filled by the x-values of the circle. z = ones(1,360); % Create a matrix of ones to be filled by the y-values of the circle.
for i = 1:1:360; % We found the x and y coordinates for every degree of the circle.
y(i) = r*cosd(i); z(i) = r*sind(i);
% count = size(y, 2); % Tpart = Ttot / count;
% Create a matrix of ones to be filled by values of theta, % where thetaA is the angle for the lower arm and theta B % is the angle for the upper arm. thetaA = ones(1,360); thetaB = ones(1,360);
for j=1:1:10; % The graphing of the circle is repeated 10 times.
for i = 1:1:360; % Iterates for all x and y values.
[thetaA(i) thetaB(i)] = invKin(10,-y(i),z(i),6); [pcA(i) pcB(i)] = getPCs(thetaA(i), thetaB(i)); a.servoWrite(2,pcA(i)) a.servoWrite(3,pcB(i)) % Finds the angles using the invKin function. 29 is the y intercept.
% gotoAngles1(thetaA(i),thetaB(i)); % Using the angles found above, the gotoAngles function orders the robot arm to draw.
We had originally decided that we would draw a five pointed star, but realized that would be difficult to code and furthermore not necessarily easy for the audience to see. We also noticed that the servo motor had difficulties reading our pulse counts, and did not know wether our angles and code were wrong or if the rounding that matlab did on values affected the pulse counts. We modified the code and realized we had made a mistake, because our servo was then able to move at the right angles. Finally, we had difficulties with the design of our arm, because the laser was too heavy and wobbled. We fixed this by switching its position and then nailing it.