Main Content

sampleUniform

Sample state using uniform distribution

Description

state = sampleUniform(space) samples a state within the bounds in the StateBounds property of the specified state space object space using a uniform probability distribution. For a stateSpaceSE3 object, the state variables corresponding to orientation are bound to a unit quaternion using a uniform distribution of random rotations.

state = sampleUniform(space,numSamples) returns a specified number of state samples numSamples within the bounds of the state space object.

example

state = sampleUniform(space,nearState,distVector,numSamples) samples states in a specified subregion of the bounds of the state space object. Specify the center of the sampling region nearState and the distance from the center of the sampling region to its boundaries distVector.

Note

The stateSpaceSE3 object does not support this syntax.

Examples

collapse all

Create an SE(3) state space.

space = stateSpaceSE3([-10 10; -10 10; -10 10; inf inf; inf inf; inf inf; inf inf])
space = 
  stateSpaceSE3 with properties:

                 Name: 'SE3'
          StateBounds: [7x2 double]
    NumStateVariables: 7
            WeightXYZ: 1
     WeightQuaternion: 0.1000

Sample 3 states within full state bounds.

state = sampleUniform(space,3)
state = 3×7

    6.2945    8.1158   -7.4603    0.6316    0.3078   -0.6921   -0.1654
    8.2675    2.6472   -8.0492   -0.0834   -0.9448    0.2709    0.1641
   -4.4300    0.9376    9.1501    0.5771   -0.5458   -0.5490   -0.2601

Input Arguments

collapse all

State space object, specified as a stateSpaceSE2, stateSpaceSE3, stateSpaceDubins, or stateSpaceReedsShepp object.

Number of samples, specified as a positive integer.

Data Types: single | double

Center of the sampling region, specified as a three-element vector of real values.

For the 2-D state space objects stateSpaceSE2, stateSpaceDubins, and stateSpaceReedsShepp, the state is a vector of form [x y theta], which defines the xy-position and orientation angle theta of a state in the state space.

Note

The stateSpaceSE3 object does not support this argument.

Data Types: single | double

Distance of sampling region boundary from the center, specified as a three-element vector of positive numbers.

For the 2-D state space objects stateSpaceSE2, stateSpaceDubins, and stateSpaceReedsShepp, the state is a vector of form [x y theta], which defines the xy-position and orientation angle theta of a state in the state space.

Note

The stateSpaceSE3 object does not support this argument.

Data Types: single | double

Output Arguments

collapse all

State samples, returned as an n-by-3 or n-by-7 matrix of real values. n is the number of samples.

For the 2-D state space objects stateSpaceSE2, stateSpaceDubins, and stateSpaceReedsShepp, each row is of form [x y theta], which defines the xy-position and orientation angle theta of the sampled states.

For the 3-D state space object stateSpaceSE3, each row is of form [x y z qw qx qy qz], which defines the xyz-position and quaternion orientation [qw qx qy qz] of the sampled states.

Data Types: single | double

Version History

Introduced in R2019b