Learning Parametric Constraints in High Dimensions from Demonstrations

  • 2019-10-08 15:46:36
  • Glen Chou, Necmiye Ozay, Dmitry Berenson
  • 0

Abstract

We present a scalable algorithm for learning parametric constraints in highdimensions from safe expert demonstrations. To reduce the ill-posedness of theconstraint recovery problem, our method uses hit-and-run sampling to generatelower cost, and thus unsafe, trajectories. Both safe and unsafe trajectoriesare used to obtain a representation of the unsafe set that is compatible withthe data by solving an integer program in that representation's parameterspace. Our method can either leverage a known parameterization or incrementallygrow a parameterization while remaining consistent with the data, and weprovide theoretical guarantees on the conservativeness of the recovered unsafeset. We evaluate our method on high-dimensional constraints forhigh-dimensional systems by learning constraints for 7-DOF arm, quadrotor, andplanar pushing examples, and show that our method outperforms baselineapproaches.

 

Quick Read (beta)

Learning Parametric Constraints in High Dimensions from Demonstrations

Glen Chou, Necmiye Ozay, and Dmitry Berenson
Department of Electrical Engineering and Computer Science
University of Michigan, Ann Arbor
{gchou, necmiye, dmitryb}@umich.edu
Abstract

We present a scalable algorithm for learning parametric constraints in high dimensions from safe expert demonstrations. To reduce the ill-posedness of the constraint recovery problem, our method uses hit-and-run sampling to generate lower cost, and thus unsafe, trajectories. Both safe and unsafe trajectories are used to obtain a representation of the unsafe set that is compatible with the data by solving an integer program in that representation’s parameter space. Our method can either leverage a known parameterization or incrementally grow a parameterization while remaining consistent with the data, and we provide theoretical guarantees on the conservativeness of the recovered unsafe set. We evaluate our method on high-dimensional constraints for high-dimensional systems by learning constraints for 7-DOF arm, quadrotor, and planar pushing examples, and show that our method outperforms baseline approaches.

\AtAppendix\AtAppendix\AtAppendix\AtAppendix\AtAppendix

Learning Parametric Constraints in High Dimensions from Demonstrations

Glen Chou, Necmiye Ozay, and Dmitry Berenson
Department of Electrical Engineering and Computer Science
University of Michigan, Ann Arbor
{gchou, necmiye, dmitryb}@umich.edu
\@float

noticebox[b]3rd Conference on Robot Learning (CoRL 2019), Osaka, Japan.\[email protected]

Keywords: learning from demonstration, safe learning, constraint inference

1 Introduction

Learning from demonstration is a powerful paradigm for enabling robots to perform complex tasks. Inverse optimal control and inverse reinforcement learning (IOC/IRL) ([irl_1, irl_2, lfd3, ng_irl]) methods have been used to learn a cost function to replicate the behavior of an expert demonstrator. However, planning problems generally also require knowledge of constraints, which define the states or trajectories that are safe. For example, to get a robot arm to efficiently transport a cup of coffee without spilling it, one can optimize a cost function describing the length of the path, subject to constraints on the pose of the end effector. Constraints can represent safety requirements more strictly than cost functions, especially in safety-critical situations: enforcing a hard constraint can enable the robot to guarantee safe behavior, as opposed to using a “softened” cost penalty term. Furthermore, learning a global constraint shared across many tasks can help the robot generalize. Consider the arm, which must avoid spilling the coffee regardless of where the cup started off or needs to go.

While constraints are important, it can be impractical to exhaustively program all the possible constraints a robot should obey across all tasks. Thus, we consider the problem of extracting the latent constraints within expert demonstrations that are shared across tasks. We adopt the insight of [extended_version] that each safe, optimal demonstration induces a set of lower-cost trajectories that must be unsafe due to violation of an unknown constraint. As in [extended_version], we sample these unsafe trajectories, ensuring that they are also consistent with the system dynamics, control constraints, and start/goal constraints. The unsafe trajectories are used together with the safe demonstrations in an “inverse” integer program that recovers an unsafe set consistent with the safe and unsafe trajectories. We make the following additional contributions in this paper. First, by using a (potentially known) parameterization of the constraints, our method enables the inference of safe and unsafe sets in high-dimensional constraint spaces. Second, we relax the known parametrization assumption and propose a means to incrementally grow a parameterization with the data. Third, we introduce a method for extracting volumes of states which are guaranteed safe or guaranteed unsafe according to the data and parameterization. Fourth, we provide theoretical analysis showing that our method is guaranteed to output conservative estimates of the unsafe and safe sets under mild assumptions. Finally, we evaluate our method on high-dimensional constraints for high-dimensional systems by learning constraints for 7-DOF arm, quadrotor, and planar pushing examples, showing that our method outperforms baseline approaches.

2 Related Work

Inverse optimal control [kalman, boyd] (IOC) and inverse reinforcement learning (IRL) [ng_irl] aim to recover an objective function that replicates provided expert demonstrations when optimized. Our method is complementary to these approaches; if the demonstrator solves a constrained optimization problem, we are finding its constraints, given the cost; IOC/IRL finds the cost, given the constraints [toussaint]. Risk-sensitive IRL [sumeet] is complementary to our work, which learns hard constraints. Similarly, [satinder] learns a state-space constraint shared across tasks as a penalty term in the reward function of an MDP. However, when representing a constraint as a penalty, it is unclear if a demonstrated action was made to avoid a penalty or to improve the trajectory cost in terms of the true cost function (or both). Thus, learning a penalty generalizing across cost functions becomes difficult. To avoid this, we assume a known cost function to explicitly reason about the constraint. Also relevant is safe reinforcement learning, which aims to perform exploration while minimizing visitation of unsafe states. Several methods [safe_exploration, krause, claire] use Gaussian process models to incrementally explore safe regions in the state space. We take a complementary approach to safe learning by using demonstrations in place of exploration to guide the learning of safe behaviors. Methods exist for learning geometric state space constraints [vijayakumar, shah], task space equality constraints [howard1, howard2], and convex constraints [melanie], which our algorithm generalizes by being able to learn arbitrary nonconvex parametric inequality constraints defined in some constraint space (not limited to the state space). Other methods aim to learn local trajectory-based constraints [dmitry, anca, lfdc1, lfdc2, lfdc3, lfdc4] by reasoning over the constraints within a single trajectory or task. In contrast, our method aims to learn a global constraint shared across tasks.

The method closest to our work is [extended_version], which learns a global shared constraint on a gridded constraint space; hence, the resulting constraint recovery method scales exponentially with the constraint space dimension and cannot exploit any side information on the structure of the constraint. This often leads to very conservative estimates of the unsafe set, and only grid cells visited by demonstrations can be learned guaranteed safe. We overcome these shortcomings with a novel algorithm that exploits constraint parameterizations for scalability and integration of prior knowledge, and also enables learning volumes of guaranteed safe/unsafe states in the original non-discretized constraint space, yielding less conservative estimates of the safe/unsafe sets under weaker assumptions than [extended_version].

3 Problem Setup

Consider a system with discrete-time dynamics xt+1=f(xt,ut,t) or continuous-time dynamics x˙=f(x,u,t), where x𝒳 and u𝒰. The system performs tasks Π represented as constrained optimization problems over state/control trajectories ξx/ξu in state/control trajectory space 𝒯x/𝒯u:

Problem 1 (Forward problem / “task” Π).
minξx,ξucΠ(ξx,ξu)s.t.ϕ(ξx,ξu)𝒮(θ)𝒞ϕ¯(ξx,ξu)𝒮¯𝒞¯ϕΠ(ξx,ξu)𝒮Π𝒞Π (1)

where cΠ():𝒯x×𝒯u is a cost function for task Π, and ϕ(,):𝒯x×𝒯u𝒞 is a known mapping from state-control trajectories to a constraint space 𝒞, elements of which are referred to as “constraint states”. Mappings ϕ¯(,):𝒯x×𝒯u𝒞¯ and ϕΠ(,):𝒯x×𝒯u𝒞Π are known and map to constraint spaces 𝒞¯ and 𝒞Π, containing a known shared safe set 𝒮¯ and a known task-dependent safe set 𝒮Π, respectively. In this paper, we take 𝒯𝒮Π to be the set of trajectories satisfying start/goal state constraints and 𝒯𝒮¯ to be the set of dynamically-feasible trajectories obeying control constraints, though the dynamics may not be known in closed form. 𝒮(θ)={k𝒞g(k,θ)>0} is an unknown safe set defined by an unknown parameter θΘ and a possibly unknown parameterization g(,). A demonstration, ξxu(ξx,ξu)𝒯xu, is a state-control trajectory which approximately solves Problem 1, i.e. it satisfies all constraints and its cost is at most a factor of δ above the cost of a globally optimal solution ξxu*, i.e. c(ξx,ξu)(1+δ)c(ξx*,ξu*). For convenience, we summarize our frequently used notation in Appendix F. In this paper, our goal is to recover the safe set 𝒮(θ) and its complement, the unsafe set 𝒜(θ)𝒮(θ)c, given Ns demonstrations {ξsj*}j=1Ns, N¬s inferred unsafe trajectories {ξ¬sk}k=1N¬s, the cost function cΠ(), task-dependent constraints 𝒮Π, and a simulator generating dynamically-feasible trajectories satisfying control constraints.

