From Hybrid Models to Embedded Software Rajeev Alur System Design Research Lab University of Pennsylvania www.cis.upenn.edu/~alur/ Workshop on Robustness,

Slides:



Advertisements
Similar presentations
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Advertisements

1 Translation Validation: From Simulink to C Michael RyabtsevOfer Strichman Technion, Haifa, Israel Acknowledgement: sponsored by a grant from General.
Hybrid Systems Presented by: Arnab De Anand S. An Intuitive Introduction to Hybrid Systems Discrete program with an analog environment. What does it mean?
Timed Automata.
ECE 720T5 Fall 2012 Cyber-Physical Systems Rodolfo Pellizzoni.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
ISBN Chapter 3 Describing Syntax and Semantics.
An Automata-based Approach to Testing Properties in Event Traces H. Hallal, S. Boroday, A. Ulrich, A. Petrenko Sophia Antipolis, France, May 2003.
Modular Specification of Hybrid Systems in CHARON R. Alur, R. Grosu, Y. Hur, V. Kumar, I. Lee University of Pennsylvania SDRL and GRASP.
Modeling and Verification of Embedded Software Rajeev Alur POPL Mentoring Workshop, Jan 2012 University of Pennsylvania.
Systems Engineering for Automating V&V of Dependable Systems John S. Baras Institute for Systems Research University of Maryland College Park
Architecture Modeling and Analysis for Embedded Systems Oleg Sokolsky CIS700 Fall 2005.
Integrated Design and Analysis Tools for Software-Based Control Systems Shankar Sastry (PI) Tom Henzinger Edward Lee University of California, Berkeley.
System Design Research Lab University of Pennylvania 2/8/2006 CHARON modeling language.
Testing and Monitoring at Penn Testing and Monitoring Model-based Generated Program Li Tan, Jesung Kim, and Insup Lee July, 2003.
DIVES: Design, Implementation and Validation of Embedded Software Alur, Kumar, Lee(PI), Pappas, Sokolsky GRASP/SDRL University of Pennsylvania
1 University of Pennsylvania Demonstrations Alur, Kumar, Lee, Pappas Rafael Fierro Yerang Hur Franjo Ivancic PK Mishra.
Chess Review May 11, 2005 Berkeley, CA Composable Code Generation for Distributed Giotto Tom Henzinger Christoph Kirsch Slobodan Matic.
SDRL and GRASP University of Pennsylvania 6/27/00 MoBIES 1 Design, Implementation, and Validation of Embedded Software (DIVES) Contract No. F C-1707.
University of Pennsylvania 1 SDRL CHARON SDRL and GRASP University of Pennsylvania Funded by DARPA ITO.
Mixing Models of Computation Jie Liu Palo Alto Research Center (PARC) 3333 Coyote Hill Rd., Palo Alto, CA joint work with Prof. Edward.
Expressing Giotto in xGiotto and related schedulability problems Class Project Presentation Concurrent Models of Computation for Embedded Software University.
NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI A New System Science.
SEC PI Meeting Annapolis, May 8-9, 2001 Component-Based Design of Embedded Control Systems Edward A. Lee & Jie Liu UC Berkeley with thanks to the entire.
Interfaces for Control Components Rajeev Alur University of Pennsylvania Joint work with Gera Weiss (and many others)
System Design Research Laboratory Model-based Testing and Monitoring for Hybrid Embedded Systems Li Tan Jesung Kim Oleg Sokolsky Insup Lee University of.
Model-based Analysis of Distributed Real-time Embedded System Composition Gabor Madl Sherif Abdelwahed
Designing Predictable and Robust Systems Tom Henzinger UC Berkeley and EPFL.
November 18, 2004 Embedded System Design Flow Arkadeb Ghosal Alessandro Pinto Daniele Gasperini Alberto Sangiovanni-Vincentelli
DIVES Alur, Lee, Kumar, Pappas: University of Pennsylvania  Charon: high-level modeling language and a design environment reflecting the current state.
Describing Syntax and Semantics
Testing and Monitoring at Penn An Integrated Framework for Validating Model-based Embedded Software Li Tan University of Pennsylvania September, 2003.
MOBIES Project Progress Report Engine Throttle Controller Design Using Multiple Models of Computation Edward Lee Haiyang Zheng with thanks to Ptolemy Group.
NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Program Review May 10,
Code Generation from CHARON Rajeev Alur, Yerang Hur, Franjo Ivancic, Jesung Kim, Insup Lee, and Oleg Sokolsky University of Pennsylvania.
Basic Concepts The Unified Modeling Language (UML) SYSC System Analysis and Design.
EECE **** Embedded System Design
Object-Oriented Software Testing. C-S 5462 Object-Oriented Software Testing Research confirms that testing methods proposed for procedural approach are.
ECE 720T5 Winter 2014 Cyber-Physical Systems Rodolfo Pellizzoni.
Model-based Analysis and Implementation of Embedded Systems
Benjamin Gamble. What is Time?  Can mean many different things to a computer Dynamic Equation Variable System State 2.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Dynamic Analysis of Multithreaded Java Programs Dr. Abhik Roychoudhury National University of Singapore.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
MURI: Integrated Fusion, Performance Prediction, and Sensor Management for Automatic Target Exploitation 1 Dynamic Sensor Resource Management for ATE MURI.
Software Synthesis from Hybrid Automata Rajeev Alur System Design Research Lab University of Pennsylvania SEES Workshop, Chicago,
System Design Research Lab University of Pennylvania 1/29/2002 CHARON modeling language.
University of Windsor School of Computer Science Topics in Artificial Intelligence Fall 2008 Sept 11, 2008.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
1 VERTAF: An Object-Oriented Application Framework for Embedded Real-Time Systems Pao-Ann Hsiung*, Trong-Yen Lee, Win-Bin See, Jih-Ming Fu, and Sao-Jie.
1 Model Checking of Robotic Control Systems Presenting: Sebastian Scherer Authors: Sebastian Scherer, Flavio Lerda, and Edmund M. Clarke.
Abstract A Structured Approach for Modular Design: A Plug and Play Middleware for Sensory Modules, Actuation Platforms, Task Descriptions and Implementations.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
What’s Ahead for Embedded Software? (Wed) Gilsoo Kim
Formal Verification. Background Information Formal verification methods based on theorem proving techniques and model­checking –To prove the absence of.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
T imed Languages for Embedded Software Ethan Jackson Advisor: Dr. Janos Szitpanovits Institute for Software Integrated Systems Vanderbilt University.
CPE555A: Real-Time Embedded Systems
Shanna-Shaye Forbes Ben Lickly Man-Kit Leung
Autonomous Cyber-Physical Systems: Synchronous Components: II
Retargetable Model-Based Code Generation in Ptolemy II
Model Checking for an Executable Subset of UML
Spring CS 599. Instructor: Jyo Deshmukh
Compositional Refinement for Hierarchical Hybrid Systems
Presented By: Darlene Banta
CHARON modeling language
Presentation transcript:

