1 / 64

Working with the S110 & Karel Controller Robot System

Working with the S110 & Karel Controller Robot System. ME 3222 Controls and Mechatronics Lab R. R. Lindeke. Outline of the Study:. The System: Robot Control Cabinet and System Teaching/Controlling the System A study of Karel as a programming environment: Looping I/O Subroutines

idana
Télécharger la présentation

Working with the S110 & Karel Controller Robot System

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Working with the S110 & Karel Controller Robot System ME 3222 Controls and Mechatronics Lab R. R. Lindeke

  2. Outline of the Study: • The System: • Robot • Control Cabinet and System • Teaching/Controlling the System • A study of Karel as a programming environment: • Looping • I/O • Subroutines • Interrupters

  3. The S110 Arm: • 5 DoF Indirect Drive Articulator: • Exhibits the d2 offset characteristics • Max speed is: 1500 mm/sec at the tool center point (notice arm speed not joint speed controller!) • Capable of Optimal (Joint) motion; Linear motion and Circular motion

  4. Working Map of the Robot:

  5. Working Data: S110 -- 5Axis

  6. Working with the System: • In Karel systems, the Program development is separate from the Geometry development! • In Karel, we develop natural language (Pascal/C) programs that require strict structural rules be followed • Each “Program” requires 3 files types (name.kl, name.pc and name.var) for complete execution

  7. Using the Controller: User Interface Panel tools • Power ON < ----- > Power Off (as required) • REMOTE ON – External Controller is “in Charge” -- REMOTE OFF – Standard Operating Panel is “in Charge” • MEMORY PROTECT ON – No Programming Changes can be done -- MEMORY PROTECT OFF – Programs can be changed (edited or positions and variables are as last written ie. updated) • FAULT RESET BUTTON – Repowers Servos after robot faults are cleared • CALIBRATE PUSH BUTTON – Moves Arm to Oriented Position • CYCLE START – Runs or Restarts (Paused) Programs • HOLD Button – Pauses Program by decelerating to a stop (THE WAY PROGRAMS SHOULD BE TERMINATED ‘IN THE MIDDLE’)

  8. U.I.P. LCD Screen: Were it all happens!

  9. Starting up in KAREL: • On the controller LCD, Press Soft key (S.K.) F1 to activate KCL • Then S.K.: Develop • Then S.K.: Default and enter a program name • Then S.K.: EDIT to enter editor • After entering editor for the first time, with a new program we enter the letter I (Capitol ‘eye’ for insert) to generate a line for starting the program (note: Insert places a line after the current line in the program)

  10. Writing the 1st Program: • All programs begin with a Define Line: • PROGRAMNAMED_1 • All programs end with the line: • ENDNAMED_1 • Because Karel is DISCIPLINED in design, we must define all variables (and initialize them) before use • Requires a variable definition section • All executable code follows a BEGIN statement (on a separate line)

  11. A 1st Program structure: PROGRAM NAMED_1 -- comments as desired -- more -- more CONST -- optional -- as needed VAR IDENTIFER: TYPE (Position and Integer among others) IDENTIFER: TYPE -- as needed BEGIN -- Program steps as required …. $SPEED = RATE – rate an integer variable, mm/sec at tool center point WITH $SYSVAR = XXXX, <$SYSVAR = YYY> MOVE TO POS_1 DELAY 20 … -- Continue, note this symbol – introduces a comment line … END NAMED_1

  12. Variable Types in Karel: • Acceptable DATA_TYPES • Simple types are: Integer, Real, Boolean, String[length] • Structured types are: Array[size], Position, Vector, Path • Example: DICK, JANE, SPOT: POSITION WORDY: STRING[10] RATE, W: INTEGER DIST1: REAL PATH_A: PATH TABLE_1: ARRAY[12] OF INTEGER -- Format is “IDENTIFIER (a name):DATA_TYPE”

  13. System Variable are very important – they control movement of the arm –and program execution • $TERMTYPE – We will choose one of: • FINE – target is closely approached • COARSE – target is also closely approached • NOSETTLE – Here, when the controller first senses that we are ‘at the target’ the controller begins execution of the next command! • NODECEL – Here, when the controller first senses that we have entered the deceleration zone for a target position the controller begins execution of the next command! • $MOTYPE – We have available 3 types: • JOINT – an optimal mode of motion, smooth curves between positions • LINEAR – a mode that tracks straight lines between the positions or nodes on paths • CIRCULAR – a mode that interpolates circles between positions • $SPEED • The speed of the tool tip measured in mm/sec (MAX is 1500). • In code we state: $SPEED = RATE or $SPEED = 500 • Here the arm speed takes on the value of the variable RATE (or it can be a constant) • As a Variable, it can be entered and changed using the Teach Pendant, or within the program code to offer more flexibility in execution

  14. KAREL has some useful tools to Work with Relative Geometries: • MOVE AWAY – a function that moves the TCP away from the current TCP position by a real number of millimeters along the negative ZTOOL (approach) direction • MOVE NEAR – a function that move close to (near!) a defined position. The stopping point is along the negative ZTOOL (approach) direction by a real number of millimeters that is stated in the command

  15. KAREL has some other useful Geometric tools: • CURPOS – a function that extracts the current arm geometry and stores it into a Position Variable • PATHPOS – a function that extracts a path node’s geometry and puts it into a Position Variable • SHIFT – a function that changes a defined position by adding a vector (which is also defined) to the current value of the Position Variable – orientation is unchanged

  16. Completing Program Entry (in the Editor): • After the Program has been written, the operator Types “S” to force a check of program syntax • Then the operator types “E” to exit and compile the code • This creates a file called NAMED_1.pc • After successful Compilation we must load the program and variable files to continue work: • using the teach pendent • running the program • Type LO AL [NAMED_1] on UIP or use KCL S.K. for Load then S.K. All

  17. Karel Coding can be produced when Working “Off-line” • Employs a soft EMULATOR called: KFLOPPY. The emulator works with an RS232 interface between the S100 Control and a local PC. • The Emulator is a “Command” program requires us to open a Command Window on the PC – actually it is best to open 2! • In the first Command Window type: • cd .. • then type: cd/KAREL • then type: KFLOPPY • Finally, press F3 (PC’s function key) to execute the Emulator (the PC is treated as a Floppy ‘storage device’ w.r.t. the Main Karel Controller) • To bring a program to the PC, start the emulator, set up the proper directory for storing the file that will be downloaded

  18. Working Offline, cont. • Return to the S110 UIP • Choose KCL S.K. then type: Copy[/OVERWRITE] BM:FILENAME.KL FD: • type OVERWRITE if the program already resides on the PC in the chosen directory this will copy the current version of filename to the PC.

  19. Working Offline, cont: • In the Second Command window we type CD .. • Type EDIT to open the structure-less text Editor • this will allow Mouse navigation and line number identity • Note: restrict any typed line to about 50 characters in length so compilation errors are not induced.

  20. Working Offline, cont: • Once the Editing of the code is completed on the PC and we wish to upload the completed code to the S100 Control: • Choose KCL S.K. then type: COPY/OVERWRITE FD:FILENAME.KL BM: • this will copy the current version of filename from the PC to the S100 Control. • NOTE: To use this changed version we must re-edit and “E” – compile – then reloaded program before it can be used

  21. Working with the Geometry Control, ‘IN PARALLEL’ • When we start our program, it makes sense to define all required (preplanned) working Geometries • Both Positions and Paths • Additionally, we will define any anticipated integer and real variables • Before uploading the Karel program for coding “off-line”, we should compile the skeletal program and load it into working memory

  22. We Then Begin Programming Positions Using The Teach Pendent • This speeds up program development • On the teach pendent we move the arm then store to position names (and save) our geometries and variable values • While any geometry programmed during a session is immediately available, they will not be written to a permanent record without our action!

  23. Using the Teach Pendent: General View

  24. Teach Pendent : LCD info

  25. Teach Pendent: Motion Details

  26. Defining Geometry: • Done separately from program generation! • Require Position or Path variables to be initialized as a program variable and then loaded into working memory – as discussed earlier • Specific geometry is programmed using the teach pendent • After desired geometries are driven to, programmed and checked, they MUST BE SAVED! • No auto-save of geometries in the KAREL environment!

  27. Positional Programming (T.P.) • Step 1: Compile and load the program on the Control • Step 2: Enable TP; Press KCL S.K. select default and enter desired program name • Step 3: Press Previous Menu 2 times, Choose F1 S.K.: TEACH • Step 4: Uses Cursor scroll keys to highlight Position Variables • Step 5: Move Robot to desired position – highlight the desired pos_name Variable; Press SHIFT + F1 (RECORD S.K. in Teach menu)

  28. Positional Programming (T.P.) • Step 6: On Controller interface Panel (UIP) on KCL sub-menu press MISC S.K., then press WHERE S.K., verify that both TP and UIP show same geometry • Step 7: On new choices press DONE S.K., this automatically (but temporally) stores the position geometry and cursors to the next position name, repeat 4 – 5 – 6 for all positions • Step 8: Once all positions have been ‘programmed’ press SAVE S.K. to store all the defined geometries into the file called: file_name.VR • NOTE: if you didn’t SAVE after defining your positions and then the robot system is powered down – all would be lost!!!

  29. Modifying/Editing Variables (T.P.) • Step 1: Compile and load all, enable TP; Press KCL S.K. select default and enter desired program name • Step 2: Press Hard Key: DISPLAY SELECT; from Menu Displayed, Select S.K. F2: VARS • Step 3: Press S.K. F2, PROGVAR – new menu; use cursor arrows to move to desired data name • Step 4: Press S.K. F5, KCL; Press S.K. F4, DATA • Step 5: Press S.K. F1, SET • Step 6: Key in the desired value (use number keypad), Press ENTER key • STEP 7: Remember to SAVE data if desired (for a permanent record!)

  30. Developing Path Variables (T.P.) • Step 1: Add PATH_NAME:PATH to the Variables section of your program • Step 2: Compile and load all, enable TP; Press KCL S.K. select default and enter desired program name • Step 3: Press Hard Key: Display Select; From Menu that is displayed, Press S.K. F2, VARS • Step 4: Press S.K. F1: POSVAR; Cursor arrows to the path name desired; Press Hard Key: PREV MENU

  31. Developing Path Variables (T.P.) • Step 5: Press S.K. F1: TEACH; Press S.K. F5, MORE • Step 6: Press SHIFT + APPEND (S.K. F2), this creates a node point PATH_NAME[1] (uninitialized) • Step 7: Move robot to desired position, again cursor to the PATH_NAME[1] label; Press SHIFT + Record (S.K. F1) – this is in the Teach submenu • Step 8: On new choices press the DONE S.K., this automatically appends and positions cursor for a new node, repeat steps 7 and 8 to add all nodes.

  32. Other Tools for Paths (T.P.) To maneuver through the nodes and add new nodes by inserting or appending, • Press TEACH S.K. (F1), press TEACH S.K. (F1) then • Press MORE S.K. (F5): • Display shows: Delete (F1), Append (F2), Insert (F3) and INDEX (F4). • To use these keys press SHIFT + Fi (they work like this): • Append: Adds node at end of list • Delete: Removes currently highlighted Node (renumbers the rest) • Index: after entering a node value moves you to that node • Insert: Inserts a node ahead of the currently highlighted node and re-numbers the existing nodes

  33. Focusing on KAREL: Moving Commands • MOVE TO POS_1 (MOVE TO PATH_NAME [j]) • WITH – allows local override of motion controls – $speed, $termtype, $motype • Path Motion: • MOVE ALONG PATH_NAME [i .. n] • i can be greater or less than n! • Allows smooth path following • Circular Motion: • MOVE TO OTHER VIA LT_ONE • forms 3 point arc from current position to OTHER (position Variable) passing thru position variable LT_ONE

  34. Program Control In KAREL: • We will study three looping Techniques: • For – Do loops • A fixed number of repeats that is automatically incremented (decremented) by the program manager • Do – While loops • Performs boolean evaluation at the beginning of a loop and enters only if expression is true • Repeat – Until loops • Executes loop once and checks for repeat if a boolean evaluation is not yet true

  35. Focus on Karel: Looping Commands (For Loops) • FOR CT_VAR = INITIAL_VALUE TO {or DOWN TO} FINAL VALUE DO •  STATEMENTS  • ENDFOR • Using this structure, the CT_VAR is automatically incremented by Program Control • Useful if we KNOW how many times we wish to iterate like populating an array, traversing individual nodes on a Path, etc. • Note, however, that the Initial and Final values can be variables which the program can change!

  36. Focus on Karel: Looping Commands (Do While Loops) • WHILE (Boolean expression) DO •  STATEMENTS  • ENDWHILE • Note the Boolean expression is evaluated before the loop is entered • A Boolean Expression is one that Evaluates to true or false • true = Numerically Positive Number or the keyword TRUE • false = Numerical Zero or keyword FALSE

  37. Boolean Expressions in KAREL • Examples of Boolean Expressions that will “work” in KAREL: • (Count <= MAX_NUM) – here it could be infinite if we don’t increment Count as part of the statements in the looping structure • (DIN 1) – executes While loop as long as the input port 1 is “On” – a logic high event; • Will allow the escape from a repeat loop when the input port goes on • This makes the condition true and is useful for handshaking communication within Karel

  38. Focus on Karel: Looping Commands (Repeat Until Loops) • REPEAT  UNTIL (boolean Expression) • Looping is executed until the boolean expression is true – will always execute once since testing is performed at the end of the loop structure. • Same Rules Apply for the (boolean) expression as with Do While • Structurally: • REPEAT •  STATEMENTS  • UNTIL (A Boolean Expression)

  39. Program Control In KAREL: • Karel also supports the Case Structure • It evaluates an integer variable • Then executes the appropriate set of statements as determined by the value

  40. Focusing on KAREL: Case Statements: • SELECT GP_COUNT OF • CASE (1): •  STATEMENTS  • CASE (2): •  STATEMENTS  • CASE (6): •  STATEMENTS  • all appropriate cases defined • ELSE: •  STATEMENTS  • ENDSELECT • NOTE: The value of GP_COUNT (an integer variable) must be defined before executing the Select (case) statement!

  41. Focusing on KAREL: Two types of Subroutines • PROCEDURES: A sequence of Program statements invoked, by name, like a single Program Statement: • PRO_NAME(var1, var2) • FUNCTIONS: A sequence of Program statements (they can be a series of computations) invoked like a single program statement, by name, but that RETURNs a single value to the calling variable: • DICKY = FUN_NAME(var1,var2) • In either case the programmer can send values (as pointers) into the routine as defined in the Routine definition statement

  42. General Ideas on Subroutines: • They Are Used To “MODULARIZE” KAREL Programs • They are Similar In Structure To Programs • They Have A Name • They Can Have Local Variables And Constants • They Require An End Routine_Name statement • RoutinesMUST be Declared Within a Program (Functions before they are used!) • Routines Can NOT Include Other Routine Declarations • (but then, why would we need to?)

  43. Why We use These Routines: • They can be used over and over throughout a program (whenever they are needed they are called) so we find that entering the same code only once reduces entry errors that are often hard to “De-Bug” • They provide consistency and maintainability (vs typing duplicate codes in many places) – we need only make a single change within our definitional section and every instance (ie. Call to the Function) is automatically updated!

  44. BUILDing A PROCEDURE • ROUTINE PRO_NAME <(parameter list)> -- parameter list is optional • -- comment • VAR – optional and as needed, any variables declared here are “local” • -- NOTE: no local Path Variables or variables from another program • CONST – optional section as needed • -- • BEGIN •  STATEMENTS  • END PRO_NAME • NOTE: The optional parameter list is use to PASS Variables from the main program to the “subroutine” • Note: Procedures are little programs built within other programs!

  45. BUILDing A FUNCTION • ROUTINE FUN_NAME <(parameter list)>: return_type • -- parameter list is optional • VAR – optional and as needed, any variables declared here are “local” • -- NOTE: no local Path Variables or variables from another program • CONST – optional section as needed • -- • BEGIN • STATEMENTS  • -- Somewhere we must include a RETURN<(VALUE)> statement • END FUN_NAME • NOTE: The optional parameter list is use to PASS Variables from the main program to the “subroutine” • Note: Routines are little programs built within other programs!

  46. Procedures & Functions • In a FUNCTION: When We Encounter A RETURN Statement -- • Control is immediately restored to the calling PROGRAM or ROUTINE • Returns the current value of the return variable to the calling location – return variable must be of type: return_type as defined in the function definition statement • Note if END statement is encountered in the FUNCTION – ie. No return is found – we get a fatal error!!

  47. Procedures & Functions • In a PROCEDURE: if we encounter a return statement -- • Program control will immediately be restored to the calling program or routine. • Same happens if we encounter the END statement without a return. Note, end statement does not produce an error since no return value is needed!!

  48. A Comment on Variables • By default, all PROGRAM variables are Global • Within a program (even in a sub-routine) any changes in a variable will be evident everywhere • If variables are needed within a subroutine we pass the values – typecast – through the parameter list defined in the Routine declaration • Note: during definition we set type and order as well as a local name • When we invoke a routine during execution, we place global variable names in the appropriate positions in the parameter list as defined using the call statement

  49. Looking At Program Interrupters • In Karel these actions are considered “Conditions” – or so-called Condition Handlers and are treated as a separate thread during program execution • As a separate thread, they are continuously monitored “In the Background” while the main program thread operates in the foreground

  50. USES: • Handle program interruptions such as errors, program pauses, program aborts or Emergency Stops that are unexpected (in a time sense) but can be anticipated to occur • They also Monitor and Control PERIPHERAL EQUIPMENT using Port I/O that can happen at unexpected times • They can Detect and Handle Time Out Conditions

More Related