Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modeling Hybrid Systems Yerang Hur CIS 640, October 10, 2002 Department of Computer and Information Science University of Pennsylvania Code generation.

Similar presentations


Presentation on theme: "Modeling Hybrid Systems Yerang Hur CIS 640, October 10, 2002 Department of Computer and Information Science University of Pennsylvania Code generation."— Presentation transcript:

1 Modeling Hybrid Systems Yerang Hur CIS 640, October 10, 2002 Department of Computer and Information Science University of Pennsylvania Code generation demo: Jesung Kim Some slides are edited from previous slides made together with others in Hybrid Systems Group.

2 Outline Hybrid Systems Simulink State-machine-based Representation C HARON Framework C HARON Language Examples Tool Demo

3 Hybrid Systems Differential equations Algebraic equations Invariant constraints Collisions Decision logic Discrete communication (send/receive) Guarded transitions between modes Represented with Physical processes in control system e.g. robots, aircraft,... Continuous BehaviorsDiscrete Events

4 Hybrid Systems - two views Control engineering-oriented view discrete control command generator dynamical system reference output

5 Hybrid Systems - two views (con’t) Computer scientist-oriented view - State machine embedding dynamics dx/dt=f(x)dx/dt=g(x) guard reset x - Continuous state variables with discrete state variables guard reset x cont x disc y dx/dt=f(x,y) Y=1update y cont x disc y dx/dt=g(x,y)

6 Simulink system block diagram sources sinks Elements of Simulink model Simulink is block diagram-based notations for modeling dynamical systems.

7 Simulink (cont’d) Blocks for representing continuous components State-Space Block Gain Block k yx : algebraic equation y=kx Sum Block Derivative Block Integrator Block a b c : algebraic equation c=a-b + - du/dt xy : differential equation y=dx/dt  x Y: Y = y 0 +  x(t)dt X=Ax+Bu Y=Cx+Du y u.

8 Simulink (cont’d) Hybrid system representation - +Kp Ki Kd zero order holder discrete time integrator derivative approximation + + + physical plant reference

9 State-machine-based Representation x > 80.0 x < 70.0 x := 73.0 Thermostat On x>=82.0 dx/dt=-x+100 Off 68.0<=x dx/dt=-x

10 Framework for Developing Hybrid System 1. High-level modeling platform independent hierarchical and modular –parallel composition of agents –specify modes and constraints –sequential composition of modes 2. Simulation, analysis, and automatic code generation 3. Deploy the code on actual target platform

11 C HARON Framework C HARON Code (High level language) Java Code C HARON to Java Translator Control Code Generator Java Libraries Human Interface Analysis Simulator Generator Drivers

12 C HARON Language Individual components described as agents Composition, Instantiation, and Hiding Individual behaviors described as modes Encapsulation, Instantiation, and Scoping of variables Shared variables as well as message passing Support for discrete and continuous behavior Well-defined formal semantics

13 Example: TwoAgent mode0 mode1 Mode choppy ATop a1 a2 Agent TwoAgentA top (10.0,0.0) (9.0,-1.0) Architectural Hierarchy Behavioral Hierarchy