From Hybrid Models to Embedded Software Rajeev Alur System Design Research Lab University of Pennsylvania Workshop on Robustness, Abstractions, and Computation Philadelphia, March 2004

Model-Based Design  Benefits of model-based design Detecting errors in early stages Powerful analysis and formal guarantees Automatic code generation  Many commercial tools are available for design of embedded control systems (e.g. Simulink) Typically, semantics is not formal Typically, only simulation-based analysis Code generation available, but precise relationship between model and code not understood

Hybrid Modeling State machines off on + Dynamical systems dx=kx x<70 dx=-k’x x>60 x>68 x<63 Past Research: Formal verification using counter-example guided predicate abstraction and reachability analysis using polyhedral approximations

Interacting Autonomous Robots Platform; AIBO robots MIPS microprocessor servo-motors touch sensors camera C++ programming env message-driven execution API for sensing and actuating Model-based Concurrency + hybrid Strategies Attack/defense modes Collaboration

Ideal Design Environment Programming/Modeling Language Based on Hybrid Automata Libraries in Base Language Platform Description Design and Analysis Tools Simulation, Verification, Optimization Formal Specification Environment Model Performance Metrics Executable Code on Embedded Processor Compiler + Scheduler Can we infer code properties from model properties ? Can we integrate task generation and scheduling? Can continuous-time semantics be a useful programming abstraction?

