Main Content

wheelEncoderOdometryUnicycle

Compute unicycle odometry using wheel encoder ticks and angular velocity

Since R2020b

Description

The wheelEncoderOdometryUnicycle System object™ computes unicycle odometry using the wheel encoder ticks and angular velocity.

To compute unicycle odometry:

  1. Create the wheelEncoderOdometryUnicycle 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 = wheelEncoderOdometryUnicycle creates a wheelEncoderOdometryUnicycle System object with default property values.

example

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

whlEncOdom = wheelEncoderOdometryUnicycle(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 = wheelEncoderOdometryUnicycle('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.

Example: 'TicksPerRevolution',2048

Data Types: double

Wheel radius, specified as a positive scalar in meters.

Example: 'WheelRadius',0.35

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]

Tunable: No

Data Types: double

Usage

Description

pose = whlEncOdom(ticks,angVel) computes the odometry of a unicycle using the specified wheel encoder ticks ticks and angular velocity angVel, and returns the position and orientation of the vehicle in the local navigation coordinate system.

[pose,velocity] = whlEncOdom(ticks,angVel) 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-element column vector. n is the number of samples in the current frame.

Example: [5; 2]

Data Types: single | double

Angular velocity of the vehicle in the vehicle body coordinate system, specified as an n-element column vector in radians per second. n is the number of samples in the current frame.

Example: [0.2; 0.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 wheelEncoderOdometryUnicycle System object.

whlEncOdom = wheelEncoderOdometryUnicycle;

Specify the number of wheel encoder ticks and angular velocity.

ticks = [5; 2];
angVel = [0.2; 0.2];

Compute the unicycle odometry.

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

    0.0054    0.0000    0.0020
    0.0075    0.0000    0.0040

vel = 2×3

    0.5369    0.0011    0.2000
    0.2148    0.0009    0.2000

Extended Capabilities

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

Version History

Introduced in R2020b