Skip to content

Commit

Permalink
Add more details to motion profiling article
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold856 committed Oct 7, 2024
1 parent f8b3afd commit d02baa5
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ The following examples are taken from the DriveDistanceOffboard example project

There are two commands in this example. They function very similarly, with the main difference being that one resets encoders, and the other doesn't, which allows encoder data to be preserved.

The subsystem contains a ``TrapezoidProfile`` with a ``Timer``. The timer is used along with a ``kDt`` constant of 0.02 seconds to calculate the current and next states from the ``TrapezoidProfile``. The current state is fed to the "smart" motor controller for PID control, while the current and next state are used to calculate feedforward outputs. Both commands end when ``isFinished(0)`` returns true, which means that the profile has reached the goal state.
The ``DriveSubsystem`` contains a ``TrapezoidProfile`` and a ``Timer``. The ``startRun`` command factory is used, with the first lambda being run when the command is scheduled. It restarts the timer, and for ``profiledDriveDistance``, it resets the encoders; for ``dynamicProfiledDriveDistance``, it sets the initial distances for the left and right encoders. The second lambda passed into ``startRun`` will repeatedly run while the command is scheduled. Inside the lambda, the timer is used along with a ``kDt`` constant of 0.02 seconds to calculate the current and next states from the ``TrapezoidProfile``. The current state is fed to the "smart" motor controller for PID control, while the current and next state are used to calculate feedforward outputs. The ``until`` decorator is used after the ``startRun`` command factory to end the command when ``isFinished(0)`` returns true, which means that the profile has reached the goal state.

0 comments on commit d02baa5

Please sign in to comment.