The CtcEval contractor
Main author: Simon Rohou
-
class CtcEval
Evaluation contractor \(\mathcal{C}_\textrm{eval}\) for scalar or vector tubes.
Given a tube \([x](\cdot)\), a derivative tube \([v](\cdot)\) and an observation \([t]\times[z]\), the contractor reduces \([t]\), \([z]\) and \([x](\cdot)\) subject to
The derivative tube is not contracted.\[ z=x(t),\qquad \dot{x}(\cdot)=v(\cdot) \]
The evaluation constraint is particularly useful in state estimation when both an observation and its acquisition time are uncertain. A position measurement, for example, may be available only within a time window due to synchronization errors.
Basic usage
Consider a trajectory \(x(\cdot)\) enclosed in a tube \([x](\cdot)\), its derivative \(v(\cdot)\) enclosed in \([v](\cdot)\), and an observation \([t_i]\times[z_i]\). The contractor implements the constraints
The observation specifies that the trajectory must visit the set \([z_i]\) at some instant in \([t_i]\), not at every instant in this interval. The derivative bounds constrain the evolution of the trajectory before and after that instant.
The contractor updates t, z and x in place. The derivative tube
v is not contracted, although its shared temporal partition may be refined
by the insertion of gates.
Scalar observation
The following example models the uncertain derivative of a sinusoidal trajectory on \([t_0,t_f]=[-\pi,\pi/2]\):
An initial state tube is built with v.primitive() using the prescribed
initial interval. A measurement is then supplied in the time-value plane:
td = create_tdomain([-PI,PI/2],0.01,True)
s = ScalarVar()
v = SlicedTube(td, AnalyticFunction([s],cos(s)+Interval(-0.1,0.1)))
x = v.primitive(Interval(-0.1,0.1))
t, z = Interval(-0.5,0.3), Interval(0.3,1.1)
ctc_eval = CtcEval()
ctc_eval.contract(t,z,x,v)
auto td = create_tdomain({-PI,PI/2.},0.01,true);
ScalarVar s;
SlicedTube v(td, AnalyticFunction({s},cos(s)+Interval(-0.1,0.1)));
auto x = v.primitive(Interval(-0.1,0.1));
Interval t(-0.5,0.3), z(0.3,1.1);
CtcEval ctc_eval;
ctc_eval.contract(t,z,x,v);
td = create_tdomain(Interval(-PI,PI/2),0.01,true);
s = ScalarVar();
v = SlicedTube(td, AnalyticFunction({s},cos(s)+Interval(-0.1,0.1)));
x = v.primitive(Interval(-0.1,0.1));
t = Interval(-0.5,0.3);
z = Interval(0.3,1.1);
ctc_eval = CtcEval();
ctc_eval.contract(t,z,x,v);
The contraction reduces the possible observation time and value. To understand why the tube can also be contracted, consider any time \(\tau\) and a candidate measurement instant \(s\in[t_i]\). A feasible trajectory satisfies
An enclosure of its possible values at \(\tau\) can therefore be expressed as
where the outer square brackets denote an interval hull. This is the continuous relation underlying the transport of feasible observation values. The sliced implementation works with the temporal partition and uses derivative-aware inversion and evaluation, followed by propagation between gates. It is not in general an exact computation of the continuous feasible set.
Local contraction of the scalar tube by CtcEval. The light gray region
shows the part of the tube removed by contraction, and the dark gray region
shows the remaining tube. The blue and red boxes represent the initial and
contracted observation, respectively. The curve and dot show a feasible
trajectory and observation.
Temporal propagation
CtcEval first narrows the temporal interval using tube inversion and then
narrows the observed value using tube evaluation. It performs local temporal
propagation within the contracted observation interval. When the time is a
singleton, it can directly update the corresponding gate.
To propagate this information to the rest of the trajectory, apply CtcDeriv
without a temporal restriction:
ctc_deriv = CtcDeriv()
ctc_deriv.contract(x,v)
CtcDeriv ctc_deriv;
ctc_deriv.contract(x,v);
ctc_deriv = CtcDeriv();
ctc_deriv.contract(x,v);
Global temporal propagation by CtcDeriv following the local contraction
by CtcEval. The light gray region shows the part of the initial tube
removed by the two contractors, and the dark gray region shows the remaining
tube.
This separation is useful when several measurements constrain the same state trajectory. Local updates can be collected first, and a single forward/backward sweep can then propagate their information throughout the tube.
Several observations and partial primitives
Suppose that, in addition to the first scalar measurement, there are two more
observations. Each has its own uncertain time and measured value. All of them
constrain the same x and v.
For repeated calls, CtcEval accepts a pair of partial primitives computed
outside the contractor. For \([v](s)=[v^-(s),v^+(s)]\), these tubes enclose
For certain dates \(a\leq b\), the integral of the derivative tube is bounded by the differences of these primitives:
The equality above refers to the exact lower and upper primitives. The precomputed tubes provide enclosures of these quantities. For backward integration, the bounds are exchanged and negated. This avoids traversing all intermediate slices for every transport. See Precomputing partial primitives for details on this optimization.
In the code below, x and v are initialized as in the scalar example,
before any observation is injected. The primitives are computed once and reused
through two sweeps of the observation constraints and the derivative constraint.
t = [Interval(-0.5,0.3),Interval(-0.6,0.8),Interval(-2.3,-2.2)]
z = [Interval(0.3,1.1),Interval(-0.5,-0.4),Interval(-0.8,-0.7)]
ctc_eval = CtcEval()
ctc_deriv = CtcDeriv()
primitives = v.partial_primitives()
for iter in range(2):
for i in range(len(t)):
ctc_eval.contract(t[i],z[i],x,v,primitives) # Optional primitives argument for faster integration
ctc_deriv.contract(x,v)
vector<Interval> t = {{-0.5,0.3},{-0.6,0.8},{-2.3,-2.2}};
vector<Interval> z = {{0.3,1.1},{-0.5,-0.4},{-0.8,-0.7}};
CtcEval ctc_eval;
CtcDeriv ctc_deriv;
auto primitives = v.partial_primitives();
for(int iter = 0 ; iter < 2 ; iter++)
{
for(size_t i = 0 ; i < t.size() ; i++)
ctc_eval.contract(t[i],z[i],x,v,primitives); // Optional primitives argument for faster integration
ctc_deriv.contract(x,v);
}
t = {Interval(-0.5,0.3),Interval(-0.6,0.8),Interval(-2.3,-2.2)};
z = {Interval(0.3,1.1),Interval(-0.5,-0.4),Interval(-0.8,-0.7)};
ctc_eval = CtcEval();
ctc_deriv = CtcDeriv();
primitives = v.partial_primitives();
for iter = 1:2
for i = 1:numel(t)
ctc_eval.contract(t{i},z{i},x,v,primitives); % Optional primitives argument for faster integration
end
ctc_deriv.contract(x,v);
end
Precomputation trades memory and initialization cost for faster integration queries. For short or infrequent observation windows, precomputation is not necessarily beneficial.
Note
The partial primitives must be recomputed if the derivative envelopes or
the temporal extent change. Refinement of the shared TDomain by slice
duplication preserves their validity but can make the new gate enclosures
less precise.
Contraction of a scalar tube using three uncertain observations. The animation
alternates between local contractions by CtcEval and the result of global
temporal propagation by CtcDeriv. The light gray regions show the parts
of the tube removed by contraction, and the dark gray region shows the
remaining tube. Blue and red boxes represent the initial and contracted
observations, respectively.
Two sweeps are used here for illustration. In general, repeat the contractions until a stopping criterion is met, for instance a negligible reduction in tube volume and observation widths, or a prescribed iteration budget. A single sweep does not imply that a fixpoint has been reached.
2d localization example
Contracting the position tube
Consider a robot following a Lissajous-type trajectory over \([0,5]\). Its initial position is unknown, but its velocity is enclosed by
A position observation gives
The position tube is initially unbounded. The evaluation contractor anchors it locally, and the derivative contractor propagates this anchor in both time directions.
td = create_tdomain([0,5],0.01,True)
s = ScalarVar()
v = SlicedTube(td, AnalyticFunction([s],[-2*sin(s),2*cos(2*s)]))
v.inflate(0.01)
x = SlicedTube(td, IntervalVector(2))
t = Interval(4.3,4.4)
z = IntervalVector([[-0.73,-0.69],[0.64,0.68]])
ctc_eval = CtcEval()
ctc_eval.contract(t,z,x,v)
CtcDeriv().contract(x,v)
auto td = create_tdomain({0,5},0.01,true);
ScalarVar s;
SlicedTube v(td, AnalyticFunction({s},{-2.*sin(s),2.*cos(2.*s)}));
v.inflate(0.01);
SlicedTube x(td, IntervalVector(2));
Interval t(4.3,4.4);
IntervalVector z({{-0.73,-0.69},{0.64,0.68}});
CtcEval ctc_eval;
ctc_eval.contract(t,z,x,v);
CtcDeriv().contract(x,v);
td = create_tdomain(Interval(0,5),0.01,true);
s = ScalarVar();
v = SlicedTube(td, AnalyticFunction({s},vec(-2*sin(s),2*cos(2*s))));
v.inflate(0.01);
x = SlicedTube(td, IntervalVector(2));
t = Interval(4.3,4.4);
z = IntervalVector({{-0.73,-0.69},{0.64,0.68}});
ctc_eval = CtcEval();
ctc_eval.contract(t,z,x,v);
ctc_deriv = CtcDeriv();
ctc_deriv.contract(x,v);
In this example, the observation alone does not distinguish any time or position within the original observation box. Its main role is to bound the position trajectory using the velocity information. The nominal curve \((2\cos(t),\sin(2t))^\mathsf{T}\) is one feasible trajectory.
Position tube obtained from an initially unbounded tube by combining an uncertain position observation with velocity information. The blue gradient represents time along the tube. The white curve is a feasible trajectory and the yellow robot indicates a feasible pose at the observation time.
Contracting the observation box
Conversely, suppose that a position tube is already available:
The robot is detected somewhere in \([-1,0]\times[0.4,1.2]\), with no information about its acquisition time except the temporal domain of the tube. Using the same derivative tube as before, one can estimate when this detection could have occurred and refine its spatial enclosure:
y = SlicedTube(td, AnalyticFunction([s],[2*cos(s),sin(2*s)]))
y.inflate(0.05)
t = td.t0_tf()
z = IntervalVector([[-1,0],[0.4,1.2]])
ctc_eval.contract(t,z,y,v)
SlicedTube y(td, AnalyticFunction({s},{2.*cos(s),sin(2.*s)}));
y.inflate(0.05);
t = td->t0_tf();
z = IntervalVector({{-1.,0.},{0.4,1.2}});
ctc_eval.contract(t,z,y,v);
y = SlicedTube(td, AnalyticFunction({s},vec(2*cos(s),sin(2*s))));
y.inflate(0.05);
t = td.t0_tf();
z = IntervalVector({{-1,0},{0.4,1.2}});
ctc_eval.contract(t,z,y,v);
Contraction of an uncertain position observation using a known position tube. The blue and red boxes represent the initial and contracted position domains, respectively. The blue gradient represents time along the tube, the white curve is a feasible trajectory and the yellow robot indicates a feasible pose at the observation time.
When the derivative is unavailable and only the observation domains need to be
refined, use tube inversion and evaluation directly:
t &= x.invert(z,t) and, provided t is non-empty, z &= x(t).
These operations do not impose an observation constraint on the tube itself.
Known observation time
A known acquisition time \(t_i\) is represented by a degenerate
Interval. If the observation is feasible, the contractor contracts the
observation value and updates the gate of \([x](\cdot)\) at \(t_i\),
creating it if necessary. No temporal propagation is performed in this case.
Use CtcDeriv to propagate the information to the rest of the tube.