4 Method

In this section, we describe our method (a full algorithm block is presented in Appendix A). In Section 4.1, we describe how to sample unsafe trajectories. In Sections 4.2 and 4.3, we present mixed integer programs which recover a consistent constraint for a fixed parameterization and extract volumes of guaranteed safe/unsafe states. In Section 4.4, we present how our method can be extended to the case of unknown parameterizations.

4.1 Sampling lower-cost trajectories

Figure 4.1: Hit-and-run. Left: Blue lines: sampled random directions; black dots: samples. Right: Each point in 𝒯𝒜ξxu* corresponds to an unsafe trajectory in the constraint space 𝒞 (here, 𝒞=𝒳).

In this section, we describe the general sampling framework presented in [extended_version] while also relaxing the assumption of known closed-form dynamics made in [extended_version]. We define the set of unsafe state-control trajectories induced by an optimal, safe demonstration ξxu*, 𝒯𝒜ξxu*, as the set of state-control trajectories of lower cost that obey the known constraints, 𝒯𝒜ξxu*{ξxu𝒯𝒮¯𝒯𝒮Πc(ξx,ξu)<c(ξx*,ξu*)}. We sample from 𝒯𝒜ξxu* to obtain lower-cost trajectories obeying the known constraints using hit-and-run sampling [hit_and_run], a method guaranteeing convergence to a uniform distribution of samples over 𝒯𝒜ξxu* in the limit; an illustration is shown in Fig. 4.1. Hit-and-run starts from an initial point within the set, chooses a direction uniformly at random, moves a random amount in that direction such that the new point remains within the set, and repeats [extended_version]. We sample from 𝒯𝒜ξxu* indirectly by sampling control sequences and rolling them out through the dynamics to generate dynamically-feasible trajectories. We emphasize that f(x,u,t) does not need to be known in closed form. Given a control sequence sampled by hit-and-run, a simulator can instead be used to output the resulting dynamically-feasible trajectory, which can then be checked for membership in 𝒯𝒜ξxu* exactly as if the dynamics were known in closed form. Also, δ-suboptimality of the demonstration ξxudem can be handled in this framework by sampling instead from {ξxu𝒯𝒮¯𝒯𝒮Πc(ξx,ξu)<c(ξxdem,ξudem)/(1+δ)}. Optimal substructure in the cost function can be exploited to sample unsafe sub-trajectories over shorter time windows on the demonstrations; shorter unsafe trajectories provide less ambiguous information regarding 𝒜 and can better reduce the ill-posedness of the constraint recovery problem [extended_version].

4.2 Recovering the constraint

Recall that the unsafe set can be described by some parameterization 𝒜(θ){k𝒞|g(k,θ)0}, where we assume for now that g(,) is known, and θ are parameters to be learned. Intuitively, g(k,θ) tells us if constraint state k (which is any element of constraint space 𝒞) is safe according to parameter θ. Then, a feasibility problem can be written to find a θ consistent with the data:

Problem 2 (Parametric constraint recovery problem).
find θ
s.t. g(ki,θ)>0,kiϕ(ξsj*),j=1,,Ns (2a)
kiϕ(ξ¬sk),g(ki,θ)0,k=1,,N¬s (2b)

Constraint (2a) enforces that each safe constraint state lies outside 𝒜(θ) and constraint (2b) enforces that at least one constraint state on each unsafe trajectory lies inside 𝒜(θ). Denote as the feasible set of Problem 2. Further denote 𝒢¬s and 𝒢s as the set of constraint states which are learned guaranteed unsafe and safe, respectively; that is, a constraint state k𝒢¬s or k𝒢s if k is classified unsafe or safe for all θ: 𝒢¬sθ{k|g(k,θ)0} (3) 𝒢sθ{k|g(k,θ)>0} (4)

In Problem 2, it is possible to learn that a constraint state is guaranteed safe/unsafe even if it does not lie directly on a demonstration/unsafe trajectory. This is due to the parameterization: for the given set of safe and unsafe trajectories, there may be no feasible θ where k is classified unsafe/safe. It is precisely this extrapolation which will enable us to learn constraints in high-dimensional spaces. We now identify classes of parameterizations for which Problem 2 can be efficiently solved:

Problem 3 (Polytopic constraint recovery problem).
find θ,{bsi}i=1Ns,{b¬si}i=1N¬s
s.t. H(θ)ki>h(θ)-M(1-bsi),bsji{0,1}Nh,
 i=1Nhbsji1,kiϕ(ξsj*),i=1,,Tj,j=1,,Ns (5a)
H(θ)kih(θ)+M(1-b¬ski)𝟏Nh,b¬ski{0,1},
 i=1Tkb¬ski1,kiϕ(ξ¬sk),k=1,,N¬s (5b)

Linear case: g(k,θ) is defined by a Boolean conjunction of linear inequalities, i.e. 𝒜(θ) can be defined as the union and intersection of half-spaces. For this case, mixed-integer programming can be employed. If g(k,θ)0 is a single polytope, i.e. g(k,θ)0H(θ)kh(θ), where H(θ) and h(θ) are affine in θ, we can solve Problem 3, a mixed integer feasibility problem, to find a feasible θ. In Problem 3, M is a large positive number and 𝟏Nh is a vector of ones of length Nh, where Nh is the number of rows in H(θ). Constraints (5a) and (5b) use the big-M formulation [bigM] to enforce that each safe constraint state lies outside 𝒜(θ) and that at least one constraint state on each unsafe trajectory lies inside 𝒜(θ). Similar problems can be solved when the safe/unsafe set can be described by unions of polytopes. As an alternative to integer programming, satisfiability modulo theories (SMT) solvers [smt] can also be used to solve Problem 2 if g(k,θ) is defined by a Boolean conjunction of linear inequalities.

Convex case: g(k,θ) is defined by a Boolean conjunction of convex inequalities, i.e. 𝒜(θ) can be described as the union and intersection of convex sets. For this case, satisfiability modulo convex optimization (SMC) [smc] can be employed to find a feasible θ.

We close this subsection with some remarks on implementation and extensions to Problems 2 and 3.

  • For suboptimal demonstrations / imperfect lower-cost trajectory sampling, Problem 3 can become infeasible. To address this, slack variables can be introduced: replace constraint i=1Tkb¬ski1 with i=1Tkb¬skivk,vk{0,1} and change the feasibility problem to minimization of k=1N¬s(1-vk); this finds a θ that is consistent with as many unsafe trajectories as possible.

  • In addition to recovering sets of guaranteed learned unsafe and safe constraint states, a probability distribution over possibly unsafe constraint states can be estimated by sampling unsafe sets 𝒜(θ) from the feasible set of Problem 2 using hit-and-run sampling, starting from a feasible θ.

4.3 Extracting guaranteed safe and unsafe states

One can check if a constraint state k𝒢s or k𝒢¬s by adding a constraint g(k,θ)0 or g(k,θ)>0 to Problem 2 and checking feasibility of the resulting program; if the program is infeasible, k𝒢s or k𝒢¬s. In other words, solving this modified integer program can be seen as querying an oracle about the safety of a constraint state k. The oracle can then return that k is guaranteed safe (program infeasible after forcing k to be unsafe), guaranteed unsafe (program infeasible after forcing k to be safe), or unsure (program remains feasible despite forcing k to be safe or unsafe).

Unlike the gridded formulation in [extended_version], Problem 2 works in the continuous constraint space. Thus, it is not possible to exhaustively check if each k𝒢¬s or k𝒢s. To address this, the neighborhood of some constraint state kquery can be checked for membership in 𝒢¬s by solving the following problem:

