Updated docs, renamed SwerveDrive lock function and setBrake function

This commit is contained in:
thenetworkgrinch
2023-02-15 22:18:27 -06:00
parent e4436b5ed2
commit e8f6ca3659
111 changed files with 3086 additions and 384 deletions

View File

@@ -1,7 +1,7 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<!-- Generated by javadoc (17) on Wed Feb 15 00:08:08 CST 2023 -->
<!-- Generated by javadoc (17) on Wed Feb 15 22:17:49 CST 2023 -->
<title>SwerveDrive</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@@ -91,30 +91,30 @@ loadScripts(document, 'script');</script>
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Field</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color"><code>private double</code></div>
<div class="col-second even-row-color"><code><a href="#angle" class="member-name-link">angle</a></code></div>
<div class="col-first even-row-color"><code>edu.wpi.first.wpilibj.smartdashboard.Field2d</code></div>
<div class="col-second even-row-color"><code><a href="#field" class="member-name-link">field</a></code></div>
<div class="col-last even-row-color">
<div class="block">The current angle of the robot and last time odometry during simulations.</div>
</div>
<div class="col-first odd-row-color"><code>edu.wpi.first.wpilibj.smartdashboard.Field2d</code></div>
<div class="col-second odd-row-color"><code><a href="#field" class="member-name-link">field</a></code></div>
<div class="col-last odd-row-color">
<div class="block">Field object.</div>
</div>
<div class="col-first even-row-color"><code>private <a href="imu/SwerveIMU.html" title="class in swervelib.imu">SwerveIMU</a></code></div>
<div class="col-second even-row-color"><code><a href="#imu" class="member-name-link">imu</a></code></div>
<div class="col-last even-row-color">
<div class="col-first odd-row-color"><code>private <a href="imu/SwerveIMU.html" title="class in swervelib.imu">SwerveIMU</a></code></div>
<div class="col-second odd-row-color"><code><a href="#imu" class="member-name-link">imu</a></code></div>
<div class="col-last odd-row-color">
<div class="block">Swerve IMU device for sensing the heading of the robot.</div>
</div>
<div class="col-first odd-row-color"><code>final <a href="math/SwerveKinematics2.html" title="class in swervelib.math">SwerveKinematics2</a></code></div>
<div class="col-second odd-row-color"><code><a href="#kinematics" class="member-name-link">kinematics</a></code></div>
<div class="col-last odd-row-color">
<div class="col-first even-row-color"><code>final <a href="math/SwerveKinematics2.html" title="class in swervelib.math">SwerveKinematics2</a></code></div>
<div class="col-second even-row-color"><code><a href="#kinematics" class="member-name-link">kinematics</a></code></div>
<div class="col-last even-row-color">
<div class="block">Swerve Kinematics object utilizing second order kinematics.</div>
</div>
<div class="col-first even-row-color"><code>private double</code></div>
<div class="col-second even-row-color"><code><a href="#lastTime" class="member-name-link">lastTime</a></code></div>
<div class="col-first odd-row-color"><code>private int</code></div>
<div class="col-second odd-row-color"><code><a href="#moduleSynchronizationCounter" class="member-name-link">moduleSynchronizationCounter</a></code></div>
<div class="col-last odd-row-color">
<div class="block">Counter to synchronize the modules relative encoder with absolute encoder when not moving.</div>
</div>
<div class="col-first even-row-color"><code>private <a href="simulation/SwerveIMUSimulation.html" title="class in swervelib.simulation">SwerveIMUSimulation</a></code></div>
<div class="col-second even-row-color"><code><a href="#simIMU" class="member-name-link">simIMU</a></code></div>
<div class="col-last even-row-color">
<div class="block">The current angle of the robot and last time odometry during simulations.</div>
<div class="block">Simulation of the swerve drive.</div>
</div>
<div class="col-first odd-row-color"><code><a href="SwerveController.html" title="class in swervelib">SwerveController</a></code></div>
<div class="col-second odd-row-color"><code><a href="#swerveController" class="member-name-link">swerveController</a></code></div>
@@ -136,11 +136,6 @@ loadScripts(document, 'script');</script>
<div class="col-last even-row-color">
<div class="block">Swerve modules.</div>
</div>
<div class="col-first odd-row-color"><code>private edu.wpi.first.wpilibj.Timer</code></div>
<div class="col-second odd-row-color"><code><a href="#timer" class="member-name-link">timer</a></code></div>
<div class="col-last odd-row-color">
<div class="block">Time during simulations.</div>
</div>
</div>
</section>
</li>
@@ -172,11 +167,12 @@ loadScripts(document, 'script');</script>
<div class="table-header col-second">Method</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#addVisionMeasurement(edu.wpi.first.math.geometry.Pose2d,double)" class="member-name-link">addVisionMeasurement</a><wbr>(edu.wpi.first.math.geometry.Pose2d&nbsp;robotPose,
double&nbsp;timestamp)</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#addVisionMeasurement(edu.wpi.first.math.geometry.Pose2d,double,boolean)" class="member-name-link">addVisionMeasurement</a><wbr>(edu.wpi.first.math.geometry.Pose2d&nbsp;robotPose,
double&nbsp;timestamp,
boolean&nbsp;soft)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Add a vision measurement to the <code>SwerveDrivePoseEstimator</code> with the given timestamp of the vision
measurement.</div>
<div class="block">Add a vision measurement to the <code>SwerveDrivePoseEstimator</code> and update the <a href="imu/SwerveIMU.html" title="class in swervelib.imu"><code>SwerveIMU</code></a> gyro reading with
the given timestamp of the vision measurement.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#drive(edu.wpi.first.math.geometry.Translation2d,double,boolean,boolean)" class="member-name-link">drive</a><wbr>(edu.wpi.first.math.geometry.Translation2d&nbsp;translation,
@@ -194,7 +190,7 @@ loadScripts(document, 'script');</script>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>edu.wpi.first.math.geometry.Rotation3d</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getGyroRotation3d()" class="member-name-link">getGyroRotation3d</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Gets the current gyro Rotation3d of the robot, as reported by the imu.</div>
<div class="block">Gets the current gyro <code>Rotation3d</code> of the robot, as reported by the imu.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>edu.wpi.first.math.kinematics.SwerveModulePosition[]</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getModulePositions()" class="member-name-link">getModulePositions</a>()</code></div>
@@ -237,31 +233,31 @@ loadScripts(document, 'script');</script>
<div class="block">Gets the current yaw angle of the robot, as reported by the imu.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#postTrajectory(edu.wpi.first.math.trajectory.Trajectory)" class="member-name-link">postTrajectory</a><wbr>(edu.wpi.first.math.trajectory.Trajectory&nbsp;trajectory)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Post the trajectory to the field</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#replaceSwerveModuleFeedforward(edu.wpi.first.math.controller.SimpleMotorFeedforward)" class="member-name-link">replaceSwerveModuleFeedforward</a><wbr>(edu.wpi.first.math.controller.SimpleMotorFeedforward&nbsp;feedforward)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Setup the swerve module feedforward.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#resetOdometry(edu.wpi.first.math.geometry.Pose2d)" class="member-name-link">resetOdometry</a><wbr>(edu.wpi.first.math.geometry.Pose2d&nbsp;pose)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Resets odometry to the given pose.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#setChassisSpeeds(edu.wpi.first.math.kinematics.ChassisSpeeds)" class="member-name-link">setChassisSpeeds</a><wbr>(edu.wpi.first.math.kinematics.ChassisSpeeds&nbsp;chassisSpeeds)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Set chassis speeds with closed-loop velocity control.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#setDriveBrake()" class="member-name-link">setDriveBrake</a>()</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#lockPose()" class="member-name-link">lockPose</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Point all modules toward the robot center, thus making the robot very difficult to move.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#postTrajectory(edu.wpi.first.math.trajectory.Trajectory)" class="member-name-link">postTrajectory</a><wbr>(edu.wpi.first.math.trajectory.Trajectory&nbsp;trajectory)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Post the trajectory to the field</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#replaceSwerveModuleFeedforward(edu.wpi.first.math.controller.SimpleMotorFeedforward)" class="member-name-link">replaceSwerveModuleFeedforward</a><wbr>(edu.wpi.first.math.controller.SimpleMotorFeedforward&nbsp;feedforward)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Setup the swerve module feedforward.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#resetOdometry(edu.wpi.first.math.geometry.Pose2d)" class="member-name-link">resetOdometry</a><wbr>(edu.wpi.first.math.geometry.Pose2d&nbsp;pose)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Resets odometry to the given pose.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#setChassisSpeeds(edu.wpi.first.math.kinematics.ChassisSpeeds)" class="member-name-link">setChassisSpeeds</a><wbr>(edu.wpi.first.math.kinematics.ChassisSpeeds&nbsp;chassisSpeeds)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Set chassis speeds with closed-loop velocity control.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#setModuleStates(swervelib.math.SwerveModuleState2%5B%5D,boolean)" class="member-name-link">setModuleStates</a><wbr>(<a href="math/SwerveModuleState2.html" title="class in swervelib.math">SwerveModuleState2</a>[]&nbsp;desiredStates,
boolean&nbsp;isOpenLoop)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
@@ -354,24 +350,17 @@ loadScripts(document, 'script');</script>
</section>
</li>
<li>
<section class="detail" id="angle">
<h3>angle</h3>
<div class="member-signature"><span class="modifiers">private</span>&nbsp;<span class="return-type">double</span>&nbsp;<span class="element-name">angle</span></div>
<div class="block">The current angle of the robot and last time odometry during simulations.</div>
<section class="detail" id="simIMU">
<h3>simIMU</h3>
<div class="member-signature"><span class="modifiers">private</span>&nbsp;<span class="return-type"><a href="simulation/SwerveIMUSimulation.html" title="class in swervelib.simulation">SwerveIMUSimulation</a></span>&nbsp;<span class="element-name">simIMU</span></div>
<div class="block">Simulation of the swerve drive.</div>
</section>
</li>
<li>
<section class="detail" id="lastTime">
<h3>lastTime</h3>
<div class="member-signature"><span class="modifiers">private</span>&nbsp;<span class="return-type">double</span>&nbsp;<span class="element-name">lastTime</span></div>
<div class="block">The current angle of the robot and last time odometry during simulations.</div>
</section>
</li>
<li>
<section class="detail" id="timer">
<h3>timer</h3>
<div class="member-signature"><span class="modifiers">private</span>&nbsp;<span class="return-type">edu.wpi.first.wpilibj.Timer</span>&nbsp;<span class="element-name">timer</span></div>
<div class="block">Time during simulations.</div>
<section class="detail" id="moduleSynchronizationCounter">
<h3>moduleSynchronizationCounter</h3>
<div class="member-signature"><span class="modifiers">private</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name">moduleSynchronizationCounter</span></div>
<div class="block">Counter to synchronize the modules relative encoder with absolute encoder when not moving.</div>
</section>
</li>
</ul>
@@ -387,10 +376,11 @@ loadScripts(document, 'script');</script>
<h3>SwerveDrive</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="element-name">SwerveDrive</span><wbr><span class="parameters">(<a href="parser/SwerveDriveConfiguration.html" title="class in swervelib.parser">SwerveDriveConfiguration</a>&nbsp;config,
<a href="parser/SwerveControllerConfiguration.html" title="class in swervelib.parser">SwerveControllerConfiguration</a>&nbsp;controllerConfig)</span></div>
<div class="block">Creates a new swerve drivebase subsystem. Robot is controlled via the drive() method, or via the setModuleStates()
method. The drive() method incorporates kinematics— it takes a translation and rotation, as well as parameters for
field-centric and closed-loop velocity control. setModuleStates() takes a list of SwerveModuleStates and directly
passes them to the modules. This subsystem also handles odometry.</div>
<div class="block">Creates a new swerve drivebase subsystem. Robot is controlled via the <a href="#drive(edu.wpi.first.math.geometry.Translation2d,double,boolean,boolean)"><code>drive(edu.wpi.first.math.geometry.Translation2d, double, boolean, boolean)</code></a> method, or via the
<a href="#setModuleStates(swervelib.math.SwerveModuleState2%5B%5D,boolean)"><code>setModuleStates(swervelib.math.SwerveModuleState2[], boolean)</code></a> method. The <a href="#drive(edu.wpi.first.math.geometry.Translation2d,double,boolean,boolean)"><code>drive(edu.wpi.first.math.geometry.Translation2d, double, boolean, boolean)</code></a> method incorporates kinematics— it takes
a translation and rotation, as well as parameters for field-centric and closed-loop velocity control.
<a href="#setModuleStates(swervelib.math.SwerveModuleState2%5B%5D,boolean)"><code>setModuleStates(swervelib.math.SwerveModuleState2[], boolean)</code></a> takes a list of SwerveModuleStates and directly passes them to the modules.
This subsystem also handles odometry.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>config</code> - The <a href="parser/SwerveDriveConfiguration.html" title="class in swervelib.parser"><code>SwerveDriveConfiguration</code></a> configuration to base the swerve drive off of.</dd>
@@ -578,7 +568,7 @@ loadScripts(document, 'script');</script>
<section class="detail" id="getGyroRotation3d()">
<h3>getGyroRotation3d</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">edu.wpi.first.math.geometry.Rotation3d</span>&nbsp;<span class="element-name">getGyroRotation3d</span>()</div>
<div class="block">Gets the current gyro Rotation3d of the robot, as reported by the imu.</div>
<div class="block">Gets the current gyro <code>Rotation3d</code> of the robot, as reported by the imu.</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>The heading as a <code>Rotation3d</code> angle</dd>
@@ -597,10 +587,11 @@ loadScripts(document, 'script');</script>
</section>
</li>
<li>
<section class="detail" id="setDriveBrake()">
<h3>setDriveBrake</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">setDriveBrake</span>()</div>
<div class="block">Point all modules toward the robot center, thus making the robot very difficult to move.</div>
<section class="detail" id="lockPose()">
<h3>lockPose</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">lockPose</span>()</div>
<div class="block">Point all modules toward the robot center, thus making the robot very difficult to move. Forcing the robot to keep
the current pose.</div>
</section>
</li>
<li>
@@ -631,7 +622,9 @@ loadScripts(document, 'script');</script>
<section class="detail" id="updateOdometry()">
<h3>updateOdometry</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">updateOdometry</span>()</div>
<div class="block">Update odometry should be run every loop.</div>
<div class="block">Update odometry should be run every loop. Synchronizes module absolute encoders with relative encoders
periodically. In simulation mode will also post the pose of each module. Updates SmartDashboard with module encoder
readings and states.</div>
</section>
</li>
<li>
@@ -642,17 +635,22 @@ loadScripts(document, 'script');</script>
</section>
</li>
<li>
<section class="detail" id="addVisionMeasurement(edu.wpi.first.math.geometry.Pose2d,double)">
<section class="detail" id="addVisionMeasurement(edu.wpi.first.math.geometry.Pose2d,double,boolean)">
<h3>addVisionMeasurement</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">addVisionMeasurement</span><wbr><span class="parameters">(edu.wpi.first.math.geometry.Pose2d&nbsp;robotPose,
double&nbsp;timestamp)</span></div>
<div class="block">Add a vision measurement to the <code>SwerveDrivePoseEstimator</code> with the given timestamp of the vision
measurement. <b>THIS WILL BREAK IF UPDATED TOO OFTEN.</b></div>
double&nbsp;timestamp,
boolean&nbsp;soft)</span></div>
<div class="block">Add a vision measurement to the <code>SwerveDrivePoseEstimator</code> and update the <a href="imu/SwerveIMU.html" title="class in swervelib.imu"><code>SwerveIMU</code></a> gyro reading with
the given timestamp of the vision measurement. <b>THIS WILL BREAK IF UPDATED TOO OFTEN.</b></div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>robotPose</code> - Robot <code>Pose2d</code> as measured by vision.</dd>
<dd><code>timestamp</code> - Timestamp the measurement was taken as time since FPGATimestamp, could be taken from
<code>Timer.getFPGATimestamp()</code>.</dd>
<dd><code>timestamp</code> - Timestamp the measurement was taken as time since startup, should be taken from
<code>Timer.getFPGATimestamp()</code> or similar sources.</dd>
<dd><code>soft</code> - Add vision estimate using the
<code>SwerveDrivePoseEstimator.addVisionMeasurement(Pose2d, double)</code> function, or hard reset
odometry with the given position with
<code>SwerveDriveOdometry.resetPosition(Rotation2d, SwerveModulePosition[], Pose2d)</code>.</dd>
</dl>
</section>
</li>