Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,115 @@ The kinematics suite contains classes for differential drive, swerve drive, and
## What is odometry?
Odometry involves using sensors on the robot to create an estimate of the position of the robot on the field. In FRC, these sensors are typically several encoders (the exact number depends on the drive type) and a gyroscope to measure robot angle. The odometry classes utilize the kinematics classes along with periodic user inputs about speeds (and angles in the case of swerve) to create an estimate of the robot's location on the field.

## Why use kinematics and odometry?

Teams should use WPILib's kinematics and odometry classes for several important reasons:

### Enhanced Autonomous Performance

**Accurate path following**: Kinematics and odometry enable your robot to precisely follow complex paths during autonomous. Instead of time-based driving ("go forward for 2 seconds"), your robot can navigate to specific field coordinates and execute sophisticated multi-step autonomous routines.

**Position tracking**: Knowing where your robot is on the field allows you to:

- Drive to specific game pieces or scoring locations
- Dynamically adjust paths based on current position
- Create reliable autonomous routines that work consistently

**Self-correction**: Combined with vision systems (like AprilTag detection), odometry can be continuously updated to correct for drift and maintain accuracy throughout a match.

### Field-Oriented Control
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really related to kinematics and odometry?


For holonomic drivetrains (swerve and mecanum), field-oriented control dramatically improves driver experience:

- Driver joystick inputs remain consistent regardless of robot orientation
- Pushing forward on the joystick always moves toward the opposite alliance station
- Robot can face any direction while moving in any direction
- Significantly reduces driver cognitive load during teleoperation

### Trajectory Generation and Following

Kinematics integrates with WPILib's trajectory generation to create smooth, dynamically-constrained paths:

- Generate realistic trajectories that respect your drivetrain's physical limits
- Follow paths with feedback control for disturbance rejection
- Combine with path planning tools like PathPlanner or Choreo

### Common Use Cases

**Autonomous routines**: Navigate to game pieces, score at specific locations, execute multi-step sequences

**Vision-assisted driving**: Use AprilTags or other vision targets to update odometry and drive to precise field locations

**Teleoperation enhancement**: Field-oriented control for intuitive driving of holonomic robots
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other then gyro, you don't need kinematics or odometry for field oriented control, right?


**Match strategy**: Plan routes that avoid defense, optimize cycle times, coordinate with alliance partners

## When to use each drivetrain type
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels really out of place to talk about drivetrain selection in kinematics/odometry. The drivetrain selection should drive the code, and these characteristics have nothing to do with kinematics or odometry.


### Differential Drive

**Best for:**
- Traditional tank drive, "West Coast Drive", or skid-steer robots
- 6-wheel or 8-wheel configurations with traction wheels
- Teams new to advanced control systems
- When pushing power and traction are priorities

**Characteristics:**
- Cannot strafe (move sideways)
- Must turn to change direction
- High traction and pushing power
- Simpler mechanical design
- Non-holonomic (requires Ramsete controller for path following)

**Example code**: See the RamseteCommand example in :doc:`/docs/software/examples-tutorials/wpilib-examples`

### Swerve Drive

**Best for:**
- Maximum maneuverability and control
- Competitive teams with advanced programming and build experience
- When field-oriented control is desired
- Robots that need to move and rotate independently

**Characteristics:**
- Holonomic (can move in any direction while facing any direction)
- Highest mobility and control
- Most complex mechanically and in software
- Requires precise module control and calibration
- Can use high-traction wheels

**Example code**: See the SwerveBot and SwerveControllerCommand examples in :doc:`/docs/software/examples-tutorials/wpilib-examples`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given wpilibsuite/allwpilib#5098 I'm not sure I'd recommend the WPILib examples.


### Mecanum Drive

**Best for:**
- Teams wanting holonomic drive with simpler mechanics than swerve
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the slipping problem, I think the simpler mechanics is more theoretical then practical

- Robots that benefit from strafing but don't need maximum pushing power
- When compactness is important

**Characteristics:**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do accurate odometry on mecanum? Or do you need vision?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this depends on:

  1. What do you consider accurate? Its tolerances are not good compared to other options but if you need broad strokes movement like in some shooting games it is just fine without.
  2. A dead wheel significantly helps. It adds complexity but not having one can give more inconsistent results
  3. How complex is the movement and at what speeds?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was statements like these that make me question. https://www.chiefdelphi.com/t/end-of-mecanum-drive/433615/119

- Holonomic (can strafe)
- Simpler than swerve mechanically
- Lower pushing power due to mecanum wheel design
- Wheels more prone to wear and slipping
- Slower when strafing than when driving forward (due to 45° roller angle)
- Requires careful weight distribution to keep all wheels on ground

**Example code**: See the MecanumBot and MecanumControllerCommand examples in :doc:`/docs/software/examples-tutorials/wpilib-examples`

## Important considerations

**Odometry drift**: Position estimates accumulate error over time, especially during physical contact with other robots. This is normal and expected. Vision-based corrections (using AprilTags) help maintain accuracy.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Odometry drift**: Position estimates accumulate error over time, especially during physical contact with other robots. This is normal and expected. Vision-based corrections (using AprilTags) help maintain accuracy.
**Odometry drift**: Position estimates accumulate error over time, especially during physical contact with other robots and field elements. This is normal and expected. Vision-based corrections (using AprilTags) help maintain accuracy.


**Sensor requirements**: All kinematics implementations require:
- Encoders for measuring wheel/module speeds and positions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning for mentioning module speeds and positions? Isn't module speed the same as wheel speed and module position is covered below.

- Gyroscope for measuring robot angle (critical for accurate odometry)
- For swerve: absolute encoders for module angles

**Autonomous period accuracy**: Odometry is typically very accurate during autonomous (15 seconds) because there's less robot-to-robot contact. Estimates may drift more during teleoperation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Autonomous period accuracy**: Odometry is typically very accurate during autonomous (15 seconds) because there's less robot-to-robot contact. Estimates may drift more during teleoperation.
**Autonomous period accuracy**: Odometry is typically very accurate during autonomous (15 seconds) because there's less robot-to-robot contact. Estimates may drift more during teleop.

Using language from the manual. TELEOP is in the glossary for "the Teleoperated Period".


**Coordinate system**: WPILib uses a specific coordinate system. See :doc:`/docs/software/basic-programming/coordinate-system` for details.

## The ChassisSpeeds Class
The ``ChassisSpeeds`` object is essential to the new WPILib kinematics and odometry suite. The ``ChassisSpeeds`` object represents the speeds of a robot chassis. This struct has three components:

Expand Down