Problem 4 (Volume extraction).
minθ,εεs.t.g(ki,θ)>0,kiϕ(ξsj*),j=1,,Nskiϕ(ξ¬sk),g(ki,θ)0,k=1,,N¬sk𝑛𝑒𝑎𝑟{k𝑛𝑒𝑎𝑟k𝑛𝑒𝑎𝑟-k𝑞𝑢𝑒𝑟𝑦ε},g(k𝑛𝑒𝑎𝑟,θ)>0

In words, Problem 4 finds the smallest ε-hypercube centered at kquery containing a k𝒢¬s; thus, any hypercube of size ε^<ε is contained within 𝒢¬s: {kk-kqueryϵ^}𝒢¬s. We can write a similar problem to check the neighborhood of kquery for membership in 𝒢s. For some common parameterizations (axis-aligned hyper-rectangles, convex sets), there are even more efficient methods for recovering subsets of 𝒢s and 𝒢¬s, which are described in Appendix B. Volumes of safe/unsafe space can thus be produced by repeatedly solving Problem 4 for different kquery, and these volumes can be passed to a planner to generate new trajectories that are guaranteed safe.

4.4 Unknown parameterizations

For many realistic applications, we do not have access to a known parameterization which can represent the unsafe set. Despite this, complex unsafe/safe sets can often be approximated as the union of many simple unsafe/safe sets. Along this line of thought, we present a method for incrementally growing a parameterization based on the complexity of the demonstrations and unsafe trajectories.

Suppose that the true parameterization g(k,θ) of the unsafe set 𝒜(θ)={kg(k,θ)0} is unknown but can be exactly or approximately expressed as the union of N* simple sets 𝒜(θ)i=1N*{kgs(k,θi)0}i=1N*𝒜(θi), where each simple set 𝒜(θi) has a known parameterization gs(,) and N*, the minimum number of simple sets needed to reconstruct 𝒜, is unknown.

A lower bound on N*, N¯, can be estimated by incrementally adding simple sets until Problem 2 becomes feasible. However, for N¯<N*, the extracted 𝒢s and 𝒢¬s are not guaranteed to be conservative estimates of 𝒮 and 𝒜 (Theorem 5.3), and 𝒢s and 𝒢¬s are only guaranteed to be conservative if N^N*, where N^ is the chosen number of simple sets (see Theorem 5.2). Unfortunately, inferring a guaranteed overestimation of N* only from data is not possible, as there can always be subsets of the constraint which are not activated by the given demonstrations. Two facts mitigate this:

  • If an upper bound on the number of simple sets needed to describe 𝒜(θ), N¯looseN*, is known (where this bound can be trivially loose), 𝒢s𝒮 and 𝒢¬s𝒜 by using N¯loose simple sets in solving Problem 2. Hence, by using N¯loose, 𝒢s and 𝒢¬s can be made guaranteed conservative (see Theorem 5.2), at the cost of the resulting 𝒢s and 𝒢¬s being potentially small.

  • As the demonstrations begin to cover the space, N¯N*. Hence, by using N¯ simple sets, 𝒢s and 𝒢¬s are asymptotically conservative.

In our experiments, we choose our simple sets as axis-aligned hyper-rectangles in 𝒞, which is motivated by: 1) any open set in 𝒞 can be approximated as a countable/finite union of open axis-aligned hyper-rectangles [tao]; 2) unions of hyper-rectangles are easily representable in Problem 3.

5 Theoretical Analysis

In this section, we present theoretical analysis on our parametric constraint learning algorithm. In particular, we analyze the conditions under which our algorithm is guaranteed to learn a conservative estimate of the safe and unsafe sets. For space, the proofs and additional results on conservativeness (Section C.2) and the learnability of a constraint (Section C.1) are presented in the appendix. We develop the theory for 𝒞=𝒳 for legibility, but the results can be easily extended to general 𝒞.

Theorem 5.1 (Conservativeness: Known parameterization).

Suppose the parameterization g(x,θ) is known exactly. Then, for a discrete-time system, extracting G¬s and Gs (as defined in (3) and (4), respectively) from the feasible set of Problem 2 returns G¬sA and GsS. Further, if the known parameterization is H(θ)xih(θ) and M in Problem 3 is chosen to be greater than

max(maxxiξsmaxθmaxj(H(θ)xi-h(θ))j,maxxiξ¬smaxθmaxj(H(θ)xi-h(θ))j),

then extracting G¬s and Gs from the feasible set of Problem 3 recovers G¬sA and GsS.

We also present conservativeness results for continuous-time dynamics in Corollary C.2.

Now, let’s consider the case where the true parameterization is not known and we use the incremental method described in Section 4.4, where gs(x,θ) is the simple parameterization. We consider the over-parameterized case (Theorem 5.2) and the under-parameterized case (Theorem 5.3). We analyze the case where the true, under-, and over-parameterization are defined respectively as:

g(x,θ)0i=1N*(gs(x,θi)0) (6)
g(x,θ)0i=1N¯(gs(x,θi)0),N¯<N* (7)

g(x,θ)0i=1N¯(gs(x,θi)0),N¯>N*. (8)

Theorem 5.2 (Conservativeness: Over-parameterization).

Suppose the true parameterization and over-parameterization are defined as in (6) and (8). Then, G¬sA and GsS.

Theorem 5.3 (Conservativeness: Under-parameterization).

Suppose the true parameterization and under-parameterization are defined as in (6) and (7). Furthermore, assume that we incrementally grow the parameterization as described in Section 4.4. Then, the following are true:

  1. 1.

    𝒢¬s and 𝒢s are not guaranteed to be contained in 𝒜 (unsafe set) and 𝒮 (safe set), respectively.

  2. 2.

    Each recovered simple unsafe set 𝒜(θi), i=1,,N¯, for any θ1,,θN¯, touches the true unsafe set (there are no spurious simple unsafe sets): for i=1,,N¯, for θ1,,θN¯, 𝒜(θi)𝒜 (N¯ is as defined in Section 4.4).

6 Results

We evaluate our method, showing that our method can be applied to constraints with unknown parameterizations (Section 6.1), high-dimensional constraints defined for high-dimensional systems (Section 6.2), and settings where the dynamics are not known in closed form (Section 6.3). We also compare our performance with a neural network (NN) baseline11 1 In all experiments, 1) the NN is trained with the safe/unsafe trajectories and predicts at test time if a queried constraint state is safe/unsafe; 2) error bars are generated by initializing the NN with 10 different random seeds and evaluating accuracy after training. The architectures/training details are presented in Appendix E.. We further compare with the grid-based method [extended_version] on the 2D examples. For space, experimental details are provided in Appendix E.

Figure 6.1: Unknown parameterization. Col. 1: Red: 𝒢¬s; Green: 𝒢s. Demonstrations are overlaid. Col. 2: Coverage of 𝒜 and 𝒮 with [extended_version]. In this (and all later examples), the demonstrations are color-coded with x-axis. Col. 3: Coverage of 𝒜 and 𝒮 with our method. Col. 4: Classification accuracy (dotted: average NN accuracy, shaded: range of NN accuracies over 10 random seeds). Col. 5: Recovered constraint with multi-polytope variant of Problem 3.

6.1 Unknown parameterization

