Clone of SwerveDrivePoseEstimator which takes into account gyroscope pitch and roll to
- achieve a more accurate estimation, originally made by Team 1466.
+
Clone of SwerveDrivePoseEstimator which takes into account gyroscope pitch and roll to achieve a more
+ accurate estimation, originally made by Team 1466.
-Starting from the Overview page, you can browse the documentation using the links in each page, and in the navigation bar at the top of each page. The Index and Search box allow you to navigate to specific declarations and summary pages, including: All Packages, All Classes and Interfaces
+Starting from the Overview page, you can browse the documentation using the links in each page, and in the navigation bar at the top of each page. The Index and Search box allow you to navigate to specific declarations and summary pages, including: All Packages, All Classes and Interfaces
Search
You can search for definitions of modules, packages, types, fields, methods, system properties and other terms defined in the API, using some or all of the name, optionally using "camelCase" abbreviations. For example:
@@ -154,6 +156,10 @@ The following sections describe the different kinds of pages in this collection.
When viewing a particular package, class or interface page, clicking on TREE displays the hierarchy for only that package.
The All Packages page contains an alphabetic index of all packages contained in the documentation.
@@ -164,7 +170,7 @@ The following sections describe the different kinds of pages in this collection.
Index
-
The Index contains an alphabetic index of all classes, interfaces, constructors, methods, and fields in the documentation, as well as summary pages such as All Packages, All Classes and Interfaces.
+
The Index contains an alphabetic index of all classes, interfaces, constructors, methods, and fields in the documentation, as well as summary pages such as All Packages, All Classes and Interfaces.
Angle motor kV used for second order kinematics to tune the feedforward, this variable should be adjusted so that
+ your drive train does not drift towards the direction you are rotating while you translate.
Angle motor kV used for second order kinematics to tune the feedforward, this variable should be adjusted so that
+ your drive train does not drift towards the direction you are rotating while you translate.
Trustworthiness of the internal model of how motors should be moving Measured in expected standard deviation
+ (meters of position and degrees of rotation)
Clone of SwerveDrivePoseEstimator which takes into account gyroscope pitch and roll to achieve a more
+ accurate estimation, originally made by Team 1466.
SwerveControllerConfiguration object storing data to generate the PIDController for controlling the
+ robot heading, and deadband for heading joystick.
Renormalizes the wheel speeds if any individual speed is above the specified maximum, as well as getting rid of
+ joystick saturation at edges of joystick.
Helper function to get the SwerveDrive.swerveController for the SwerveDrive which can be used to
+ generate ChassisSpeeds for the robot to orient it correctly given axis or angles, and apply
+ SlewRateLimiter to given inputs.
").text(i.label)).appendTo(e)},_move:function(t,e){return this.menu.element.is(":visible")?this.menu.isFirstItem()&&/^previous/.test(t)||this.menu.isLastItem()&&/^next/.test(t)?(this.isMultiLine||this._value(this.term),this.menu.blur(),void 0):(this.menu[t](e),void 0):(this.search(null,e),void 0)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(t,e){(!this.isMultiLine||this.menu.element.is(":visible"))&&(this._move(t,e),e.preventDefault())},_isContentEditable:function(t){if(!t.length)return!1;var e=t.prop("contentEditable");return"inherit"===e?this._isContentEditable(t.parent()):"true"===e}}),t.extend(t.ui.autocomplete,{escapeRegex:function(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(e,i){var s=RegExp(t.ui.autocomplete.escapeRegex(i),"i");return t.grep(e,function(t){return s.test(t.label||t.value||t)})}}),t.widget("ui.autocomplete",t.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(t){return t+(t>1?" results are":" result is")+" available, use up and down arrow keys to navigate."}}},__response:function(e){var i;this._superApply(arguments),this.options.disabled||this.cancelSearch||(i=e&&e.length?this.options.messages.results(e.length):this.options.messages.noResults,this.liveRegion.children().hide(),t("
").text(i).appendTo(this.liveRegion))}}),t.ui.autocomplete});
\ No newline at end of file
diff --git a/docs/script-dir/jquery-ui.structure.min.css b/docs/script-dir/jquery-ui.structure.min.css
new file mode 100644
index 0000000..e880892
--- /dev/null
+++ b/docs/script-dir/jquery-ui.structure.min.css
@@ -0,0 +1,5 @@
+/*! jQuery UI - v1.12.1 - 2018-12-06
+* http://jqueryui.com
+* Copyright jQuery Foundation and other contributors; Licensed MIT */
+
+.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important;pointer-events:none}.ui-icon{display:inline-block;vertical-align:middle;margin-top:-.25em;position:relative;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-icon-block{left:50%;margin-left:-8px;display:block}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{margin:0;cursor:pointer;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-item-wrapper{position:relative;padding:3px 1em 3px .4em}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item-wrapper{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0}
\ No newline at end of file
diff --git a/docs/stylesheet.css b/docs/stylesheet.css
index 4a576bd..836c62d 100644
--- a/docs/stylesheet.css
+++ b/docs/stylesheet.css
@@ -611,7 +611,6 @@ main, nav, header, footer, section {
ul.ui-autocomplete {
position:fixed;
z-index:999999;
- background-color: #FFFFFF;
}
ul.ui-autocomplete li {
float:left;
@@ -621,9 +620,6 @@ ul.ui-autocomplete li {
.result-highlight {
font-weight:bold;
}
-.ui-autocomplete .result-item {
- font-size: inherit;
-}
#search-input {
background-image:url('resources/glass.png');
background-size:13px;
diff --git a/docs/swervelib/SwerveController.html b/docs/swervelib/SwerveController.html
index f5b8d4d..ec96ff7 100644
--- a/docs/swervelib/SwerveController.html
+++ b/docs/swervelib/SwerveController.html
@@ -1,17 +1,18 @@
-
-SwerveController (YAGSL-Lib API)
+
+SwerveController
+
-
+
@@ -35,7 +36,7 @@ loadScripts(document, 'script');
SwerveControllerConfiguration object storing data to generate the PIDController
- for controlling the robot heading, and deadband for heading joystick.
+
SwerveControllerConfiguration object storing data to generate the PIDController for controlling the
+ robot heading, and deadband for heading joystick.
SwerveControllerConfiguration object storing data to generate the PIDController
- for controlling the robot heading, and deadband for heading joystick.
+
SwerveControllerConfiguration object storing data to generate the PIDController for controlling the
+ robot heading, and deadband for heading joystick.
Trustworthiness of the internal model of how motors should be moving Measured in expected
- standard deviation (meters of position and degrees of rotation)
+
Trustworthiness of the internal model of how motors should be moving Measured in expected standard deviation
+ (meters of position and degrees of rotation)
Helper function to get the swerveController for the SwerveDrive
- which can be used to generate ChassisSpeeds for the robot to orient it correctly given
- axis or angles, and apply SlewRateLimiter to given inputs.
+
Helper function to get the swerveController for the SwerveDrive which can be used to
+ generate ChassisSpeeds for the robot to orient it correctly given axis or angles, and apply
+ SlewRateLimiter to given inputs.
Trustworthiness of the internal model of how motors should be moving Measured in expected
- standard deviation (meters of position and degrees of rotation)
+
Trustworthiness of the internal model of how motors should be moving Measured in expected standard deviation
+ (meters of position and degrees of rotation)
Creates a new swerve drivebase subsystem. Robot is controlled via the drive(edu.wpi.first.math.geometry.Translation2d, double, boolean, boolean)
- method, or via the setRawModuleStates(swervelib.math.SwerveModuleState2[], boolean) method. The drive(edu.wpi.first.math.geometry.Translation2d, double, boolean, boolean)
- method incorporates kinematics-- it takes a translation and rotation, as well as parameters for
- field-centric and closed-loop velocity control. setRawModuleStates(swervelib.math.SwerveModuleState2[], boolean) takes a
- list of SwerveModuleStates and directly passes them to the modules. This subsystem also handles
- odometry.
The primary method for controlling the drivebase. Takes a Translation2d and a rotation rate,
- and calculates and commands module states accordingly. Can use either open-loop or closed-loop
- velocity control for the wheel velocities. Also has field- and robot-relative modes, which
- affect how the translation vector is used. This method defaults to no heading correction.
+
The primary method for controlling the drivebase. Takes a Translation2d and a rotation rate, and calculates and
+ commands module states accordingly. Can use either open-loop or closed-loop velocity control for the wheel
+ velocities. Also has field- and robot-relative modes, which affect how the translation vector is used. This method
+ defaults to no heading correction.
Parameters:
-
translation - Translation2d that is the commanded linear velocity of the robot, in
- meters per second. In robot-relative mode, positive x is torwards the bow (front) and
- positive y is torwards port (left). In field-relative mode, positive x is away from the
- alliance wall (field North) and positive y is torwards the left wall when looking through
- the driver station glass (field West).
-
rotation - Robot angular rate, in radians per second. CCW positive. Unaffected by
- field/robot relativity.
+
translation - Translation2d that is the commanded linear velocity of the robot, in meters per
+ second. In robot-relative mode, positive x is torwards the bow (front) and positive y is
+ torwards port (left). In field-relative mode, positive x is away from the alliance wall (field
+ North) and positive y is torwards the left wall when looking through the driver station glass
+ (field West).
+
rotation - Robot angular rate, in radians per second. CCW positive. Unaffected by field/robot
+ relativity.
fieldRelative - Drive mode. True for field-relative, false for robot-relative.
-
isOpenLoop - Whether to use closed-loop velocity control. Set to true to disable
- closed-loop.
+
isOpenLoop - Whether to use closed-loop velocity control. Set to true to disable closed-loop.
The primary method for controlling the drivebase. Takes a Translation2d and a rotation rate,
- and calculates and commands module states accordingly. Can use either open-loop or closed-loop
- velocity control for the wheel velocities. Also has field- and robot-relative modes, which
- affect how the translation vector is used.
+
The primary method for controlling the drivebase. Takes a Translation2d and a rotation rate, and calculates and
+ commands module states accordingly. Can use either open-loop or closed-loop velocity control for the wheel
+ velocities. Also has field- and robot-relative modes, which affect how the translation vector is used.
Parameters:
-
translation - Translation2d that is the commanded linear velocity of the robot, in
- meters per second. In robot-relative mode, positive x is torwards the bow (front) and
- positive y is torwards port (left). In field-relative mode, positive x is away from the
- alliance wall (field North) and positive y is torwards the left wall when looking through
- the driver station glass (field West).
-
rotation - Robot angular rate, in radians per second. CCW positive. Unaffected by
- field/robot relativity.
+
translation - Translation2d that is the commanded linear velocity of the robot, in meters per
+ second. In robot-relative mode, positive x is torwards the bow (front) and positive y is
+ torwards port (left). In field-relative mode, positive x is away from the alliance wall
+ (field North) and positive y is torwards the left wall when looking through the driver
+ station glass (field West).
+
rotation - Robot angular rate, in radians per second. CCW positive. Unaffected by field/robot
+ relativity.
fieldRelative - Drive mode. True for field-relative, false for robot-relative.
-
isOpenLoop - Whether to use closed-loop velocity control. Set to true to disable
- closed-loop.
-
headingCorrection - Whether to correct heading when driving translationally. Set to true
- to enable.
+
isOpenLoop - Whether to use closed-loop velocity control. Set to true to disable closed-loop.
+
headingCorrection - Whether to correct heading when driving translationally. Set to true to enable.
Resets odometry to the given pose. Gyro angle and module positions do not need to be reset when
- calling this method. However, if either gyro angle or module position is reset, this must be
- called in order for odometry to keep working.
+
Resets odometry to the given pose. Gyro angle and module positions do not need to be reset when calling this
+ method. However, if either gyro angle or module position is reset, this must be called in order for odometry to
+ keep working.
maximumSpeed - Maximum speed for the drive motors in meters / second.
-
updateModuleFeedforward - Update the swerve module feedforward to account for the new
- maximum speed. This should be true unless you have replaced the drive motor feedforward
- with replaceSwerveModuleFeedforward(SimpleMotorFeedforward)
+
updateModuleFeedforward - Update the swerve module feedforward to account for the new maximum speed. This
+ should be true unless you have replaced the drive motor feedforward with
+ replaceSwerveModuleFeedforward(SimpleMotorFeedforward)
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.
+
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.
Add a vision measurement to the SwerveDrivePoseEstimator and update the SwerveIMU gyro reading with the given timestamp of the vision measurement.
- IT IS HIGHLY RECOMMENDED TO UPDATE YOUR GYROSCOPE OFFSET AFTER USING THIS FUNCTION!
- To update your gyroscope readings directly use setGyroOffset(Rotation3d).
+
Add a vision measurement to the SwerveDrivePoseEstimator and update the SwerveIMU gyro reading with
+ the given timestamp of the vision measurement. IT IS HIGHLY RECOMMENDED TO UPDATE YOUR GYROSCOPE OFFSET
+ AFTER USING THIS FUNCTION! To update your gyroscope readings directly use
+ setGyroOffset(Rotation3d).
Parameters:
robotPose - Robot Pose2d as measured by vision.
-
timestamp - Timestamp the measurement was taken as time since startup, should be taken
- from Timer.getFPGATimestamp() or similar sources.
-
soft - Add vision estimate using the PoseEstimator.addVisionMeasurement(Pose2d, double) function, or hard reset
- odometry with the given position with SwerveDriveOdometry.resetPosition(Rotation2d, SwerveModulePosition[], Pose2d).
-
trustWorthiness - Trust level of vision reading when using a soft measurement, used to
- multiply the standard deviation. Set to 1 for full trust. Higher = Less Weight.
+
timestamp - Timestamp the measurement was taken as time since startup, should be taken from
+ Timer.getFPGATimestamp() or similar sources.
+
soft - Add vision estimate using the
+ SwerveDrivePoseEstimator.addVisionMeasurement(Pose2d, double) function, or hard
+ reset odometry with the given position with
+ SwerveDriveOdometry.resetPosition(Rotation2d, SwerveModulePosition[], Pose2d).
+
trustWorthiness - Trust level of vision reading when using a soft measurement, used to multiply the standard
+ deviation. Set to 1 for full trust. Higher = Less Weight.
Add a vision measurement to the SwerveDrivePoseEstimator and update the SwerveIMU gyro reading with the given timestamp of the vision measurement.
+
Add a vision measurement to the SwerveDrivePoseEstimator and update the SwerveIMU gyro reading with
+ the given timestamp of the vision measurement.
Parameters:
robotPose - Robot Pose2d as measured by vision.
-
timestamp - Timestamp the measurement was taken as time since startup, should be taken
- from Timer.getFPGATimestamp() or similar sources.
-
soft - Add vision estimate using the PoseEstimator.addVisionMeasurement(Pose2d, double) function, or hard reset
- odometry with the given position with SwerveDriveOdometry.resetPosition(Rotation2d, SwerveModulePosition[], Pose2d).
+
timestamp - Timestamp the measurement was taken as time since startup, should be taken from
+ Timer.getFPGATimestamp() or similar sources.
+
soft - Add vision estimate using the
+ SwerveDrivePoseEstimator.addVisionMeasurement(Pose2d, double) function, or
+ hard reset odometry with the given position with
+ SwerveDriveOdometry.resetPosition(Rotation2d, SwerveModulePosition[], Pose2d).
visionMeasurementStdDevs - Vision measurement standard deviation that will be sent to the
- SwerveDrivePoseEstimator.
Set the expected gyroscope angle using a Rotation3d object. To reset gyro, set to a new
- Rotation3d subtracted from the current gyroscopic readings SwerveIMU.getRotation3d().
+
Set the expected gyroscope angle using a Rotation3d object. To reset gyro, set to a new Rotation3d
+ subtracted from the current gyroscopic readings SwerveIMU.getRotation3d().
Set the desired state of the swerve module.
- WARNING: If you are not using one of the functions from SwerveDrive you may screw up
- SwerveDrive.kinematics
+
Set the desired state of the swerve module. WARNING: If you are not using one of the functions from
+ SwerveDrive you may screw up SwerveDrive.kinematics
Parameters:
desiredState - Desired swerve module state.
isOpenLoop - Whether to use open loop (direct percent) or direct velocity control.
-
force - Disables optimizations that prevent movement in the angle motor and forces the
- desired state onto the swerve module.
+
force - Disables optimizations that prevent movement in the angle motor and forces the desired state
+ onto the swerve module.
Updates the robot's position on the field using forward kinematics and integration of the pose
- over time. This method automatically calculates the current time to calculate period
- (difference between two timestamps). The period is used to calculate the change in distance
- from a velocity. This also takes in an angle parameter which is used instead of the angular
- rate that is calculated from forward kinematics. This also takes in pitch and roll to allow for
- more accurate pose estimation on angled surfaces using a rotation matrix.
+
Updates the robot's position on the field using forward kinematics and integration of the pose over time. This
+ method automatically calculates the current time to calculate period (difference between two timestamps). The
+ period is used to calculate the change in distance from a velocity. This also takes in an angle parameter which is
+ used instead of the angular rate that is calculated from forward kinematics. This also takes in pitch and roll to
+ allow for more accurate pose estimation on angled surfaces using a rotation matrix.
Parameters:
gyroYaw - The yaw reported by the gyro.
pitch - The pitch reported by the gyro.
roll - The roll reported by the gyro.
-
modulePositions - The current position of all swerve modules. Please provide the positions
- in the same order in which you instantiated your SwerveDriveKinematics.
+
modulePositions - The current position of all swerve modules. Please provide the positions in the same order
+ in which you instantiated your SwerveDriveKinematics.
public class SwerveKinematics2extends edu.wpi.first.math.kinematics.SwerveDriveKinematics
-
Clone of WPI SwerveKinematics, which implements second order kinematics when calculating modules
- states from chassis speed. Makes use of SwerveModuleState2 to add the angular velocity
- that is required of the module as an output.
+
Clone of WPI SwerveKinematics, which implements second order kinematics when calculating modules states from chassis
+ speed. Makes use of SwerveModuleState2 to add the angular velocity that is required of the module as an
+ output.
-
+
-
-
Nested Class Summary
-
-
Nested classes/interfaces inherited from class edu.wpi.first.math.kinematics.SwerveDriveKinematics
Renormalizes the wheel speeds if any individual speed is above the specified maximum, as well
- as getting rid of joystick saturation at edges of joystick.
+
Renormalizes the wheel speeds if any individual speed is above the specified maximum, as well as getting rid of
+ joystick saturation at edges of joystick.
Constructs a swerve drive kinematics object. This takes in a variable number of wheel locations
- as Translation2ds. The order in which you pass in the wheel locations is the same order that
- you will receive the module states when performing inverse kinematics. It is also expected that
- you pass in the module states in the same order when calling the forward kinematics methods.
+
Constructs a swerve drive kinematics object. This takes in a variable number of wheel locations as Translation2ds.
+ The order in which you pass in the wheel locations is the same order that you will receive the module states when
+ performing inverse kinematics. It is also expected that you pass in the module states in the same order when
+ calling the forward kinematics methods.
Parameters:
wheelsMeters - The locations of the wheels relative to the physical center of the robot.
Renormalizes the wheel speeds if any individual speed is above the specified maximum.
Sometimes, after inverse kinematics, the requested speed from one or more modules may be
- above the max attainable speed for the driving motor on that module. To fix this issue, one can
- reduce all the wheel speeds to make sure that all requested module speeds are at-or-below the
- absolute threshold, while maintaining the ratio of speeds between modules.
+ above the max attainable speed for the driving motor on that module. To fix this issue, one can reduce all the
+ wheel speeds to make sure that all requested module speeds are at-or-below the absolute threshold, while
+ maintaining the ratio of speeds between modules.
Parameters:
moduleStates - Reference to array of module states. The array will be mutated with the
- normalized speeds!
+ normalized speeds!
attainableMaxSpeedMetersPerSecond - The absolute max speed that a module can reach.
Renormalizes the wheel speeds if any individual speed is above the specified maximum, as well
- as getting rid of joystick saturation at edges of joystick.
+
Renormalizes the wheel speeds if any individual speed is above the specified maximum, as well as getting rid of
+ joystick saturation at edges of joystick.
Sometimes, after inverse kinematics, the requested speed from one or more modules may be
- above the max attainable speed for the driving motor on that module. To fix this issue, one can
- reduce all the wheel speeds to make sure that all requested module speeds are at-or-below the
- absolute threshold, while maintaining the ratio of speeds between modules.
+ above the max attainable speed for the driving motor on that module. To fix this issue, one can reduce all the
+ wheel speeds to make sure that all requested module speeds are at-or-below the absolute threshold, while
+ maintaining the ratio of speeds between modules.
Parameters:
-
moduleStates - Reference to array of module states. The array will be mutated with the
- normalized speeds!
+
moduleStates - Reference to array of module states. The array will be
+ mutated with the normalized speeds!
currentChassisSpeed - The current speed of the robot
attainableMaxModuleSpeedMetersPerSecond - The absolute max speed that a module can reach
-
attainableMaxTranslationalSpeedMetersPerSecond - The absolute max speed that your robot
- can reach while translating
-
attainableMaxRotationalVelocityRadiansPerSecond - The absolute max speed the robot can
- reach while rotating
+
attainableMaxTranslationalSpeedMetersPerSecond - The absolute max speed that your robot can reach while
+ translating
+
attainableMaxRotationalVelocityRadiansPerSecond - The absolute max speed the robot can reach while rotating
Performs inverse kinematics to return the module states from a desired chassis velocity. This
- method is often used to convert joystick values into module speeds and angles.
+
Performs inverse kinematics to return the module states from a desired chassis velocity. This method is often used
+ to convert joystick values into module speeds and angles.
This function also supports variable centers of rotation. During normal operations, the
- center of rotation is usually the same as the physical center of the robot; therefore, the
- argument is defaulted to that use case. However, if you wish to change the center of rotation
- for evasive maneuvers, vision alignment, or for any other use case, you can do so.
+ center of rotation is usually the same as the physical center of the robot; therefore, the argument is defaulted to
+ that use case. However, if you wish to change the center of rotation for evasive maneuvers, vision alignment, or
+ for any other use case, you can do so.
In the case that the desired chassis speeds are zero (i.e. the robot will be stationary),
the previously calculated module angle will be maintained.
toSwerveModuleStates in class edu.wpi.first.math.kinematics.SwerveDriveKinematics
Parameters:
chassisSpeeds - The desired chassis speed.
-
centerOfRotationMeters - The center of rotation. For example, if you set the center of
- rotation at one corner of the robot and provide a chassis speed that only has a dtheta
- component, the robot will rotate around that corner.
+
centerOfRotationMeters - The center of rotation. For example, if you set the center of rotation at one corner
+ of the robot and provide a chassis speed that only has a dtheta component, the robot
+ will rotate around that corner.
Returns:
-
An array containing the module states. Use caution because these module states are not
- normalized. Sometimes, a user input may cause one of the module speeds to go above the
- attainable max velocity. Use the DesaturateWheelSpeeds function to rectify this issue.
+
An array containing the module states. Use caution because these module states are not normalized.
+ Sometimes, a user input may cause one of the module speeds to go above the attainable max velocity. Use the
+ DesaturateWheelSpeeds function to rectify this issue.
Performs forward kinematics to return the resulting chassis state from the given module states.
- This method is often used for odometry -- determining the robot's position on the field using
- data from the real-world speed and angle of each module on the robot.
+
Performs forward kinematics to return the resulting chassis state from the given module states. This method is
+ often used for odometry -- determining the robot's position on the field using data from the real-world speed and
+ angle of each module on the robot.
Parameters:
-
wheelStates - The state of the modules (as a SwerveModuleState type) as measured from
- respective encoders and gyros. The order of the swerve module states should be same as
- passed into the constructor of this class.
+
wheelStates - The state of the modules (as a SwerveModuleState type) as measured from respective encoders and
+ gyros. The order of the swerve module states should be same as passed into the constructor of
+ this class.
Performs forward kinematics to return the resulting chassis state from the given module states.
- This method is often used for odometry -- determining the robot's position on the field using
- data from the real-world speed and angle of each module on the robot.
+
Performs forward kinematics to return the resulting chassis state from the given module states. This method is
+ often used for odometry -- determining the robot's position on the field using data from the real-world speed and
+ angle of each module on the robot.
Overrides:
toTwist2d in class edu.wpi.first.math.kinematics.SwerveDriveKinematics
Parameters:
-
wheelDeltas - The latest change in position of the modules (as a SwerveModulePosition
- type) as measured from respective encoders and gyros. The order of the swerve module states
- should be same as passed into the constructor of this class.
+
wheelDeltas - The latest change in position of the modules (as a SwerveModulePosition type) as measured from
+ respective encoders and gyros. The order of the swerve module states should be same as passed
+ into the constructor of this class.
Limits a commanded velocity to prevent exceeding the maximum acceleration given by calcMaxAccel(edu.wpi.first.math.geometry.Rotation2d, java.util.List<swervelib.math.Matter>, double, swervelib.parser.SwerveDriveConfiguration).
public staticdoublecalculateDegreesPerSteeringRotation(double angleGearRatio,
double pulsePerRotation)
-
Calculate the degrees per steering rotation for the integrated encoder. Encoder conversion
- values. Drive converts motor rotations to linear wheel distance and steering converts motor
- rotations to module azimuth.
+
Calculate the degrees per steering rotation for the integrated encoder. Encoder conversion values. Drive converts
+ motor rotations to linear wheel distance and steering converts motor rotations to module azimuth.
Parameters:
angleGearRatio - The gear ratio of the steering motor.
-
pulsePerRotation - The number of pulses in a complete rotation for the encoder, 1 if
- integrated.
+
pulsePerRotation - The number of pulses in a complete rotation for the encoder, 1 if integrated.
Returns:
Degrees per steering rotation for the angle motor.
Calculates the maximum acceleration allowed in a direction without tipping the robot. Reads arm position from
+ NetworkTables and is passed the direction in question.
+
+
Parameters:
+
angle - The direction in which to calculate max acceleration, as a Rotation2d. Note that this is
+ robot-relative.
+
matter - Matter that the robot is composed of in kg. (Includes chassis)
+
robotMass - The weight of the robot in kg. (Including manipulators, etc).
+
config - The swerve drive configuration.
+
Returns:
+
Maximum acceleration allowed in the robot direction.
+
+
+
+
PoseLog
public staticedu.wpi.first.math.geometry.Twist2dPoseLog(edu.wpi.first.math.geometry.Pose2d transform)
Limits a commanded velocity to prevent exceeding the maximum acceleration given by calcMaxAccel(edu.wpi.first.math.geometry.Rotation2d, java.util.List<swervelib.math.Matter>, double, swervelib.parser.SwerveDriveConfiguration). Note that this takes and returns field-relative velocities.
public staticdoubleplaceInAppropriate0To360Scope(double scopeReference,
double newAngle)
-
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.
+
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.
Minimize the change in heading the desired swerve module state would require by potentially
- reversing the direction the wheel spins. If this is used with the PIDController class's
- continuous input functionality, the furthest a wheel will ever rotate is 90 degrees.
+
Minimize the change in heading the desired swerve module state would require by potentially reversing the direction
+ the wheel spins. If this is used with the PIDController class's continuous input functionality, the furthest a
+ wheel will ever rotate is 90 degrees.
Parameters:
desiredState - The desired state.
currentAngle - The current module angle.
lastState - The last state of the module.
-
moduleSteerFeedForwardClosedLoop - The module feed forward closed loop for the angle
- motor.
+
moduleSteerFeedForwardClosedLoop - The module feed forward closed loop for the angle motor.
Represents an odometry record. The record contains the inputs provided as well as the pose that was observed based
+ on these inputs, as well as the previous record and its inputs.
+
+
+
+
+
+
+
Field Summary
+
Fields
+
+
Modifier and Type
+
Field
+
Description
+
private final edu.wpi.first.math.geometry.Rotation2d
Clone of SwerveDrivePoseEstimator which takes into account gyroscope pitch and roll to
- achieve a more accurate estimation, originally made by Team 1466.
+
Clone of SwerveDrivePoseEstimator which takes into account gyroscope pitch and roll to achieve a more
+ accurate estimation, originally made by Team 1466.
Constructs a SwerveDrivePoseEstimator with default standard deviations for the model and vision
- measurements.
+
Constructs a SwerveDrivePoseEstimator with default standard deviations for the model and vision measurements.
The default standard deviations of the model states are 0.1 meters for x, 0.1 meters for y,
- and 0.1 radians for heading. The default standard deviations of the vision measurements are 0.9
- meters for x, 0.9 meters for y, and 0.9 radians for heading.
+ and 0.1 radians for heading. The default standard deviations of the vision measurements are 0.9 meters for x, 0.9
+ meters for y, and 0.9 radians for heading.
Parameters:
kinematics - A correctly-configured kinematics object for your drivetrain.
modulePositions - The current distance and rotation measurements of the swerve modules.
initialPoseMeters - The starting pose estimate.
-
stateStdDevs - Standard deviations of the pose estimate (x position in meters, y position
- in meters, and heading in radians). Increase these numbers to trust your state estimate
- less.
-
visionMeasurementStdDevs - Standard deviations of the vision pose measurement (x position
- in meters, y position in meters, and heading in radians). Increase these numbers to trust
- the vision pose measurement less.
+
stateStdDevs - Standard deviations of the pose estimate (x position in meters, y position in
+ meters, and heading in radians). Increase these numbers to trust your state
+ estimate less.
+
visionMeasurementStdDevs - Standard deviations of the vision pose measurement (x position in meters, y
+ position in meters, and heading in radians). Increase these numbers to trust the
+ vision pose measurement less.
Sets the pose estimator's trust of global measurements. This might be used to change trust in
- vision measurements after the autonomous period, or to change trust as distance to a vision
- target increases.
+
Sets the pose estimator's trust of global measurements. This might be used to change trust in vision measurements
+ after the autonomous period, or to change trust as distance to a vision target increases.
Parameters:
-
visionMeasurementStdDevs - Standard deviations of the vision measurements. Increase these
- numbers to trust global measurements from vision less. This matrix is in the form [x, y,
- theta]^T, with units in meters and radians.
+
visionMeasurementStdDevs - Standard deviations of the vision measurements. Increase these numbers to trust
+ global measurements from vision less. This matrix is in the form [x, y, theta]^T,
+ with units in meters and radians.
Adds a vision measurement to the Kalman Filter. This will correct the odometry pose estimate
- while still accounting for measurement noise.
+
Adds a vision measurement to the Kalman Filter. This will correct the odometry pose estimate while still accounting
+ for measurement noise.
This method can be called as infrequently as you want, as long as you are calling SwerveDrivePoseEstimator.update(edu.wpi.first.math.geometry.Rotation2d, edu.wpi.first.math.kinematics.SwerveModulePosition[]) every loop.
To promote stability of the pose estimate and make it robust to bad vision data, we
- recommend only adding vision measurements that are already within one meter or so of the
- current pose estimate.
+ recommend only adding vision measurements that are already within one meter or so of the current pose estimate.
Parameters:
visionRobotPoseMeters - The pose of the robot as measured by the vision camera.
-
timestampSeconds - The timestamp of the vision measurement in seconds. Note that if you
- don't use your own time source by calling SwerveDrivePoseEstimator.updateWithTime(double, Rotation2d, SwerveModulePosition[]) then
- you must use a timestamp with an epoch since FPGA startup (i.e., the epoch of this
- timestamp is the same epoch as Timer.getFPGATimestamp().)
- This means that you should use Timer.getFPGATimestamp() as
- your time source or sync the epochs.
+
timestampSeconds - The timestamp of the vision measurement in seconds. Note that if you don't use your
+ own time source by calling
+ SwerveDrivePoseEstimator.updateWithTime(double, Rotation2d, SwerveModulePosition[]) then you must use a timestamp with an epoch since FPGA
+ startup (i.e., the epoch of this timestamp is the same epoch as
+ Timer.getFPGATimestamp().) This means that you should
+ use Timer.getFPGATimestamp() as your time source or sync
+ the epochs.
Adds a vision measurement to the Kalman Filter. This will correct the odometry pose estimate
- while still accounting for measurement noise.
+
Adds a vision measurement to the Kalman Filter. This will correct the odometry pose estimate while still accounting
+ for measurement noise.
This method can be called as infrequently as you want, as long as you are calling SwerveDrivePoseEstimator.update(edu.wpi.first.math.geometry.Rotation2d, edu.wpi.first.math.kinematics.SwerveModulePosition[]) every loop.
To promote stability of the pose estimate and make it robust to bad vision data, we
- recommend only adding vision measurements that are already within one meter or so of the
- current pose estimate.
+ recommend only adding vision measurements that are already within one meter or so of the current pose estimate.
Note that the vision measurement standard deviations passed into this method will continue
- to apply to future measurements until a subsequent call to PoseEstimator.setVisionMeasurementStdDevs(Matrix) or this method.
+ to apply to future measurements until a subsequent call to
+ SwerveDrivePoseEstimator.setVisionMeasurementStdDevs(Matrix) or this method.
Parameters:
visionRobotPoseMeters - The pose of the robot as measured by the vision camera.
-
timestampSeconds - The timestamp of the vision measurement in seconds. Note that if you
- don't use your own time source by calling SwerveDrivePoseEstimator.updateWithTime(double, Rotation2d, SwerveModulePosition[]), then
- you must use a timestamp with an epoch since FPGA startup (i.e., the epoch of this
- timestamp is the same epoch as Timer.getFPGATimestamp()).
- This means that you should use Timer.getFPGATimestamp() as
- your time source in this case.
-
visionMeasurementStdDevs - Standard deviations of the vision pose measurement (x position
- in meters, y position in meters, and heading in radians). Increase these numbers to trust
- the vision pose measurement less.
+
timestampSeconds - The timestamp of the vision measurement in seconds. Note that if you don't use your
+ own time source by calling
+ SwerveDrivePoseEstimator.updateWithTime(double, Rotation2d, SwerveModulePosition[]), then you must use a timestamp with an epoch since FPGA
+ startup (i.e., the epoch of this timestamp is the same epoch as
+ Timer.getFPGATimestamp()). This means that you should
+ use Timer.getFPGATimestamp() as your time source in
+ this case.
+
visionMeasurementStdDevs - Standard deviations of the vision pose measurement (x position in meters, y
+ position in meters, and heading in radians). Increase these numbers to trust the
+ vision pose measurement less.
Clone of SwerveDrivePoseEstimator which takes into account gyroscope pitch and roll to
- achieve a more accurate estimation, originally made by Team 1466.
+
Clone of SwerveDrivePoseEstimator which takes into account gyroscope pitch and roll to achieve a more
+ accurate estimation, originally made by Team 1466.
Set the current limit for the swerve drive motor, remember this may cause jumping if used in
- conjunction with voltage compensation. This is useful to protect the motor from current spikes.
+
Set the current limit for the swerve drive motor, remember this may cause jumping if used in conjunction with
+ voltage compensation. This is useful to protect the motor from current spikes.
Returns the enum constant of this class with the specified name.
+The string must match exactly an identifier used to declare an
+enum constant in this class. (Extraneous whitespace characters are
+not permitted.)
+
+
Parameters:
+
name - the name of the enum constant to be returned.
Set the current limit for the swerve drive motor, remember this may cause jumping if used in
- conjunction with voltage compensation. This is useful to protect the motor from current spikes.
+
Set the current limit for the swerve drive motor, remember this may cause jumping if used in conjunction with
+ voltage compensation. This is useful to protect the motor from current spikes.
public abstractvoidsetCurrentLimit(int currentLimit)
-
Set the current limit for the swerve drive motor, remember this may cause jumping if used in
- conjunction with voltage compensation. This is useful to protect the motor from current spikes.
+
Set the current limit for the swerve drive motor, remember this may cause jumping if used in conjunction with
+ voltage compensation. This is useful to protect the motor from current spikes.
Parameters:
currentLimit - Current limit in AMPS at free speed.
Set the current limit for the swerve drive motor, remember this may cause jumping if used in
- conjunction with voltage compensation. This is useful to protect the motor from current spikes.
+
Set the current limit for the swerve drive motor, remember this may cause jumping if used in conjunction with
+ voltage compensation. This is useful to protect the motor from current spikes.
Set the current limit for the swerve drive motor, remember this may cause jumping if used in
- conjunction with voltage compensation. This is useful to protect the motor from current spikes.
+
Set the current limit for the swerve drive motor, remember this may cause jumping if used in conjunction with
+ voltage compensation. This is useful to protect the motor from current spikes.
Construct the swerve controller configuration. Assumes hypotenuse deadband of 0.5 (minimum
- radius for angle to be set on angle joystick is .5 of the controller).
+
Construct the swerve controller configuration. Assumes hypotenuse deadband of 0.5 (minimum radius for angle to be
+ set on angle joystick is .5 of the controller).
Angle motor kV used for second order kinematics to tune the feedforward, this variable should
- be adjusted so that your drive train does not drift towards the direction you are rotating
- while you translate.
+
Angle motor kV used for second order kinematics to tune the feedforward, this variable should be adjusted so that
+ your drive train does not drift towards the direction you are rotating while you translate.
Angle motor kV used for second order kinematics to tune the feedforward, this variable should
- be adjusted so that your drive train does not drift towards the direction you are rotating
- while you translate. When set to 0 the calculated kV will be used.
+
Angle motor kV used for second order kinematics to tune the feedforward, this variable should be adjusted so that
+ your drive train does not drift towards the direction you are rotating while you translate. When set to 0 the
+ calculated kV will be used.
driveGearRatio - Gear ratio of the drive motor. Number of motor rotations to rotate the
- wheel.
-
angleGearRatio - Gear ratio of the angle motor. Number of motor rotations to spin the
- wheel.
+ wheel.
+
angleGearRatio - Gear ratio of the angle motor. Number of motor rotations to spin the wheel.
wheelDiameter - Wheel diameter in meters.
-
wheelGripCoefficientOfFriction - Wheel grip coefficient of friction on carpet given by
- manufacturer.
+
wheelGripCoefficientOfFriction - Wheel grip coefficient of friction on carpet given by manufacturer.
optimalVoltage - Optimal robot voltage.
driveMotorCurrentLimit - Current limit for the drive motor.
angleMotorCurrentLimit - Current limit for the angle motor.
-
driveMotorRampRate - The time in seconds to go from 0 to full throttle on the motor.
- (Prevents over drawing power from battery)
-
angleMotorRampRate - The time in seconds to go from 0 to full throttle on the motor.
- (Prevents overdrawing power and power loss).
-
driveEncoderPulsePerRotation - The number of encoder pulses per motor rotation, 1 for
- integrated encoders.
-
angleEncoderPulsePerRotation - The number of encoder pulses per motor rotation, 1 for
- integrated encoders.
-
moduleSteerFFCL - The kV applied to the steering motor to ensure your drivetrain does not
- drift towards a direction when rotating while translating.
+
driveMotorRampRate - The time in seconds to go from 0 to full throttle on the motor. (Prevents
+ over drawing power from battery)
+
angleMotorRampRate - The time in seconds to go from 0 to full throttle on the motor. (Prevents
+ overdrawing power and power loss).
+
driveEncoderPulsePerRotation - The number of encoder pulses per motor rotation, 1 for integrated encoders.
+
angleEncoderPulsePerRotation - The number of encoder pulses per motor rotation, 1 for integrated encoders.
+
moduleSteerFFCL - The kV applied to the steering motor to ensure your drivetrain does not drift
+ towards a direction when rotating while translating.
@@ -351,24 +346,20 @@ loadScripts(document, 'script');
double angleMotorRampRate,
int driveEncoderPulsePerRotation,
int angleEncoderPulsePerRotation)
-
Construct the swerve module physical characteristics. Assume coefficient of friction is 1.19
- (taken from blue nitrile on carpet from Studica) and optimal voltage is 12v. Assumes the drive
- motor current limit is 40A, and the angle motor current limit is 20A.
+
Construct the swerve module physical characteristics. Assume coefficient of friction is 1.19 (taken from blue
+ nitrile on carpet from Studica) and optimal voltage is 12v. Assumes the drive motor current limit is 40A, and the
+ angle motor current limit is 20A.
Parameters:
-
driveGearRatio - Gear ratio of the drive motor. Number of motor rotations to rotate the
- wheel.
-
angleGearRatio - Gear ratio of the angle motor. Number of motor rotations to spin the
- wheel.
+
driveGearRatio - Gear ratio of the drive motor. Number of motor rotations to rotate the wheel.
+
angleGearRatio - Gear ratio of the angle motor. Number of motor rotations to spin the wheel.
wheelDiameter - Wheel diameter in meters.
-
driveMotorRampRate - The time in seconds to go from 0 to full throttle on the motor.
- (Prevents over drawing power from battery)
-
angleMotorRampRate - The time in seconds to go from 0 to full throttle on the motor.
- (Prevents overdrawing power and power loss).
-
driveEncoderPulsePerRotation - The number of encoder pulses per motor rotation, 1 for
- integrated encoders.
-
angleEncoderPulsePerRotation - The number of encoder pulses per motor rotation, 1 for
- integrated encoders.
+
driveMotorRampRate - The time in seconds to go from 0 to full throttle on the motor. (Prevents over
+ drawing power from battery)
+
angleMotorRampRate - The time in seconds to go from 0 to full throttle on the motor. (Prevents
+ overdrawing power and power loss).
+
driveEncoderPulsePerRotation - The number of encoder pulses per motor rotation, 1 for integrated encoders.
+
angleEncoderPulsePerRotation - The number of encoder pulses per motor rotation, 1 for integrated encoders.
Angle motor kV used for second order kinematics to tune the feedforward, this variable should
- be adjusted so that your drive train does not drift towards the direction you are rotating
- while you translate.
+
Angle motor kV used for second order kinematics to tune the feedforward, this variable should be adjusted so that
+ your drive train does not drift towards the direction you are rotating while you translate.
The grip tape coefficient of friction on carpet. Used to calculate the practical maximum
- acceleration.
+
The grip tape coefficient of friction on carpet. Used to calculate the practical maximum acceleration.
moduleFeedForwardClosedLoop
publicdoublemoduleFeedForwardClosedLoop
-
Angle motor kV used for second order kinematics to tune the feedforward, this variable should
- be adjusted so that your drive train does not drift towards the direction you are rotating
- while you translate. Default value is 0. If robot arcs while translating and rotating negate
- this.
+
Angle motor kV used for second order kinematics to tune the feedforward, this variable should be adjusted so that
+ your drive train does not drift towards the direction you are rotating while you translate. Default value is 0. If
+ robot arcs while translating and rotating negate this.
Location JSON parsed class. Used to access the JSON data. Module locations, in inches, as
- distances to the center of the robot. +x is towards the robot front, and +y is towards robot
- left.
+
Location JSON parsed class. Used to access the JSON data. Module locations, in inches, as distances to the center of
+ the robot. +x is towards the robot front, and +y is towards robot left.
Creates a new simulation profile for a TalonFX device.
+
+
Parameters:
+
falcon - The TalonFX device
+
accelToFullTime - The time the motor takes to accelerate from 0 to full, in seconds
+
fullVel - The maximum motor velocity, in ticks per 100ms
+
sensorPhase - The phase of the TalonFX sensors
+
+
+
+
+
+
+
+
+
+
Method Details
+
+
+
+
run
+
publicvoidrun()
+
Runs the simulation profile.
+
+
This uses very rudimentary physics simulation and exists to allow users to test features of
+ our products in simulation using our examples out of the box. Users may modify this to utilize more accurate
+ physics simulation.
Creates a new simulation profile for a TalonSRX device.
+
+
Parameters:
+
talon - The TalonSRX device
+
accelToFullTime - The time the motor takes to accelerate from 0 to full, in seconds
+
fullVel - The maximum motor velocity, in ticks per 100ms
+
sensorPhase - The phase of the TalonSRX sensors
+
+
+
+
+
+
+
+
+
+
Method Details
+
+
+
+
run
+
publicvoidrun()
+
Runs the simulation profile.
+
+
This uses very rudimentary physics simulation and exists to allow users to test features of
+ our products in simulation using our examples out of the box. Users may modify this to utilize more accurate
+ physics simulation.
Creates a new simulation profile for a VictorSPX device.
+
+
Parameters:
+
victor - The VictorSPX device
+
+
+
+
+
+
+
+
+
+
Method Details
+
+
+
+
run
+
publicvoidrun()
+
Runs the simulation profile.
+
+
This uses very rudimentary physics simulation and exists to allow users to test features of
+ our products in simulation using our examples out of the box. Users may modify this to utilize more accurate
+ physics simulation.
The direction the robot should be facing when the "Robot Rotation" is zero or blank. This
- option is often useful to align with odometry data or match videos. 'up', 'right', 'down' or
- 'left'
+
The direction the robot should be facing when the "Robot Rotation" is zero or blank. This option is often useful to
+ align with odometry data or match videos. 'up', 'right', 'down' or 'left'
maxAngularVelocity
public staticdoublemaxAngularVelocity
-
The maximum achievable angular velocity of the robot. This is used to visualize the angular
- velocity from the chassis speeds properties.
+
The maximum achievable angular velocity of the robot. This is used to visualize the angular velocity from the
+ chassis speeds properties.
measuredChassisSpeeds
public staticdouble[]measuredChassisSpeeds
-
The maximum achievable angular velocity of the robot. This is used to visualize the angular
- velocity from the chassis speeds properties.
+
The maximum achievable angular velocity of the robot. This is used to visualize the angular velocity from the
+ chassis speeds properties.