Main Content

wheelEncoderAckermann

Simulate wheel encoder sensor readings for Ackermann vehicle

Since R2020b

Description

The wheelEncoderAckermann System object™ computes wheel encoder tick readings based on the pose input of an Ackermann vehicle.

To obtain the encoder tick readings:

  1. Create the wheelEncoderAckermann 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

example

encoder = wheelEncoderAckermann creates a wheelEncoderAckermann System object, encoder.

encoder= wheelEncoderAckermann(Name,Value) sets properties for the encoder using one or more name-value pairs. For example, wheelAckermann('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.

Example: 'SampleRate',100

Data Types: double

Number of encoder ticks per wheel revolution, specified as a four-element vector of positive integers. The first, second, third, and fourth elements are for the back-left, back-right, front-left, and front-right wheels, respectively.

Data Types: double

Wheel radius, specified as a four-element vector of positive scalars in meters. The first, second, third, and fourth elements are for the back-left, back-right, front-left, and front-right wheels, respectively.

Data Types: double

Bias of the wheel radius, specified as a four-element vector of scalars in meters. The first, second, third, and fourth elements are for the back-left, back-right, front-left, and front-right wheels, respectively.

Data Types: double

Standard deviation of wheel position error, specified as a four-element vector of nonnegative scalars in radians. The first, second, third, and fourth elements are for the back-left, back-right, front-left, and front-right wheels, respectively.

Data Types: double

Slip or skid ratio of the wheel, specified as a four-element vector of scalars in which each scalar is larger than or equal to –1. The first, second, third, and fourth elements are for the back-left, back-right, front-left, and front-right wheels, respectively.

  • 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

Distance between the wheel axles, specified as a two-element vector of positive scalars in meters. The first element is for the back track, and the second element is for the front track.

Data Types: double

Bias of track width, specified as a two-element vector of scalars in meters. The first element is for the back track, and the second element is for the front track.

Data Types: double

Distance between the front and the rear axles, specified as a positive scalar in meters.

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, form 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-by-4 matrix of nonnegative integers. N is the number of samples. The first, second, third, and fourth columns are for the back-left, back-right, front-left, and front-right wheels, respectively.

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 = wheelEncoderAckermann;

Define poses of the vehicle.

orient = [quaternion([60 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×4

     3     6     6     8
     6     7     6     7

Extended Capabilities

Version History

Introduced in R2020b