Rule-based control Northwestern University CS 395 Behavior-Based Robotics Ian Horswill.

Slides:



Advertisements
Similar presentations
CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
Advertisements

Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 17 Templates.
Pascal Syntax. What you have learnt so far writeln() and write(); readln() and read(); variables (integers, strings, character) manipulation of variables.
Selection Control Structures Chapter 5: Selection Asserting Java © Rick Mercer.
1 Languages and Compilers (SProg og Oversættere) Code Generation.
Lecture 8: Three-Level Architectures CS 344R: Robotics Benjamin Kuipers.
Chapter 3 Functional Programming. Outline Introduction to functional programming Scheme: an untyped functional programming language.
Introduction to Object-Oriented Programming CS 21a: Introduction to Computing I First Semester,
Expert System Human expert level performance Limited application area Large component of task specific knowledge Knowledge based system Task specific knowledge.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Goals, plans, and planning Northwestern University CS 395 Behavior-Based Robotics Ian Horswill.
Means-ends analysis Northwestern University CS 395 Behavior-Based Robotics Ian Horswill.
Conflict resolution CS 395 Behavior-Based Robotics.
CSE241 R1 Verilog.1Kahng & Cichy, UCSD ©2003 CSE241 VLSI Digital Circuits Winter 2003 Recitation 1: Verilog Introduction.
Thirteen conditional expressions: letting programs make “decisions”
Fall 2004COMP 3351 Context-Free Languages. Fall 2004COMP 3352 Regular Languages.
4/6/08Prof. Hilfinger CS164 Lecture 291 Code Generation Lecture 29 (based on slides by R. Bodik)
CPSC Compiler Tutorial 3 Parser. Parsing The syntax of most programming languages can be specified by a Context-free Grammar (CGF) Parsing: Given.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
State Machine Diagram Chapter 10. State Machine Diagram Used to describe system behavior.
Some Useful Circuits Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
SUNY Polytechnic Institute CS 490 – Web Design, AJAX, jQueryAngularJS AngularJS is a client-side JavaScript Framework for adding interactivity to HTML.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Programmatic Building of Models Just for Pretty Printing DSM October 2006 Tero Hasu Helsinki Institute for Information Technology.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 10Slide 1 Architectural Design l Establishing the overall structure of a software system.
©Ian Sommerville 1995 Software Engineering, 5th edition. Chapter 13Slide 1 Architectural Design u Establishing the overall structure of a software system.
Prof. Bodik CS 164 Lecture 51 Building a Parser I CS164 3:30-5:00 TT 10 Evans.
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
Architectural Design portions ©Ian Sommerville 1995 Establishing the overall structure of a software system.
Introduction to Object-Oriented Programming
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 10Slide 1 Architectural Design l Establishing the overall structure of a software system.
Introduction to Parsing Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
Lesson 3 CDT301 – Compiler Theory, Spring 2011 Teacher: Linus Källberg.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
CPS120: Introduction to Computer Science Lecture 14 Functions.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
Semantics In Text: Chapter 3.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
A Level Computing#BristolMet Session Objectives#U2 S3 MUST use/read programme flow charts accurately SHOULD adapt the calculator programme to include a.
COMP 3438 – Part II-Lecture 6 Syntax Analysis III Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
Topics for today: 1.Comments 2.Data types 3.Variable declaration.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Anupam Joshi University of Maryland, Baltimore County Joint work with Tim Finin and several students Computational/Declarative Policies.
CSE 341 Lecture 21 delayed evaluation; thunks; streams slides created by Marty Stepp
Clojure Macros. Homoiconicity All versions of Lisp, including Clojure, are homoiconic This means that there is no difference between the form of the data.
Operational Semantics of Scheme
Programming and File Management Part 2
Introduction to Parsing (adapted from CS 164 at Berkeley)
Add and subtract complex numbers
Ch. 4 – Semantic Analysis Errors can arise in syntax, static semantics, dynamic semantics Some PL features are impossible or infeasible to specify in grammar.
Syntax Analysis Sections :.
Debugging with Eclipse
Phil Tayco Slide version 1.0 Created Oct 2, 2017
Programming Fundamentals (750113) Ch1. Problem Solving
Rosen 5th ed., §2.1 ~31 slides, ~1 lecture
Algorithm and Ambiguity
Rules of evaluation The value of a number is itself.
Rosen 5th ed., §2.1 ~31 slides, ~1 lecture
6.001 SICP Variations on a Scheme
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Introduction to Object-Oriented Programming
Chapter 3: Selection Structures: Making Decisions
Avoiding Run-on Sentences, Comma Splices, and Fragments
Debugging with Eclipse
Programming The ideal style of programming is Structured or
Presentation transcript:

Rule-based control Northwestern University CS 395 Behavior-Based Robotics Ian Horswill

