Main Content

wheelEncoderDifferentialDrive

Simulate wheel encoder sensor readings for differential drive vehicle

Description

The wheelEncoderDifferentialDrive System object™ computes wheel encoder tick readings based on the pose input of a differential drive vehicle.

To obtain the encoder tick readings:

  1. Create the wheelEncoderDifferentialDrive 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 = wheelEncoderDifferentialDrive creates a wheelEncoderDifferentialDrive System object, encoder.

encoder= wheelEncoderDifferentialDrive(Name,Value) sets properties for the encoder using one or more name-value pairs. For example, wheelEncoderDifferentialDrive('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 two-element vector of positive integers. The first element is for the left wheel, and the second element is for the right wheel.

Data Types: double

Wheel radius, specified as a two-element vector of positive scalars in meters. The first element is for the left wheel, and the second element is for the right wheel.

Data Types: double

Bias of the wheel radius, specified as a two-element vector of scalars in meters. The first element is for the left wheel, and the second element is for the right wheel.

Data Types: double

Standard deviation of wheel position error, specified as a two-element vector of nonnegative scalars in radians. The first element is for the left wheel, and the second element is for the right wheel.

Data Types: double

Slip or skid ratio of the wheel, specified as a two-element vector of scalars in which each scalar is larger than or equal to –1. The first element is for the left wheel, and the second element is for the right wheel.

  • 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 positive scalar in meters.

Data Types: double

Bias of track width, specified as a 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-2 matrix of integers. N is the number of samples. The first column is for the left wheel, and the second column is for the right wheel.

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

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×2

     3     6
     6     7

Extended Capabilities

Introduced in R2020b