Main Content

wheelEncoderBicycle

Simulate wheel encoder sensor readings for bicycle vehicle

Since R2020b

Description

The wheelEncoderBicycle System object™ computes wheel encoder tick readings based on the pose input for a bicycle vehicle.

To obtain the encoder tick readings:

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

example

encoder= wheelEncoderBicycle(Name,Value) sets properties for the encoder using one or more name-value pairs. For example, wheelEncoderBicycle('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 back wheel, and the second element is for the front wheel.

Data Types: double

Wheel radius, specified as a two-element vector of positive scalars in meters. The first element is for the back wheel, and the second element is for the front 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 back wheel, and the second element is for the front 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 back wheel, and the second element is for the front 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 back wheel, and the second element is for the front 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 front and the rear wheels, 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, from 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 back wheel, and the second column is for the front 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 = wheelEncoderBicycle;

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

     0     5
     6     7

Extended Capabilities

Version History

Introduced in R2020b