14 Example: TwoAgent mode0 mode1 Mode choppy ATop a1 a2 Agent TwoAgentA top (10.0,0.0) (9.0,-1.0) agent TwoAgent() { private analog real v1,v2; agent a1 = A (10.0, 0.0) [vIn, vOut := v2, v1] ; agent a2 = A (9.0, -1.0) [vIn, vOut := v1, v2] ; } agent A(real initValue, real c) { read analog real vIn ; write analog real vOut ; mode top=Atop(initValue,c) ; } mode Atop(real iVal, real c) { read analog real vIn ; write analog real vOut ; mode mode0=choppy(2.0,-50.0,c); mode mode1=choppy(2.0,1.0,c) ; trans initTrans from default to mode0 when true do {vOut=iVal} …

15 Modes of Agent A1 ATop write analog real v1 write discrete int p1 inv invChoppy {v1>0.0} diff fv1 {d(v1)==2.0*v1-50.0+c } mode0mode1 write analog real v1 write discrete int p1 inv invChoppy {v1>0.0} diff fv1 {d(v1)==2.0*v1+1.0+c } v1<8.0 && |v1-v2|>1.1 v1>12.0 && |v1-v2|>1.0 transition guard: g1 mode name variable declaration dynamics invariant: flow constraint do {p1:=1} do {p1:=0}

16 Architectural Hierarchy Robots Monitor pos 1 pos 2 write analog position pos 1, pos 2 class position {double x; double y;} Variable Specifiers Update: discrete/analog I/O interface: read/write/private

17 Architectural Hierarchy Robot 1 Robots Robot 2 pos 1 pos 2 r1Est 1 r1Est 2 r2Est 1 r2Est 2 Robots Monitor pos 1 pos 2

18 Behavioral Hierarchy pos r2Est 1 r2Est 2 r1Est 1 r1Est 2 Robot 1 dTimer timer == 1. private analog real timer awTarget dPlan iAway atTarget dStop iAt arrive pos == target moving dSteer aOmega iFreq sensing dStop iConst sense move arrive timer/updateFreq == 0 omega == k * (theta – phi) pos.x == v * cos(phi) pos.y == v * sin(phi)..

19 Example: the Simplex Architecture- based Inverted Pendulum Safety Controller Baseline Controller Experimental Controller Decision Module Physical System usus ubub ueue xu Safety Controller Baseline Controller Experimental Controller x0x0 Equilibrium state

20 The Inverted Pendulum m l  x g M ufuf

21 Control Task and C HARON Description Control objective: to move the cart from one position to a desired target position x t maintaining the pendulum at the upright position. Planner: generates a set point x s every T seconds with rate c until the generated set point reaches the target position. Lower level: stabilizes the system about [ x s, 0, 0, 0 ]

22 Controllers

23 Physical System

24 Decision Module

25 Simulation Results Sampling Frequency 50Hz Maximum Position Tracking Error : 0.17m < 0.2m Initial Position : 0.0 Initial Cart Velocity : 0.0 m/s Initial Angle : 5.0 deg Initial Angular Velocity : 0.0 deg/s Maximum Control Value : 3.78V < 4.96V Maximum Cart Velocity : 0.32m/s < 1.0m/s Maximum Angle : 5.0 deg< 10.0 deg

26 C HARON Simulator Generation Process C HARON model Agent and Mode generator Simulator main generator Agents Modes Simulator main Trace Plotter Trace generator User-defined external classes Numerical integrator Differential Equations Invariants Algebraic Equations Guards Actions Assertions

27 Wrap-up: Two Worlds Affect Each Other - Simulink is augemented with a hierarchical state machine. We call it Simulink/Stateflow. - Among other design tools of interest are Ptolemy II with continuous time domain, S HIFT /Teja, Modelica, and RT-UML. - Controllers/Decision Module/Physical system case study in C HARON : E.g. the Simplex-Architecture-based inverted pendulum controller[RTSSWIP 2000] and autonomous distributed multi-robots.

28 Wrap-up: Features of C HARON - Discrete event/discrete state representation: discrete int/bool - Discrete event/continuous state representation: discrete real - Continuous time/continuous state representation: analog real - Behavior description: mode with hierarchy - Architecture description: agent with hierarchy -Structured modern programming language : variable scoping, type-checking rules, formal semantics

29 Wrap-up: Features of C HARON (cont’d) - Software engineering tool : reusable agent/mode definition, : simulator generator, verification tool box, code generator - Non-determinism : non-deterministic execution of agents when more than one agent observe enabled transitions at once, currently interleaving semantics : non-deterministic choice of transitions when more than one transitions are enabled at once, currently randomly selected or user-guided : non-deterministic non-urgent jump when a guard is enabled while the invariant is not violated, currently probabilistically taken and 80/20 rule is embedded : non-deterministic differential and algebraic constraints with inequalities, currently only front-end supports this

30 Wrap-up: Interface Qualifiers of Agent Variables Input from environment: input (v0.1) --> read (v0.37) Output to environment: output (v0.1) --> write (v0.37) --> write/readwrite (v0.4) --> write exclusive/write shared (v0.7) Local private (v0.1) --> hiding operation (v0.12) --> private (v0.6)

31 Wrap-up: Other Type Qualifiers Update Qualifiers: analog for continuous update or reset discrete for discrete update Channel Qualifiers: buffered non-blocking communication channel combined with buffer size, message type, buffer management policy Example: write channel [2] of real cold chan1;

32 Tool Demo For manuals and more examples, visit http://www.cis.upenn.edu/mobies/experiments.php3.


Download ppt "Modeling Hybrid Systems Yerang Hur CIS 640, October 10, 2002 Department of Computer and Information Science University of Pennsylvania Code generation."

Similar presentations


Ads by Google