Document 11847632

advertisement
ROSE-HULMAN INSTITUTE OF TECHNOLOGY
Department of Mechanical Engineering
ME 123
Comp Apps I
Mini-­‐Project #2: Motion Planning and Generation for a Robot Arm Team Assignment: Your professor will assign the teams. You will have about 5 minutes to get acquainted, exchange contact information and schedules, and to prepare yourself for what is to come. Overview: Imagine that you are helping to set up an assembly line. The section of the line on which you are working uses robots to place screws into specific rivnuts (i.e. special tubes designed to bulge when the screw is tightened). In a previous step, another operator will have already placed some of the screws, so your robot must be able to identify which screws are already in the correct rivnuts and decide how best to move the remaining screws to their associated rivnuts. However, this is a reconfigurable manufacturing line—you won’t always be dealing with the same screw/rivnut locations. To help the operator, two Excel spreadsheets are provided which give the coordinates for each screw and rivnut. You are responsible for creating code that translates any valid spreadsheet data into an efficient set of instructions for the robot. Efficiency is important here because this operation is the slowest one on this line—decreasing the time the robot takes will directly translate into the ability to create more finished parts each day. We are going to simulate this task using the Mechanical Engineering Department’s ST Robotics Firefly manipulator arms (see Figure 1 below). Your mission is to write a program that will generate a set of commands for the robot to efficiently move the screws that are not already in the correct rivnuts to their associated rivnuts. We will define efficiency as the total distance the robot arm travels to pick and place the screws. Figure 1. ST Robotics Firefly manipulator arm. Page 1 of 7 ROSE-HULMAN INSTITUTE OF TECHNOLOGY
Department of Mechanical Engineering
ME 123
Comp Apps I
The Information You Will Receive: The robot, the screws (i.e. colored tubes), and rivnuts (i.e. colored dots) will be on a table-­‐top. The robot will automatically start from an initial position of (x,y) coordinate (0,2000), and return to coordinate (0,2000) at the completion of the code. There will always be a total of 9 screws and 9 rivnuts. There are three types of each: Type 1 (red), Type 2 (green), and Type 3 (blue). Each screw will always have a corresponding rivnut, and there will always be 3 of each type of screw-­‐rivnut pair. The starting x-­‐ and y-­‐coordinates of all the screws will be given to you as an Excel spreadsheet (screw_data.xlsx), and the rivnut locations will be given to you as a second Excel spreadsheet (rivnut_data.xlsx). The table below shows the format of the spreadsheet for the screws; the rivnut spreadsheet will be formatted in the same way: Screw 1 x Screw 1 y Screw 1 type (1, 2, or 3) Screw 2 x Screw 2 y Screw 2 type (1, 2, or 3) Screw 3 x Screw 3 y Screw 3 type (1, 2, or 3) Screw 4 x Screw 4 y Screw 4 type (1, 2, or 3) ⋮ ⋮ ⋮ Screw 9 x Screw 9 y Screw 9 type (1, 2, or 3) There are two sample spreadsheets (screws and rivnuts) posted on the course website that you may use to test your program. You can also create your own set of sample data, of course. Your program will plan the sequence in which the screws are moved to a corresponding rivnut (i.e. Type 1 screw in a Type 1 rivnut). Since there are thousands of possible sequences for moving the screws to the rivnuts, you may want to find a few solutions and choose the “best”. Recall that we will use the total linear x-­‐y distance traveled by the robot arm as the measure of efficiency; don’t forget the robot will start and finish at (0,2000)! Once your program has a set of moves planned, you will need to generate the robot language (Roboforth) code to tell the robot to actually make those moves. To help you out, we have written a set of MATLAB functions that print out the Roboforth code to perform simple tasks. You will call those functions from your MATLAB code. (The functions are on the course website and are described on the next page.) Page 2 of 7 ROSE-HULMAN INSTITUTE OF TECHNOLOGY
Department of Mechanical Engineering
ME 123
Comp Apps I
Functions: The MATLAB functions that are provided for your use are basically translators that generate a set of commands in Roboforth, the language that the robotic arm understands. DO NOT MODIFY THESE FUNCTIONS!!! THIS COULD BREAK THE ROBOT. Just use them as we have given them to you. These functions are very simple to use. Function file_no =
initialize('filename.txt')
Inputs filename is the name of the text file for the commands. moveto(file_no,x,y)
file_no is the number of the output file obtained from the initialize function. x,y are the coordinates to which you want to move the arm. file_no is the number of the output file obtained from the initialization function. pickup(file_no)
putdown(file_no)
file_no is the number of the output file obtained from the initialization function. close_out(file_no)
file_no is the number of the output file obtained from the initialization function.
Outputs file_no is the number used in subsequent commands and functions for fprintf. None. Commands are generated and appended to the text file without sending a result back to the MATLAB session. Purpose Prepares the text file. It also moves the robot arm to the start position. Moves the arm from its present position to the position you have specified. None. Commands are generated and appended to the text file without sending a result back to the MATLAB session. None. Commands are generated and appended to the text file without sending a result back to the MATLAB session. Moves the arm down, closes the grips and brings the screw back to the plane of motion. Moves down, “screws in the screw” (puts it on the table), and then moves back to the plane of motion. Closes the output file and moves arm to the finish position. None. Page 3 of 7 ROSE-HULMAN INSTITUTE OF TECHNOLOGY
Department of Mechanical Engineering
ME 123
Comp Apps I
Testing: We have posted two sample spreadsheets (one for screws, the other for rivnuts) on the course website that you can use in developing your code. To test your output on a real robot (optional, but recommended), course instructors will be in the Rotz Lab to take your Roboforth code and put it on the robot so you can see if it works during 10th hour (4:20 pm – 5:10 pm) and 11th hour (5:10 pm – 6 pm) on Tuesday, Wednesday, and Thursday this week. Note that you must have long pants, closed-­‐toe shoes, and safety glasses to enter the Rotz Lab. (We will provide the safety glasses.) If you are not dressed appropriately, you will not be permitted to enter the lab. During class on Friday April 29, we will give you a new set of spreadsheets and have you generate new Roboforth code. You will have until the end of the class hour on Friday to upload your Roboforth code text file to Moodle. (If your program is working correctly, this will be a very short class!) We will test your submitted code on the actual robot during our class hour on Monday May 2. (We will meet in the Rotz Lab that day, so please be wearing long pants and closed-­‐toe shoes). (Note that Exam 2 is Tuesday May 3 [written] and Thursday May 5 [computer].) Summary of Deliverables (one set of deliverables per team): 1. By Friday April 29, you must have a MATLAB program ready to run that • accepts data from the Excel spreadsheets (screw_data.xlsx and rivnut_data.xlsx); • prints a valid Roboforth program to a text file; • and computes the distance traveled by the robot for the move sequence in the text file submitted – remember the robot always starts and stops at (0,2000). 2. Roboforth text file submitted to Moodle by the end of class on Friday April 29. 3. Well-­‐documented MATLAB code uploaded to Moodle by Friday May 6 by 5 pm. Grading: Your grade for the mini-­‐project will be computed with the weights shown below: 40 pts Robot performance 60 pts MATLAB code (well-­‐documented and easy to follow) 100 pts Page 4 of 7 ROSE-HULMAN INSTITUTE OF TECHNOLOGY
Department of Mechanical Engineering
ME 123
Comp Apps I
Robot performance: No submission Roboforth code submitted but does not correctly execute the task Roboforth code correctly executes task. Score depends on formula below. 0 pts 12 pts 24-­‐40 pts percent slower = 𝑥 = 100% × !"#$ !"#$%&'( – (!"# !"#$ !"#$%&'()
!"# !"#$ !"#$%&'(
robot performance score =
24
for 𝑥 ≥ 50%
40 − 0.32𝑥
for 0% ≤ 𝑥 < 50%
MATLAB code: Submit a well-­‐documented MATLAB code (main routine and any functions you created). If your code did not correctly execute the task, fix the mistake(s) and add comments explaining what you fixed before you upload your code to Moodle by Friday May 6 by 5 pm. Page 5 of 7 ROSE-HULMAN INSTITUTE OF TECHNOLOGY
Department of Mechanical Engineering
ME 123
Comp Apps I
Hints on How You May Wish to Approach This Project: Calculating distance: One of your required deliverables is the value of the distance the robot travels. One option would be to create a simple function that accepts the x and y locations for two points and computes the linear distance between the two. This function could be used over and over to compute the total distance. Another option would be to create a function which accepts a matrix of (x,y) pairs representing each location the robot will visit in order (i.e. the sequence), and then computes the total distance for that sequence. Deciding how to move the screws: There are a number of approaches you could use to move the screws into valid rivnuts. We’ve listed a few options below, but there are certainly other ways to do it! 1) Pick up the first screw in the list, check its Type, and place it in the first available rivnut listed with the same Type. This is simple to code, but will likely be slow. 2) Pick up the first screw in the list, check its Type, and place it in the closest rivnut of the same Type. This is a little more complex to code up, but should greatly reduce the total distance traveled by the robot. 3) Find every possible valid screw-­‐rivnut combination, compute the distance for each of the sequences, and then choose the optimum path. Coding this is a challenge, but it guarantees you get the shortest distance. 4) Let MATLAB randomly choose a sequence of moves for you, check to ensure the moves are valid (i.e. the screw and rivnut types match), and then compute the distance. Repeat this processes thousands of times. It is statistically likely you will find one of the most efficient sequences using this approach. You’ll need to research how to get MATLAB to randomly choose sequences (see the next page for hints). To check or not to check: You already know that some of the screws will already be in a valid rivnut at the start. Therefore, it may be wise to check to see which screws actually need to be moved. This may not be necessary to successfully complete the task, but if you are moving a screw that is already in a valid rivnut, it is going to significantly slow down the robot and hence you’ll be losing points! Page 6 of 7 ROSE-HULMAN INSTITUTE OF TECHNOLOGY
Department of Mechanical Engineering
ME 123
Comp Apps I
Useful MATLAB Syntax and Commands: As the instructors came up with their own solutions, a few of us used some MATLAB syntax and commands that we have not yet taught you. Using these commands and syntax is certainly not necessary to complete this project, but we wanted to provide the information in case you were interested. Deleting a row or column: Consider a matrix ⎡1 2 3⎤
[ A] = ⎢⎢4 5 6⎥⎥ ⎣⎢7 8 9⎦⎥
Recall, this could be created in MATLAB as follows: A = [1 2 3; 4 5 6; 7 8 9];
Let’s say you wish to delete the second row of the matrix for some reason, which would result in ⎡1 2 3⎤
[ A] = ⎢
⎥ ⎣7 8 9 ⎦
This can be done in MATLAB using the following syntax: A(2,:) = [];
You can think of this as replacing all the columns in row 2 of matrix A with nothing. Similarly, if you wanted to delete the third column, the syntax would be A(:,3) = [];
Permuting various sequences:
MATLAB has a number of built-­‐in functions to compute permutations, combinations, random numbers, etc. Here are some functions that you may wish to investigate: rand, randi, perms, randperm, unique, nchoosek
Page 7 of 7 
Download