Brad Hamner Robotics Institute – Carnegie Mellon University April 8, 2008.

Slides:



Advertisements
Similar presentations
Driving Test 1 Marking Scheme Focus on five areas to pass driving test 1.
Advertisements

Yoshi
Exception Handling Chapter 15 2 What You Will Learn Use try, throw, catch to watch for indicate exceptions handle How to process exceptions and failures.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 15: Exception Handling.
CSE 332: C++ exceptions Overview of C++ Exceptions Normal program control flow is halted –At the point where an exception is thrown The program call stack.
Chapter 16: Exception Handling C++ Programming: From Problem Analysis to Program Design, Fifth Edition.
Objectives In this chapter you will: Learn what an exception is Learn how to handle exceptions within a program See how a try / catch block is used to.
Chapter 8Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 8 l Basic Exception Handling »the mechanics of exceptions l.
Chapter 12 By Tony Gaddis Modified by Elizabeth Adams Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 16: Exception Handling.
Jerry Lebowitz. Topics  Provides a facility for a systematic object oriented approach to handling runtime errors ◦ Can also handle runtime errors.
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
COP INTERMEDIATE JAVA Exception Handling Serialization.
Exceptions. Errors and Exceptions An error is a bug in your program –dividing by zero –going outside the bounds of an array –trying to use a null reference.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Spring 2005 Chapter 8  Errors and Exceptions Throwable class.
Chapter 11: Distributed Processing Variations of subprogram control
Exceptions. Many problems in code are handled when the code is compiled, but not all Some are impossible to catch before the program is run  Must run.
Week 14 - Monday.  What did we talk about last time?  Image manipulation  Inheritance.
June 14, 2001Exception Handling in Java1 Richard S. Huntrods June 14, 2001 University of Calgary.
CIS 270—Application Development II Chapter 13—Exception Handling.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
COMPUTER PROGRAMMING 2 Exceptions. What are Exceptions? Unexpected events that happen when the code is executing (during runtime). Exceptions are types.
Slides Credit Umair Javed LUMS Web Application Development.
Exceptions 1. Your computer takes exception Exceptions are errors in the logic of a program (run-time errors). Examples: Exception in thread “main” java.io.FileNotFoundException:
Bill's Amazing Content Rotator jQuery Content Rotator.
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
COMPUTER PROGRAMMING. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may repeat code.
Errors And How to Handle Them. GIGO There is a saying in computer science: “Garbage in, garbage out.” Is this true, or is it just an excuse for bad programming?
Exceptions Syntax, semantics, and pragmatics Exceptions1.
Architecture for Autonomous Assembly 1 Reid Simmons Robotics Institute Carnegie Mellon University.
A Language for Task-Level Executives Reid Simmons David Apfelbaum Carnegie Mellon University.
Introduction to Exception Handling and Defensive Programming.
Chapter 14: Exception Handling. Objectives In this chapter, you will: – Learn what an exception is – Learn how to handle exceptions within a program –
CPS120: Introduction to Computer Science Decision Making in Programs.
Exceptions in Java. Exceptions An exception is an object describing an unusual or erroneous situation Exceptions are thrown by a program, and may be caught.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
BIO Java 1 Exception Handling Aborting program not always a good idea – can’t lose messages – E-commerce: must ensure correct handling of private.
1 CS161 Introduction to Computer Science Topic #9.
Computer Programming with JAVA Chapter 8. Exception Handling Basic Exception Handling the mechanics of exceptions Defining and Using Exceptions some "simple"
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
Mike Graves Summer 2005 University of Texas at Dallas Implicit Invocation: The Task Control Architecture Mike Graves CS6362 Term Paper Dr. Lawrence Chung.
Autonomy for General Assembly Reid Simmons Research Professor Robotics Institute Carnegie Mellon University.
CRE Programming Club - Class 2 Robert Eckstein and Robert Heard.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
CSE 332: C++ Statements C++ Statements In C++ statements are basic units of execution –Each ends with ; (can use expressions to compute values) –Statements.
Christina Aiello, 12/3/2015. Reminder: Seen in lecture notes for Exceptions: “Side note: we will NOT expect you to know/remember how to do keyboard input/output.
Chapter 15: Exception Handling C++ Programming: Program Design Including Data Structures, Fifth Edition.
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
Copyright © Curt Hill Error Handling in Java Throwing and catching exceptions.
CS116 COMPILER ERRORS George Koutsogiannakis 1. How to work with compiler Errors The Compiler provide error messages to help you debug your code. The.
Written by: Dr. JJ Shepherd
(c) University of Washington10-1 CSC 143 Java Errors and Exceptions Reading: Ch. 15.
JavaScript and Ajax (Control Structures) Week 4 Web site:
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
CHAPTER 18 C – C++ Section 1: Exceptions. Error Handling with Exceptions Forces you to defend yourself Separates error handling code from the source.
Introduction to Exceptions in Java CS201, SW Development Methods.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
Exceptions in the Java programming language J. W. Rider.
Programming Language Basics. What is a Programming Language? “A computer, human-created language used to write instructions for a computer.” “An artificial.
User-Written Functions
Syntax, semantics, and pragmatics
Error Handling Summary of the next few pages: Error Handling Cursors.
CS 240 – Lecture 11 Pseudocode.
Chapter 14: Exception Handling
PL/SQL Scripting in Oracle:
Java Programming Language
Programming Language Basics
CMSC 202 Exceptions.
Exceptions.
Presentation transcript:

