azero-crossing detection algorithm for robustsimulation of ......zero-crossing detection actually...

21
A Zero-crossing Detection Algorithm for Robust Simulation of Hybrid Systems Jumping on Surfaces David A. Copp a,, Ricardo G. Sanfelice b,∗∗ a Department of Mechanical Engineering, University of California, Santa Barbara, CA 93106-9560, USA b Department of Computer Engineering, University of California, Santa Cruz, CA 95064, USA Abstract Hybrid systems are inherently fragile with respect to perturbations when their state experiences jumps on surfaces. Zero-crossing detection algorithms are capable of robustly detecting the crossing of such surfaces, but, up to now, the effects of adding such algorithms to the system being simulated are unknown. In this paper, we propose a mathematical model for hybrid systems that incorporates zero-crossing detection as well as a hybrid simulator for it. First, we discuss adverse effects that measurement noise and discretization can have on hybrid systems jumping on surfaces and prove that, under mild regularity conditions, zero- crossing detection algorithms can robustify the original system. Then, we show that integration schemes with zero-crossing detection actually compute a robustified version of the fragile nominal model. In this way, we rigorously characterize their effect on solutions to the simulated system. Finally, we show that both the model and simulator are not only robust, but also that the hybrid simulator preserves asymptotic stability properties, semiglobally and practically (on the step size), of the original system. Several examples throughout the paper illustrate these ideas and results. Keywords: Hybrid Systems, Zero-crossing Detection, Simulation 1. Introduction This work considers dynamical systems with a state that experiences instantaneous resets (jumps) when it hits a switching surface S . A switching surface is typically defined as the zero-level set of a continuously differentiable function, defining in this way a codimension one submanifold of R n ; see, e.g., [1, 2, 3]. The state is denoted by x and takes values from a region of operation X⊂ R n . When x is away from the surface S , the continuous dynamics (flows) of the system are given by a differential equation. This can be written more precisely as ˙ x = f (x) when x ∈X\S . (1) When x hits the surface S while in the region of operation X , the state is reset via a difference equation which defines the jumps of the system. More precisely, the new value of x after the jump, denoted x + , is determined by x + = g(x) when x ∈S∩X . (2) In this way, the trajectories are allowed to flow when x ∈X\S and are allowed to jump when x ∈S∩X . This model captures the dynamics of control systems in which a controller makes decisions when certain variables hit a surface. For instance, in reset control systems (see, e.g., [4], [5], [6], [7]), the output of the controller is reset to zero whenever its input and output satisfy an algebraic condition. Reset controllers have Principal corresponding author ∗∗ Corresponding author Email addresses: [email protected] (David A. Copp), [email protected] (Ricardo G. Sanfelice) URL: https://hybrid.soe.ucsc.edu (Ricardo G. Sanfelice) Preprint submitted to Simulation Modelling Practice and Theory May 26, 2016

Upload: others

Post on 21-Feb-2021

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

A Zero-crossing Detection Algorithm for Robust Simulation of

Hybrid Systems Jumping on Surfaces

David A. Coppa,∗, Ricardo G. Sanfeliceb,∗∗

aDepartment of Mechanical Engineering, University of California, Santa Barbara, CA 93106-9560, USAbDepartment of Computer Engineering, University of California, Santa Cruz, CA 95064, USA

Abstract

Hybrid systems are inherently fragile with respect to perturbations when their state experiences jumps onsurfaces. Zero-crossing detection algorithms are capable of robustly detecting the crossing of such surfaces,but, up to now, the effects of adding such algorithms to the system being simulated are unknown. In thispaper, we propose a mathematical model for hybrid systems that incorporates zero-crossing detection aswell as a hybrid simulator for it. First, we discuss adverse effects that measurement noise and discretizationcan have on hybrid systems jumping on surfaces and prove that, under mild regularity conditions, zero-crossing detection algorithms can robustify the original system. Then, we show that integration schemeswith zero-crossing detection actually compute a robustified version of the fragile nominal model. In thisway, we rigorously characterize their effect on solutions to the simulated system. Finally, we show thatboth the model and simulator are not only robust, but also that the hybrid simulator preserves asymptoticstability properties, semiglobally and practically (on the step size), of the original system. Several examplesthroughout the paper illustrate these ideas and results.

Keywords: Hybrid Systems, Zero-crossing Detection, Simulation

1. Introduction

This work considers dynamical systems with a state that experiences instantaneous resets (jumps) whenit hits a switching surface S. A switching surface is typically defined as the zero-level set of a continuouslydifferentiable function, defining in this way a codimension one submanifold of Rn; see, e.g., [1, 2, 3]. Thestate is denoted by x and takes values from a region of operation X ⊂ R

n. When x is away from the surfaceS, the continuous dynamics (flows) of the system are given by a differential equation. This can be writtenmore precisely as

x = f(x) when x ∈ X \ S. (1)

When x hits the surface S while in the region of operation X , the state is reset via a difference equationwhich defines the jumps of the system. More precisely, the new value of x after the jump, denoted x+, isdetermined by

x+ = g(x) when x ∈ S ∩ X . (2)

In this way, the trajectories are allowed to flow when x ∈ X \ S and are allowed to jump when x ∈ S ∩ X .This model captures the dynamics of control systems in which a controller makes decisions when certainvariables hit a surface. For instance, in reset control systems (see, e.g., [4], [5], [6], [7]), the output of thecontroller is reset to zero whenever its input and output satisfy an algebraic condition. Reset controllers have

∗Principal corresponding author∗∗Corresponding author

Email addresses: [email protected] (David A. Copp), [email protected] (Ricardo G. Sanfelice)URL: https://hybrid.soe.ucsc.edu (Ricardo G. Sanfelice)

Preprint submitted to Simulation Modelling Practice and Theory May 26, 2016

Page 2: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

been found useful in applications as they improve the performance of linear systems [4]. In state-dependentimpulsive control systems, (see, e.g., [1], [8]), jumps occur when the state of the system belongs to a surfacein the state space of the system. Impulsive controllers are widely used in robotics to switch among severalfeedback laws when the state of the system reaches a surface [9, 10].

Several difficulties arise when dealing with systems jumping on surfaces. One such difficulty is with“grazing” of the flowing solution at the boundary of the switching surface S without crossing over it. Thiscan lead to non-unique solutions and is known as the grazing phenomenon. For a discussion of methods tohandle this phenomenon, see [11]. Further difficulties may be caused by perturbations due to measurementnoise or numerical errors due to discretization. For example, suppose that the value of the state x of thesystem is perturbed when nearby S (e.g., due to measurement noise). Letting e denote this perturbationon x, the perturbed state can be written as x+ e. Suppose that, for a given solution x(t) to system (1)-(2)(using an appropriate notion of solution), e is zero when x(t) 6= S but equal to a nonzero constant ε whenx(t) = S. Then, when the perturbation e is added, for any nonzero ε, the same solution x(t) will notsatisfy the condition x(t)+ e(t) ∈ S, and therefore, will not jump at the instant that it would without noise.This suggests that arbitrarily small perturbations to (1)-(2) can generate trajectories that are nowhere closeto the trajectories of the nominal system; see [12] for related discussions. Similarly, issues can arise fromnumerical errors introduced by discretization, such as numerical integration errors. In the presence of smallnumerical integration errors, which can be made arbitrarily small by adjusting the step size used in thesimulator, trajectories obtained through simulation may never hit the surface, and therefore, never jump.

One way to resolve the issue of the numerical solution never hitting the switching surface, which is widelyused in simulation packages, is to include zero-crossing detection (ZCD) algorithms to detect crossing of thesurface S. For instance, in MATLAB/Simulink, a block called Hit Crossing detects when the input of theblock u reaches a specified offset parameter value u∗ (other blocks and local ZCD options are also availablein MATLAB/Simulink). The output of the block equals 1 when the value of the input has hit or crossedthe offset parameter, or 0 otherwise. In fact, MATLAB/Simulink help files note the following [13]:

“if the input signal is exactly the value of the offset value after the hit crossing is detected, theblock continues to output a value of 1. If the input signals at two adjacent points bracket theoffset value (but neither value is exactly equal to the offset), the block outputs a value of 1 atthe second time step.”

More precisely, denoting the step size by s, this block determines if the sign of u−u∗ at the integration timet has changed with respect to its value at the previous integration time t− s, i.e., it determines whether

(u(t)− u∗)(u(t− s)− u∗) ≤ 0. (3)

In order to determine whether this condition holds, a memory state must be added to keep track of thesign (relative to u∗) of the previous input to the block. While zero-crossing detection might be a remedy todetect the crossings of S, a simulator utilizing ZCD actually modifies the original system by incorporatingan extra mechanism for the detection of zero crossings. On the other hand, the relationship between thesimulations obtained with ZCD and the true solutions of a system is not well understood.

