Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for LTV Unicycle Controller #2792

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

spacey-sooty
Copy link
Contributor

RamseteController was deprecated in wpilibsuite/allwpilib#6494
Does 1 part of #2651

@spacey-sooty spacey-sooty force-pushed the replace-ramsette-with-ltv branch 4 times, most recently from 7921bb9 to ac12f3e Compare October 16, 2024 08:09
RamseteController was deprecated in wpilibsuite/allwpilib#6494
Does 1 part of wpilibsuite#2651

Signed-off-by: Jade Turner <[email protected]>
@spacey-sooty spacey-sooty force-pushed the replace-ramsette-with-ltv branch from ac12f3e to ce8e711 Compare October 16, 2024 08:15
@sciencewhiz sciencewhiz force-pushed the replace-ramsette-with-ltv branch from 7d4f988 to eb547d3 Compare January 3, 2025 04:57
@sciencewhiz sciencewhiz force-pushed the replace-ramsette-with-ltv branch from eb547d3 to e7143e7 Compare January 3, 2025 04:58
@sciencewhiz sciencewhiz marked this pull request as ready for review January 3, 2025 05:07
@sciencewhiz sciencewhiz changed the title Replace trajectories page on Ramsete with LTV Unicycle Add documentation for LTV Unicycle Controller Jan 3, 2025

## Constructing the LTV Unicycle Controller Object

The LTV Unicycle controller should be initialized with four parameters. `qelms` is a vector of the maximum desired error tolerance in the X and Y directions and heading. `relms` is a vector of the desired control effort in linear velocity and angular velocity. `dt` represents the timestep used in calculations (the default loop rate of 20 ms is a reasonable value) and `maxVelocity` should be the max velocity your robot can achieve. See :ref:`The State Space contrl LQR Tuning <docs/software/advanced-controls/state-space/state-space-intro:LQR: tuning>` for more information on the effect of `relms` and `qelms` on the controller.
Copy link
Member

Choose a reason for hiding this comment

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

qelms and relms are misspelled. LTVUnicycleController.java spells them qelems and relems, like "Q elements" and "R elements".


The LTV Unicycle controller should be initialized with four parameters. `qelms` is a vector of the maximum desired error tolerance in the X and Y directions and heading. `relms` is a vector of the desired control effort in linear velocity and angular velocity. `dt` represents the timestep used in calculations (the default loop rate of 20 ms is a reasonable value) and `maxVelocity` should be the max velocity your robot can achieve. See :ref:`The State Space contrl LQR Tuning <docs/software/advanced-controls/state-space/state-space-intro:LQR: tuning>` for more information on the effect of `relms` and `qelms` on the controller.

The code example below initialize the LTV Unicycle Controller with `qelms` of 0.0625 m in X, 0.125 m in Y, and 2 radians in heading; `relms` of 1 m/s of linear velocity, and 2 rad/sec angular velocity; `dt` of 20 ms; and `maxVelocity` of 9 m/s.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The code example below initialize the LTV Unicycle Controller with `qelms` of 0.0625 m in X, 0.125 m in Y, and 2 radians in heading; `relms` of 1 m/s of linear velocity, and 2 rad/sec angular velocity; `dt` of 20 ms; and `maxVelocity` of 9 m/s.
The code example below initializes the LTV Unicycle Controller with `qelms` of 0.0625 m in X, 0.125 m in Y, and 2 radians in heading; `relms` of 1 m/s of linear velocity, and 2 rad/sec angular velocity; `dt` of 20 ms; and `maxVelocity` of 9 m/s.

This should probably justify why the heading tolerance is so large so students don't repeatedly ask about it. It's to allow the y controller (crosstrack error controller) to overpower the heading controller so crosstrack error gets driven to zero.

## Getting Adjusted Velocities
The LTV Unicycle controller returns "adjusted velocities" so that the when the robot tracks these velocities, it accurately reaches the goal point. The controller should be updated periodically with the new goal. The goal comprises of a desired pose, desired linear velocity, and desired angular velocity. Furthermore, the current position of the robot should also be updated periodically. The controller uses these four arguments to return the adjusted linear and angular velocity. Users should command their robot to these linear and angular velocities to achieve optimal trajectory tracking.

.. note:: The "goal pose" represents the position that the robot should be at a particular timestep when tracking the trajectory. It does NOT represent the final endpoint of the trajectory.
Copy link
Member

Choose a reason for hiding this comment

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

This isn't entirely accurate. The trajectory classes define goal to be where the robot should be eventually, and they define reference to be where the robot should be right now.

## Using the Adjusted Velocities
The adjusted velocities are of type ``ChassisSpeeds``, which contains a ``vx`` (linear velocity in the forward direction), a ``vy`` (linear velocity in the sideways direction), and an ``omega`` (angular velocity around the center of the robot frame).

The returned adjusted speeds can be converted to usable speeds using the kinematics classes for your drivetrain type. For example, the adjusted velocities can be converted to left and right velocities for a differential drive using a ``DifferentialDriveKinematics`` object.
Copy link
Member

@calcmogul calcmogul Jan 3, 2025

Choose a reason for hiding this comment

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

We should mention earlier in the article that this controller only applies to nonholonomic drivetrains like differential drive. Holonomic drivetrains can use strictly better controllers like separate decoupled PD controllers, because they don't have to deal with nonholonomic limitations like not being able to move sideways. Using a nonholonomic controller on a holonomic drivetrain unnecessarily makes the feedback response worse.

The LTV Unicycle Controller ([C++](https://github.wpilib.org/allwpilib/docs/release/cpp/classfrc_1_1_l_t_v_unicycle_controller.html), [Java](https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/math/controller/LTVUnicycleController.html), :external:py:class:`Python <wpimath.controller.LTVUnicycleController>`) is a trajectory tracker that is built in to WPILib. This tracker can be used to accurately track trajectories with correction for minor disturbances.

## Constructing the LTV Unicycle Controller Object

Copy link
Contributor

Choose a reason for hiding this comment

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

Control is misspelled in State Space contrl LQR tuning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants