Main Content

wheelEncoderOdometryDifferentialDrive

Compute differential-drive vehicle odometry using wheel encoder ticks

Since R2020b

Description

The wheelEncoderOdometryDifferentialDrive System object™ computes differential-drive vehicle odometry using the wheel encoder ticks.

To compute differential-drive vehicle odometry:

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

whlEncOdom = wheelEncoderOdometryDifferentialDrive creates a wheelEncoderOdometryDifferentialDrive System object with default property values.

example

whlEncOdom = wheelEncoderOdometryDifferentialDrive(encoder) creates a wheelEncoderOdometryDifferentialDrive System object using the specified wheelEncoderDifferentialDrive System object, encoder, to set properties.

whlEncOdom = wheelEncoderOdometryDifferentialDrive(Name,Value) sets Properties using one or more name-value pairs. Unspecified properties have default values. Enclose each property name in quotes.

For example, whlEncOdom = wheelEncoderOdometryDifferentialDrive('SampleRate',100) sets the sample rate of the sensor to 100 Hz.

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 sensor, specified as a positive scalar in hertz.

Example: 'SampleRate',100

Data Types: double

Number of encoder ticks per wheel revolution, specified as a positive integer or two-element vector of positive integers.

When specifying this value as a two-element vector, the first element corresponds to the left wheel and the second to the right wheel.

Example: 'TicksPerRevolution',[2048 2048]

Data Types: double

Wheel radius, specified as a positive scalar or two-element vector of positive numbers in meters.

When specifying this value as a two-element vector, the first element corresponds to the left wheel and the second to the right wheel.

Example: 'WheelRadius',[0.35 0.35]

Data Types: double

Distance between the wheels on the axle, specified as a positive scalar in meters.

Example: 'TrackWidth',1.572

Data Types: double

Initial pose of the vehicle, specified as three-element vector of the form [X Y Yaw]. X and Y specify the vehicle position in meters. Yaw specifies the vehicle orientation in radians. All values are in the local navigation coordinate system.

Example: 'InitialPose',[0 0 0]

Data Types: double

Usage

Description

pose = whlEncOdom(ticks) computes the odometry of a differential-drive vehicle using the specified wheel encoder ticks ticks, and returns the position and orientation of the vehicle in the local navigation coordinate system.

[pose,velocity] = whlEncOdom(ticks) additionally returns the linear and angular velocity of the vehicle in the local navigation coordinate system.

example

Input Arguments

expand all

Number of wheel encoder ticks, specified as an n-by-2 matrix. n is the number of samples in the current frame.

Each row of the matrix specifies wheel encoder ticks in the form [ticksLeft ticksRight], where ticksLeft and ticksRight specify the number of ticks for the left and right wheels, respectively.

Example: [5 5; 2 2]

Data Types: single | double

Output Arguments

expand all

Position and orientation of the vehicle, returned as an n-by-3 matrix. n is the number of samples in the current frame. Each row of the matrix specifies the position and orientation of a sample in the form [X Y Yaw]. X and Y specify the vehicle position in meters. Yaw specifies the vehicle orientation in radians. All values are in the local navigation coordinate system.

Data Types: single | double

Linear and angular velocity of the vehicle, returned as an n-by-3 matrix. n is the number of samples in the current frame. Each row of the matrix specifies the linear and angular velocity of a sample in the form [velX velY yawRate]. velX and velY specify the linear velocity of the vehicle in meters per second. yawRate specifies the angular velocity of the vehicle in radians per second. All values are in the local navigation coordinate system.

Data Types: single | double

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 a wheelEncoderOdometryDifferentialDrive System object.

whlEncOdom = wheelEncoderOdometryDifferentialDrive;

Specify the number of wheel encoder ticks.

ticks = [5 5; 2 2];

Compute the differential-drive vehicle odometry.

[pose,vel] = whlEncOdom(ticks)
pose = 2×3

    0.0054         0         0
    0.0075         0         0

vel = 2×3

    0.5369         0         0
    0.2148         0         0

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2020b