The purpose of this paper is to introduce a mathematical framework for theoretical study of such algo-rithms and their effect in simulation of hybrid systems. To that end, the effect of perturbations to hybridsystems jumping on surfaces is highlighted. In particular, we point out that measurement noise and dis-cretization due to numerical integration can lead to simulations that do not hit the surface and never jump.Following the ideas discussed above in zero-crossing detection algorithms used in software packages, we pro-pose a mathematical model of a hybrid system incorporating a zero-crossing algorithm. We prove that, undermild regularity conditions, such a resulting hybrid system not only includes all of the nominal solutions (noperturbations) to the original system but is also robust to measurement noise. We argue that, rather thancomputing the solutions to the discretization of the fragile nominal model (1)-(2), integration schemes withzero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model.Finally, we propose a hybrid simulator for the hybrid system with incorporated zero-crossing detection. Asa difference to [14, 15, 16], we focus on detection of zero-crossing rather than accurate location, which is

2

Page 3: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

another important issue in simulating systems like (1)-(2). Even though we do not discuss finding accuratelocations of zero-crossings, we show that our proposed hybrid simulator enjoys the following properties,which are illustrated in examples throughout the paper:

1) Trajectories obtained with the proposed simulator with zero-crossing detection approximate the solu-tions to the original hybrid system with arbitrary precision. See Theorem 5.8.

2) The proposed simulator with zero-crossing detection preserves the asymptotic stability properties ofthe original hybrid system. Furthermore, the proposed simulator with zero-crossing detection hasan asymptotically stable compact set that converges to the asymptotically stable compact set of theoriginal hybrid system. See Theorems 5.10 and 5.11.

An important feature of the proposed hybrid simulator is that it confers the above properties to thesimulation of the original hybrid system by minimally affecting the original system. In fact, the only additionto the original system consists of a scalar variable with appropriately defined dynamics for robust triggeringof jumps; cf. the thickening of the switching surfaces proposed in [12] and the domain relaxations proposedin [17]. Furthermore, the proposed hybrid simulator is designed to guarantee stability and robustnessproperties when implemented numerically through the use of well-known solvers, which makes it suitablefor the simulation of complex systems, such as hybrid and cyber-physical systems.

The remainder of this paper is organized as follows. Section 2 introduces notation used throughout thepaper. Section 3 presents a mathematical model of hybrid systems with dynamics (1)-(2), a hybrid simulatorfor it, as well as issues with perturbations. A model of a hybrid system with added zero-crossing detectionand a hybrid simulator for it are given in Section 4. Our main results appear in Section 5. A preliminaryversion of the results in this paper appeared without proof in [18].

2. Notation

The following notation will be used throughout the paper.

• Rn denotes the n-dimensional Euclidean space.

• R denotes the real numbers.

• R≥0 denotes the nonnegative real numbers, i.e., R≥0 = [0,∞).

• N denotes the natural numbers including 0, i.e., N = {0, 1, ...}.

• int S denotes the interior of the set S.

• sgn denotes the sign function defined as sgn(ξ) = 1 if ξ > 0, sgn(ξ) = −1 if ξ < 0, and sgn(ξ) = 0if ξ = 0.

• B denotes the closed unit ball centered at the origin in Euclidean space.

• x+ εB denotes a closed ball of radius ε centered at x.

• Given a set S, S denotes its closure.

• TS(x) denotes the tangent cone of the surface of S at x (i.e., the collection of vectors that are tangentto the surface).

• Given a set S, coS denotes the convex hull of S, and coS the closure of the convex hull.

• Given sets As and A, dH(As,A) denotes the Hausdorff distance between sets As and A.

• Given a set K ⊂ Rn and a point x ∈ R

n, |x|K := infy∈K |x− y|.

3

Page 4: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

3. Hybrid Systems Jumping on Surfaces

Throughout this paper, we model systems and their simulators within the hybrid systems framework of[19] and [20]. In this way, we write the system (1)-(2) as

H :