U-shape: We first present a kinematic 2D example where a U-shape 𝒜 is to be learned, but the number of simple unsafe sets needed to represent 𝒜 (three) is unknown. In Row 1, Column 1 of Fig. 6.1, we outline 𝒜 in black and overlay 𝒢¬s, 𝒢s, and the six provided demonstrations, synthetically generated via trajectory optimization. We note that due to the chosen control constraints and U-shape, there are parts of 𝒜 (a subset of the white region in Fig. 6.1, Row 1, Column 1) which cannot be implied unsafe by sampled unsafe trajectories and the parameterization (see Theorem C.1). As a result, 𝒢¬s may not fully cover 𝒜, even with more demonstrations (Fig. 6.1, Row 1, Column 3). Note that the decrease in coverage22 2 Coverage is measured as the intersection over union (IoU) of the relevant sets (see legends for exact formula). at the third demonstration is due to a increase from a two-box parameterization to a three-box parameterization. Likewise, the accuracy33 3 In all experiments, computed accuracies are: IP (safe) = Vol(𝒢s𝒮)/Vol(𝒢s), IP (unsafe) = Vol(𝒢¬s𝒜)/Vol(𝒢¬s), NN (safe) = (i=1q𝐈(xi𝒮)(NN classified xi as safe))/i=1q𝐈xi𝒮, NN (unsafe) = (i=1q𝐈(xi𝒜)(NN classified xi as unsafe)/i=1q𝐈xi𝒜, where x1,,xq are query states sampled from 𝒢¬s𝒢s and 𝐈() is the indicator function. Note that NN accuracy is computed only on (𝒢s𝒢¬s)𝒞. decreases at the second demonstration due to over-approximation of 𝒜 with two boxes (Fig. 6.1, Row 1, Column 4), but this over-approximation vanishes when switching to the three-box parameterization (which is exact; hence 𝒢s and 𝒢¬s are guaranteed conservative, c.f. Theorem 5.1). The grid-based method in [extended_version] always has perfect accuracy, since it does not extrapolate beyond the observed trajectories. However, as a result of that, it also yields low coverage (Fig. 6.1, Row 1, Column 2). The NN baseline achieves lower accuracy for the unsafe set as it misclassifies some corners of the U. Recovering a feasible θ using a multi-box variant of Problem 3 recovers 𝒜 exactly (Fig. 6.1, Row 1, Column 5). Finally, we note that in this (and future) examples, demonstrations were specifically chosen to be informative about the constraint. We present a version of this example in Appendix D with random demonstrations and show that the constraint is still learned (albeit needing more demonstrations).

Infinite boxes: To show that our method can still learn a constraint that cannot be easily expressed using a chosen parameterization, we limit our parameterization to an unknown number of axis-aligned boxes and attempt to learn a diagonal “I” unsafe set (see Fig. 6.1, Row 2). This is a particularly difficult example, since an infinite number of axis-aligned boxes will be needed to recover 𝒜 exactly. However, for finite data, only a finite number of boxes will be needed; in particular, for 1, 2, 3, and 4 demonstrations (which are synthetically generated assuming kinematic system constraints), 3, 5, 6, and 6 boxes are required to generate a parameterization consistent with the data (see Fig. 6.1, Row 2, Column 1). Also overlaid in Fig. 6.1, Row 2, Column 1 are 𝒢¬s and 𝒢s, which are approximated by solving Problem 4 for randomly sampled kcenter. Compared to the gridded formulation in [extended_version] (see Fig. 6.1, Row 2, Column 3), 𝒢s and 𝒢¬s cover 𝒮 and 𝒜 far better due to the parameterization enabling the IP to extrapolate more from the demonstrations. Furthermore, we note that while the gridded case has perfect accuracy for the safe set, it does not for the unsafe set, due to grid alignment [extended_version]. Overall, the multi-box variant of Problem 3 recovers 𝒜 well (Fig. 6.1, Row 2, Column 5), and the remaining gap can be improved with more data. Last, we note that the NN baseline reaches comparable accuracies here (Fig. 6.1, Row 2, Column 4), since our method suffers from a few disadvantages for this particular example. First, attempting to represent the “I” with a finite number of boxes introduces a modeling bias that the NN does not have. Second, since the system is kinematic and the constraint is low-dimensional, many unsafe trajectories can be sampled, providing good coverage of the unsafe set. We show later that for higher dimensional constraints/systems with highly constrained dynamics, it becomes difficult to gather enough data for the NN to perform well.

6.2 High-dimensional examples

6D pose constraint for a 7-DOF robot arm: In this example, we learn a 6D hyper-rectangular pose constraint for the end effector of a 7-DOF Kuka iiwa arm. One such setting is when the robot is to bring a cup to a human while ensuring its contents do not spill (angle constraint) and proxemics constraints (i.e. the end effector never gets too close to the human) are satisfied (position constraint). We examine this problem for the cases of optimal and suboptimal demonstrations.

Demonstration setup: The end effector orientation (parametrized in Euler angles) and position are constrained to satisfy (α,β,γ)[α¯,α¯]×[β¯,β¯]×[γ¯,γ¯] and (x,y,z)[x¯,x¯]×[y¯,y¯]×[z¯,z¯] (see Fig. 6.2, Column 1). For the optimal case, we synthetically generate seven demonstrations minimizing joint-space trajectory length. For the suboptimal case, five suboptimal continuous-time demonstrations approximately optimizing joint-space trajectory length are recorded in a virtual reality environment, where a human demonstrator moves the arm from desired start to goal end effector configurations using an HTC Vive (see Fig. E.1). The demonstrations are time-discretized for lower-cost trajectory sampling [extended_version]. In both cases, the constraint is recovered with Problem 3, where H(θ)=[I,-I] and h(θ)=θ=[x¯,y¯,z¯,α¯,β¯,γ¯,x¯,y¯,z¯,α¯,β¯,γ¯]. For the suboptimal case, slack variables are added to ensure feasibility of Problem 3, and for a suboptimal demonstration of cost c^, we only use trajectories of cost less than 0.9c^ as unsafe trajectories.

Figure 6.2: Rows 1:2: 7-DOF arm, optimal demonstrations Col. 1: Experimental setup. Gray boxes are projections of 𝒜. Projections of demonstrations in position/angle space are overlaid. Col. 2: Top: Comparing safe/unsafe set coverage as a function of demonstrations. Bottom: Prediction accuracy. Cols. 3-4: projections of 𝒢^¬s using all demonstrations. For the optimal case, the red boxes over-approximate the blue boxes, as the complement of 𝒢^¬s (not 𝒢^¬s itself) is plotted. Col. 5: projections of 𝒢s using all demonstrations. Rows 3:4: Same for 7-DOF arm, suboptimal demonstrations.

Results: The coverage plots (Fig. 6.2, Rows 1 and 3, Col. 2) show that as the number of demonstrations increases, 𝒢s/𝒢¬s approach the true safe/unsafe sets 𝒮/𝒜 44 4 For the unsafe sets, the IoUs are computed between 𝒢¬sc and 𝒜c, as in high dimensions, the IoU changes more smoothly for the complements than the IoU between 𝒢¬s and 𝒜, so we plot the the former for visual clarity.. For the suboptimal case, the low IoU values for lower numbers of demonstrations is due to overapproximation of the unsafe set in the α component (arising from continuous-time discretization and imperfect knowledge of the suboptimality bound); the fifth demonstration, where α takes values near -π,π greatly reduces this overapproximation. The accuracy plots (Fig. 6.2, Rows 2 and 4, Col. 2) present results consistent with the theory: for the optimal case, all constraint states in 𝒢s and 𝒢¬s are truly safe and unsafe (Theorem 5.1), and the small over-approximation for the suboptimal case is consistent with the continuous-time conservativeness (Theorem C.2). Note that the NN accuracy is lower and can oscillate with demonstrations, since it finds just a single constraint which is approximately consistent with the data, while our method classifies safety by consulting all possible constraints which are exactly consistent with the data, thus performing more consistently. The NN performs better on the suboptimal case than it does on the optimal case, as more unsafe trajectories are sampled due to the suboptimality, improving coverage of the unsafe set. The projections of 𝒢^¬sc (Fig. 6.2, Cols. 3-4, in red), where 𝒢^¬s𝒢¬s is obtained using the method in Appendix B, are compared to the safe set (blue outline), showing that the two match nearly exactly (though the gap for the suboptimal case is larger), and the gap can be likely reduced with more demonstrations. The projections of 𝒢s (Fig. 6.2, Col. 5) match exactly with 𝒜 for the optimal case (true safe set is outlined in blue) and match closely for the suboptimal case. Note that 𝒢s𝒮, as is the case for all axis-aligned box parameterizations.

Figure 6.3: Left: Known unsafe set in (x,y,z) (red); (x,y,z) components of demonstrations are overlaid. Right: Unknown unsafe set in (α˙,β˙,γ˙) (gray); (α˙,β˙,γ˙) components of demonstrations are overlaid.

3D constraint for 12D quadrotor model: We learn a 3D box angular velocity constraint for a quadrotor with discrete-time 12D dynamics (see Appendix E for details). In this scenario, the quadrotor must avoid an a priori known unsafe set in position space while also ensuring that angular velocities are below a threshold: (α˙,β˙,γ˙)[α¯˙,α˙¯]×[β¯˙,β˙¯]×[γ¯˙,γ˙¯]. The (α˙,β˙,γ˙) safe set is to be inferred from two demonstrations (see Fig. 6.3). The constraint is recovered with Problem 3, where H(θ)=[I,-I] and h(θ)=θ=[α˙¯,β˙¯,γ˙¯,α¯˙,β¯˙,γ¯˙]. Fig. 6.4 shows that with more demonstrations, 𝒢s approaches the true safe set 𝒮 and 𝒢¬s approaches the true unsafe set 𝒜, respectively. Consistent with Theorem 5.1, our method has perfect accuracy in 𝒢¬s and 𝒢s. Here, the NN struggles more compared to the arm examples since due to the more constrained dynamics, fewer unsafe trajectories can be sampled, and a parameterization needs to be leveraged in order to say more about the unsafe set. The remaining columns of Fig. 6.4 show that we recover 𝒢¬s and 𝒢s exactly (the true safe set is outlined in blue).

Figure 6.4: Constraint recovery for a 12D quadrotor. Col. 1: Coverage of 𝒜 and 𝒮. Col. 2: Classification error between 𝒢s/𝒮 and 𝒢¬s/𝒜. Cols. 3-4: 𝒢^¬s using all demonstrations. Col. 5: 𝒢s using all demonstrations.

6.3 Planar pushing example

Figure 6.5: Constraint recovery without closed-form dynamics. Cols. 1-2: Setup (unsafe set in red) and demonstrations (unsafe set in gray). Cols. 3-4: Coverage of 𝒜 and 𝒮; classification accuracy. Col. 5: 𝒢¬s / 𝒢s using all demonstrations.

In this section, using the FetchPush-v1 environment in OpenAI Gym [openai], we aim to learn a 2D box unsafe set on the center-of-mass (CoM) of a block pushed by the Fetch arm (see Fig. 6.5) using two demonstrations. Here, the dynamics of the block CoM are not known in closed form, but rollouts can still be sampled using the simulator. Since the block CoM is highly underactuated, it is not possible to sample short sub-trajectories. Thus, without leveraging a parameterization, the constraint recovery problem is very ill-posed. Furthermore, while our method can explicitly consider the unsafeness in longer unsafe trajectories (at least one state is unsafe), the NN struggles with this example as it fails to accurately model that fact. Overall, Fig. 6.5 presents that 𝒢¬s/𝒢s match up well with 𝒜/𝒮, and our classification accuracy for safeness/unsafeness is perfect across demonstrations.

7 Discussion and Conclusion

In this paper, we present a method capable of learning parametric constraints in high-dimensional spaces with and without known parameterizations. We also present a method for extracting volumes of guaranteed safe and guaranteed unsafe states, information which can be directly used in a planner to enforce safety constraints. We analyze our algorithm, showing that these recovered guaranteed safe/unsafe states are truly safe/unsafe under mild assumptions. We evaluate the method by learning a variety of constraints defined in high-dimensional spaces for systems with high-dimensional dynamics. One shortcoming of our work is scalability with the amount of data, due to the number of integer variables growing linearly with the number of safe/unsafe trajectories. As a result, learning constraints without extensive sampling of unsafe trajectories is a direction of future work.

Acknowledgments

This work was supported in part by a National Defense Science and Engineering Graduate (NDSEG) Fellowship, Office of Naval Research (ONR) grants N00014-18-1-2501 and N00014-17-1-2050, and National Science Foundation (NSF) grants ECCS-1553873 and IIS-1750489.

References

Appendix A Detailed algorithm block

\SetAlgoLined\SetKwInOutInputInput \SetKwInOutOutputOutput \Outputθ (a feasible unsafe/safe set describing the safe/unsafe trajectories),
𝒢s (the set of guaranteed safe constraint states),
𝒢¬s (the set of guaranteed unsafe constraint states) \Inputξs={ξ1*,,ξNs*}, cΠ(), known constraints, {kqueryq}q=1Q ξ¬s{}\[email protected]
\tccSample unsafe trajectories ξ¬s \Fori = 1:Ns ξ¬sξ¬s𝖧𝗂𝗍𝖠𝗇𝖽𝖱𝗎𝗇(ξi*)\[email protected]
\tccConstraint recovery θ Problem Y(ξs,ξ¬s)\[email protected]
\tccY = 2 if general parameterization \tccY = 3 if polytope parameterization 𝒢s,𝒢¬s{},{}\[email protected]
\tccGuaranteed safe/unsafe recovery \uIfgeneral parameterization \Forq=1,,Q \tccExtract safe/unsafe volume around query point kqueryq 𝒢s(kqueryq),𝒢¬s(kqueryq) Problem 4(kqueryq)\[email protected]
𝒢s𝒢s𝒢s(kqueryq)\[email protected]
𝒢¬s𝒢¬s𝒢¬s(kqueryq)\[email protected]
\uElseIfaxis-aligned hyper-rectangle parameterization 𝒢s,𝒢^¬s Procedure in Appendix B.1\[email protected]
\uElseIfconvex parameterization 𝒢s,𝒢^¬s Procedure in Appendix B.2\[email protected]
\algorithmcfname 1 Overall method

Appendix B Extraction of 𝒢s and 𝒢¬s

In this section, we discuss specific ways of extracting sets of guaranteed safe/unsafe states for axis-aligned hyper-rectangles (this method is used for all numerical examples in Section 6.2 and Section 6.3) and for convex parameterizations.

B.1 Axis-aligned hyper-rectangle parameterization

In this parameterization, 𝒞n, θ=[k¯1,k¯1,,k¯n,k¯n], and g(k,θ)0H(θ)kh(θ), where H(θ)k=[In×n,-In×n] and h(θ)=[k¯1,,k¯n,k¯1,,k¯n]. Here, k¯i and k¯i are the lower and upper bounds of the hyper-rectangle for coordinate i.

As the set of axis-aligned hyper-rectangles is closed under intersection, 𝒢¬s is also an axis-aligned hyper-rectangle, the axis-aligned bounding box of any two constraint states k1,k2𝒢¬s is also contained in 𝒢¬s. This also implies that 𝒢¬s can be fully described by finding the top and bottom corners [k¯1,,k¯n] and [k¯1,,k¯n]. Suppose we start with a known k𝒢¬s. Then, finding [k¯1,,k¯n] amounts to performing a binary search for each of the n dimensions, and the same holds for finding [k¯1,,k¯n].

Recovering 𝒢s is not as straightforward, as the complement of axis-aligned boxes is not closed under intersection. While we can still solve Problem 4 to recover 𝒢s, an inner approximation of 𝒢s can be more efficiently obtained: starting at a constraint state k𝒢¬s, 2n line searches can be performed to find the two points of transition to 𝒢¬s in each constraint coordinate. Denote as 𝒢^s the complement of the axis-aligned bounding box of these 2n points; 𝒢^s is an inner approximation of 𝒢s, as 𝒢s=(θ{x|g(x,θ)0})cAABB(θ{x|g(x,θ)0})c, where AABB() denotes the axis-aligned bounding box of a set of points. For example, consider the scenario in Fig. B.1 where there are only two feasible parameters, θ1 and θ2. Here, 𝒢s is (𝒜(θ1)𝒜(θ2))c and 𝒢^s under-approximates the safe set (𝒢s is in general not representable as the complement of an axis-aligned box).

Figure B.1: Comparison of the true 𝒢s (left, in green) and the extracted inner approximation 𝒢^s (right, in green).

B.2 Convex parameterization

In this parameterization, for fixed θ, {k|g(k,θ)0} is convex.

While apart from solving Problem 4 it is hard to recover 𝒢¬s exactly, an inner approximation of 𝒢¬s can be extracted more efficiently by taking the convex hull of any k1,k2,𝒢¬s, as the convex hull is the minimal convex set containing k1,k2,.

The same approaches apply for recovering 𝒢s when it is instead the safe set which is an axis-aligned hyper-rectangle or a convex set.

Appendix C Theoretical Analysis (Expanded)

In this section, we present theoretical analysis on our parametric constraint learning algorithm. In particular, we analyze the limits of what constraint states can be learned guaranteed unsafe/safe (Section C.1) as well as the conditions under which our algorithm is guaranteed to learn a conservative estimate of the safe and unsafe sets (Section C.2). For ease of reading, we repeat the theorem statements from the main body (the corresponding theorem numbers from the main body are listed in the theorem statement). We develop the theory for 𝒞=𝒳 for legibility, but the results can be easily extended to general 𝒞.

C.1 Learnability

In this section, we develop results for learnability of the unsafe set in the parametric case. We begin with the following notation:

Definition C.1 (Signed distance).

Signed distance from point pRm to set SRm, 𝗌𝖽(p,S)=-infySp-y if pS; infySp-y if pSc.

Definition C.2 (Δx-shell).

For a discrete time system satisfying xt+1-xtΔx for all t, denote the Δx shell of the unsafe set as: AΔx{xA|-Δx𝗌𝖽(x,A)0}.

Definition C.3 (Implied unsafe set).

For some set BΘ, denote I(B)θB{x|g(x,θ)0} as the set of states that are implied unsafe by restricting the parameter set to B. In words, I(B) is the set of states for which all θB mark as unsafe.

Definition C.4 (Feasible set ).

Denote as F the feasible set of Problem 2 with Ns demonstrations and N¬s unsafe trajectories sampled using the hit-and-run method presented in Section 4.1:

={θ| i{1,,Ns},xξi*,g(x,θ)>0,
j{1,,N¬s},xξj,g(x,θ)0}.
Definition C.5 (Learnability and learnable set 𝒢¬s*).

A state xA is learnable if there exists any set of Ns demonstrations and N¬s unsafe trajectories sampled using the hit-and-run method presented in Section 4.1, where Ns and N¬s may be infinite, such that xI(F). Accordingly, we define the learnable set of unsafe states G¬s* as the union of all learnable states. Note that by this definition, a state xsS is always learnable, since there always exists some safe demonstration passing through xs.

Lemma C.1.

Suppose BB^, for some other set B^. Then, I(B^)I(B).

Proof.

By definition,

I(^) =θ^{x|g(x,θ)0}
=θ((^)){x|g(x,θ)0}
θ{x|g(x,θ)0}
=I().

Lemma C.2.

Each unsafe trajectory ξj with start and goal states in the safe set contains at least one state in the Δx-shell AΔx: j{1,,N¬s},xξj,xAΔx.

Proof.

For each unsafe trajectory ξj with start and goal states in the safe set, there exists xξj,x𝒜. Further, if there exists xξj(𝒜𝒜Δx), then there also exists xξj𝒜Δx. For contradiction, suppose there exists a time t^{1,,Tj} for which ξj(t^)(𝒜𝒜Δx) and t{1,,Tj} for which ξj(t)𝒜Δx. But this implies t<t^,ξ(t)-ξ(t+1)>Δx or t>t^,ξ(t)-ξ(t-1)>Δx, i.e. to skip deeper than Δx into the unsafe set without first entering the Δx shell, the state must have changed by more than Δx in a single time-step. Contradiction. An analogous argument holds for the continuous-time case. ∎

The following result states that in discrete time, the learnable set of unsafe states 𝒢¬s* is contained by the set of states which must be implied unsafe by setting 𝒜Δx as unsafe. Furthermore, in continuous time, the same holds, except the 𝒜Δx is replaced by the boundary of the unsafe set, 𝒜.

Theorem C.1 (Discrete time learnability for parametric constraints).

For trajectories generated by discrete time systems, G¬sG¬s*I(FΔx), where

Δx={θ| i{1,,Ns},xξi*,g(x,θ)>0,x𝒜Δx,g(x,θ)0}.
Proof.

Recall that 𝒢¬sθ{x|g(x,θ)0}, where as previously defined, is the feasible set of Problem 2. We can then show that Δx, since enforcing that g(x,θ)0 for all x𝒜Δx implies that there exists xξj, for all j{1,,N¬s} such that g(x,θ)0, via Lemma C.2. Then, via Lemma C.1, 𝒢¬s=I()I(Δx). As this holds for any arbitrary set of trajectories, 𝒢¬s*I(Δx) as well, and 𝒢¬s𝒢¬s*. ∎

Corollary C.1 (Continuous-time learnability for parametric constraints).

For trajectories generated by continuous time systems, G¬sG¬s*I(FA), where

𝒜={θ| xξi*,i{1,,Ns},g(x,θ)>0,x𝒜,g(x,θ)0}.
Proof.

Since going from discrete time to continuous time implies Δx0, 𝒜Δx𝒜. Then, the logic from the proof of Theorem C.1 can be similarly applied to show the result. ∎

C.2 Conservativeness: Parametric

We write conditions for conservative recovery of the unsafe set and safe set when solving Problems 2 and 3 for discrete time and continuous time systems.

Theorem C.2 (Conservativeness: Known parameterization (Theorem 5.1 in the main body) ).

Suppose the parameterization g(x,θ) is known exactly. Then, for a discrete-time system, extracting G¬s and Gs (as defined in (3) and (4), respectively) from the feasible set of Problem 2 returns G¬sA and GsS. Further, if the known parameterization is H(θ)xih(θ) and M in Problem 3 is chosen to be greater than

max(maxxiξsmaxθmaxj(H(θ)xi-h(θ))j,maxxiξ¬smaxθmaxj(H(θ)xi-h(θ))j),

then extracting G¬s and Gs from the feasible set of Problem 3 recovers G¬sA and GsS.

Proof.

We first prove that 𝒢¬s𝒜. Consider first the case of Problem 2, or equivalently the case of Problem 3 where M= (in this case, Problem 3 exactly enforces that at least one state in each unsafe trajectory is unsafe and all states on demonstrations are safe).

Suppose for contradiction that there exists some x𝒢¬s,x𝒜. By definition of 𝒢¬s, g(x,θ)0, for all θ, where is the feasible set of parameters θ in Problem 2. However, as x𝒜, but for all θ,g(x,θ)0 we know that θ𝒜, where θ𝒜 is the parameter associated with the true unsafe set 𝒜. However, will always contain θ𝒜, since:

  • θ𝒜 satisfies g(x,θ𝒜)>0 for all x in safe demonstrations, since all demonstrations are safe with respect to the true θ𝒜.

  • For each trajectory ξ¬s sampled using the hit-and-run procedure in Section 4.1, there exists xξ¬s such that g(x,θ𝒜)0.

We come to a contradiction, and hence for Problem 2 and for Problem 3 where M=, 𝒢¬s𝒜.

Now, we consider the conditions on M such that choosing Mconst or M= causes no changes in the solution of Problem 3. M must be chosen such that 1) H(θ)xi-h(θ)>-M𝟏H(θ)xi-h(θ)>-𝟏, for all safe states xiξs, and 2) H(θ)xi-h(θ)M𝟏H(θ)xi-h(θ)𝟏 for all states xi on unsafe trajectories ξ¬s. Condition 1 is met if -M<minxiξsminθminj(H(θ)xi-h(θ))j, where vj denotes the j-th element of vector v; denote as M1 an M which satisfies this inequality. Condition 2 is met if Mmaxxiξ¬smaxθmaxj(H(θ)xi-h(θ))j; denote as M2 an M which satisfies this inequality. Then, M should be chosen to satisfy M>max(M1,M2).

