scenic.core.pruning

Pruning parts of the sample space which violate requirements.

The top-level function here, prune, is called as the very last step of scenario compilation (from translator.constructScenarioFrom).

Summary of Module Members

Functions

checkConditionedCycle

Returns true if A depends on B

conditionedDeps

conditionedVal

currentPropValue

Get the current value of an object's property, taking into account prior pruning.

feasibleRHPolygon

Find where objects aligned to the given fields can satisfy the given RH bounds.

isFunctionCall

Match calls to a given function, taking into account distribution decorators.

isMethodCall

Match calls to a given method, taking into account distribution decorators.

matchInRegion

Match uniform samples from a Region

matchPolygonalField

Match orientation yaw defined by a PolygonalVectorField at the given position.

maxDistanceBetween

Upper bound the distance between the given Objects.

percentagePruned

prune

Prune a Scenario, removing infeasible parts of the space.

pruneContainment

Prune based on the requirement that individual Objects fit within their container.

pruneRelativeHeading

Prune based on requirements bounding the relative heading of an Object.

pruneVisibility

relativeHeadingRange

Lower/upper bound the possible RH between two headings with bounded disturbances.

unpackWorkspace

visibilityBound

Upper bound the distance from an Object to another it can see.

Member Details

currentPropValue(obj, prop)[source]

Get the current value of an object’s property, taking into account prior pruning.

isMethodCall(thing, method)[source]

Match calls to a given method, taking into account distribution decorators.

isFunctionCall(thing, function)[source]

Match calls to a given function, taking into account distribution decorators.

matchInRegion(position)[source]

Match uniform samples from a Region

Returns the Region, if any, the offset that should be added to the base, and the PointInRegionDistribution itself.

matchPolygonalField(heading, position)[source]

Match orientation yaw defined by a PolygonalVectorField at the given position.

Matches the yaw attribute of orientations exactly equal to a PolygonalVectorField, or offset by a bounded disturbance. Returns a triple consisting of the matched field if any, together with lower/upper bounds on the disturbance.

prune(scenario, verbosity=1)[source]

Prune a Scenario, removing infeasible parts of the space.

This function directly modifies the Distributions used in the Scenario, but leaves the conditional distribution under the scenario’s requirements unchanged. See Samplable.conditionTo.

Currently, the following pruning techniques are applied in order:

pruneContainment(scenario, verbosity)[source]

Prune based on the requirement that individual Objects fit within their container.

Specifically, if O is positioned uniformly (with a possible offset) in region B and has container C, then we can instead pick a position uniformly in their intersection. If we can also lower bound the radius of O, then we can first erode C by that distance minus that maximum offset distance.

pruneRelativeHeading(scenario, verbosity)[source]

Prune based on requirements bounding the relative heading of an Object.

Specifically, if an object O is:

  • positioned uniformly within a polygonal region B;

  • aligned to a polygonal vector field F (up to a bounded offset);

and another object O’ is:

  • aligned to a polygonal vector field F’ (up to a bounded offset);

  • at most some finite maximum distance from O;

  • required to have relative heading within a bounded offset of that of O;

then we can instead position O uniformly in the subset of B intersecting the cells of F which satisfy the relative heading requirements w.r.t. some cell of F’ which is within the distance bound.

maxDistanceBetween(scenario, obj, target)[source]

Upper bound the distance between the given Objects.

visibilityBound(obj, target)[source]

Upper bound the distance from an Object to another it can see.

feasibleRHPolygon(field, offsetL, offsetR, tField, tOffsetL, tOffsetR, lowerBound, upperBound, maxDist)[source]

Find where objects aligned to the given fields can satisfy the given RH bounds.

relativeHeadingRange(baseHeading, offsetL, offsetR, targetHeading, tOffsetL, tOffsetR)[source]

Lower/upper bound the possible RH between two headings with bounded disturbances.

checkConditionedCycle(A, B)[source]

Returns true if A depends on B