{x = f(x) x ∈ X \ S =: Cx+ = g(x) x ∈ S ∩ X =: D.

(4)

Following [19], a solution to a hybrid system is a function defined on a hybrid time domain satisfying certainconditions. A set E ⊂ R≥0 × N is a compact hybrid time domain if

E =

J−1⋃

j=0

([tj , tj+1]× {j})

for some finite sequence of times 0 = t0 ≤ t1 ≤ t2... ≤ tJ . The set E is a hybrid time domain if for all(T, J) ∈ E, E ∩ ([0, T ] × 0, 1, ...J) is a compact hybrid domain. By hybrid arc or hybrid trajectory weunderstand a pair consisting of a hybrid time domain domx and a function x : domx → R

n such that, foreach j, t 7→ x(t, j) is locally absolutely continuous for (t, j) ∈ domx. A hybrid arc φ : domφ → R

n is asolution to a hybrid system H with data (C, f,D, g) if

(S0) φ(0, 0) ∈ C ∪D;

(S1) For each j ∈ N and each Ij := {t : (t, j) ∈ domφ } with nonempty interior int Ij ,

φ(t, j) ∈ C for all t ∈ int Ijφ(t, j) = f(φ(t, j)) for almost all t ∈ int Ij ;

(S2) For each (t, j) ∈ domφ such that (t, j + 1) ∈ domφ,

φ(t, j) ∈ D, φ(t, j + 1) = g(φ(t, j)).

Now we introduce a few examples that will be revisited throughout the paper.

Example 3.1. (bouncing ball) Consider a bouncing ball as a point mass vertically bouncing on a horizontalsurface. The ball is dropped from some initial height and experiences acceleration due to gravity. At eachimpact with the surface, the velocity can be approximated as instantaneously reversing direction and possiblydecreasing in magnitude due to energy dissipation. If we denote the state of the system as x = [x1 x2]

where the height above the surface is x1 and the vertical velocity is x2, then we can write the bouncing ballsystem in our hybrid systems framework as

X ⊂ R2,

f(x) =

[x2

−M(x1)−N(x1)x2

], g(x) =

[0

−λx2

],

S = {x ∈ X : x1 = 0, x2 ≤ −δ } ,

(5)

where M and N are given as

M(x1) =

{γεx1 for x1 < ε

γ for x1 ≥ ε, N(x1) =

{−x1 + ε for x1 < ε

0 for x1 ≥ ε,

γ > 0 is the gravitational constant, λ ∈ [0, 1) is the restitution coefficient, and δ and ε are positive constants.This model comes from the non-Zeno bouncing ball model described in [21, Example 4.2]. In this model,the functions M and N are used to capture compression of the ball at impacts with the surface. Whenx1 ≥ ε > 0, this model is equivalent to a Zeno bouncing ball model. △

4

Page 5: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

Example 3.2. (unicycle avoiding obstacle) Consider a mobile robot of the unicycle type being steered to-wards a target while avoiding a circular obstacle [2]. Let ξ = [ξ1 ξ2 ξ3]

⊤, where [ξ1 ξ2]⊤ denotes the robot’s

position and ξ3 the robot’s orientation. Let q be the controller state, q ∈ {1, 2}, where q = 1 means travellingtowards the target, and q = 2 means travelling away from the obstacle. The value of q is chosen dependingon the robot’s radial distance from the obstacle. Two circular surfaces, Sq, with radii aq, a2 > a1, are definedaround the obstacle for this purpose. When the robot enters one of these surfaces, the continuous dynamicsof the system do not change, but if a change in direction is desired, the controller state must be updated fromq = 1 to q = 2, or vice versa, according to the update law q+ = 3− q. The current orientation of the robotdepends on the value of a function defining a local mode-based controller.

Denoting the state of the system by x = [ξ1 ξ2 ξ3 q]⊤, the closed-loop system can be written as

X ⊂ R3 × {1, 2},

f(x) =

v cos(ξ3)v sin(ξ3)κ(q, ξ)

0

, g(x) =

3− q

],

S = ∪q∈{1,2}(Sq × {q}),

Sq ={x ∈ X : (ξ◦1 − ξ1)

2 + (ξ◦2 − ξ2)2 = a2q

},

(6)

where v is the tangential velocity of the robot, the function κ(q, ξ) defines the mode-based controller whichthe robot should use in order to steer the robot to the target (q = 1) or away from the obstacle (q = 2), and(ξ◦1 , ξ

◦2) denotes the obstacle’s location. △

Example 3.3. (unicycle on a track) Consider a mobile robot of the unicycle type being steered to travelalong a given track with state ξ as in Example 3.2. Let q be the controller state, q ∈ {1, 2}, where q = 1means traveling to the left, and q = 2 means traveling to the right.1 The value of q is chosen depending onwhether the robot crosses the left or right boundaries of the track. The boundaries are given by surfaces Sq.

Denoting the state of the system by x = [ξ1 ξ2 ξ3 q]⊤, the closed-loop system is given by

X ⊂ R3 × {1, 2},

f(x) =

v cos(ξ3)v sin(ξ3)κ(q, ξ)

0

, g(x) =

3− q

],

S = ∪q∈{1,2}(Sq × {q}),

S1 = {x ∈ X : ξ1 = 1, q = 1 } ,

S2 = {x ∈ X : ξ1 = −1, q = 2 } ,

(7)

where v is the tangential velocity of the robot, and the function κ(q, ξ) defines the mode-based controllerwhich the robot should use in order to stay within the track. △

3.1. Nonrobustness to measurement noise

As pointed out in Section 1, if the measurements of the state x are noisy, solutions to H may fail tojump due to never belonging to S. In fact, for every nominal solution to H, it is possible to construct an

1A control mode to keep the vehicle within the track could also be incorporated.

5

Page 6: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

arbitrarily small measurement noise signal e so that x + e ∈ S never holds. A hybrid system H with data(C, f,D, g) and measurement noise e : dom e→ R

n is denoted He and is given by

He :

{x = f(x+ e) x+ e ∈ C

x+ = g(x+ e) x+ e ∈ D.

A solution to He, that is, a solution to H for a given measurement noise e, consists of a hybrid arc φe :domφe → R

n satisfying

(S0e) φe(0, 0) + e(0, 0) ∈ C ∪D;

(S1e) For each j ∈ N and each Ij = {t : (t, j) ∈ domφe } with nonempty interior int Ij ,

φe(t, j) + e(t, j) ∈ C for all t ∈ int Ijφe(t, j) = f(φe(t, j) + e(t, j)) for almost all t ∈ int Ij ;

(S2e) For each (t, j) ∈ domφe such that (t, j + 1) ∈ domφe,

φe(t, j) + e(t, j) ∈ D, φe(t, j + 1) = g(φe(t, j) + e(t, j)).

The following proposition formalizes the fact that arbitrarily small measurement noise may preventsolutions to H from jumping on S. We say that a function ℓ : Rn → R

n is locally bounded on an open setO if for each compact set K ⊂ O there exists a compact set K ′ ⊂ R

n such that ℓ(K) ⊂ K ′. Also, we saythat a set K is a codimension one submanifold of Rn if K ⊂ R

n and n− dim(K) = 1.

Proposition 3.4. (no jumps due to measurement noise) Suppose H = (C, f,D, g) as in (4) is such that

1. f : Rn → Rn and g : Rn → R

n are locally bounded on an open set containing X ;

2. S ∩ X is a codimension one submanifold of Rn.

Then, for each ε > 0, T > 0, and x0 ∈ X , every solution φe to H with measurement noise e and φe(0, 0) = x0satisfies domφe ⊂ [0, T ]× {0}, for some measurable function e : dom e→ εB.

Proof. Following [12, Definition 2.12], the Krasovskii regularization of H is given by H = (C, f , D, g),

where C = C, D = D while f : C ⇒ Rn, g : D ⇒ R

n are defined by

∀x ∈ C f(x) :=⋂

δ>0

cof((x+ δB) ∩ C), ∀x ∈ D g(x) :=⋂

δ>0

g((x+ δB) ∩D).

Using item 2 of the assumptions, the flow set C = X \ S is such that C = X . Then, C = X . It follows

that for every x0 ∈ X there exists a maximal solution φ to H that only flows, i.e., dom φ ⊂ R≥0 × {0}.Using item 1 of the assumptions, [12, Theorem 3.1] implies that every Krasovskii solution to H is a Hermes

solution to H, in particular, the solution φ is a Hermes solution to H. Then, for every compact hybrid timedomain E := [0, T ] × {0} ⊂ dom φ, there exists a sequence of solutions φi to H with measurement noise

ei : dom ei → εiB, εi ց 0, with domains dom φi = dom ei graphically converging to the truncation of φ toE. Picking i such that that εi < ε, the claim follows with φe = φi and e = ei. �

3.2. Properties of numerical simulations of H

The simulation of H can be interpreted as the numerical computation of the solutions to the discretizedversion of H, defining a simulator. A hybrid simulator for H is given by the family of systems Hs param-eterized by step size s satisfying s ∈ (0, s∗], with the maximum step size s∗ > 0. The data of the hybrid

6

Page 7: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

simulator Hs is denoted by (Cs, f s, Ds, gs). For simplicity, we will assume that the region of operation X isnot discretized. Following [20], a hybrid simulator Hs for the hybrid system H is written as

Hs

{x+s = f s(xs) xs ∈ X \ Ss =: Cs

x+s = gs(xs) xs ∈ Ss ∩ X =: Ds.

Comparing H with Hs, the dynamics for the flows of H have been replaced by the integration schemex+s = f s(xs), where f

s is constructed from f . The jump map of H has been replaced by the discretized mapgs, and the flow and jump sets C and D have been replaced by the discretized sets Cs and Ds, where Ss isthe discretization of S.

The dynamics of the hybrid simulator Hs are purely discrete, so the solutions to Hs are given on discreteversions of hybrid time domains. Following the definition of hybrid time domain, a subset E ⊂ N × N is acompact discrete time domain if

E =

J−1⋃

j=0

Kj+1⋃

k=Kj

(k, j)

for some finite sequence 0 = K0 ≤ K1 ≤ K2... ≤ KJ , Kj ∈ N for every j ≤ J , j ∈ N. It is a discrete timedomain if ∀(K, J) ∈ E, E ∩ ({0, 1, . . .K} × {0, 1, . . . J}) is a compact discrete time domain. Solutions toHs are given by discrete arcs φs : domφs → R

n, where domφs is a discrete time domain. Then, a discretearc φs : domφs → R

n is a solution to the hybrid system H with a hybrid simulator Hs, s > 0, if

(S1s) for all k, j ∈ N such that (k, j), (k + 1, j) ∈ domφs,

φs(k, j) ∈ Cs, φs(k + 1, j) = f s(φs(k, j));

(S2s) for all k, j ∈ N such that (k, j), (k, j + 1) ∈ domφs,

φs(k, j) ∈ Ds, φs(k, j + 1) = gs(φs(k, j)).

Similar to the lack of robustness to measurement noise highlighted in Proposition 3.4, numerical simu-lations of hybrid systems are susceptible to problems due to numerical approximations. For example, whenimplementing the hybrid system H in a simulator, the discretization in time produced by the ODE solvermay prevent jumps from being triggered since the condition xs ∈ Ss may not hold. To illustrate this,consider the flow map f discretized with an Euler integration scheme, i.e. f s(x) = x+ s. It follows that forevery s∗ > 0 and each x0 ∈ X , every solution φs to Hs with some step size s ∈ (0, s∗] and φs(0, 0) = x0 hasless jumps than the original solution. In fact, fix the initial condition x0 ∈ X , and suppose that for eachs ∈ (0, s∗] and every solution φs to Hs, we have φs(k∗, 0) ∈ Ss for some k∗ ∈ N (depending on s and φs).Then, by the definition of solution to Hs, we have φs(k, 0) = f s(φs(k − 1, 0)) for each k = 1, 2, . . . , k∗ withφs(0, 0) = x0. Equivalently, we can write that φs(k∗, 0) = f s ◦ f s ◦ . . . ◦ f s(x0) =: (f s)k

(x0), where (f s)k∗

denotes k∗ compositions of f s. By continuity in s of the resulting map, we have that φs(k∗, 0) cannot be inSs for each s.

Now, we illustrate this issue in the three examples of hybrid systems jumping on surfaces introducedearlier. Throughout this paper, all numerical examples are simulated using the Hybrid Equations (HyEQ)Toolbox as described in [22].

Example 3.5. (bouncing ball (revisited)) Consider a hybrid simulator Hs for the system in Example 3.1with gs = g, Ss = S, and f s given by the Euler integration scheme, i.e., f s(x) = x + sf(x) = x +

s[x2, −M(x1)−N(x1)x2

]⊤. The type of solutions to Hs depend on the definition of X . For the choice

X ={x ∈ R

2 : x1 ≥ 0}∪{x ∈ R

2 : x2 ≤ −δ}, Hs has solutions that only flow and step over S (for some

step size s), which corresponds to the ball passing through the surface on which it is supposed to bounce.For the choice X =

{x ∈ R

2 : x1 ≥ 0}, Hs has solutions that may flow and step over the surface S

(because x1 may never be identically equal to 0), leaving X after a finite number of steps. In other words,the simulation stops prematurely because solutions are not in X or S.

7

Page 8: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

1.2x1

t

(a) Height of a bouncing ball with solutions thatpass through S. The region of operation is X ={

x ∈ R2 : x1 ≥ 0}

∪{

x ∈ R2 : x2 ≤ −δ}

.

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

1.2

x1

t

(b) Height of a bouncing ball with solutions thatstop prematurely. The region of operation is X ={

x ∈ R2 : x1 ≥ 0}

.

Figure 1: Solutions to the bouncing ball system in Example 3.5.

Figures 1(a) and 1(b) show simulation results with this simulator for γ = 9.81, λ = 0.8, δ = 0.1, ε = 1,and step size s = 0.02. The ball is dropped from an initial height of 1, and the step size is such that thesolution continues flowing and passes through S. In the simulation shown in Figure 1(b), the integrationstops prematurely due to the simulated solution leaving X . In each case, the results obtained from thesimulations do not represent the behavior of the physical system because, due to discretization, the systemdoes not jump, i.e., solutions to Hs never satisfy the condition x ∈ S. △

Example 3.6. (unicycle avoiding obstacle (revisited)) Consider a hybrid simulator Hs for the system inExample 3.2 with gs = g, Ss = ∪q∈{1,2}(Sq × {q}), and f s given by the Euler integration scheme, i.e.,

f s(x) = x + sf(x) = x + s[v cos(ξ3), v sin(ξ3), κ(q, ξ), 0

]⊤. The robot changes steering modes when it

crosses the surface Sq in order to maneuver around the obstacle and towards the target. As pointed out inSection 1, arbitrarily small measurement noise can prevent the robot from switching modes when reaching aboundary. This could lead the robot to collide with the obstacle or move away from the target.

Figure 2 shows a solution to Hs starting at (ξ1, ξ2) = (0, 0) moving towards the green target at (ξ∗1 , ξ∗2) =

(50, 90) while operating in mode q = 1. The obstacle is at (ξ◦1 , ξ◦2) = (35, 35) with radius smaller than a1.

The radii of the surfaces around the obstacle are a1 = 15 and a2 = 20. The control law is chosen as (see[2]) κ(1, ξ) = 0.9(arctan 90−ξ2

50−ξ1− ξ3) and κ(2, ξ) = 0.2(ξ3 − arctan 35−ξ2

35−ξ1). Figure 2(a) shows a solution to

Hs where the robot crosses the surface S1, changes mode to q = 2 to move away from the obstacle, andthen, due to discretization effects, steps over S2 and fails to change mode back to q = 1. On the other hand,Figure 2(b) shows the situation where a jump to mode q = 2 is not triggered. Both of these cases can occurdue to numerical error in the simulation. △

Example 3.7. (unicycle on a track (revisited)) Consider a hybrid simulator Hs for the system in Ex-ample 3.3 with gs = g, Ss = ∪q∈{1,2}(Sq × {q}), and f s given by the Euler integration scheme, i.e.,

f s(x) = x + sf(x) = x + s[v cos(ξ3), v sin(ξ3), κ(q, ξ), 0

]⊤. The robot changes steering modes when it

crosses the surface Sq in order to steer the robot back inside the track. Figure 3 shows a solution to Hs whenthe tangential velocity of the vehicle is v = 1, the control law is κ(1, ξ) = π

4 − ξ3 and κ(2, ξ) = 3π4 − ξ3, the

initial position in the plane is (ξ1, ξ2) = (0, 0), and the initial orientation angle is ξ3 = π4 radians. With an

arbitrarily small step size, discretization effects cause the solution to step over the surface S and miss themode change. △

8

Page 9: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

−20 0 20 40 60−10

0

10

20

30

40

50

60

70

80

90

100

target

obstacle

ξ1

ξ 2

S1

S2

(a) Solution of robot missing second mode changeand never reaching target.

�20 0 20 40 60�10

0

10

20

30

40

50

60

70

80

90

100

target

obstacle

ξ1

ξ 2

S1

S2

(b) Solution of robot missing first mode change andpotentially colliding with obstacle.

Figure 2: Solutions to the unicycle system in Example 3.6 that do not capture mode changes. The target is located at(ξ∗

1, ξ∗

2) = (50, 90) and the obstacle at (ξ◦

1, ξ◦

2) = (35, 35).

0 0.5 1 1.5 2 2.5 3 3.5 4-1.5

-1

-0.5

0

0.5

1

1.5

2

2.5

3

t

ξ 1

Figure 3: Solution for Example 3.7 that steps over S.

4. A hybrid model for hybrid systems jumping on surfaces with zero-crossing detection

4.1. A hybrid system model of H with zero-crossing detection

For the simulation of nonlinear systems, software packages use special algorithms to capture when solu-tions hit a surface. As pointed out in Section 1, a memory state variable can be added to evaluate condition(3) and determine when the state should jump.

For example, when using the Hit Crossing block in MATLAB/Simulink, shown in Figure 4, to detectthe jumps of system (4) with scalar state x and S := {x ∈ R : x = x∗ }, the input u would be equal to thestate of the system x, and the output of the block would be equal to a value {0, 1}, where 0 corresponds toflowing and 1 corresponds to a hit on or crossing of x∗ ∈ R. Denoting the memory state by z and initializingit to a value with the same sign as x(0)− x∗, which determines which “side” of S the state starts from, theoperation of the Hit Crossing block might be described as follows:

when (x(t) − x∗)z(t) > 0 ⇒ keep flowing (8)

when (x(t) − x∗)z(t) ≤ 0 ⇒ jump. (9)

9

Page 10: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

HitHit Crossing

Figure 4: Hit Crossing block in MATLAB/Simulink.

In general, this mechanism can be captured by a function that changes sign according to the location ofx with respect to S. We call such a function a zero-crossing function (cf. [23, Chapter 3]).

Definition 4.1 (zero-crossing function). A zero-crossing function on a set X ⊂ Rn for a switching

surface S is given by a function h : X → R that implicitly characterizes S and splits X into two setsX1,X2 ⊂ R

n as follows:

S ∩ X = {x ∈ X : h(x) = 0},

X1 = {x ∈ X : h(x) < 0},

X2 = {x ∈ X : h(x) > 0}.

For Example 3.1, a zero-crossing function h on X ={x ∈ R

2 : x1 ≥ 0}∪{x ∈ R

2 : x2 ≤ −δ}, for S

as in (5), is given byh(x) := c1(x)x

21 + c2(x2)x

22 ∀x ∈ X (10)

with c1(x)x21 continuously differentiable and such that c1(x) = 1 if x1 ≥ 0 and c1(x) = −1 if x1 < 0 and

x2 ≤ −δ, while c2 is such that c2(x2) = 1 if x2 > −δ and c2(x2) = 0 otherwise. The sets X1 and X2 become

X1 = {x ∈ X : x1 < 0, x2 ≤ −δ } ,

X2 = {x ∈ X : x1 > 0 } ∪ {x ∈ X : x1 = 0, x2 > −δ } .

For Example 3.2, a zero-crossing function h on X = R3 × {1, 2} for S as in (6) is given by

h(x) = hq(ξ) := (ξ◦1 − ξ1)2 + (ξ◦2 − ξ2)

2 − a2q ∀x ∈ X , (11)

and the sets X1 and X2 become

X1 =({ξ ∈ R

3 : h1(ξ) < 0}× {1}

)∪({ξ ∈ R

3 : h2(ξ) < 0}× {2}

),

X2 =({ξ ∈ R

3 : h1(ξ) > 0}× {1}

)∪({ξ ∈ R

3 : h2(ξ) > 0}× {2}

).

For Example 3.3, a zero-crossing function h on X = R3 × {1, 2} for S as in (7) is given by

h(x) = h(ξ) :=

{1− |ξ1| |ξ1| < 1 or |ξ1| > 1

0 |ξ1| = 1∀x ∈ X , (12)

and the sets X1 and X2 become

X1 ={ξ ∈ R

3 : |ξ1| > 1}

X2 ={ξ ∈ R

3 : |ξ1| < 1}.

A version of the hybrid system H with zero-crossing detection capabilities is denotedHZCD = (CZCD, fZCD, DZCD, gZCD) and is given by

[x

z

]=

[f(x)0

]=: fZCD(x) (x, z) ∈ CZCD

[x+

z+

]=

[g(x)

h(g(x))

]=: gZCD(x) (x, z) ∈ DZCD,

(13)

10

Page 11: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

where z ∈ R is a memory state, h is a zero-crossing function on X for S, and

CZCD := {(x, z) ∈ X × R : h(x)z ≥ 0 } ,

DZCD := {(x, z) ∈ X × R : h(x)z ≤ 0 } .

The memory state z is added to keep track of whether the state x is in the side of S with h negative (x ∈ X1)or in the side of S with h positive (x ∈ X2). At jumps, if g(x) ∈ X1, then h(g(x)) < 0. Similarly if g(x) ∈ X2,then h(g(x)) > 0. The value of z is always reset to h(g(x)) so that after each jump x is in the flow set. Inthis way, solutions flow when h(x) and z have the same sign (i.e., h(x)z ≥ 0) and jump when h(x) evaluatedalong the solution attempts to take a different sign from that of z (h(x)z ≤ 0).

Note that h(x) captures the term x(t)− x∗ in (8) and (9) (see also (3)). Furthermore, CZCD correspondsto the condition (8) while DZCD corresponds to (9). The equality included in CZCD does not affect solutionswhen the flow map f is not tangent to S.

4.2. A numerical simulation model of HZCD

Given a hybrid system H as in (4) and its augmentation with zero-crossing detectionHZCD = (CZCD, fZCD, DZCD, gZCD) as in (13), a hybrid simulator for HZCD is given by the family of systemsHs

ZCDparameterized by step size s satisfying s ∈ (0, s∗], s∗ > 0. The data of the hybrid simulator Hs

ZCDis

given by (CsZCD

, f sZCD

, DsZCD

, gsZCD

). The hybrid simulator HsZCD

is given by[x+sz+s

]=

[f s(xs)

0

]=: f s

ZCD(xs, zs) (xs, zs) ∈ Cs

ZCD,

[x+sz+s

]=

[gs(xs)

hs(gs(xs))

]=: gs

ZCD(xs, zs) (xs, zs) ∈ Ds

ZCD,

CsZCD

:= {(xs, zs) ∈ X × R : hs(xs)zs ≥ 0 } ,

DsZCD

:= {(xs, zs) ∈ X × R : hs(xs)zs ≤ 0 } .

The dynamics of the x component for the flows of HZCD have been replaced by the integration schemex+s = f s(xs), where f

s is constructed from f . The jump map of HZCD has been replaced by gsZCD

, and theflow and jump sets CZCD and DZCD have been replaced by the sets Cs

ZCDand Ds

ZCD, respectively. The function

hs is the discretization of the switching function h, and the memory state variable z has been replaced byzs. The operation of zs is the discretized equivalent to that of z in HZCD. Because the dynamics of thehybrid simulator Hs

ZCDare purely discrete, the solutions to Hs

ZCDare given on discrete versions of hybrid

time domains as previously described.Now we revisit the examples and add zero-crossing detection to the models.

Example 4.2. (bouncing ball (revisited)) Consider again the bouncing ball model in Example 3.1 with X ={x ∈ R

2 : x1 ≥ 0}∪{x ∈ R

2 : x2 ≤ −δ}. When adding zero-crossing detection to the model in (5), we

obtain the hybrid system

fZCD(x, z) =

x2−M(x1)−N(x1)x2

0

, gZCD(x, z) =

0−λx2h(g(x))

S = {x ∈ X : x1 = 0, x2 ≤ −δ } ,

where g is the jump map of the hybrid system in Example 3.1, and the functions M and N are also givenin Example 3.1. Now consider a hybrid simulator with zero-crossing detection Hs

ZCDwith gs

ZCD= gZCD,

hs = h, Ss = S, and f sZCD

given by the Euler integration scheme, i.e., fsZCD

(x, z) = [x⊤z]⊤ + sf(x, z) =

[x⊤z]⊤ + s[x2, −M(x1)−N(x1)x2, 0

]⊤.

Figure 5(a) shows the solution to HsZCD

when γ = 9.81, λ = 0.8, δ = 0.3, ε = 0.15, the initial state is[x⊤ z]⊤ = [1, 0, 1]⊤, and the step size is s = 0.01. In contrast to the simulator in Example 3.5, notice thatthis time the correct results are produced. Figure 5(b) shows a plot of h(x)z, with h as in (10), as a functionof t. Notice that the value of h(x)z switches sign at the same instant that the solution to Hs

ZCDjumps because

that is the instant where the memory state z changes sign. △

11

Page 12: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

0 1 2 3 4 5 6 7 8-0.2

0

0.2

0.4

0.6

0.8

1x1

t

(a) Height of the bouncing ball.

0 1 2 3 4 5 6 7 8-20

0

20

40

60

80

100

120

140

160

h(x)z

t

(b) h(x)z

Figure 5: Solution for Example 4.2 using Hs

ZCD framework.

Example 4.3. (unicycle avoiding obstacle (revisited)) Consider again the unicycle model in Example 3.2.Adding zero-crossing detection to the model in (6), we obtain the hybrid system

X ⊂ R3 × {1, 2},

fZCD(x, z) =

v cos(ξ3)v sin(ξ3)κ(q, ξ)

00

, gZCD(x, z) =

ξ

3− q

h(g(x))

S = ∪q∈{1,2}(Sq × {q})

Sq ={ξ ∈ X : (ξ◦1 − ξ1)

2 + (ξ◦2 − ξ2)2 = a2q

},

where g is the jump map of the hybrid system in Example 3.2. Now consider a hybrid simulator withzero-crossing detection Hs

ZCDwith gs

ZCD= gZCD, h

s = h, Ss = ∪q∈1,2(Sq × q), and f sZCD

given by the Euler

integration, i.e., f sZCD

(x, z) = x+ sfZCD(x, z) = x+ s[v cos(ξ3), v sin(ξ3), κ(q, ξ), 0, 0

]⊤.

Figure 6(a) shows a solution to HsZCD

with the control modes given in Example 3.6 when the initial stateis [ξ1 ξ2 ξ3 q z]

⊤ = [0, 0, 0, 1, 1]⊤, and the step size is s = 0.1. Figure 6(b) shows a plot of h(x)z, withh as in (11), as a function of t. In contrast to the simulation in Example 3.6, the mode changes are madesuccessfully, and the unicycle reaches the target. △

Example 4.4. (unicycle on a track (revisited)) Consider again the unicycle model in Example 3.3. Whenadding zero-crossing detection to the model in (7), we obtain the hybrid system HZCD given by

X ⊂ R3 × {1, 2},

fZCD(x, z) =

v cos(ξ3)v sin(ξ3)κ(q, ξ)

00

, gZCD(x, z) =

ξ

3− q

h(g(x))

S = ∪q∈{1,2}(Sq × {q})

S1 = {x ∈ X : ξ1 = 1, q = 1 }

S2 = {x ∈ X : ξ1 = −1, q = 2 } ,

12

Page 13: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

�20 0 20 40 60 80�10

0

10

20

30

40

50

60

70

80

90

100

target

obstacle

ξ1

ξ 2

S1

S2

(a) Solution to unicycle avoiding obstacle example.Solution starts from (0, 0). The location where jumps(mode changes) occur are labeled with red circles.

0 2 4 6 8 10 12 14 16 18

×105

-1

0

1

2

3

4

5

6

7

h(x)z

t

(b) h(x)z

Figure 6: Solution for Example 4.3 using Hs

ZCD framework.

where g is the jump map of the hybrid system in Example 3.3. Now consider a hybrid simulator for thissystem, denoted Hs

ZCD, with gs

ZCD= gZCD, h

s = h, Ss = ∪q∈{1,2}(Sq×{q}), and f sZCD

given by Euler integration,

i.e., f sZCD

(x, z) = x + sfZCD(x, z) = x + s[v cos(ξ3), v sin(ξ3), −ξ3 + κ(q, ξ), 0, 0

]⊤. Figure 7(a) shows a

solution to HsZCD

with the control law κ(1, ξ) = π4 − ξ3 and κ(2, ξ) = 3π

4 − ξ3 when the initial state is[ξ1 ξ2 ξ3 q z]

⊤ = [0, 0, π4 , 1, 1]

⊤, and the step size is s = 0.1. In contrast to the simulation in Example 3.7,the mode changes are made successfully. In fact, when the unicycle encounters the boundary, the solutionjumps, and, with some overshoot, the unicycle is steered back inside the track. Figure 7(b) shows a plot ofh(x)z, with h(x) as in (12), as a function of t. △

0 5 10 15-1.5

-1

-0.5

0

0.5

1

1.5

t

ξ 1

(a) Solution of unicycle on track example. Solutionstarts from (ξ1, ξ2, ξ3) = (0, 0, π/4).

2 4 6 8 10 12 14

-0.02

-0.01

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0.08

h(x)z

t

(b) h(x)z

Figure 7: Solution for Example 4.4 using Hs

ZCD framework.

13

Page 14: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

5. Main Results

In this section, we investigate properties of HZCD, state results addressing the previous concerns ofmeasurement noise and robustness, and give properties of the simulation framework for hybrid systemsincorporating zero-crossing detection.

5.1. Nominal Properties of HZCD

Given H as in (4), we are interested in conditions on the data of a hybrid system H under which HZCD

has basic regularity properties leading to robustness to perturbations. For this reason, the following mildconditions are imposed on the data of H.

Assumption 5.1. Given a hybrid system H = (C, f,D, g) as in (4) with associated sets X and S, thefollowing conditions hold:

1. X is closed (relative to Rn);

2. f : Rn → Rn is continuous on X ;

3. g : Rn → Rn is continuous on X ;

4. There exists a continuous zero-crossing function h on X for S.

The following lemma shows that, under these assumptions, HZCD has regular data by construction.

Lemma 5.2. (regularity of data of HZCD) Suppose that a hybrid system H = (C, f,D, g) as in (4) withassociated sets X and S satisfies Assumption 5.1. Then, the data of HZCD is such that CZCD and DZCD areclosed, and fZCD and gZCD are continuous.

Proof. For every sequence (ui, vi) ∈ CZCD with limi→∞(ui, vi) = (u∗, v∗), we have, by definition of CZCD,h(ui)vi ≥ 0. Using the continuity of h, limi→∞ h(ui) = h(u∗). Then, 0 ≤ limi→∞ h(ui) limi→∞ vi = h(u∗)v∗.This implies that (u∗, v∗) ∈ CZCD and, hence, that CZCD is closed. It follows similarly that DZCD is closed.Continuity of fZCD and of gZCD follows directly from their definition and the continuity of f , h, and g. �

When the flows of the hybrid system are transverse to the switching surface and the jump map doesnot map points back to the switching surface, the construction of HZCD is such that it captures all of thesolutions to H (and vice versa). The following proposition states this transversality condition.

Proposition 5.3. (properties of solutions to HZCD) Given a hybrid system H = (C, f,D, g) as in (4) withassociated sets X and S, assume the following:

1. f : Rn → Rn is continuous on X ;

2. Every maximal solution from D to

x = f(x) x ∈ C (14)

is trivial, i.e., each maximal solution φ to (14) with φ(0, 0) ∈ D is such that domφ = {(0, 0)}.

3. The jump map g satisfies g(x) 6∈ D for all x ∈ D.

Then, for every solution φ to H, there exists a solution ψ to HZCD such that φ ≡ ψx, where ψx denotesthe x component of ψ. Furthermore, for every solution ψ to HZCD there exists a solution φ to H such that2

ψx ≡ φ.

2 There exist solutions ψ′ to HZCD that start from D and initially jump due to the value of z, that is, (0, 1) is an elementof domψ′. For such solutions, the equivalence ψx ≡ φ holds for the solution to HZCD defined as ψ(t, j) = ψ′(t, j + 1) for each(t, j) ∈ domψ′.

14

Page 15: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

Proof. Let φ be a solution to H starting from X \ S, which exists due to item 1, and let {tj+1}jmax

j=0 ,jmax = supj{domφ} − 1, be the sequence determining the jump instants (tj+1, j) of φ. First, fix j = 0. Bydefinition of solutions to H, we have φ(t, 0) ∈ X \ S for all t ∈ (0, t1). Without loss of generality, usingthe definition of h, we can assume that, for all t ∈ (0, t1), we have φ(t, 0) ∈ X2, i.e., h(φ(t, 0)) > 0. Bydefinition of the jump set of H, we have h(φ(t1, 0)) = 0. By item 2, flows are not possible for t > t1. Then,the function ψ = [ψ⊤

x ψz]⊤ defined for all t ∈ [0, t1] as ψx(t, 0) = φ(t, 0), ψz(t, 0) = h(φ(0, 0)) is a maximal

solution tox = f(x)z = 0

}(x, z) ∈ CZCD.

Now, let j = 1 and note that by the condition on g and S in item 3 of the assumptions we have φ(t1, 1) =g(φ(t1, 0)) 6∈ D. If φ(t1, 1) 6∈ X or φ(t1, 1) is a point in the boundary of X from where flowing into X \ S isnot possible, then the augmentation of ψ by ψx(t1, 1) = φ(t1, 1), ψz(t1, 1) = h(φ(t1, 1)) finishes the proof.Otherwise, there exists t2 > t1 such that φ(t, 1) ∈ X \ S for all t ∈ (t1, t2). The argument for j = 0 canbe applied again (and successively) to augment ψ and construct a solution ψ. The other direction followsusing a similar construction. �

The properties in Proposition 5.3 guarantee that solutions to HZCD do not get repeatedly mapped to nor“slide” along (tangent to) the switching surface S. We now check these properties for Examples 3.1, 3.2,and 3.3. Considering item 1, it is easy to see that f in each of the Examples 3.1, 3.2, and 3.3 is continuouson X by inspection. Satisfaction of item 2 for Examples 3.1, 3.2, and 3.3 can be confirmed by noting thatf on D points outward of C (see also Figures 5, 6, and 7).

To check item 3, we first compute g(D) and then show that g(D)∩D = ∅ for each example. For Example3.1, g(D) =

{x ∈ R

2 : x1 = 0, x2 ≥ λδ}. Therefore, g(D) ∩D = ∅ because λδ > −δ, so item 3 is satisfied

for Example 3.1. For Example 3.2,

g(D) ={(ξ, q) ∈ R

3 × {1, 2} : (ξo1 − ξ1)2 + (ξo2 − ξ2)

2 = a1, q = 2}∪

{(ξ, q) ∈ R

3 × {1, 2} : (ξo1 − ξ1)2 + (ξo2 − ξ2)

2 = a2, q = 1}.

The value of q always switches thereby ensuring that g(D) ∩D = ∅, so item 3 is satisfied for Example 3.2.For Example 3.3,

g(D) ={(ξ, q) ∈ R

3 × {1, 2} : ξ1 = 1, q = 2}∪{(ξ, q) ∈ R

3 × {1, 2} : ξ1 = −1, q = 1}.

Again, g(D) ∩D = ∅ because of the same reasoning as that for Example 3.2. Therefore, items 1, 2, and 3in Proposition 5.3 are satisfied in Examples 3.1, 3.2, and 3.3.

5.2. Robustness to measurement noise of HZCD

Next we show that HZCD is robust to measurement noise. This is proven by embedding the hybridsystem HZCD with measurement noise e, denoted He

ZCD, into an inflated version of HZCD. More precisely,

given ε1 > 0, HZCD is inflated via an outer perturbation giving the perturbed hybrid system

Hε1ZCD

:

{x ∈ cofZCD(x+ ε1B) x ∈ Cε1

ZCD

x+ ∈ gZCD(x+ ε1B) x ∈ Dε1ZCD

,(15)

where co denotes the closed convex hull operation, and

Cε1ZCD

:= {x ∈ Rn : (x+ ε1B) ∩ CZCD 6= ∅ }

Dε1ZCD

:= {x ∈ Rn : (x+ ε1B) ∩DZCD 6= ∅ } .

(16)

This perturbed hybrid system is such that it captures all of the solutions to HeZCD

with measurement noisee : dom e→ ε1B. Under the conditions in Assumption 5.1, it follows that every solution to Hε1

ZCDis close (in

an appropriate sense and on compact hybrid time domains) to an unperturbed solution to HZCD. Then, theequivalence result in Proposition 5.3 permits relating these solutions to those of H.

15

Page 16: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

Before presenting the robustness result, we introduce a notion of closeness of hybrid arcs from [19]. Thesame property can be defined for two discrete arcs as well as for a hybrid arc and a discrete arc; see [20] formore details.

Definition 5.4. ((T, J, µ)-closeness) Given T, J ≥ 0 and µ > 0, two hybrid arcs x1 : domx1 → Rn and

x2 : domx2 → Rn are (T, J, µ)-close if

(a) for all (t, j) ∈ domx1 with t ≤ T, j ≤ J there exists s such that (s, j) ∈ domx2, |t− s| < µ, and

|x1(t, j)− x2(s, j)| < µ,

(b) for all (t, j) ∈ domx2 with t ≤ T, j ≤ J there exists s such that (s, j) ∈ domx1, |t− s| < µ, and

|x2(t, j)− x1(s, j)| < µ.

Theorem 5.5. (robustness of HZCD to measurement noise) Suppose that a hybrid system H = (C, f,D, g)as in (4) with associated sets X and S satisfy Assumption 5.1 and items 2 and 3 of Proposition 5.3. LetK ⊂ R

n be a compact set such that every maximal solution φ to H with φ(0, 0) ∈ K is either bounded orcomplete. Then, for every µ > 0 and (T, J) ∈ R≥0 × N there exists ε∗ > 0 such that, for every measurablesignal e : dom e→ εB, 0 < ε ≤ ε∗, every solution ψe to He

ZCDwith3 ψe

x(0, 0) ∈ K+εB, ψez(0, 0) = h(ψe

x(0, 0)),is such that there exists a solution φ to H with φ(0, 0) ∈ K such that ψe

x and φ are (T, J, µ) close.

Proof. Using Assumption 5.1, by Lemma 5.2, HZCD is such that CZCD and DZCD are closed, and fZCD andgZCD are continuous. Let e : dom e → ε1B, with ε1 > 0 to be specified later, and consider the inflation ofHZCD given by (15)-(16). By construction, each solution to He

ZCDis a solution to Hε1

ZCD. Using [20, Theorem

3.4], we have that, for every µ1 > 0 and given (T, J), there exists ε∗1 such that, for each ε1 ∈ (0, ε∗1], for eachsolution ψε1 to Hε1

ZCDwith ψε1

x (0, 0) ∈ K + ε1B (in particular, those that are solutions to HeZCD

) there existsa solution ψ to HZCD with ψx(0, 0) ∈ K that is (T, J, µ1)-close to ψ

ε1 (and, in particular, since each solutionto He

ZCDis a solution to Hε1

ZCD, to the associated solution ψe). Using Assumption 5.1 and items 2 and 3 of

Proposition 5.3, the claim follows with ε∗ = ε∗1 and µ = µ1 using the second result in Proposition 5.3, whichimplies that there exists a solution φ to H with the property ψe

x ≡ φ. �

5.3. Properties of HsZCD

As pointed out in Section 3.2, a hybrid simulator for H that simply discretizes its dynamics may not becapable of reproducing the jumps of the solutions to H; see, e.g., [15, 16]. As a consequence, solutions to Hcannot be reproduced by Hs with arbitrary precision. In this section, we present conditions on the data ofHs that guarantee that when zero-crossing detection is incorporated, which results in the hybrid simulatorHs

ZCD, solutions to H can be reproduced with arbitrary precision. To this end, the following conditions on

the data of Hs are imposed.

Assumption 5.6. The data f s and gs of the hybrid simulator Hs = (Cs, f s, Ds, gs) for the hybrid systemH = (C, f,D, g) and the associated zero-crossing function hs satisfy the following:

(B0) f s is such that, for each compact set K ⊂ Rn, there exists ρ ∈ K∞ and s∗ > 0 such that for each

x ∈ Cs ∩K and each s ∈ (0, s∗],

f s(x) ∈ x+ s co f(x+ ρ(s)B) + sρ(s)B;

3ψe

xdenotes the x component of ψ and ψe

zthe z component.

16

Page 17: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

(B1) gs is such that for any positive sequence {si}∞i=1, si ց 0,

limsiց0

gsi(x) = g(x) ∀x ∈ Rn;

(B2) hs is such that for any positive sequence {si}∞i=1, si ց 0,

limsiց0

hsi(x) = h(x) ∀x ∈ Rn.

Integration schemes such as Euler, as in Examples 3.5, 3.6, and 3.7, and Runge-Kutta satisfy condition (B0).Conditions (B1) and (B2) hold when the perturbed functions are continuous in the step size; see also [20,Examples 4.8 and 4.9].

When the data of the simulator Hs and zero-crossing function associated with H satisfy Assumption 5.6,the data of Hs

ZCDhave regularity properties guaranteeing closeness between the solutions to H and its

simulations obtained via HsZCD

. The next lemma formalizes this fact.

Lemma 5.7. (regularity of data of HsZCD

) AssumeHs = (Cs, f s, Ds, gs) and hs are such that Assumption 5.6hold. Then, Hs

ZCD= (Cs

ZCD, f s

ZCD, Ds

ZCD, gs

ZCD) is such that f s

ZCDand gs

ZCDsatisfy (B0) and (B1), respectively, in

Assumption 5.6, and Cs and Ds are such that

(B3) for any positive sequence {si}∞i=1 such that si ց 0, lim supi→∞ Csi ⊂ C, lim supi→∞Dsi ⊂ D,where lim supi→∞ Csi , lim supi→∞Dsi are the outer limits of the sequence of sets Csi , Dsi , respec-tively.

Proof. Since f s and gs satisfy (B0) and (B1), by construction, the functions f sZCD

and gsZCD

also satisfy(B0) and (B1). Let si ց 0 be a positive sequence and take (x′, z′) ∈ Csi = {(x, z) : hsi(x)z ≥ 0 }. Sincehs satisfies (B2), we have that there exists δi > 0, δi ց 0, and N > 0 such that hsi(x′) ∈ h(x′) + δiB for alli > N . It follows that Csi ⊂ C ∪ δiB for all i > N . Then, using [24, Proposition 5.12], Csi satisfies (B3).Similar arguments show that Dsi satisfies (B3). �

As pointed out in Section 3.2, solutions to H cannot be approximated by Hs with arbitrary precision.However, on finite simulation horizons (T, J), the solutions to hybrid simulators Hs

ZCD, with data satisfying

(B0)-(B3), can approximate the solutions to H with arbitrary precision, and this key relationship betweenthe solutions to H and its simulations via Hs

ZCDis stated in the following result.

Theorem 5.8. (closeness between solutions to H and HsZCD

) Suppose that a hybrid system H = (C, f,D, g)as in (4) with associated sets X and S satisfies Assumption 5.1 and items 2 and 3 of Proposition 5.3.Furthermore, suppose Hs

ZCDsatisfies Assumption 5.6. Then, for every compact set K ⊂ R

n, µ > 0, andsimulation horizon (T, J) ∈ R≥0 × N there exists s∗ > 0 with the following property: for any s ∈ (0, s∗]and any solution ψs

x(0, 0) ∈ K there exists a solution φ to H with φ(0, 0) ∈ K such that ψsx and φ are

(T, J, µ)-close.

Proof. Using Assumption 5.1, by Lemma 5.2, HZCD is such that CZCD and DZCD are closed, and fZCD andgZCD are continuous. Using Assumption 5.6, by Lemma 5.7, Hs

ZCDis such that f s

ZCDand gs

ZCDsatisfy (B0) and

(B1) in Assumption 5.6, and Cs and Ds satisfy (B3). Using [20, Theorem 5.2], it follows that for every K,µ > 0, and (T, J) as in the statement, there exists s∗ > 0 with the following property: for every s ∈ (0, s∗]and every solution ψs to Hs

ZCDwith ψs

x(0, 0) ∈ K there exists a solution ψ to HZCD with ψx(0, 0) ∈ K suchthat ψs and ψ are (T, J, µ)-close. The proof of the claim is complete after an application of Proposition 5.3,which permits obtaining a solution φ to H that is equivalent to ψx. �

17

Page 18: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

Example 5.9. (unicycle avoiding obstacle (revisited)) Consider the unicycle model with zero-crossing de-tection in Example 4.3. The results of Theorem 5.8 are illustrated by plotting the solutions of Hs

ZCDfrom

Example 4.3 for different step sizes. Figure 8 shows the exact solution (in black) and simulated solutions(in blue) in the same plot. Figure 8(b) shows a zoomed in version of Figure 8(a). Similarly, Figure 9 showsthe hybrid arc solution and closeness of the simulated solution to the exact solution in a finite simulationhorizon (T, J). Figure 9(b) shows a zoomed in version of Figure 9(a). Notice that the simulated solutionsconverge to the exact solution as the step size is decreased. △

�20 0 20 40 60 80�10

0

10

20

30

40

50

60

70

80

90

100

obstacle

target

ξ1

ξ 2

S1

S2

(a) Exact solution (in black), and simulated solutionswith decreasing step size (in blue *).

5 10 15 20 25 30 35 40

35

40

45

50

55

60

65

obstacle

ξ1

ξ 2 S1

S2

(b) Zoomed in version showing closeness. Exact so-lution shown as solid black line.

Figure 8: Closeness between exact solution and simulated solutions of Example 3.2. Solutions start from (0, 0).

012

05

1015

0

10

20

30

40

50

ξ 1

t j

(a) Discrete arc (blue *), exact hybrid arc solution(black), and exact hybrid time domain (red) areshown.

(b) Zoomed in version showing closeness.

Figure 9: Closeness between exact hybrid arc solution and simulated solutions of Example 3.2.

5.4. Application to hybrid systems H with asymptotically stable compact sets

In this section, we consider the setting when a compact set is asymptotically stable for the hybrid systemH in (4). This is the case when there exists a compact set A ⊂ R

n with the following properties:

18

Page 19: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

• stable if for each ε > 0 there exists δ > 0 such that each solution φ to H with |φ(0, 0)|A ≤ δ satisfies|φ(t, j)|A ≤ ε for all (t, j) ∈ domφ;

• attractive if there exists µ > 0 such that every solution φ to H with |φ(0, 0)|A ≤ µ is bounded and ifit is complete satisfies lim(t,j)∈domφ,t+j→∞ |φ(t, j)|A = 0;

• asymptotically stable if stable and attractive.

When the attractivity property holds for every solution starting from C ∪D, a stable compact set A is saidto be globally asymptotically stable.

Whether or not a hybrid simulator preserves the asymptotic stability properties of H depends on theeffect of perturbations. Therefore, in light of the lack of robustness of H to measurement noise pointed outin Proposition 3.4, it is not expected for Hs to preserve asymptotic stability because numerical integrationcan be interpreted similarly as a perturbation. In spite of this, the simulator with zero-crossing detectiongiven by Hs

ZCD, when designed with regular data, does, in fact, preserve stability as stated in the following

result.

Theorem 5.10. (semiglobal practical stability) Suppose that a hybrid system H = (C, f,D, g) as in (4)with associated sets X and S satisfies Assumption 5.1 and items 2 and 3 of Proposition 5.3. Furthermore,suppose that A is a globally asymptotically stable compact set for H and that Hs

ZCDsatisfies Assumption 5.6.

Then, A is semiglobally practically asymptotically stable for HsZCD

, i.e., there exists β ∈ KL such that, forevery compact set K ⊂ R

n, ε > 0, and simulation horizon (T, J) ∈ R≥0 × N there exists s∗ > 0 such that,for each s ∈ (0, s∗], every solution φs to Hs

ZCDwith φs(0, 0) ∈ K satisfies for all (k, j) ∈ domφs

|φs(k, j)|A ≤ β(|φs(0, 0)|A, ks+ j) + ε.

Proof. By the equivalence of solutions in Proposition 5.3, A is globally asymptotically stable for HZCD.Using the assumptions, Lemma 5.2 and Lemma 5.7 imply that HZCD and Hs

ZCDhave regular data. It follows

that the conditions in the semiglobal practical asymptotic stability result for general simulators in [20,Theorem 5.3] hold for these systems, which establishes the claim. �

The semiglobal practical asymptotic stability property established in the result above holds for sufficientlysmall step size. The bound s∗ on the step size s decreases with ε, which defines the level of closeness to Athat solutions to Hs should arrive at.

Our final result follows directly from [20, Theorem 5.4], Proposition 5.3, Lemma 5.2, and Lemma 5.7. Itestablishes that the semiglobally asymptotically stable set for Hs

ZCD, denoted As, converges to A as the step

size s becomes smaller. In other words, the set As depends continuously on the step size.

Theorem 5.11. (continuity of asymptotically stable sets) Suppose the assumptions of Theorem 5.10 hold.Then, there exists s∗ > 0 such that for each s ∈ (0, s∗], the hybrid simulator Hs

ZCDhas a semiglobally

asymptotically stable compact set As satisfying dH(As,A) → 0 as sց 0.

Example 5.12. (bouncing ball (revisited)) Recall Example 3.5 where the solutions to a bouncing ball examplepass through the surface on which it is supposed to bounce. We know that the origin, i.e., the compact setA = {(0, 0)}, is globally asymptotically stable for HZCD, but when solutions pass through S, this stabilityproperty no longer holds. This means that in Example 3.5, the origin is not globally asymptotically stablefor Hs because every solution does not converge to the origin. This can be seen in Figure 1(a). However,if we instead simulate the bouncing ball example with the Hs

ZCDframework, the stability property holds.

This property is highlighted in Figure 10 which shows the tail of a simulated solution to HsZCD

as given inExample 4.2 with γ = 9.81, λ = 0.8, δ = 0.3, ε = 0.15, the initial state [x⊤ z]⊤ = [1, 0, 1]⊤, and step sizes = 0.001. As a result of the non-Zeno bouncing ball model, the tail of this simulated solution shows theheight of the ball oscillating between positive and negative values. In this way, the solution is asymptoticallyconverging to the compact set A = {(0, 0)}, which follows from Theorem 5.10. △

19

Page 20: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

112 113 114 115 116 117 118 119 120

×10 -3

-3

-2.5

-2

-1.5

-1

-0.5

0

0.5

1

1.5

2

2.5

3

x1,x

2

t

Figure 10: Tail of a solution to the bouncing ball in Example 4.2. Height (x1) is denoted in blue, and velocity (x2) is denotedin red. Following Theorem 5.10, the solution is asymptotically converging to the compact set A = {(0, 0)}.

6. Conclusion

A mathematical framework for hybrid systems incorporating zero-crossing detection algorithms wasintroduced. Unlike previous work in the literature, the proposed framework allows for analytical study ofthe effects of zero-crossing detection algorithms in the simulation of hybrid systems. Adverse effects ofperturbations in hybrid systems jumping on surfaces was highlighted, and a hybrid model and simulatorincorporating zero-crossing detection were proposed. We established that the resulting system with zero-crossing detection is robust to measurement noise and to discretization effects in numerical simulation.Our results suggest that integration schemes with zero-crossing detection algorithms actually compute thesolutions of a robustified version of the fragile nominal model. These results are assured when the simulatoris implemented numerically using standard available solvers, so this approach is suitable for simulation ofcomplex systems, e.g. hybrid and cyber-physical systems. These results were illustrated in several numericalexamples throughout the paper.

7. Acknowledgements

This research has been partially supported by the National Science Foundation under CAREER Grantno. ECS-1150306 and by the Air Force Office of Scientific Research under Grant no. FA9550-12-1-0366.

References

[1] D. D. Bainov and P. S. Simeonov. Systems with Impulse Effect: Stability, Theory, and Applications. Ellis HorwoodLimited, 1989.

[2] M. Boccadoro, Y. Wardi, M. Egerstedt, and E. Verriest. Optimal control of switching surfaces in hybrid dynamicalsystems. Discrete Event Dynamic Systems-Theory and Applications, 15(4):433–448, 2005.

[3] B. Morris and J. W. Grizzle. Hybrid invariant manifolds in systems with impulse effects with application to periodiclocomotion in bipedal robots. IEEE Trans. Aut. Control, 54(8):1751–1764, 2009.

[4] J. C. Clegg. A nonlinear integrator for servomechanisms. Transactions A.I.E.E., 77(Part II):41–42, 1958.[5] K. R. Krishnan and I. M. Horowitz. Synthesis of a non-linear feedback system with significant plant-ignorance for prescribed

system tolerances. International Journal of Control, 19:689–706, 1974.[6] O. Beker, C. V. Hollot, Y. Chait, and H. Han. Fundamental properties of reset control systems. Automatica, 40(6):905–915,

2004.[7] L. Zaccarian, D. Nesic, and A. R. Teel. First order reset elements and the clegg integrator revisited. Proc. 24th American

Control Conference, pages 563–568, 2005.[8] V. Chellaboina, S. P. Bhat, and W. H. Haddad. An invariance principle for nonlinear hybrid and impulsive dynamical

systems. Nonlinear Analysis, Theory, Methods and Applications, 53:527–550, 2003.

20

Page 21: AZero-crossing Detection Algorithm for RobustSimulation of ......zero-crossing detection actually compute the solutions of a robustified version of the fragile nominal model. Finally,

[9] R. C. Arkin. Behavior Based Robotics. The MIT Press, 1998.[10] M. Egerstedt. Behavior based robotics using hybrid automata. Hybrid Systems: Computation and Control Lecture Notes

in Computer Science, 1790:103–116, 2000.[11] V. Donde and I. A. Hiskens. Shooting methods for locating grazing phenomena in hybrid systems. International Journal

of Bifurcation and Chaos, 16(03):671–692, 2006.[12] R. G. Sanfelice, R. Goebel, and A. R. Teel. Generalized solutions to hybrid dynamical systems. ESAIM: Control,

Optimisation and Calculus of Variations, 14(4):699–724, 2008.[13] The Mathworks, Inc. Hit Crossing. http://www.mathworks.com/help/simulink/slref/hitcrossing.html, 1984-2015.[14] L. Shampine, I. Gladwell, and R. Brankin. Reliable solution of special event location problems for ODEs. ACM Transac-

tions on Mathematical Software, 17(1):11–25, 1991.[15] J. M. Esposito, V. Kumar, and G. J. Pappas. Accurate event detection for simulating hybrid systems. In Hybrid Systems:

Computation and Control: 4th International Workshop, pages 204–217, 2001.[16] F. Zhang, M. Yeddanapudi, and P. J. Mosterman. Zero-crossing location and detection algorithms for hybrid system

simulation. In 17th IFAC World Congress, pages 7967–7972, 2008.[17] S. Burden, H. Gonzalez, R. Vasudevan, R. Bajcsy, and S. S. Sastry. Numerical integration of hybrid dynamical systems

via domain relaxation. In 50th IEEE Conference on Decision and Control, pages 3958–3965, December 2011.[18] D. A. Copp and R. G. Sanfelice. On the effect and robustness of zero-crossing detection algorithms in simulation of hybrid

systems jumping on surfaces. In Proc. 31st American Control Conference, pages 2449–2454, 2012.[19] R. Goebel, R. G. Sanfelice, and A. R. Teel. Hybrid dynamical systems. IEEE Control Systems Magazine, pages 28–93,

2009.[20] R. G. Sanfelice and A. R. Teel. Dynamical properties of hybrid systems simulators. Automatica, 46(2):239–248, 2010.[21] R. G. Sanfelice and A. R. Teel. A nested matrosov theorem for hybrid systems. In Proc. 27th American Control Conference,

pages 2915–2920, 2008.[22] R. G. Sanfelice, D. A. Copp, and P. Nanez. A toolbox for simulation of hybrid systems in Matlab/Simulink: Hybrid

equations (HyEQ) Toolbox. In 16th International Conference on Hybrid Systems: Computation and Control, pages101–106, 2013.

[23] R. I. Leine and H. Nijmeijer. Dynamics and Bifurcations of Non-Smooth Mechanical Systems. Springer, 2004.[24] R. T. Rockafellar and R. J-B Wets. Variational Analysis. Springer, 1998.

21