The proof that 𝒢s𝒮 is analogous. If there exists x𝒢s,x𝒮, g(x,θ)>0, for all θ, then θ𝒜. We follow the same reasoning from before to show that θ𝒜 for M=. Now, provided the condition on M holds, we reach a contradiction. ∎

Remark.

A simple corollary from Theorem C.2 is that by solving Problem 4 repeatedly for different query centers xquery for a discrete-time system and unioning over the resulting volumes will also provide conservative estimates of 𝒢s and 𝒢¬s. Further, if the assumption on M holds, then the volume extraction analogue of Problem 3 will also return conservative estimates of 𝒢s and 𝒢¬s.

As discussed in [extended_version], with continuous-time system dynamics, assigning unsafeness in lower-cost trajectories difficult since there are an infinite number of states on the continuous trajectory. To ameliorate this, as in [extended_version], we time-discretize the sampled lower-cost trajectories and feed the resulting discrete-time trajectories into Problems 2 and 3. This can potentially cause a mild overapproximation of the unsafe set, which we quantify after introducing some notation.

Definition C.6 (Normal vectors).

Denote the outward-pointing normal vector at a point pA as n^(p). Furthermore, at non-differentiable points on A, n^(p) is replaced by the set of normal vectors for the sub-gradient of the Lipschitz function describing A at that point ([thickness]).

