You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>RoBOP</strong>-a-<strong>Mole</strong><br />
Julia Barry<br />
Patrick Chang<br />
Ryan Stewart<br />
Alex Choi<br />
ME 4451: Robotics<br />
Fall 2007<br />
December 7 th , 2007
Table of Contents<br />
INITIAL PLAN .................................................................................................................. 1<br />
KINEMATICS.................................................................................................................... 4<br />
PROBLEMS ....................................................................................................................... 5<br />
SOLUTIONS ...................................................................................................................... 7<br />
ACHIEVEMENTS/RESULTS ........................................................................................... 9<br />
WHAT WE LEARNED.................................................................................................... 10<br />
IMPROVEMENTS ........................................................................................................... 10
INITIAL PLAN<br />
Goal:<br />
The intention of this project was to robotically simulate the game “Whack-a-<strong>Mole</strong>.”<br />
The “Whack-a-<strong>Mole</strong>” game consists of a platform with several holes drilled into it. A small<br />
object, or “mole,” appears randomly from one of these holes and remains there for a small<br />
period of time. The object of the player is to force the individual moles back into their holes<br />
by hitting them directly on the head with a mallet. If the player does not strike the mole<br />
within the time limit, it will eventually sink back into its hole. The player’s goal is to hit as<br />
many moles as possible before the game ends.<br />
Materials and Construction:<br />
In this project, instead of a human player, a robotic arm played the game. The robot<br />
that was used was the ROBIX serial robot kit provided in laboratory. A plastic mallet<br />
provided by the team was placed in its end-effector. The robot was placed in front of a square<br />
platform with edges of length 30 cm. Nine 5 cm diameter holes were drilled into the platform<br />
in a 3x3 grid formation (Appendix A). The platform was constructed from a black foam<br />
board by the team. Above the platform was a DVT camera provided by the laboratory. The<br />
camera was set high enough above the platform so it could see the entire platform, but low<br />
enough so that only the platform could be seen. The camera was connected to a computer.<br />
The computer was then connected to the robotic arm. The computer was simultaneously<br />
running “MATLAB” and the “DVT Vision System” program. The mole was a small, white,<br />
stuffed bulldog provided by the team. The entire setup and configuration are shown in<br />
Appendix B.<br />
1
Overall Procedure:<br />
The robot began in an initial position that did not obstruct the camera’s view of the<br />
platform. The game began once one of the team members pushed the mole through one of the<br />
holes of the platform. The mole was a white color and appeared clearly against the black<br />
color of the platform and holes. The camera began scanning each hole on the platform for a<br />
white color. Once the camera found the white color, it returned which hole that the color<br />
appeared. The holes were numbered 1 through 9 using the convention shown in Appendix A.<br />
Afterwards, MATLAB read in the value of the hole. It then passed the hole number to a final<br />
function. This function moved the robot to a predefined set joint angles corresponding to each<br />
hole. Finally, the function used the end-effector’s motor to rotate the end-effector, causing the<br />
mallet to rotate downwards and “whack” the hole that the mole was located in. After the<br />
procedure was completed, the arm moved back into its initial position and the process started<br />
over. If more than one mole appeared on the platform, the robot would whack all the moles<br />
before moving back into its initial position. The moles were whacked in numerical order,<br />
starting with the first hole and moving to the ninth hole.<br />
Detailed Procedure:<br />
Platform and <strong>Mole</strong>:<br />
The platform was placed roughly three feet underneath the camera. Since the camera<br />
position was fixed at a height of roughly four feet above the ground, the platform and the<br />
robot were placed one foot above the ground. The mole was pushed through the hole by a<br />
team member who was wearing a long, black glove. The member had to wear this glove to<br />
prevent the camera from detecting the skin color of the team member.<br />
Camera:<br />
The camera was used because it has the ability to detect “blobs” by color. The<br />
platform, the holes, and the member’s arm were all colored black to make sure that the only<br />
2
non-black object that the camera detected was the white dog. The camera’s DVT Vision<br />
System program contained a program called “blob detector” that could detect color changes<br />
in a defined area of the camera’s view. Nine different “blob detectors” were placed over each<br />
hole of the platform. When the mole appeared in one of the holes, the blob detector would<br />
detect a white blob. A function created in the DVT program called “findTheBlob” performed<br />
a binary check on each blob detector by using the “NumBlobs” function. If “NumBlobs”<br />
returned a value greater than “0,” then “findTheBlob” would then return a value of “1,”<br />
meaning that it had detected a mole. If, on the other hand, “NumBlobs” returned “0,” then<br />
“findTheBlob” would return a “0” as well, meaning it had not detected a mole.<br />
“findTheBlob” checked all nine holes and returned a “0” or “1” corresponding to whether<br />
each hole had a mole or not.<br />
Computer:<br />
The computer was running the MATLAB and DVT Vision System Program<br />
simultaneously. Once the values of “1” and “0” were returned by the DVT Vision System,<br />
MATLAB ran the “robopamole.m,” function, which read the values into a vector of size nine,<br />
with each entry corresponding to the appropriate hole on the platform. For instance, the first<br />
entry corresponded to the first hole on the platform and contained a “1” or “0” depending on<br />
whether there was a mole at the hole. The “robopamole” script would then call the<br />
“gotohole.m” function with the vector as an input. The “gotohole” function checked the<br />
vector; for each entry that contained a “1,” “gotohole” would call the “RRR_go_angles.m”<br />
with the appropriate joint angles provided. The joint angles defined in “gotohole” were found<br />
using the method described in the “Kinematics” section. The “RRR_go_angles” function<br />
moved the ROBIX serial arm to the joint angles of the target hole. After calling<br />
“RRR_go_angles,” the “gotohole” function would then call the “whack.m” function. The<br />
“whack” function actuated the 5 th motor of the robot, causing the hammer in the robot’s<br />
gripper to swing downward, resulting in the head of the hammer hitting the mole. The<br />
3
“whack.m” function then reset the position of the hammer. Finally, “gotohole” reset the arm<br />
back to its initial position. A summary of the functions that MATLAB utilizes are provided in<br />
flow chart in Appendix C.<br />
KINEMATICS<br />
A ROBIX robot arm was adopted as serial RRR robot with links of 9.5cm, 13.3cm,<br />
and 7.6cm in lengths. A small plastic hammer was attached at the arm’s end effecter to whack<br />
a mole as the end effecter would rotate on desired trajectory. First, calibrations between rotor<br />
angles to counts were needed given the ranges of angles of each rotor and counts that servo<br />
takes. Acknowledging that the counts from 0 to 255 corresponds to angles from 0 to 180 for<br />
the first motor and from -90 to 90 for the other two motors, four different sample counts of 0,<br />
40, 80 and 120 were tested and corresponding rotor angles were recorded manually. The<br />
measures were then plotted and angles to counts calibration table was obtained from trend<br />
line shown in Appendix D. Once the calibrations were coded into the program with proper<br />
conditions, adjustments were performed from trial and errors to obtain precise conversion<br />
property as shown in RRR_go_angles.m and angles2counts.m.<br />
After the calibration, the origin of the system was determined as the arm was attached<br />
onto the top of the platform, and positions of nine holes were configured in accordance with<br />
the system. Both reverse and forward displacement analysis of RRR serial robot were used to<br />
enable the system to whack onto a designated hole.<br />
First, given the coordination of nine holes with offset of 10.6cm applied for the length<br />
of the hammer, joint angles for all coordination were derived from reverse displacement<br />
analysis. Then, using forward displacement analysis the end effecter could move to the<br />
desired point, rotate itself to whack onto the hole. For the consistency, elbowplus value was<br />
set as 1. Next step was to input the hole coordination read from the DVT sensor. Initial<br />
4
attempts included defining the origin and distinguishing coordination of nine holes<br />
accordingly. The sensor should constantly scan the platform for any changes in gradient,<br />
record the coordinates to the register so the program could read them. However, challenge<br />
arose during the mole detection, that finding centroid of the white region did not result in fine<br />
consistency. The problem was resolved using rather simpler method, by assigning precise<br />
rotor angles for each hole. Also each hole was assigned as a blob region which detects for any<br />
blobs or white region. The code used for the DVT sensor was encoded as shown in Appendix<br />
E, which recorded values for 9 assigned registers that a program roBOPamole.m could read.<br />
An array of corresponding numbers was then created as input to a program gotohole.m,<br />
which initiates movement of the arm and whacking. All programs mentioned are shown in<br />
Appendix F.<br />
PROBLEMS<br />
Throughout the course of the assignment, many obstacles arose that were not<br />
accounted for in the initial plan for the project. These problems are classified into three<br />
types: calibration problems, logic problems, and programming problems. The first<br />
complications arose during the calibration of the RRR robot. The robot was calibrated by<br />
specifying motor counts to achieve a position. Next, this position was fed into a RRR reverse<br />
kinematic algorithm to supply corresponding joint angles. From this method, a linear fit was<br />
used to relate the motor counts to real world joint angles; however, there were two notable<br />
hurdles in this approach. First, the joint angles calculated from the reverse program would<br />
sometimes return values greater than 360. This was troubling because the individual motors<br />
had only 180 degrees of motion. Additionally, upon completion of the calibration, there was<br />
still error when specifying robot positions.<br />
5
The next set of problems arose from the logic developed to control the robot. The<br />
initial plan for the algorithm was to have the camera system return the centroids of the moles<br />
and the robot would perform a reverse analysis to determine how it needed to move to this<br />
point. It was soon discovered that the robot has extra degrees of freedom associated with<br />
rotating a hammer about an axis parallel to the plane of the platform that were no accounted<br />
for in the RRR reverse algorithm. Even if a complex algorithm to solve the reverse analysis<br />
were created, performing the calculation every time the robot sensed a mole would be very<br />
computationally taxing and could slow the response of the robot. In addition, while using a<br />
reverse analysis approach, singular configurations become a problem, because the robot can<br />
become unstable at these configurations. Aside from the extra degree of freedom of the<br />
robot, using the camera system to identify centroids presented another problem. The<br />
reference frame of the camera and the reference frame of the platform are different. In order<br />
for the robot to be able to whack centroids in the platform reference frame a very meticulous<br />
transform is required to relate the coordinates of centroids the camera sees to coordinates<br />
relative to the robot. Additionally, this transform heavily depended on the height of the<br />
camera which would make the daily setup of the project time consuming.<br />
Next, the project encountered smaller obstacles relating to the specifics in the robot<br />
programming. First of all the there was a small learning curve involved in controlling the<br />
timing of the program. When the robot is supplied an integer 1-9, telling the robot to whack<br />
the corresponding hole, the individual motor commands in MATLAB are not performed<br />
completely sequentially. In other words, when telling the robot to move first and whack<br />
second, MATLAB will begin the movement operation, and then begin the whack operation<br />
without waiting for the movement operation to be completed. This resulted in the robot<br />
whacking while it was translating to a hole. Another small complication arose in the<br />
communication between MATLAB and the DVT. The iterations of the program to have the<br />
robot play the whack-a-mole game happen faster than the camera can update; similarly,<br />
6
MATLAB iterates faster than time required for the robot to move and whack a hole. This<br />
would result in the robot repeating the same motions over and over because it accrued a large<br />
stack of commands before the game state could be changed. Outside of MATLAB, the DVT<br />
software had its own difficulties. The camera system and algorithms ran smoothly when the<br />
whack-a-mole game was simulated by placing white pieces of paper over the platform while<br />
it was resting on the table. However, when implementing the whack-a-mole game in its<br />
entirety, the robot would falsely identify moles in all of the holes. Lastly, since the robot<br />
passes over the platform to perform a whack the robot arm blocks the view of the camera and<br />
the robot has no way of identifying moles underneath the robot arm.<br />
SOLUTIONS<br />
The project ran into a significant number of hurdles towards completing the task.<br />
Through brainstorming and lateral thinking the group promptly solved these problems and<br />
progress could again be attained. There were two main problems associated with the<br />
calibration of the robot. First, the reverse algorithm while relating motor counts to angles<br />
would return angles greater than 360. This small setback was quickly solved by creating<br />
additional logic in the algorithm to relate larger angles to the smaller workspace of the<br />
motors. In fact, the angles larger than 360 were still correct; however, the additional logic<br />
ensured the robot would not attempt to travel through the complete angle, but rather travel to<br />
resulting end effecter location. Although the calibration turned out to be a useful starting<br />
point, it did not provide the exact control that the problem required. In order to achieve more<br />
exact motions the coefficients in the linear interpolation between angles and motor counts<br />
were adjusted using through trail and error.<br />
As presented earlier, the initial logic in the solution lead to some unique hindrances<br />
that required the group to reanalyze the project and change the initial approach. The initial<br />
7
procedure of having the camera system return the coordinates of centroids to the robot which<br />
would, in turn, perform a reverse analysis to reach these points proved computationally<br />
taxing and creating difficulties in relating the camera space to the platform space. To avoid<br />
these problems the group decided it is best to completely abandon this approach and try<br />
something new. Instead of having the camera search for blobs and centroids inside a large<br />
space encompassing the entire platform, the camera now searched within nine separate spaces<br />
each containing a single hole. If a camera sensed any number of blobs within a hole, it would<br />
record a “true” for that hole. Once all the holes are checked, the program returns a vector<br />
containing 9 “true” or “false” values corresponding to each hole. This method avoids the<br />
need for a complicated transform to relate coordinates in the camera space to the coordinates<br />
of the platform, which would additionally reduce daily setup times. On the robot side,<br />
instead of using a reverse analysis to locate the holes, the group hard coded a specific<br />
orientation for the robot for all nine holes. When the camera returns a “true” for a hole, the<br />
robot will call upon its stored orientation to reach the specified hole. By doing this, there was<br />
no longer a need to develop a complicated reverse kinematic algorithm to account for the<br />
additional degree of freedom of the hammer. This solution proved very simple to program<br />
and quick to implement.<br />
Near the completion of the project, a few smaller problems arose from specific<br />
programming of the robot. The most significant of these problems resulted in camera<br />
outputting false positives for the holes. In other words, the camera would identify a mole<br />
when, in actuality, no mole was present. Adjusting the threshold and requiring a more<br />
significant blob to appear in order for the camera to count it corrected this problem. Next, the<br />
MATLAB loops iterated significantly faster than both the refresh rate of the camera, and the<br />
time required for the robot to complete a whack. Additionally, the DVT sometimes produces<br />
an error when there is a change over one of the holes, which would cause MATLAB to return<br />
a terminal error. Both of these problems were corrected by adding in a pause in the loop.<br />
8
The iterative loops now wait for a user input to begin a search for a new game state. Lastly,<br />
the small problem of the camera not being able to see moles underneath the robot is solved by<br />
both the pause in the program and having the robot return to a position off of the platform<br />
after whacking.<br />
ACHIEVEMENTS/RESULTS<br />
The initial goal of the project was achieved, although the final methods deviated<br />
greatly from the initial plan, which was to read the coordinates of the mole into Matlab and<br />
send the arm and the hammer to those coordinates. Because this approach would require the<br />
definition and calibration of several coordinate systems, within the DVT program and within<br />
Matlab, a simpler approach was used. Instead of using one blob softsensor to encompass the<br />
entire board and reading in the centroid coordinates of any blob sensed, nine blob softsensors<br />
were placed, one around each hole. The vision program then wrote a boolean for each hole to<br />
Matlab. As for Matlab, it was determined that predetermining the orientation of the robot<br />
arm at each hole and hard coding these positions into the program was more efficient than<br />
creating and interpreting a coordinate system. The script, roBOPamole, reads in the boolean<br />
values from the vision program and sent the arm and hammer to each hole with a boolean<br />
value of one, calling upon the whack function as well.<br />
Overall, the project was a success, and all design parameters were met. The DVT<br />
camera successfully detected the moles without identifying false positives, such as reflection,<br />
the arm of the team members, or the actual arm itself. The robot hit all the moles squarely on<br />
the head. The system was robust enough to handle more than one mole. There were no<br />
recorded failures.<br />
9
WHAT WE LEARNED<br />
In this project, the team became accustomed to applied robotics, mainly learning to<br />
autonomously extract geometric information from the camera’s image and use that<br />
information to perform a particular task. The team members acquainted themselves with the<br />
provided equipment and learned that it is important to work within the parameters of the<br />
equipment; for example, the pause function stopped the Matlab script from advancing ahead<br />
of the arm’s movements. It was found there were many ways to approach a problem, as was<br />
the case with the vision system. As with the vision system and the predetermined robot arm<br />
orientations, the best solution was usually the simplest and the quickest. Considering the<br />
equipment itself, it was found that the camera had a slow refresh rate and had difficulties<br />
handling glare. Fortunately, the problem of glare was easily solved by lowering the threshold<br />
percent. The robot arm, although difficult to calibrate, proved to be fast and simple to<br />
control, perfect for the whacking motion needed to simulate a person swinging a hammer.<br />
Finally, the group learned how to integrate multiple hardware and software components to<br />
create a functional robotic system.<br />
IMPROVEMENTS<br />
Although the system was completely functional, there are several possibilities of<br />
improving the overall performance. For instance, instead of hitting the moles in a numerical<br />
order, the robot could have hit them in a time-optimized order, thereby decreasing the amount<br />
of time needed to whack all the moles on the board. Also, instead of returning to its initial<br />
position after one pass, the robot could have continuously whack moles. In order to do this,<br />
the camera would’ve needed to ignore the robot arm while it was moving. In addition, a timer<br />
could have been utilized instead of having a person end the program. This could have been<br />
done in a while loop that kept track of time. Finally, a score system could have been<br />
10
implemented to better model the actual “Whack-a-<strong>Mole</strong>” game. These improvements are not<br />
vital to the overall success of the project, but would add to its overall appeal.<br />
11
Appendix A
Appendix B
Appendix C<br />
robopamole.m<br />
Description: Main script of the program. Runs everything necessary to<br />
make the robot function.<br />
Inputs: A “1” or “0” corresponding to each hole on the board. Reads<br />
from the DVT Vision System program.<br />
Variables: holes<br />
holes<br />
Description: A vector of size 9 containing a “1” or “0”,<br />
corresponding with whether each hole has a mole or<br />
not. For instance, if holes[1] = 1, then the first hole<br />
has a mole.<br />
gotohole.m<br />
Description: Moves the ROBIX robot to a hole and whacks it.<br />
Then moves back to the initial position. Does this for all nine<br />
holes.<br />
Inputs: holes, ssc<br />
(1) RRR_go_angles.m<br />
Description: Moves the ROBIX robot to a specified set of joint angles.<br />
Inputs: theta – a vector of size 3 containing the joint angles of the RRR robot.<br />
ssc.<br />
(2) whack.m<br />
Description: whacking function. Draws the hammer<br />
back, pauses, whacks, pauses, and then returns to an<br />
upright position.<br />
angles2counts.m<br />
Description: Converts joint angles to counts. The robot can only move<br />
counts, so the joint angles must be converted to a system that the robot<br />
can recognize.<br />
Inputs: theta – a joint angle. servo – which joint the joint angle<br />
corresponds to.
Appendix D. Calibration Factor<br />
Motor1<br />
140<br />
120<br />
100<br />
counts<br />
80<br />
60<br />
40<br />
20<br />
0<br />
y = -1.1641x + 240.14<br />
0 50 100 150 200 250<br />
angle<br />
Motor2<br />
counts<br />
140<br />
120<br />
100<br />
80<br />
60<br />
40<br />
y = 1.0131x + 120.58<br />
20<br />
0<br />
-120 -100 -80 -60 -40 -20 0<br />
angle<br />
*actual<br />
conversion factor<br />
applied was<br />
refined through<br />
trials<br />
Motor3<br />
counts<br />
140<br />
120<br />
100<br />
80<br />
y = 1.4489x + 162.85<br />
60<br />
40<br />
20<br />
0<br />
-120 -100 -80 -60 -40 -20 0<br />
angle
public void inspect() { //initialize vector to hold information on where blobs are. {<br />
means no blob, 1 means the hole is occupied. int A1, A2, A3, A4, A5, A6, A7, A8, A9; A1=2;A2=0;A3=0;A4=0;A5=0;A6=0;A7=0;A8=0;A9=0; //0<br />
statements to examine each hole. If hole is occupied, //output array<br />
(B1.NumBlobs > 0) {A1 = 1;} //if<br />
(B2.NumBlobs 0) {A2 if (B3.NumBlobs > 0) {A3 if<br />
(B4.NumBlobs {A4 (B5.NumBlobs {A5 (B6.NumBlobs {A6 if (B7.NumBlobs > 0) {A7 = 1;}<br />
(B8.NumBlobs {A8 = 1;} if (B9.NumBlobs > 0)<br />
Appendix E. DVT Sensor Code<br />
findTheBlob class<br />
RegisterWriteShort(86,A9);<br />
RegisterWriteShort(84,A8);<br />
= 1;} RegisterWriteShort(70,A1); RegisterWriteShort(72,A2); {A9<br />
RegisterWriteShort(76,A4); RegisterWriteShort(78,A5); RegisterWriteShort(80,A6); RegisterWriteShort(74,A3);<br />
RegisterWriteShort(82,A7);
Appendix F. MATLAB Code<br />
a. RRR_go_angles.m<br />
% Project Whack-A-<strong>Mole</strong>, ME 4451<br />
%<br />
% Created 11-09-07 by Patrick, Alex and Ryan (in lab)<br />
%<br />
% INPUTS:<br />
% 1. theta, a vector containing 3 angles for the motor to move to<br />
% theta(1) must be between 0 and 180 degrees<br />
% theta(2) must be between -90 and 90 degrees<br />
% theta(3) must be between -90 and 90 degrees<br />
% 2. ssc, the SSC Matlab interface, which has already been opened<br />
%<br />
% The function takes the form<br />
% function RRR_go_angles(theta,ssc)<br />
% This function moves the arm, using ssc, to the three angles<br />
defined in<br />
% theta.<br />
function RRR_go_angles(theta,ssc)<br />
% Put in constraints to make sure program doesn't get confused.<br />
if theta(1) < 0 | theta(1) > 180<br />
error('Input angle between 0 and 180 degrees for first<br />
angle')<br />
end<br />
if theta(2) 90<br />
error('Input angle between -90 and 90 for second angle')<br />
end<br />
if theta(3) 90<br />
error('Input angle between -90 and 90 for third angle')<br />
end<br />
% If passes constraints, convert angles to counts for each motor<br />
count1 = angles2counts(theta(1),1);<br />
count2 = angles2counts(theta(2),2);<br />
count3 = angles2counts(theta(3),3);<br />
% Move the robot arm to the specified configuration<br />
sscservoset(ssc,1,count1);<br />
sscservoset(ssc,2,count2);<br />
sscservoset(ssc,3,count3);<br />
b. angles2counts.m<br />
% Project Whack-A-<strong>Mole</strong>, ME 4451<br />
%<br />
% Created 10-19-07 by Julia, Patrick, Alex and Ryan (in lab)<br />
%<br />
% INPUTS:<br />
% 1. degrees, the angle at which the arm in question should end<br />
% 2. servo, the motor to be activated<br />
%<br />
% The function takes the form<br />
% count = angles2counts(degrees, servo)
% This function transforms angles into counts to be used in the<br />
ssc<br />
% interface. The transforming functions were determined via<br />
% experimentation, reverse kinematics, and linear regression.<br />
function count = angles2counts(degrees, servo)<br />
if servo == 1<br />
count = degrees * (-1.1641) + 240.14;<br />
elseif servo == 2<br />
count = degrees * (1.16) + 150.58;<br />
elseif servo == 3<br />
count = degrees * 1.17 + 140.85;<br />
else<br />
Error('please input a real motor');<br />
end<br />
c. roBOPamole.m<br />
% Project Whack-A-<strong>Mole</strong>, ME 4451<br />
%<br />
% Created 12-04-07 by Julia % This function is the mother script.<br />
Using an infinite while loop, this<br />
% script reads in the data for each of the nine holes from the<br />
camera into<br />
% the vector holes. This function is then inputted into the<br />
function<br />
% gotoholes.<br />
%<br />
% SSC Interface should already be open.<br />
clc;<br />
clear all;<br />
ssc = sscopen('COM1');<br />
%start infinite loop<br />
x=0;<br />
while x < 1<br />
%dvtread<br />
for i = 1:9<br />
holes(i)=dvtread('130.207.153.170',68+2*i);<br />
end<br />
end<br />
holes<br />
gotohole(holes, ssc)<br />
pause(2)<br />
%this won't ever be read<br />
clear ssc;sscclose(ssc);
d. gotohole.m<br />
% Project Whack-A-<strong>Mole</strong>, ME 4451<br />
%<br />
% Created 11-02-07 by Julia, Patrick, Alex and Ryan (in lab)<br />
% Modified 11-09-07 to go to specific positions by Patrick Alex<br />
Ryan<br />
% Modified 11-30-07 to take in vector of holes, in light of new<br />
vision<br />
% system by Julia, Patrick, Alex and Ryan (in lab)<br />
%<br />
% INPUTS:<br />
% 1. holes, vector with 9 entries containing 0's (hole is empty)<br />
and 1's<br />
% (hole is occupied)<br />
% 2. ssc, the SSC Matlab interface, which has already been opened<br />
%<br />
% The function takes the form<br />
% gotohole(holes, ssc)<br />
% and moves arm to predetermined position to whack the mole in<br />
any position<br />
% which has been marked occupied in vector holes.<br />
function gotohole(holes, ssc)<br />
% initial position is set up, via experimentation, to not block<br />
the camera<br />
init = [0 44 46];<br />
% optimal arm orientation is determined through experimentation<br />
hole1 = [0 19 90];<br />
hole2 = [8 70 76];<br />
hole3 = [51 72 56];<br />
hole4 = [10 26 56];<br />
hole5 = [12 60 44];<br />
hole6 = [43 60 31];<br />
hole7 = [24 34 7];<br />
hole8 = [35 42 11];<br />
hole9 = [62 30 10];<br />
% go through the vector of holes. If occupied, go to the hole<br />
and hit it.<br />
if holes(1) == 1<br />
RRR_go_angles(hole1, ssc);<br />
whack(ssc);<br />
end<br />
if holes(2) == 1<br />
RRR_go_angles(hole2, ssc);<br />
whack(ssc);<br />
end<br />
if holes(3) == 1<br />
RRR_go_angles(hole3, ssc);<br />
whack(ssc);<br />
end<br />
if holes(4) == 1<br />
RRR_go_angles(hole4, ssc);<br />
whack(ssc);<br />
end<br />
if holes(5) == 1<br />
RRR_go_angles(hole5, ssc);<br />
whack(ssc);<br />
end
if holes(6) == 1<br />
RRR_go_angles(hole6, ssc);<br />
whack(ssc);<br />
end<br />
if holes(7) == 1<br />
RRR_go_angles(hole7, ssc);<br />
whack(ssc);<br />
end<br />
if holes(8) == 1<br />
RRR_go_angles(hole8, ssc);<br />
whack(ssc);<br />
end<br />
if holes(9) == 1<br />
RRR_go_angles(hole9, ssc);<br />
whack(ssc);<br />
end<br />
% go back to the initial position, out of the way<br />
RRR_go_angles(init, ssc);<br />
e. whack.m<br />
% Project Whack-A-<strong>Mole</strong>, ME 4451<br />
%<br />
% Created 10-26-07 by Patrick, Alex and Ryan (in lab)<br />
% Modified 11-30-07 by Julia, Patrick, Alex and Ryan (in lab) to<br />
draw back % and pause to keep things from being redundant.<br />
%<br />
% INPUTS:<br />
% 1. ssc, the SSC Matlab interface, which has already been opened<br />
%<br />
% The function takes the form<br />
% whack(ssc)<br />
% This function goes through the whacking motion.<br />
function whack(ssc)<br />
sscservoset(ssc,4,84);<br />
pause(.8);<br />
sscservoset(ssc,4,240);<br />
pause(1);<br />
sscservoset(ssc,4,127);<br />
pause(1);