# Difference between revisions of "Robot Laser"

Line 26: | Line 26: | ||

=== Completed Project Design === | === Completed Project Design === | ||

− | |||

− | |||

=== Results === | === Results === | ||

Line 69: | Line 67: | ||

===Pictures of Our Arm=== | ===Pictures of Our Arm=== | ||

+ | |||

+ | [[File:Capture d’écran 2012-12-16 à 20.22.05.png]] | ||

+ | |||

===Code=== | ===Code=== | ||

[[File:LASER_PART_II.zip]] | [[File:LASER_PART_II.zip]] |

## Revision as of 20:23, 16 December 2012

## Contents

## Team Super Laser Robot

### Participants

### Abstract

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.

### Introduction

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.

### Background/Theory

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:

#### Inverse Kin

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

### Results

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);

end

% 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.

pause(.01);

end end

### Discussion/Conclusion

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.