Added matter calculator

This commit is contained in:
thenetworkgrinch
2023-02-24 22:10:33 -06:00
parent 69edd17103
commit 4651cccb8e
112 changed files with 535 additions and 257 deletions

View File

@@ -1,7 +1,7 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<!-- Generated by javadoc (17) on Fri Feb 24 19:09:47 CST 2023 -->
<!-- Generated by javadoc (17) on Fri Feb 24 22:08:26 CST 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">
@@ -114,10 +114,9 @@ loadScripts(document, 'script');</script>
<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,double,double,edu.wpi.first.math.geometry.Translation3d,swervelib.parser.SwerveDriveConfiguration)" class="member-name-link">calcMaxAccel</a><wbr>(edu.wpi.first.math.geometry.Rotation2d&nbsp;angle,
double&nbsp;chassisMass,
<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&nbsp;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>&lt;<a href="Matter.html" title="class in swervelib.math">Matter</a>&gt;&nbsp;matter,
double&nbsp;robotMass,
edu.wpi.first.math.geometry.Translation3d&nbsp;chassisCenterOfGravity,
<a href="../parser/SwerveDriveConfiguration.html" title="class in swervelib.parser">SwerveDriveConfiguration</a>&nbsp;config)</code></div>
<div class="col-last odd-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>
@@ -171,17 +170,15 @@ loadScripts(document, 'script');</script>
<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,double,edu.wpi.first.math.geometry.Translation3d,swervelib.parser.SwerveDriveConfiguration)" class="member-name-link">limitVelocity</a><wbr>(edu.wpi.first.math.geometry.Translation2d&nbsp;commandedVelocity,
<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&nbsp;commandedVelocity,
edu.wpi.first.math.kinematics.ChassisSpeeds&nbsp;fieldVelocity,
edu.wpi.first.math.geometry.Pose2d&nbsp;robotPose,
double&nbsp;loopTime,
double&nbsp;chassisMass,
double&nbsp;robotMass,
edu.wpi.first.math.geometry.Translation3d&nbsp;chassisCenterOfGravity,
<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>&lt;<a href="Matter.html" title="class in swervelib.math">Matter</a>&gt;&nbsp;matter,
<a href="../parser/SwerveDriveConfiguration.html" title="class in swervelib.parser">SwerveDriveConfiguration</a>&nbsp;config)</code></div>
<div class="col-last odd-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,double,double,edu.wpi.first.math.geometry.Translation3d,swervelib.parser.SwerveDriveConfiguration)"><code>calcMaxAccel(Rotation2d, double, double, Translation3d, SwerveDriveConfiguration)</code></a>.</div>
<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&lt;swervelib.math.Matter&gt;, 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&nbsp;angle)</code></div>
@@ -353,22 +350,20 @@ loadScripts(document, 'script');</script>
</section>
</li>
<li>
<section class="detail" id="calcMaxAccel(edu.wpi.first.math.geometry.Rotation2d,double,double,edu.wpi.first.math.geometry.Translation3d,swervelib.parser.SwerveDriveConfiguration)">
<section class="detail" id="calcMaxAccel(edu.wpi.first.math.geometry.Rotation2d,java.util.List,double,swervelib.parser.SwerveDriveConfiguration)">
<h3>calcMaxAccel</h3>
<div class="member-signature"><span class="modifiers">private static</span>&nbsp;<span class="return-type">double</span>&nbsp;<span class="element-name">calcMaxAccel</span><wbr><span class="parameters">(edu.wpi.first.math.geometry.Rotation2d&nbsp;angle,
double&nbsp;chassisMass,
<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>&lt;<a href="Matter.html" title="class in swervelib.math">Matter</a>&gt;&nbsp;matter,
double&nbsp;robotMass,
edu.wpi.first.math.geometry.Translation3d&nbsp;chassisCenterOfGravity,
<a href="../parser/SwerveDriveConfiguration.html" title="class in swervelib.parser">SwerveDriveConfiguration</a>&nbsp;config)</span></div>
<div class="block">Calculates the maximum acceleration allowed in a direction without tipping the robot. Reads arm position from
NetworkTables and is passed the direction in question.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>angle</code> - The direction in which to calculate max acceleration, as a Rotation2d. Note that this
is robot-relative.</dd>
<dd><code>chassisMass</code> - Chassis mass in kg. (The weight of just the chassis not anything else)</dd>
<dd><code>angle</code> - The direction in which to calculate max acceleration, as a Rotation2d. Note that this is
robot-relative.</dd>
<dd><code>matter</code> - Matter that the robot is composed of in kg. (Includes chassis)</dd>
<dd><code>robotMass</code> - The weight of the robot in kg. (Including manipulators, etc).</dd>
<dd><code>chassisCenterOfGravity</code> - Chassis center of gravity.</dd>
<dd><code>config</code> - The swerve drive configuration.</dd>
<dt>Returns:</dt>
<dd>Maximum acceleration allowed in the robot direction.</dd>
@@ -376,29 +371,26 @@ loadScripts(document, 'script');</script>
</section>
</li>
<li>
<section class="detail" id="limitVelocity(edu.wpi.first.math.geometry.Translation2d,edu.wpi.first.math.kinematics.ChassisSpeeds,edu.wpi.first.math.geometry.Pose2d,double,double,double,edu.wpi.first.math.geometry.Translation3d,swervelib.parser.SwerveDriveConfiguration)">
<section class="detail" id="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)">
<h3>limitVelocity</h3>
<div class="member-signature"><span class="modifiers">public static</span>&nbsp;<span class="return-type">edu.wpi.first.math.geometry.Translation2d</span>&nbsp;<span class="element-name">limitVelocity</span><wbr><span class="parameters">(edu.wpi.first.math.geometry.Translation2d&nbsp;commandedVelocity,
edu.wpi.first.math.kinematics.ChassisSpeeds&nbsp;fieldVelocity,
edu.wpi.first.math.geometry.Pose2d&nbsp;robotPose,
double&nbsp;loopTime,
double&nbsp;chassisMass,
double&nbsp;robotMass,
edu.wpi.first.math.geometry.Translation3d&nbsp;chassisCenterOfGravity,
<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>&lt;<a href="Matter.html" title="class in swervelib.math">Matter</a>&gt;&nbsp;matter,
<a href="../parser/SwerveDriveConfiguration.html" title="class in swervelib.parser">SwerveDriveConfiguration</a>&nbsp;config)</span></div>
<div class="block">Limits a commanded velocity to prevent exceeding the maximum acceleration given by
<a href="#calcMaxAccel(edu.wpi.first.math.geometry.Rotation2d,double,double,edu.wpi.first.math.geometry.Translation3d,swervelib.parser.SwerveDriveConfiguration)"><code>calcMaxAccel(Rotation2d, double, double, Translation3d, SwerveDriveConfiguration)</code></a>. Note that
this takes and returns field-relative velocities.</div>
<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&lt;swervelib.math.Matter&gt;, double, swervelib.parser.SwerveDriveConfiguration)</code></a>.
Note that this takes and returns field-relative velocities.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>commandedVelocity</code> - The desired velocity</dd>
<dd><code>fieldVelocity</code> - The velocity of the robot within a field relative state.</dd>
<dd><code>robotPose</code> - The current pose of the robot.</dd>
<dd><code>loopTime</code> - The time it takes to update the velocity in seconds. <b>Note: this should include the
100ms that it takes for a SparkMax velocity to update.</b></dd>
<dd><code>chassisMass</code> - Chassis mass in kg. (The weight of just the chassis not anything else)</dd>
100ms that it takes for a SparkMax velocity to update.</b></dd>
<dd><code>matter</code> - Matter that the robot is composed of with position in meters and mass in kg.</dd>
<dd><code>robotMass</code> - The weight of the robot in kg. (Including manipulators, etc).</dd>
<dd><code>chassisCenterOfGravity</code> - Chassis center of gravity.</dd>
<dd><code>config</code> - The swerve drive configuration.</dd>
<dt>Returns:</dt>
<dd>The limited velocity. This is either the commanded velocity, if attainable, or the closest attainable