Acknowledgements  Thanks to the Charon group at Penn Generating embedded software from hierarchical hybrid models; LCTES’03, with Ivancic, Kim, Lee, and Sokolsky Integrated scheduling and code generation (ongoing work with C.G.Arun)  Caution: Ongoing work (more questions than solutions!); feedback welcome.

Talk Outline  Charon Overview and Case Study  Sample Research Issues From continuous-time model to discrete software Missed events and switching errors Control blocks and optimal code generation

CHARON Language Features  Individual components as agents Composition, instantiation, and hiding  Individual behaviors as modes Encapsulation, instantiation, and Scoping  Support for concurrency Shared variables as well as message passing  Discrete and continuous behavior Differential as well as algebraic constraints Discrete transitions can call Java routines Software engineering (hierarchy, reuse) Concurrency theory (Compositionality, refinement) Hybrid systems theory

 Input –touch sensors  Output –desired angles of each joint  Components –Brain: control four legs –Four legs: control servo motors Instantiated from the same pattern Walking Model: Architecture and Agents

x y j1 j2 L1 (x, y) v L2 Walking Model: Behavior and Modes dx = dy = 0 dy = kv dt = 1 dy = -kv dx = kv x < str /2 On GroundUp ForwardDown y==0 -> turn++ turn == i t==2 Shared variable Time triggered 2x==str Event triggered

CHARON Toolkit

Programming in Charon  Formal and modular semantics modes and agents have compositional semantics in terms of sets of observable behaviors  Rich and high-level programming model Shared variables; synchronous communication Switches can be time-triggered, event-triggered  Verification for linear systems Predicate abstraction + Polyhedra based approx.  But this is just the core, many extensions desirable (e.g. types, interfaces, inheritence…)

Code Generation Case Study  Front-end Translate CHARON objects into modular C++ objects  Back-end Map C++ objects to execution environment agent mode analog var diff/alge eqn transition class agent class mode diff() trans() class var scheduler API CHARON objectsC++ objects Execution environment Target platform front-endback-end

Code Generator: Front-end  Variable C++ class: read and write to variables can be mapped to system API  Differential equation Euler’s method: x’ == 100  x += 100 * h h: step size (0.008 ms in AIBO)  Algebraic equation Assignment statement executed in a data dependency order x == 2y; y == 2z  y = 2z; x = 2y;  Transition If-then statement  Mode C++ class: collection of variables, equations, transitions, and reference to submodes  Agent C++ class: interleave execution of each step of subagents

Code Generator: Back-end  Maps variables in the model to system API of the target platform  Our approach: “Makefile-like” script.{read|write}: : | x: joint(TAIL_JOINT) joint(id).write: rgn SetJointGain(rgn, id, value, newValue); TAIL_JOINT: #include “def.h” rgn: Region* #include “def.h” rgn = FindFreeRegion() x: joint(TAIL_JOINT) joint(id).write: rgn SetJointGain(rgn, id, value, newValue); TAIL_JOINT: #include “def.h” rgn: Region* #include “def.h” rgn = FindFreeRegion() #include “def.h” class joint: public var { public: joint(int id) id(id) { } virtual void write(double value) { SetJointGain(rgn, id, value, newValue); } static Region* rgn; private: int id; } x(TAIL_JOINT); #include “def.h” class joint: public var { public: joint(int id) id(id) { } virtual void write(double value) { SetJointGain(rgn, id, value, newValue); } static Region* rgn; private: int id; } x(TAIL_JOINT);

What did we learn?  Mapping structured hybrid automta to code is feasible, in principle  Many research questions Discretization Switching errors and non-determinism Task generation and scheduling  Not addressed in this talk Logical to physical concurrency Platform specification Evaluation (e.g. with respect to Simulink)

Wagging the Tail  Variables –x: angle (env state) –u: speed (control output)  Non-deterministic switching  Continuous-time semantics dx=u u=+1 x<=25 dx=u u=-1 x>=-25 x u time

