mani_skill.envs.utils.rewards#

Submodules#

Functions#

tolerance(x[, lower, upper, margin, sigmoid, ...])

Returns 1 when x falls inside the bounds, between 0 and 1 otherwise.

Package Contents#

mani_skill.envs.utils.rewards.tolerance(x, lower=0.0, upper=0.0, margin=0.0, sigmoid='gaussian', value_at_margin=0.1)[source]#

Returns 1 when x falls inside the bounds, between 0 and 1 otherwise.

Parameters:
  • x – A torch array. (B, 3)

  • lower – specifying inclusive (lower, upper) bounds for the target interval. These can be infinite if the interval is unbounded at one or both ends, or they can be equal to one another if the target value is exact.

  • upper – specifying inclusive (lower, upper) bounds for the target interval. These can be infinite if the interval is unbounded at one or both ends, or they can be equal to one another if the target value is exact.

  • margin

    Float. Parameter that controls how steeply the output decreases as x moves out-of-bounds. * If margin == 0 then the output will be 0 for all values of x

    outside of bounds.

    • If margin > 0 then the output will decrease sigmoidally with increasing distance from the nearest bound.

  • sigmoid – String, choice of sigmoid type. Valid values are: ‘gaussian’, ‘linear’, ‘hyperbolic’, ‘long_tail’, ‘cosine’, ‘tanh_squared’.

  • value_at_margin – A float between 0 and 1 specifying the output value when the distance from x to the nearest bound is equal to margin. Ignored if margin == 0.

Returns:

A torch array with values between 0.0 and 1.0.

Raises:
  • ValueError – If bounds[0] > bounds[1].

  • ValueError – If margin is negative.

  • ValueError – If not 0 < value_at_margin < 1,

  • except for linear, cosine and quadratic sigmoids, which allow value_at_margin == 0.

  • ValueError – If sigmoid is of an unknown type.