Outline  A digression on accumulators, a cute feature of GRL  Rule-based control  Other cool topics, time permitting

GRL example (define-signal p (and q r)) (define-signal q (and r s)) (define-signal r (or t u (not v)))

Accumulators  It’s sometimes a pain to specify signals in terms of their inputs  Sometimes you’d prefer to specify them by their outputs  An accumulator is a signal that searches for its inputs at compile time  Inputs are specfied by tagging them with a drives declaration

Using accumulators  Signal definitions can be annotated with declarations  (type t) Signal is of type t  (drives accumulator …) Signal is an input to the specified accumulators  (requires signal …) If you compile this signal, also compile these others (define-signal p (and q r)) (define-signal q (and r s)) (define-signal r (accumulate or)) (define-signal t … (drives r)) (define-signal u … (drives r)) (define-signal foo (not v) (drives r))

If only you could just say … (if (and q r) p) (if (and r s) q) (if t r) (if u r) (if (not v) r))

The rules macro  First line means “r is a signal that’s an OR of other sigals, but I’m not telling you which ones yet.”  Says:  Signal r should be true when t, u, or not v  Z should be true when a and not (q and r) (define-signal r (accumulate or)) … (rules (when a (if (and q r) p z) (if (and r s) q)) (if t r) (if u r) (if (not v) r))

Equivalent code using define-signal  The compiler generates the same code for these two examples (define-signal r (or t u (not v))) (define-signal p (and a q r)) (define-signal z (and a (not (and q r)))) (define-signal q (and a r s))

How to write the rules macro (simplified version)  The declare expression adds a new declaration to the signal ?ante (define-syntax rules (syntax-rules () ((rules (if ?antecedent ?consequent) …) (signal-expression (list (declare ?ante (drives ?conseq)) …))))))

Outline A digression on accumulators, a cute feature of GRL  Rule-based control  Other cool topics, time permitting

The story so far …  Programs  policies  Compose policies from behaviors  Behavior = policy + trigger  Bottom-up composition using arbitration  Behavior-or, behavior-+, behavior-max  Behaviors self-activate  Top-down composition using plans  Routine activates subroutine  Subroutine activates sub-subroutines, etc.  Leaves activate behaviors

Playing a first-person shooter  If you see ammo, get it  If you see a bigger gun than you have, get it  If you see an enemy { if they have a bigger gun run else kill them }

Using bottom-up control  Code is hard to understand  Can’t really understand the logic of run-away without also reading code for attack the drive-base call.  Okay, so this is a lame example. I can’t think of a better one that’s compact enough for a slide. (define-signal get-ammo (behavior see-ammo? …)) (define-signal get-weapon (behavior (and see-weapon? studly-weapon?) …)) (drive-base (behavior-or get-ammo get-weapon attack run-away))) (define-signal attack (behavior (and see-enemy? (not studly-enemy?)) …)) (define-signal run-away (behavior see-enemy? …))

Top-down control using plans  Separates definition of how to perform behavior from when to perform behavior  Makes it easier to take complex contexts into account in selecting actions  But actions aren’t interruptable … (define-plan (live-and-let-die) (while #t (cond (see-ammo? (get-ammo)) … (see-enemy? (if studly-enemy? (run-away) (attack)))))) (define-action ( get-ammo ) (terminate-when have-ammo?) …) (define-action ( get-weapon ) …) (define-action ( attack ) …) (define-signal ( run-away ) …) (drive-base get-ammo get-weapon attack run-away)))

Rule-based top-down control  Control is reactive  Rules and behaviors can be interrupted  Note terminate-when has been removed  Still separates activation from behaviors (rules (when see-ammo? (get-ammo)) (when (and see-weapon? studly-weapon?) (get-weapon)) (when see-enemy? (if studly-enemy? (run-away) (attack)))) (define-action ( get-ammo ) …) (define-action ( get-weapon ) …) (define-action ( attack ) …) (define-signal ( run-away ) …) (drive-base get-ammo get-weapon attack run-away)))

Rule syntax  (if test consequent alternative) (if test consequent) Self-explanatory  (when test consequents …) (unless test alternatives …) Same, but multiple outputs  (let ((var expr)) rules …) Also let*, letrec  (set! register value) Sets register to value when rule runs.

Rule syntax (2)  Allowable consequents and alternatives  An accumulator  Another rule  (action args …) Runs the action as long as the test is true  (start! (action args …)) (stop! action) Starts/stops up the action whenever rule is true

Rules as actions  (define-rule-action (name args …) (terminate-when expression) rules …)  Like define-plan or define-action in that it can be called as an action  But rules only “run” when action is “called”  If action stopped, all rules immediately retract

Outline A digression on accumulators, a cute feature of GRL  Rule-based control  Other cool topics, time permitting