Main Content

wheelEncoderUnicycle

Simulate wheel encoder sensor readings for unicycle vehicle

Since R2020b

Description

The wheelEncoderUnicycle System object™ computes wheel encoder tick readings based on the pose input of a unicycle vehicle.

To obtain the encoder tick readings:

  1. Create the wheelEncoderUnicycle object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

encoder = wheelEncoderUnicycle creates a wheelEncoderUnicycle System object encoder.

example

encoder = wheelEncoderUnicycle(Name,Value) sets properties for the encoder using one or more name-value pairs. For example, wheelEncoderUnicycle('SampleRate',120) sets the sample rate of the encoder to 120 Hz. Unspecified properties have default values. Enclose each property name in quotes.

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Sample rate of the encoder, specified as a positive scalar in Hz.

Data Types: double

Number of encoder ticks per wheel revolution, specified as a positive integer.

Data Types: double

Wheel radius, specified as a positive scalar in meters.

Data Types: double

Bias of the wheel radius, specified as a scalar in meters.

Data Types: double

Standard deviation of wheel position error, specified as a nonnegative scalar in radians.

Data Types: double

Slip or skid ratio of the wheel, specified as a scalar larger than or equal to –1.

  • For a wheel that slips (over rotation), specify it as a positive value. A higher value denotes more slipping.

  • For a wheel that skids (under rotation), specify it as a negative value larger than or equal to –1. A lower value denotes more skidding. For a wheel that does not rotate, specify it as –1.

Data Types: double

Random number source, specified as a character vector or string:

  • 'Global stream' –– Random numbers are generated using the current global random number stream.

  • 'mt19937ar with seed' –– Random numbers are generated using the mt19937ar algorithm with the seed specified by the Seed property.

Data Types: char | string

Initial seed of an mt19937ar random number generator algorithm, specified as a nonnegative integer.

Dependencies

To enable this property, set RandomStream to 'mt19937ar with seed'.

Usage

Description

ticks = encoder(velocity,angularVelocity,orientation) return the wheel tick readings ticks from the specified velocity, angular velocity, and orientation information.

Input Arguments

expand all

Velocity of the vehicle in the local navigation frame, specified as an N-by-3 matrix of scalars in m/s. N is the number of samples.

Angular velocity of the vehicle in the local navigation frame, specified as an N-by-3 matrix of scalars in rad/s. N is the number of samples.

Orientation of the vehicle in the local navigation frame, specified as an N-element vector of quaternion or a 3-by-3-by-N array of rotation matrices. N is the number of samples. Each quaternion or rotation matrix is a frame rotation from the local navigation coordinate system to the current vehicle body coordinate system.

Output Arguments

expand all

Number of wheel ticks the vehicle moved per time step, returned as an N-element vector of nonnegative integers. N is the number of samples.

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

cloneCreate duplicate System object
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object
isLockedDetermine if System object is in use

Examples

collapse all

Create the wheel encoder sensor.

encoder = wheelEncoderUnicycle;

Define poses of the vehicle.

orient = [quaternion([90 0 0],'eulerd','ZYX','frame'); quaternion([45 0 0], 'eulerd', 'ZYX', 'frame')];
vel = [1 0 0; 0 1 0];
angvel = [0 0 0.2; 0 0 0.1];

Generate wheel ticks from the poses.

ticks = encoder(vel,angvel,orient)
ticks = 2×1

     0
     6

Extended Capabilities

Version History

Introduced in R2020b