Student Work W2014

Friday, February 14, 2014

Creating a Tool in superMatterTools

Hey! So today, you learn how to teach a tool not manually, but digitally, to the robot.
There are two parts to this. 1) you need to give the robot the tool, and 2) you need to tell it what it is. We will be working in Rhino and in Python, respectively.
We are going to start by taking an existing tool and converting it into our tool, the Pointy Cylinder. You can find the existing tools in the SMT/Resources/Geometry folder.
I'm starting with Laser_UofM.3dm, but you could use any of the other tools in there. You're going to notice all the tools are names <toolname>_UofM. This is important. First thing we're going to do is Save As so we have our own file and we get rid of an existing tool. I now have a file in the same sMT/Resources/Geometry folder named Cylinder_UofM.3dm that has a laser in it.
There are four parts of this tool. From bottom up, they are:

  1. The Orientation Points
  2. The Tool Changer
  3. The Tool
  4. The Tool Tip (TCP)

The Orientation Points and the TCP are the only parts of this model that sMT needs. The Tool and Tool Changer are what will appear when you simulate your program and are, presumably, how you will define your TCP.
The TCP is the very end of your tool, be it the nozzle of the extruder, the focal point of the laser, or the tip of your marker. It is a set of (x,y,z,a,b,c) coordinates. This point will follow the tool path precisely.
The Tool is a model of your tool. It is up to you the level of detail you want to go with this, as it will only be visible in sMT simulations. The part of this that should be precise is the tip of the tool, as that will be how you define your TCP.
The Tool Changer is what will allow us to easily switch between different tools in the future. The tools have the female end, and the robot the male end. When the male Tool Changer is attached to the robot, you will have to attach your tools to the female one in order to get them on the robot. As this has not yet happened, it is not important to us at this time.
The Orientation Points are how sMT knows the position and orientation of your tool. They are named <toolname>_UofM_Pt00, <toolname>_UofM_Pt01, and <toolname>_UofM_Pt02. They are located at the Origin, the Z axis, and the X axis, respectively. They must be named correctly in order for the tool to be read by sMT. sMT pulls a vector from 00 to 01 and another from 00 to 02, so they need not be at any specific distance, simply along the correct axis. A good rule of thumb is not to change or move anything unless you have to, however.

You can now delete any existing geometry you do not need, except for the Orientation Points. Rename these to match your file and tool name. You can rename objects at the top of the properties panel. Rename the layer that all the objects are on to match as well.
Next, we will model the tool. Look at how good I am at Rhino!
You may have noticed that all part of the existing tools are meshes and named <toolname>_UofM. We must do the same for our tool. You can do this using the Rhino command Mesh, and renaming the resulting meshes in the properties panel. When you are done modelling, don't forget to delete anything that is not a mesh or an Orientation Point! All your meshes must be "good" closed meshes, but it does not matter if they are joined or continuous or whatever. This can be verified with the Rhino command Check.
If there are any issues with your mesh, you can find instructions on how to fix it under the Mesh Diagnostics section of the Rhino 5 Check Help Article or you could try the MeshRepair plugin.
Next, locate your TCP's coordinates in your Rhino model, either a) by teaching the tool to the robot like we did for the last assignment and getting the coordinates from there, OR b) by snapping to it in your incredibly precise model and reading the coordinates from the bottom right corner of the screen. Take note of these as you will need them shortly. Convention dictates putting a point at your TCP, but it's not strictly necessary.
Save, and you have given the robot your tool. Part 1, complete!

Now we teach the tool to sMT. Open up the RhinoPython editor by typing in EditPythonScript (this should be familiar). This time, instead of opening up the usual sMT_00 file, we will be opening sMT_02_WorkCells. The following will involve editing variables in the code, but don't worry, no knowledge of code is in any way required.
First, we will edit the WorkCell Definition Dictionary. The Dictionary starts on line 355, but the Dictionary Definition we want to edit is for the Agilus Workcell. It is found at line 448. We need to include your tool as an option in the Process drop down menu. On line 449, after "Posprocess" and before the square bracket, type in a comma (,), a space ( ) and the name of your tool (<toolname>_UofM) inside quotations ("). It should look like this. Save the file.
Next, we are going to create a Dictionary Definition for our tool in the Process Dictionary. This Dictionary starts on line 539. To do this, we are going to copy an existing definition and edit it. Go ahead and copy all of the None_UofM definition (lines 546 - 577) and paste it at the end of the UofM section dictionary, before the MIT section (line 1187). Delete spacing dots as necessary if you want everything to align. For this simple tool (which doesn't turn on or off, doesn't rotate, etc) we will only have to edit 3 lines: 1188, 1192, and 1193. Line 1188 should say your <toolname> instead of the word "None". Line 1192, tCPDef, should be the coordinates of your TCP, written in (x, y, z, a, b, c). Copy them in either from real life or from your digital model. Finally, line 1193, tCPID. This should be the number of the tool you've taught the robot, or the tool number you would like it to use. This is less important now, because there are no set tools apart from yours, but will need to be more rigorous as we start adding tools. In context, with our relevant information changed, your new tool's Dictionary Definition should look something like this.
Save, and under the "Tools" menu at the top of the Python Editor, click "Reset Script Engine". You've told the robot what the tool is. Part 2 complete! You've done it! Hooray! Now you can run sMT, pick your tool, and have it not only appear in sMT but be included in your code.
To add the tool to the robots, go to
Startup -> Calibrate -> Tool -> Numeric input
Select tool no. 2 and change the x,y,z,a,b,c. Hit next to save. Should be good to go!

If there are any questions, see you guys at Office Hours.
Peace!