Definition C.7 (γ-offset padding).

Define the γ-offset padding Aγ as: Aγ={xX|x=y+dn^(y),d[0,γ],yA}.

Definition C.8 (γ-padded set).

We define the γ-padded set of the unsafe set A, A(γ), as the union of the γ-offset padding and A: A(γ)AγA.

Definition C.9 (Maximum distance on trajectories).

Denote Dξ([a,b])supt1[a,b],t2[t1,b]ξ(t1)-ξ(t2)2, for some trajectory ξ. Denote D*maxi{1,,N¬s}Dξi*([ai,bi]). In words, Dξ([a,b]) is the maximum distance between any two points on trajectory ξ from time a to time b, and D* takes the maximum distance over all N¬s trajectories.

Lemma C.3 (Maximum distance).

Consider a continuous time trajectory ξ:[0,T]X. Suppose it is known that in some time interval [a,b],ab,a,b[0,T], ξ is unsafe; denote this sub-segment as ξ([a,b]). Consider any t[a,b]. Then, the signed distance from ξ(t) to the unsafe set, 𝗌𝖽(ξ(t),A), is bounded by Dξ([a,b])supt1[a,b],t2[t1,b]ξ(t1)-ξ(t2)2.

Proof.

Since there exists t~[a,b] such that ξ(t~)𝒜, supt[a,b]𝗌𝖽(ξ(t),𝒜)=supt[a,b]𝗌𝖽(ξ(t),ξ(t~))supt1[a,b],t2[t1,b]ξ(t1)-ξ(t2)2. ∎

