Skip to content

Commit

Permalink
[wpimath] improve LTVUnicycleController docs (NFC)
Browse files Browse the repository at this point in the history
Document the states and inputs so it isn't necessary to look at the code
Fix max velocity throws doc
  • Loading branch information
sciencewhiz committed Dec 28, 2024
1 parent 0470e51 commit ad5d57b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ private enum State {

/**
* Constructs a linear time-varying unicycle controller with default maximum desired error
* tolerances of (0.0625 m, 0.125 m, 2 rad) and default maximum desired control effort of (1 m/s,
* 2 rad/s).
* tolerances of (x = 0.0625 m, y = 0.125 m, heading = 2 rad), default maximum desired control
* effort of (linear velocity = 1 m/s, angular velocity = 2 rad/s), and default maximum Velocity
* of 9 m/s.
*
* @param dt Discretization timestep in seconds.
*/
Expand All @@ -65,13 +66,13 @@ public LTVUnicycleController(double dt) {

/**
* Constructs a linear time-varying unicycle controller with default maximum desired error
* tolerances of (0.0625 m, 0.125 m, 2 rad) and default maximum desired control effort of (1 m/s,
* 2 rad/s).
* tolerances of (x = 0.0625 m, y = 0.125 m, heading = 2 rad), default maximum desired control
* effort of (1 m/s, 2 rad/s).
*
* @param dt Discretization timestep in seconds.
* @param maxVelocity The maximum velocity in meters per second for the controller gain lookup
* table. The default is 9 m/s.
* @throws IllegalArgumentException if maxVelocity <= 0.
* @throws IllegalArgumentException if maxVelocity <= 0 m/s or >= 15 m/s.
*/
public LTVUnicycleController(double dt, double maxVelocity) {
this(VecBuilder.fill(0.0625, 0.125, 2.0), VecBuilder.fill(1.0, 2.0), dt, maxVelocity);
Expand All @@ -84,8 +85,11 @@ public LTVUnicycleController(double dt, double maxVelocity) {
* href="https://docs.wpilib.org/en/stable/docs/software/advanced-controls/state-space/state-space-intro.html#lqr-tuning">https://docs.wpilib.org/en/stable/docs/software/advanced-controls/state-space/state-space-intro.html#lqr-tuning</a>
* for how to select the tolerances.
*
* @param qelems The maximum desired error tolerance for each state.
* @param relems The maximum desired control effort for each input.
* <p>The default maximum Velocity is 9 m/s.
*
* @param qelems The maximum desired error tolerance for each state (x, y, heading).
* @param relems The maximum desired control effort for each input (linear velocity, angular
* velocity).
* @param dt Discretization timestep in seconds.
*/
public LTVUnicycleController(Vector<N3> qelems, Vector<N2> relems, double dt) {
Expand All @@ -99,8 +103,9 @@ public LTVUnicycleController(Vector<N3> qelems, Vector<N2> relems, double dt) {
* href="https://docs.wpilib.org/en/stable/docs/software/advanced-controls/state-space/state-space-intro.html#lqr-tuning">https://docs.wpilib.org/en/stable/docs/software/advanced-controls/state-space/state-space-intro.html#lqr-tuning</a>
* for how to select the tolerances.
*
* @param qelems The maximum desired error tolerance for each state.
* @param relems The maximum desired control effort for each input.
* @param qelems The maximum desired error tolerance for each state (x, y, heading).
* @param relems The maximum desired control effort for each input (linear velocity, angular
* velocity).
* @param dt Discretization timestep in seconds.
* @param maxVelocity The maximum velocity in meters per second for the controller gain lookup
* table. The default is 9 m/s.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ class WPILIB_DLLEXPORT LTVUnicycleController {
public:
/**
* Constructs a linear time-varying unicycle controller with default maximum
* desired error tolerances of (0.0625 m, 0.125 m, 2 rad) and default maximum
* desired control effort of (1 m/s, 2 rad/s).
* desired error tolerances of (x = 0.0625 m, y = 0.125 m, heading = 2 rad)
* and default maximum desired control effort of (linear velocity = 1 m/s,
* angular velocity = 2 rad/s).
*
* @param dt Discretization timestep.
* @param maxVelocity The maximum velocity for the controller gain lookup
* table.
* @throws std::domain_error if maxVelocity &lt;= 0.
* @throws std::domain_error if maxVelocity <= 0 m/s or >= 15 m/s.
*/
explicit LTVUnicycleController(
units::second_t dt, units::meters_per_second_t maxVelocity = 9_mps);
Expand All @@ -51,8 +52,10 @@ class WPILIB_DLLEXPORT LTVUnicycleController {
* https://docs.wpilib.org/en/stable/docs/software/advanced-controls/state-space/state-space-intro.html#lqr-tuning
* for how to select the tolerances.
*
* @param Qelems The maximum desired error tolerance for each state.
* @param Relems The maximum desired control effort for each input.
* @param Qelems The maximum desired error tolerance for each state (x, y,
* heading).
* @param Relems The maximum desired control effort for each input (linear
* velocity, angular velocity).
* @param dt Discretization timestep.
* @param maxVelocity The maximum velocity for the controller gain lookup
* table.
Expand Down

0 comments on commit ad5d57b

Please sign in to comment.