mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-19 06:21:40 +00:00
Updated swerve module optimizations and moved math to SwerveMath.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!-- Generated by javadoc (17) on Tue Mar 28 10:14:05 CDT 2023 -->
|
||||
<!-- Generated by javadoc (17) on Wed Mar 29 07:20:20 CDT 2023 -->
|
||||
<title>SwerveMath</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="dc.created" content="2023-03-28">
|
||||
<meta name="dc.created" content="2023-03-29">
|
||||
<meta name="description" content="declaration: package: swervelib.math, class: SwerveMath">
|
||||
<meta name="generator" content="javadoc/ClassWriterImpl">
|
||||
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
|
||||
@@ -106,85 +106,105 @@ loadScripts(document, 'script');</script>
|
||||
<div class="table-header col-first">Modifier and Type</div>
|
||||
<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-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#applyDeadband(double,boolean,double)" class="member-name-link">applyDeadband</a><wbr>(double value,
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static void</code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#antiJitter(swervelib.math.SwerveModuleState2,swervelib.math.SwerveModuleState2,double)" class="member-name-link">antiJitter</a><wbr>(<a href="SwerveModuleState2.html" title="class in swervelib.math">SwerveModuleState2</a> moduleState,
|
||||
<a href="SwerveModuleState2.html" title="class in swervelib.math">SwerveModuleState2</a> lastModuleState,
|
||||
double maxSpeed)</code></div>
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Perform anti-jitter within modules if the speed requested is too low.</div>
|
||||
</div>
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#applyDeadband(double,boolean,double)" class="member-name-link">applyDeadband</a><wbr>(double value,
|
||||
boolean scaled,
|
||||
double deadband)</code></div>
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Algebraically apply a deadband using a piece wise function.</div>
|
||||
</div>
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>private static double</code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calcMaxAccel(edu.wpi.first.math.geometry.Rotation2d,java.util.List,double,swervelib.parser.SwerveDriveConfiguration)" class="member-name-link">calcMaxAccel</a><wbr>(edu.wpi.first.math.geometry.Rotation2d angle,
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>private static double</code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calcMaxAccel(edu.wpi.first.math.geometry.Rotation2d,java.util.List,double,swervelib.parser.SwerveDriveConfiguration)" class="member-name-link">calcMaxAccel</a><wbr>(edu.wpi.first.math.geometry.Rotation2d angle,
|
||||
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a><<a href="Matter.html" title="class in swervelib.math">Matter</a>> matter,
|
||||
double robotMass,
|
||||
<a href="../parser/SwerveDriveConfiguration.html" title="class in swervelib.parser">SwerveDriveConfiguration</a> config)</code></div>
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Calculates the maximum acceleration allowed in a direction without tipping the robot.</div>
|
||||
</div>
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calculateAngleKV(double,double,double)" class="member-name-link">calculateAngleKV</a><wbr>(double optimalVoltage,
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calculateAngleKV(double,double,double)" class="member-name-link">calculateAngleKV</a><wbr>(double optimalVoltage,
|
||||
double motorFreeSpeedRPM,
|
||||
double angleGearRatio)</code></div>
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Calculate the angle kV which will be multiplied by the radians per second for the feedforward.</div>
|
||||
</div>
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calculateDegreesPerSteeringRotation(double,double)" class="member-name-link">calculateDegreesPerSteeringRotation</a><wbr>(double angleGearRatio,
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calculateDegreesPerSteeringRotation(double,double)" class="member-name-link">calculateDegreesPerSteeringRotation</a><wbr>(double angleGearRatio,
|
||||
double pulsePerRotation)</code></div>
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Calculate the degrees per steering rotation for the integrated encoder.</div>
|
||||
</div>
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calculateMaxAcceleration(double)" class="member-name-link">calculateMaxAcceleration</a><wbr>(double cof)</code></div>
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calculateMaxAcceleration(double)" class="member-name-link">calculateMaxAcceleration</a><wbr>(double cof)</code></div>
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Calculate the practical maximum acceleration of the robot using the wheel coefficient of friction.</div>
|
||||
</div>
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calculateMaxAcceleration(double,double,double,double,double)" class="member-name-link">calculateMaxAcceleration</a><wbr>(double stallTorqueNm,
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calculateMaxAcceleration(double,double,double,double,double)" class="member-name-link">calculateMaxAcceleration</a><wbr>(double stallTorqueNm,
|
||||
double gearRatio,
|
||||
double moduleCount,
|
||||
double wheelDiameter,
|
||||
double robotMass)</code></div>
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Calculate the maximum theoretical acceleration without friction.</div>
|
||||
</div>
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calculateMaxAngularVelocity(double,double,double)" class="member-name-link">calculateMaxAngularVelocity</a><wbr>(double maxSpeed,
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calculateMaxAngularVelocity(double,double,double)" class="member-name-link">calculateMaxAngularVelocity</a><wbr>(double maxSpeed,
|
||||
double furthestModuleX,
|
||||
double furthestModuleY)</code></div>
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Calculate the maximum angular velocity.</div>
|
||||
</div>
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calculateMetersPerRotation(double,double,double)" class="member-name-link">calculateMetersPerRotation</a><wbr>(double wheelDiameter,
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#calculateMetersPerRotation(double,double,double)" class="member-name-link">calculateMetersPerRotation</a><wbr>(double wheelDiameter,
|
||||
double driveGearRatio,
|
||||
double pulsePerRotation)</code></div>
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Calculate the meters per rotation for the integrated encoder.</div>
|
||||
</div>
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static <a href="../parser/SwerveModuleConfiguration.html" title="class in swervelib.parser">SwerveModuleConfiguration</a></code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#getSwerveModule(swervelib.SwerveModule%5B%5D,boolean,boolean)" class="member-name-link">getSwerveModule</a><wbr>(<a href="../SwerveModule.html" title="class in swervelib">SwerveModule</a>[] modules,
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static <a href="../parser/SwerveModuleConfiguration.html" title="class in swervelib.parser">SwerveModuleConfiguration</a></code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#getSwerveModule(swervelib.SwerveModule%5B%5D,boolean,boolean)" class="member-name-link">getSwerveModule</a><wbr>(<a href="../SwerveModule.html" title="class in swervelib">SwerveModule</a>[] modules,
|
||||
boolean front,
|
||||
boolean left)</code></div>
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Get the fruthest module from center based on the module locations.</div>
|
||||
</div>
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static edu.wpi.first.math.geometry.Translation2d</code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#limitVelocity(edu.wpi.first.math.geometry.Translation2d,edu.wpi.first.math.kinematics.ChassisSpeeds,edu.wpi.first.math.geometry.Pose2d,double,double,java.util.List,swervelib.parser.SwerveDriveConfiguration)" class="member-name-link">limitVelocity</a><wbr>(edu.wpi.first.math.geometry.Translation2d commandedVelocity,
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static edu.wpi.first.math.geometry.Translation2d</code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#limitVelocity(edu.wpi.first.math.geometry.Translation2d,edu.wpi.first.math.kinematics.ChassisSpeeds,edu.wpi.first.math.geometry.Pose2d,double,double,java.util.List,swervelib.parser.SwerveDriveConfiguration)" class="member-name-link">limitVelocity</a><wbr>(edu.wpi.first.math.geometry.Translation2d commandedVelocity,
|
||||
edu.wpi.first.math.kinematics.ChassisSpeeds fieldVelocity,
|
||||
edu.wpi.first.math.geometry.Pose2d robotPose,
|
||||
double loopTime,
|
||||
double robotMass,
|
||||
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a><<a href="Matter.html" title="class in swervelib.math">Matter</a>> matter,
|
||||
<a href="../parser/SwerveDriveConfiguration.html" title="class in swervelib.parser">SwerveDriveConfiguration</a> config)</code></div>
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Limits a commanded velocity to prevent exceeding the maximum acceleration given by <a href="#calcMaxAccel(edu.wpi.first.math.geometry.Rotation2d,java.util.List,double,swervelib.parser.SwerveDriveConfiguration)"><code>calcMaxAccel(edu.wpi.first.math.geometry.Rotation2d, java.util.List<swervelib.math.Matter>, double, swervelib.parser.SwerveDriveConfiguration)</code></a>.</div>
|
||||
</div>
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#normalizeAngle(double)" class="member-name-link">normalizeAngle</a><wbr>(double angle)</code></div>
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#normalizeAngle(double)" class="member-name-link">normalizeAngle</a><wbr>(double angle)</code></div>
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Normalize an angle to be within 0 to 360.</div>
|
||||
</div>
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static <a href="SwerveModuleState2.html" title="class in swervelib.math">SwerveModuleState2</a></code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#optimize(swervelib.math.SwerveModuleState2,edu.wpi.first.math.geometry.Rotation2d,double)" class="member-name-link">optimize</a><wbr>(<a href="SwerveModuleState2.html" title="class in swervelib.math">SwerveModuleState2</a> desiredState,
|
||||
edu.wpi.first.math.geometry.Rotation2d currentAngle,
|
||||
double secondOrderOffsetDegrees)</code></div>
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Optimize the angle of the <a href="SwerveModuleState2.html" title="class in swervelib.math"><code>SwerveModuleState2</code></a> to be the closest angle to the current angle.</div>
|
||||
</div>
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#placeInAppropriate0To360Scope(double,double)" class="member-name-link">placeInAppropriate0To360Scope</a><wbr>(double scopeReference,
|
||||
double newAngle)</code></div>
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
|
||||
<div class="block">Put an angle within the 360 deg scope of a reference.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -415,6 +435,55 @@ loadScripts(document, 'script');</script>
|
||||
</dl>
|
||||
</section>
|
||||
</li>
|
||||
<li>
|
||||
<section class="detail" id="optimize(swervelib.math.SwerveModuleState2,edu.wpi.first.math.geometry.Rotation2d,double)">
|
||||
<h3>optimize</h3>
|
||||
<div class="member-signature"><span class="modifiers">public static</span> <span class="return-type"><a href="SwerveModuleState2.html" title="class in swervelib.math">SwerveModuleState2</a></span> <span class="element-name">optimize</span><wbr><span class="parameters">(<a href="SwerveModuleState2.html" title="class in swervelib.math">SwerveModuleState2</a> desiredState,
|
||||
edu.wpi.first.math.geometry.Rotation2d currentAngle,
|
||||
double secondOrderOffsetDegrees)</span></div>
|
||||
<div class="block">Optimize the angle of the <a href="SwerveModuleState2.html" title="class in swervelib.math"><code>SwerveModuleState2</code></a> to be the closest angle to the current angle. Taken from <a href="https://github.com/pittsfordrobotics/REVSwerve2023/blob/master/src/main/java/com/team3181/lib/swerve
|
||||
/SwerveOptimizer.java">Team 3181.</a></div>
|
||||
<dl class="notes">
|
||||
<dt>Parameters:</dt>
|
||||
<dd><code>desiredState</code> - Desired <a href="SwerveModuleState2.html" title="class in swervelib.math"><code>SwerveModuleState2</code></a> to achieve.</dd>
|
||||
<dd><code>currentAngle</code> - Current angle as a <code>Rotation2d</code>.</dd>
|
||||
<dd><code>secondOrderOffsetDegrees</code> - Offset calculated using 2nd order kinematics.</dd>
|
||||
<dt>Returns:</dt>
|
||||
<dd>Optimized <a href="SwerveModuleState2.html" title="class in swervelib.math"><code>SwerveModuleState2</code></a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
</li>
|
||||
<li>
|
||||
<section class="detail" id="placeInAppropriate0To360Scope(double,double)">
|
||||
<h3>placeInAppropriate0To360Scope</h3>
|
||||
<div class="member-signature"><span class="modifiers">public static</span> <span class="return-type">double</span> <span class="element-name">placeInAppropriate0To360Scope</span><wbr><span class="parameters">(double scopeReference,
|
||||
double newAngle)</span></div>
|
||||
<div class="block">Put an angle within the 360 deg scope of a reference. For example, given a scope reference of 756 degrees, assumes
|
||||
the full scope is (720-1080), and places an angle of 22 degrees into it, returning 742 deg.</div>
|
||||
<dl class="notes">
|
||||
<dt>Parameters:</dt>
|
||||
<dd><code>scopeReference</code> - Current Angle (deg)</dd>
|
||||
<dd><code>newAngle</code> - Target Angle (deg)</dd>
|
||||
<dt>Returns:</dt>
|
||||
<dd>Closest angle within scope (deg)</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</li>
|
||||
<li>
|
||||
<section class="detail" id="antiJitter(swervelib.math.SwerveModuleState2,swervelib.math.SwerveModuleState2,double)">
|
||||
<h3>antiJitter</h3>
|
||||
<div class="member-signature"><span class="modifiers">public static</span> <span class="return-type">void</span> <span class="element-name">antiJitter</span><wbr><span class="parameters">(<a href="SwerveModuleState2.html" title="class in swervelib.math">SwerveModuleState2</a> moduleState,
|
||||
<a href="SwerveModuleState2.html" title="class in swervelib.math">SwerveModuleState2</a> lastModuleState,
|
||||
double maxSpeed)</span></div>
|
||||
<div class="block">Perform anti-jitter within modules if the speed requested is too low.</div>
|
||||
<dl class="notes">
|
||||
<dt>Parameters:</dt>
|
||||
<dd><code>moduleState</code> - Current <a href="SwerveModuleState2.html" title="class in swervelib.math"><code>SwerveModuleState2</code></a> requested.</dd>
|
||||
<dd><code>lastModuleState</code> - Previous <a href="SwerveModuleState2.html" title="class in swervelib.math"><code>SwerveModuleState2</code></a> used.</dd>
|
||||
<dd><code>maxSpeed</code> - Maximum speed of the modules, should be in <a href="../parser/SwerveDriveConfiguration.html#maxSpeed"><code>SwerveDriveConfiguration.maxSpeed</code></a>.</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user