Corollary C.2.

For a continuous-time system where demonstrations and sampled unsafe trajectories are time-discretized, if M is chosen as in Theorem C.2, GsS, where S is the safe set, and G¬sA(D*), where D* is as defined in Definition C.9.

Proof.

The reasoning for 𝒢s𝒮 follows from the proof of 𝒢¬s𝒜 in the proof of Theorem C.2.

Now we prove 𝒢¬s𝒜(D*). Suppose in this case, there exists a state x=ξj(ti)𝒜 which is truly safe but lies on a sampled unsafe trajectory ξj([aj,bj]), and suppose that {t1,,tN} is chosen such that for all k{1,,N}{i}, ξj(tk) belongs to a known safe cell. Then, we may incorrectly learn that ξj(ti) is unsafe, as we force at least one point in the sampled trajectory to be unsafe. Via Lemma C.3, we know that ξj(ti) is at most Dξj([aj,bj]) signed distance away from 𝒜. Hence, for this trajectory, any learned guaranteed unsafe state must be contained in the Dξj([aj,bj])-padded unsafe set. For this to hold for all unsafe trajectories sampled with the hit-and-run procedure presented in Section 4.1, we must pad the unsafe set by D*. Hence, under this assumption, the algorithm returns a conservative estimate of the D*-padded unsafe set. ∎

Let’s consider the case where the true parameterization is not known and we use the method described in Section 4.4, where gs(x,θ) is the simple parameterization. We consider the under-parameterized case (Theorem 5.3) and the over-parameterized case (Theorem 5.2). In particular, we analyze the case where the true parameterization, the under-parameterization, and the over-parameterization are defined respectively as:

g(x,θ)0i=1N*(gs(x,θi)0) (9)
g(x,θ)0i=1N¯(gs(x,θi)0),N¯<N* (10)

g(x,θ)0i=1N¯(gs(x,θi)0),N¯>N*. (11)

Theorem C.3 (Conservativeness: Over-parameterization (Theorem 5.2 in the main body) ).

Suppose the true parameterization and over-parameterization are defined as in (9) and (11). Then, G¬sA and GsS.

Proof.

Note that (9) is equivalent to (i=1N¯(gs(x,θi)0)), where θN*+1,,θN¯ are constrained to satisfy {xgs(x,θi)0}=,i=N*+1,,N¯. Thus, the true θ is equivalent to adding additional constraints on a loosened parameterization (the over-parameterization). Let ^ be the feasible set of Problem 2 with θ loosened as above, i.e. =^{θ{xgs(x,θi)0}=,i=N*+1,,N¯}. Via Lemma C.1, ^; thus, I¬s(^)I¬s()𝒜, where the last set containment follows from Theorem 5.1. Vice versa, Is(^)Is()𝒮, where again the last set containment follows from Theorem 5.1. ∎

Theorem C.4 (Conservativeness: Under-parameterization (Theorem 5.3 in the main body) ).

Suppose the true parameterization and under-parameterization are defined as in (9) and (10). Furthermore, assume that we incrementally grow the parameterization as described in Section 4.4. Then, the following are true:

  1. 1.

    𝒢¬s and 𝒢s are not guaranteed to be contained in 𝒜 (unsafe set) and 𝒮 (safe set), respectively.

  2. 2.

    Each recovered simple unsafe set 𝒜(θi), i=1,,N¯, for any θ1,,θN¯, touches the true unsafe set (there are no spurious simple unsafe sets): for i=1,,N¯, for θ1,,θN¯, 𝒜(θi)𝒜 (N¯ is as defined in Section 4.4).

Proof.
  1. 1.

    We first formally prove the statement with a counterexample and then follow up with logic related to the proof of Theorem C.3.

    Consider the example in Fig. C.1, where the parameterization is chosen as a single axis-aligned box [I2×2,-I2×2]xθ but 𝒜 is only representable with at least two boxes. Suppose demonstrations are provided which imply that (al,bl) and (au,bu) are unsafe; then AABB({(al,bl),(au,bu)})𝒜 is implied unsafe.

    Figure C.1: Counterexample used in the proof of the first statement in Theorem C.4.

    Note that (10) is equivalent to (i=1N*(gs(x,θi)0)), where θN¯+1,,θN* are constrained to satisfy {xgs(x,θi)0}=,i=N¯+1,,N*. Thus, restricting the parameterization is equivalent to adding additional constraints on the true θ. Let ^ be the feasible set of Problem 2 with θ restricted as above, i.e. ^={θ{xgs(x,θi)0}=,i=N¯+1,,N*}. Via Lemma C.1, ^; thus, I¬s()I¬s(^). Since I¬s() can equal 𝒜, potentially 𝒢¬s=I¬s(^)𝒮. Vice versa, Is()Is(^), and since Is() can equal 𝒮, potentially 𝒢s=Is(^)𝒮.

  2. 2.

    Assume, by contradiction, that Problem 2 outputs a simple unsafe set 𝒜(θi),i{1,,N¯}, which does not touch the true unsafe set: i{1,,N¯},𝒜(θi)𝒜(θ*)=. Then, θj,j{1,,N¯}{i} would be a feasible point for Problem 2 with a parametrization that contains only N¯-1 simple sets. However, we know Problem 2 with N¯-1 simple sets is infeasible. Contradiction.

Appendix D Extra numerical examples

D.1 U-shape (random demonstrations)

In this example, we show what the performance of our method looks like with random demonstrations on the U-shape example. On the left of Fig. D.1, we show that our coverage grows more slowly than for the case where demonstrations are chosen for their informativeness; furthermore, coverage for the safe set is higher and coverage for the unsafe set is lower in the random demonstration case. This is because by using random demonstrations, we cover a good deal of 𝒮, so 𝒢s becomes larger; on the other hand, many of these safe demonstrations may not come in contact with the constraint, so there are relatively few unsafe trajectories that can be sampled, so 𝒢¬s is not as large. In the center of Fig. D.1, we show that the accuracy of our method doesn’t change much, though the relative performance of the NN gets worse for classifying safe states; this is because the accuracy for the NN is now being evaluated on a larger region since 𝒢s is larger due to more demonstrations. As in previous examples, the NN error bars are generated by training the NN ten times with initializations using different random seeds. On the right of Fig. D.1, we display a feasible 𝒜(θ) recovered by solving a multi-box variant of Problem 3. With more demonstrations, the gap between 𝒜(θ) and the true unsafe set 𝒜 will continue to shrink.

The main takeaways from this experiment are: 1) when demonstrations are not informative (in the sense that they do not interact with the constraint), it can take many demonstrations to learn the unsafe set (this holds for any constraint recovery method), and 2) our accuracy remains just as high as for the case with specifically chosen demonstrations and is not much affected by the coverage.

Figure D.1: U-shape performance with random demonstrations. Left: Coverage of 𝒜 and 𝒮. Center: Classification accuracy. Right: A recovered feasible 𝒜(θ), overlaid with demonstrations, and the true unsafe set 𝒜 is outlined in blue.

Appendix E Experimental details

For all neural network baseline results in every experiment, the network is trained with weights initialized using ten different random seeds, and the resulting performance range (displayed as a shaded region) and average performance over the ten random seeds are plotted in the figures.

E.1 Unknown parameterizations

We emphasize that for all examples with unknown parameterization, by following the incremental procedure detailed in Section 4.4, we are finding the minimum number of boxes required to represent the data; in other words, we are always operating with the minimal feasible parameterization.

