MAVLINKHUD

Overview

The WENC parameter group configures the Wheel Encoders. These sensors measure the rotation of the vehicle's wheels (or tracks) to provide an accurate estimate of ground velocity and distance traveled.

Wheel encoders are the primary method for high-precision navigation in GPS-denied environments for ground rovers.

Key Concepts

1. Encoder Types (WENCn_TYPE)

ArduPilot supports up to 2 wheel encoder instances.

  • 1 (Quadrature): Uses two digital pins (A and B) to detect both speed and direction.
  • 2 (Single Pin): Uses one pin to detect speed (cannot detect reverse automatically).

2. Resolution (WENCn_CPR)

Defines how many pulses the encoder generates for one full rotation of the motor or wheel.

  • Calculation: Pulses_per_revolution * Gear_Ratio.

3. Physical Dimensions (WENCn_RADIUS)

The autopilot needs to know the radius (meters) of the wheel to convert "rotations" into "meters traveled."

Parameter Breakdown

  • WENC1_TYPE: Driver selection.
  • WENC1_PINA / PINB: GPIO pin assignments.
  • WENC1_POS_X/Y/Z: Physical offset of the wheel from the vehicle center.

Integration Guide

  1. Hardware: Mount encoders to the driven wheels.
  2. Enable: Set WENC1_TYPE = 1.
  3. Calibrate: Set the CPR and RADIUS accurately.
  4. Verify: Push the rover forward 10 meters and verify the GCS reports exactly 10.0m traveled.

Developer Notes

  • Library: libraries/AP_WheelEncoder.
  • EKF Fusion: Wheel encoder data is fused into AP_NavEKF3 to provide a "dead-reckoning" solution when GPS is lost.

WENC2_CPR

Default WHEELENCODER_CPR_DEFAULT
Range null

WheelEncoder 2 counts per revolution

Note: This parameter functions identically to WENC_CPR.

WENC2_PINA

Default 53
Range null

Second Encoder Input Pin A

Note: This parameter functions identically to WENC_PINA.

WENC2_PINB

Default 52
Range null

Second Encoder Input Pin B

Note: This parameter functions identically to WENC_PINB.

WENC2_POS

m
Default 0.0f
Range -5 5

Wheel2's Z position offset

Note: This parameter functions identically to WENC_POS.

WENC2_RADIUS

m
Default WHEELENCODER_RADIUS_DEFAULT
Range null

Wheel2's radius

Note: This parameter functions identically to WENC_RADIUS.

WENC2_TYPE

Default 0
Range null

Second WheelEncoder type

Note: This parameter functions identically to WENC_TYPE.

WENC_CPR

Default 0
Range 0 100000

Wheel Encoder Counts Per Revolution (WENC_CPR)

Description

WENC_CPR calibrates the encoder resolution.

If your encoder has 1000 lines and uses quadrature (4x) decoding, the CPR is 4000. Correct setting is essential for accurate odometry.

Tuning & Behavior

  • Default Value: 0 (or Driver Default).
  • Calculation: Lines * 4 for Quadrature.

WENC_PINA

Default -1
Range -1 103

Wheel Encoder Pin A (WENC_PINA)

Description

WENC_PINA defines the input pin for Phase A of the primary wheel encoder.

Wheel encoders typically use two pins (A and B) to determine both speed and direction of rotation. Phase A provides the primary pulse count.

Tuning & Behavior

  • Default: -1.
  • Setup: Set this to the digital input pin connected to your encoder's A channel. If using an IOMCU-equipped board (like Pixhawk), these must typically be AUX pins configured as GPIO.
  • Integration: You must also configure WENC_PINB for quadrature decoding to function.

WENC_PINB

Default -1
Range -1 103

Wheel Encoder Pin B (WENC_PINB)

Description

WENC_PINB defines the input pin for Phase B of the primary wheel encoder.

In a quadrature encoder, Phase B is offset from Phase A. By comparing the timing of the pulses on these two pins, the autopilot can detect if the wheel is spinning forward or backward.

Tuning & Behavior

  • Default: -1.
  • Direction Fix: If your Rover reports it is moving forward when it is actually reversing, swap the values of WENC_PINA and WENC_PINB in the parameters.

WENC_POS

m
Default 0
Range -5 5

Wheel Encoder Position Offset (WENC_POS)

Description

WENC_POS (often appearing as WENC_POS_X/Y/Z) tells the autopilot exactly where the wheel is located on your frame.

If you are using encoders for high-precision autonomous navigation (like indoor mapping), the autopilot must know if the wheel is at the front, back, or side of the drone. This allows the EKF to correctly translate the wheel's rotation into the movement of the vehicle's center of gravity.

  • X: Positive = Forward.
  • Y: Positive = Right.
  • Z: Positive = Down.

WENC_POS_X

m
Default 0
Range -5 5

Wheel Encoder Position X (WENC_POS_X)

Description

WENC_POS_X defines the forward/backward offset of the wheel relative to the flight controller (or COG).

Accurate positioning helps the EKF account for the "Lever Arm" effect when the vehicle turns.

Tuning & Behavior

  • Default Value: 0 m.

WENC_POS_Y

m
Default 0
Range -5 5

Wheel Encoder Position Y (WENC_POS_Y)

Description

WENC_POS_Y defines the left/right offset of the wheel.

Tuning & Behavior

  • Default Value: 0 m.

WENC_POS_Z

m
Default 0
Range -5 5

Wheel Encoder Position Z (WENC_POS_Z)

Description

WENC_POS_Z defines the vertical offset.

Tuning & Behavior

  • Default Value: 0 m.

WENC_RADIUS

m
Default 0.05
Range 0.001 10.0

Wheel Radius (WENC_RADIUS)

Description

WENC_RADIUS defines the physical size of the wheel being monitored.

This value is used by the autopilot to translate "Wheel Rotations" (from the encoder) into "Meters Traveled" (for the EKF). If this value is incorrect, the drone will have a massive error in its position and speed estimate when relying on odometry.

The Mathematics

$$ \text{Distance} = \text{Rotations} \times 2\pi \times \text{WENC\_RADIUS} $$

Tuning & Behavior

  • Default: 0.05 m (5 cm).
  • Recommendation: Measure the wheel carefully with calipers. Include the tire if applicable.
  • Note: If your Rover is moving 10m in reality but the GCS says 11m, your radius parameter is likely 10% too large.

WENC_TYPE

Default 0
Range 0 10

Wheel Encoder Type (WENC_TYPE)

Description

WENC_TYPE enables the primary wheel encoder.

Wheel encoders provide high-precision distance and velocity measurements by counting the rotations of the vehicle's wheels. This is critical for Rovers operating in GPS-denied environments (Dead Reckoning) or for precise low-speed positioning.

  • 0: None. Disabled.
  • 1: Quadrature. For standard optical or magnetic encoders with A/B signal phases.
  • 10: SITL Quadrature. For simulation testing.

Tuning & Behavior

  • Reboot Required: Yes.
  • Integration: Once enabled, you must also configure the counts per revolution (WENC_CPR) and the wheel radius (WENC_RADIUS).