Brad Hamner Robotics Institute – Carnegie Mellon University April 8, 2008

 Concerned with accomplishing tasks  Breaking tasks into subtasks  Sequencing tasks to achieve larger goals  Recovering if a task fails  By launching more tasks

 The base unit of the executive layer is…  The task!  Tasks are written in TDL  Task Description Language

 Written on top of C++  Like C++, but with extra keywords and syntax  Allows  Tasks to be spawned on any agent  Sequencing of tasks ▪ A starts after B ends ▪ A starts 10 seconds after B ends ▪ A starts after B starts ▪ A starts after B starts and B ends when A ends ▪ A and B end together ▪ …

 src/Scenarios/Ace/LeaderAgent/Feb2008A ceDemoTask.tdl  What you should learn here:  Task header  spawn  with  serial  On : Spawn a task on another agent  Naming a task in the tree

 See the manual 

 Goal and Command keywords essentially mean same thing  Use Goal when task spawns other tasks  Use Command otherwise

 Put Distributed before task header to make it possible to spawn this task from another agent

 On agentname,you know  But the agentname isn’t really agent name  Agent has executive and behavioral layer  Need to tell TDL to use executive layer  So really it’s On agentname:exec

 Frequently, you want to make something happen, then wait for results  Use POSTPONE  Then you make “resume clauses”  Functions that say what happens next

 Task is postponed  Waiting for results or error notification  Notification comes from events or IPC messages  Need handlers to receive these  Handlers will call a resume clause

 See IPC slides for basics on handlers  For now, see src/Scenarios/Ace/LeaderAgent/RoughBas eMoveTask.tdl  Spawns PoseEstimationTask and postpones  Handler catches pose result  Resumes Task  Resume clause spawns base move

 Handler needs to spawn a specific task  Could be more than one of a task in the tree  Therefore, you need task reference  In main task clause, create reference to self  Pass self reference to handler  Handler uses reference to resume right task

 Handler calls resume clause with task reference  Resume clause’s header doesn’t have task reference  TDL does some automatic compiling there

 Have to check the task didn’t disappear while waiting for event or message  It’s that big if statement in example handlers  Just copy that when you write a handler

 Task’s parameters are persistent between main function and resume clauses  Anything else you want is declared PERSISTENT  Task reference needs to be accessed by handler  So it’s persistent

 Create an event reference  SkmInterface::EventRef eventRefName  Subscribe to the event  eventRefName = skm->subscribeEvent (“BlockName");  Connect the event to a handler  eventRefName().connect(bind(slot(&eventCall backName), taskSelfRefName));

 Event callbacks similar to IPC handlers  See src/Components/MobileManipulator/GoToGoalT ask.tdl  Make the event ref persistent if you want to unsubscribe later  skm->unsubscribeEvent(eventRefName);

 Here’s an example

 TDL creates different header files for tasks to be spawned on same agent (locally) vs. tasks to be spawned on different agent (remotely)  Creates task.tdl.loc.H and task.tdl.rem.H  Be sure to include the right one when you need to spawn that task

 I haven’t used these yet, but I’ll explain what I know

 Somewhere you declare a type of exception  Use the Exception keyword and give it a name  Also give it a data type  Exception exceptionName (DataType dataName);  See src/Components/Tasks/VisualServo/VisualS ervoWaypointTask.tdl

 Then throw the exception  FAIL exceptionName (data);  This keyword ends the task as well

 Somewhere up the task tree  Ie. A task that spawned the failing task or its parent  Create an exception handler

 See src/Components/Tasks/VisualServo/VisualS ervoTask.tdl  Declare the handler in the task header

 Then in the handler header say what it handles  Resuming the task is usually a good thing to do in the handler Remember the exception data?

 If parent task doesn’t handle exception, system searches its parent task, etc., until it finds one that does  If no task handles exception, everything goes boom  (I think)

 Common model is action task paired with monitor task  Action task tries to actually complete the task  Monitor task checks status info and makes sure task completes