Code Generation 1. Generate task M : {up, down} sense(x); if (M==up) { if x > 25 error; if (x >= 20) {M=down; u=-1} } else { … } actuate(u); dx=u u=+1 x<=25 dx=u u=-1 x>= Determine scheduling parameters - Period Delta - Deadline Delta Hopefully guided by control-theoretic analysis (e.g. sensitivity, robustness) up down

Semantics: From Model to Code 1. Continuous-time semantics: Task executes instantaneously at every time point Continuous 2. Discrete/simulation semantics: Task executes instantaneously at fixed (periodic) discrete points sense/compute/update 3. Periodic computation that takes time (predictable) SenseActuateComputeSenseActuateCompute 4. Scheduled computation (variable time)

Bridging the gap between 1 and 2  Rich theory of sampled control (but mainly for purely continuous systems) Discrete-time control design Sampling errors  Accurate simulation (well-studied area) How to choose step size How to choose integration methods Variable step size to ensure events (that trigger mode switches) are not missed  How can code ensure that events are not missed?

Avoiding Switching Errors Execute every Delta sec sense(x); if (M==up) { if x > 25 error; if (x >= 20) {M=down; u=-1} } else { … } actuate(u); dx=u u=+1 x<=25 dx=u u=-1 x>=-25 When can we be sure to avoid error? In mode up, if x<20 holds at time T then x should not exceed 25 at time T + Delta This depends on model dynamics up down

Requirement on Models  Δ look-ahead condition: Given a step size Δ and a hybrid automaton, check whether for all pairs of invariants I and guards g of outgoing transitions, Post Δ (I & ~g) is a subset of I  If the model satisfies the condition then no switches are missed  For systems with linear dynamics this requirement can be checked automatically Model non-determinism is necessary for implementability!

Semantics: From Model to Code Continuous SenseActuateComputeSenseActuateCompute Control theory has many tools to bridge gaps between 2,3,4 u(t) depends on x(t-tau) Robustness of controllers Integrating control and scheduling Programming abstractions: Synchrony hypothesis, Giotto …

Why use continuous-time semantics?  There is no “standardized” discrete-time simulator (or semantics) Many tricks, many approaches This is a recurring discussion topic in HSIF  Committing to a discretization may be pessimistic  Continuous-time semantics has many benefits Composable models Portable models (or blocks of code) Powerful control design tools available

Code from Structured Designs  How to map control blocks to tasks?  The choice can depend on many parameters: computation times, sensitivity ox x to u and v, performance objective  Many choices for code Two tasks: C1 and C2 with their own periods One task: Read(x);C1;C2;Actuate One task: Read(x);C1;Read(x);C2;Actuate C1 x C2 uv

Simulation Experiment  Goal: Head to target while avoiding obstacle Only an estimate of obstacle (model based on sensory vision) Estimate improves as robot gets near the obstacle  Control output: Direction  Three blocks C1: Sense current position C2: Compute obstacle estimate C3: Decide direction  Blocks take d1, d2, d3 time units to execute Initial Position Target Obstacle Estimate

Simulation Experiment  Performance metric defined wrt to continuous model Total distance travelled, or Error wrt reference trajectory  Assume d1 < d2,d3  Two reasonable choices C1;C2;C3 executed repeatedly C1;C2;C1;C3 executed repeatedly  Second choice performs better (updated position allows to change direction earlier) Initial Position Target Obstacle Estimate

Optimal Code Generation  Input Set of control tasks (including sensing and actuating) Graph of dependencies among them Relative complexity estimates for all the tasks Some measure of dependence of state on outputs of individual tasks  Output: Cyclic executive schedule that optimizes something (error wrt continuous model)  Solution: Using ideas from theory of non- preemptive scheduling

Wrap-Up  Generating software from hybrid models with continuous-time semantics has many appeals  Many theoretical research directions  Bridging the gap between model and code  Optimal code generation to follow reference trajectories  Many engineering issues  Platform specification for automatic compilation  Distributed platforms  Experimentation: Penn UAV platform