U-shape and infinite boxes:

  • For both experiments, the system dynamics are xt+1[χt+1,yt+1]=[χt,yt]+[utχ,uty]. The U-shape experiment uses control constraints [utχ,uty]20.5, while the infinite-box experiment uses control constraints [utχ,uty]21.

  • For both experiments, the cost function is c(ξx,ξu)=i=1T-1xt+1-xt22.

  • Since the cost function has optimal substructure, 100000 unsafe trajectories for each sub-trajectory are sampled. The dataset is downsampled to 50 unsafe trajectories for each sub-trajectory, which are to be fed into the multi-box variant of Problem 3.

  • For both experiments, the initial parameter set is restricted to [-5,-5,-3,-3]θi[8,8,3,3], for each θi (the parameter for box i). For the infinite-box experiment, each box is restricted to be at least 1.25×1.25 in width/height.

  • Sampling time is around 15 seconds per demonstration (for the U-shape experiment) and 10 seconds per demonstration (for the infinite-box experiment). Computation time for solving Problem 3 is around 40 seconds (for the U-shape experiment) and 15-20 seconds (for the infinite-box experiment).

  • The same data is used for training the neural network (7800 trajectories total for the U-shape case, 2000 trajectories for the infinite-box case). The neural network architecture used for this example is a fully connected (FC) layer, 2×10 LSTM, 10×10 FC 10×1 (the recurrent layer is used since we have variable length trajectories as training input). The network is trained using Adam.

U-shape with random demonstrations:

  • The system dynamics are xt+1[χt+1,yt+1]=[χt,yt]+[utχ,uty] with control constraints [utχ,uty]20.5.

  • The cost function is c(ξx,ξu)=i=1T-1xt+1-xt22.

  • Demonstrations are generated for 35 pairs of start/goal states sampled uniformly at random over (χ,y)[-2,2]×[-2,2], rejecting any start/goal states that lie in 𝒜.

  • Since the cost function has optimal substructure, 10000 unsafe trajectories for each sub-trajectory are sampled. The dataset is downsampled to 25 unsafe trajectories for each sub-trajectory, which are to be fed into the multi-box variant of Problem 3.

  • The initial parameter set is restricted to [-5,-5,-3,-3]θi[8,8,3,3], for each θi (the parameter for box i).

  • Sampling time is around 2 minutes total. Computation time for solving the multi-box variant of Problem 3 is around 90 seconds.

  • The same data is used for training the neural network (10100 trajectories total). The neural network architecture used for this example is a fully connected (FC) layer, 2×10 LSTM, 10×10 FC 10×1. The network is trained using Adam.

E.2 High-dimensional examples

7-DOF arm, optimal/suboptimal demonstrations

  • The system dynamics are θt+1i=θti+uti, i=1,,7, with control constraints -2uti2, i=1,,7, where the state is x=[θ1,,θ7].

  • The cost function is c(ξx,ξu)=i=1T-1xt+1-xt22. Note that the generate demonstrations (displayed in Fig. 6.2) push up against the position constraint, since the trajectory minimizing joint-space path length without the position constraint is an arc that exceeds the bounds of the position constraint; the position constraint ends up increasing the cost by truncating that arc.

  • The true safe set is (x,y,z,α,β,γ)[-0.51,0.51]×[-0.3,1.1]×[-0.51,0.51]×[-π,π]×[-π/120,π/120]×[-π/120,π/120] for the optimal case and the true safe set is (x,y,z,α,β,γ)[-0.57,0.47]×[-0.10,1.17]×[-0.56,0.56]×[-π,π]×[-0.12,0.12]×[-0.125,0.125] for the suboptimal case.

  • Since the cost function has optimal substructure, 250000 unsafe trajectories for each sub-trajectory are sampled. For the suboptimal case, the continuous-time demonstrations are time-discretized down to T=10 time-steps. The dataset is downsampled to 500 unsafe trajectories for each sub-trajectory, which are to be fed into Problem 3.

  • For the optimal case, the demonstrations are obtained by solving trajectory optimization problems solved with the IPOPT solver [ipopt]. For the suboptimal case, the demonstrations are recorded in a virtual reality (VR) environment displayed in Fig. E.1.

  • The initial parameter set is restricted to [-1.5,-1.5,-1.5,-π,-π,-π][x,y,z,α,β,γ][1.5,1.5,1.5,π,π,π].

  • Sampling time is 12.5 minutes total for the optimal case and 9 minutes total for the suboptimal case. Computation time for solving Problem 2 is around 2 seconds for both the optimal/suboptimal case.

  • The same data is used for training the neural network (70000 trajectories total for the optimal case, 49900 trajectories total for the suboptimal case). The neural network architecture used for this example is a fully connected (FC) layer, 3×20 LSTM, 20×20 FC 20×1. The network is trained using Adam.

Figure E.1: VR setup. Left: VR environment as viewed from the Vive headset. The green box represents the position constraints on the end effector. The end effector is commanded to move by dragging it with the HTC Vive controllers (right).

12D quadrotor example

  • The system dynamics [quad_kth] are

    [χ˙y˙z˙α˙β˙γ˙χ¨y¨z¨α¨β¨γ¨]=[χ˙y˙z˙β˙sin(γ)cos(β)+γ˙cos(γ)cos(β)βcos(γ)-γ˙sin(γ)α˙+β˙sin(γ)tan(β)+γ˙cos(γ)tan(β)-1m[sin(γ)sin(α)+cos(γ)cos(α)sin(β)]u1-1m[cos(α)sin(γ)-cos(γ)sin(α)sin(β)]u1g-1m[cos(γ)cos(β)]u1Iy-IzIxβ˙γ˙+1Ixu2Iz-IxIyα˙γ˙+1Iyu3Ix-IyIzα˙β˙+1Izu4], (12)

    with control constraints [0,-0.02,-0.02,-0.02]ut[mg,0.02,0.02,0.02]. For our purposes, we convert the dynamics to discrete time by performing forward Euler integration with discretization time δt=0.4 seconds. The state is x=[χ,y,z,α,β,γ,x˙,y˙,z˙,α˙,β˙,γ˙], and the constants are g=-9.81m/s2, m=1kg, Ix=0.5kgm2, Iy=0.1kgm2, and Iz=0.3kgm2.

  • The known unsafe set in (χ,y,z) is (χ,y,z)[-0.5,0.5]×[-0.5,0.5]×[-0.5,0.5].

  • The true safe set in (α˙,β˙,γ˙) is (α˙,β˙,γ˙)[-0.006,0.006]3.

  • The cost function is c(ξx,ξu)=i=1T-1[χi+1,yi+1,zi+1,α˙i+1,β˙i+1,γ˙i+1]-[χi,yi,zi,α˙i,β˙i,γ˙i]2 (penalizing acceleration and path length).

  • The demonstrations are obtained by solving trajectory optimization problems solved with the IPOPT solver [ipopt].

  • Since the cost function has optimal substructure, 10000 unsafe trajectories for each sub-trajectory are sampled. The dataset is downsampled to 500 unsafe trajectories for each sub-trajectory, which are to be fed into Problem 3.

  • The initial parameter set is restricted to [-π/2,-π/2,-π/2][α˙,β˙,γ˙][π/2,π/2,π/2].

  • Sampling time is 8.5 minutes total for the optimal case and 9 minutes total for the suboptimal case. Computation time for solving Problem 2 is 12 seconds.

  • The same data is used for training the neural network (30000 trajectories total). The neural network architecture used for this example is a fully connected (FC) layer, 6×36 LSTM, 36×42 FC 42×1. The network is trained using Adam.

E.3 Black-box system dynamics

Pushing example

  • The cost function is c(ξx,ξu)=i=1T-1xt+1-xt22. The two demonstrations are manually generated and are not exactly optimal.

  • 1000 unsafe trajectories for each demonstrations are sampled.

  • The initial parameter set is restricted to [-5,-5,-3,-3]θi[8,8,3,3].

  • Sampling time is 2 hours for each demonstration (using the simulator is slower than using the closed form dynamics). Computation time for solving Problem 2 is around 1 second.

  • Demonstrations are time-discretized to 40 simulator timesteps when input to Problem 3.

  • The same data is used for training the neural network (2700 trajectories total). The neural network architecture used for this example is a fully connected (FC) layer, 8×10 FC, 10×10 FC 10×1. No recurrent layer is used this time since all trajectories are of the same length (no sub-trajectories were sampled this time due to speed). The network is trained using Adam.

Appendix F Summary of frequently used notation

Meaning Notation
State, state space x, 𝒳
Control, control space u, 𝒰
State/control trajectory ξx, ξu
Constraint state, constraint space k, 𝒞
Safe set, unsafe set 𝒮, 𝒜
Parameterized safe set 𝒮(θ)={kg(k,θ)>0}
Parameterized unsafe set 𝒜(θ)={kg(k,θ)0}
Safe demonstration j ξsj*
Sampled unsafe trajectory k ξ¬sk
Guaranteed safe set 𝒢s
Guaranteed unsafe set 𝒢¬s
Table 1: Notation.