Main Content

wheelEncoderOdometryAckermann

Compute Ackermann vehicle odometry using wheel encoder ticks and steering angle

Description

The wheelEncoderOdometryAckermann System object™ computes Ackermann vehicle odometry using the wheel encoder ticks and steering angle of the vehicle.

To compute Ackermann vehicle odometry:

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

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

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

whlEncOdom = wheelEncoderOdometryAckermann(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 = wheelEncoderOdometryAckermann('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 back left wheel and the second to the back 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 back left wheel and the second to the back 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

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

Example: 'WheelBase',2.818

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,steer) computes the odometry of an Ackermann vehicle using the specified wheel encoder ticks ticks and steering angle steer, and returns the position and orientation of the vehicle in the local navigation coordinate system.

example

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

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 [ticksBackLeft ticksBackRight], where ticksBackLeft and ticksBackRight specify the number of ticks for the back left and back right wheels, respectively.

Example: [5 5; 2 2]

Data Types: single | double

Steering angle of the vehicle, specified as an n-element column vector in radians. 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 wheelEncoderOdometryAckermann System object.

whlEncOdom = wheelEncoderOdometryAckermann;

Specify the number of wheel encoder ticks and the steering angle.

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

Compute the Ackermann vehicle odometry.

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

    0.0053689   1.0368e-06   0.00038621
    0.0075165   2.0321e-06   0.00054069

vel = 2×3

      0.53689   0.00020735     0.038621
      0.21476   0.00011612     0.015448

Extended Capabilities

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

Introduced in R2020b