sample
Description
Examples
Sample SE(2) State Space Using Uniform State Sampler
Use Default State Space as Input
Create a uniform state sampler with default properties. By default, the sampler uses the SE(2) state space as the configuration space for motion planning. The limits of the state variables [x
, y
, theta
] in the default state space are [-100 100; -100 100; -3.1416 3.1416]
. The values of x
and y
are in meters. theta
is in radians.
sampler = stateSamplerUniform;
Check the bounds of the input state space.
bounds = sampler.StateSpace.StateBounds
bounds = 3×2
-100.0000 100.0000
-100.0000 100.0000
-3.1416 3.1416
Sample the input state space. Set the number of samples to select as 10.
states = sample(sampler,10);
Check the sampled state variables.
disp(states)
62.9447 81.1584 -2.3437 82.6752 26.4718 -2.5287 -44.3004 9.3763 2.8746 92.9777 -68.4774 2.9568 91.4334 -2.9249 1.8867 -71.6227 -15.6477 2.6121 58.4415 91.8985 0.9785 -92.8577 69.8259 2.7269 35.7470 51.5480 1.5276 -21.5546 31.0956 -2.0660
Use Custom State Space as Input
Define a custom SE(2) state space by specifying the limits of the state variables [x
, y
, theta
]. The values of x
and y
are in meters. theta
is in radians.
ss = stateSpaceSE2([-1 1; -2 2; -pi/2 pi/2]);
Create a uniform state sampler with the custom state space as input.
sampler = stateSamplerUniform(ss);
Sample the input state space. Set the number of samples to select as 10.
states = sample(sampler,10);
Check the sampled state variables.
disp(states)
0.4121 -1.8727 -0.7008 -0.9077 -1.6115 1.0162 0.3897 -0.7316 1.4144 -0.9311 -0.2450 -0.3721 0.5310 1.1808 -0.9837 -0.0205 -0.2177 0.4597 0.4187 1.0187 -0.7036 0.3594 0.6204 -1.0599 -0.7620 -0.0065 1.4443 -0.3192 0.3411 -0.8677
Input Arguments
sampler
— State sampler object
stateSamplerUniform
object
State sampler object, specified as a stateSamplerUniform
object.
numsamples
— Number of samples
1
(default) | positive integer
Number of samples, specified as a positive integer.
Data Types: double
Output Arguments
states
— State samples
M-by-N matrix of real values
State samples, returned as an M-by-N matrix of
real values. M is the number of states. N is the
number of state variables. Each row of the matrix specifies the state variables
corresponding to the input state space model. For example, for the SE(2) state space
model, N is 3, and each row is of the form [x
,
y
, theta
].
Data Types: double
Version History
Introduced in R2023b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)