Skip to content

Commit

Permalink
formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
narmstro2020 committed Oct 10, 2024
1 parent fe8441a commit 2ec0101
Show file tree
Hide file tree
Showing 3 changed files with 259 additions and 335 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@
/** This class simulates the state of the drivetrain. */
public class DifferentialDrivetrainSimBase extends LinearSystemSim<N4, N2, N4> {
/**
* Represents a gearing option of the Toughbox mini. 12.75:1 -- 14:50 and 14:50
* 10.71:1 -- 14:50
* and 16:48 8.45:1 -- 14:50 and 19:45 7.31:1 -- 14:50 and 21:43 5.95:1 -- 14:50
* and 24:40
* Represents a gearing option of the Toughbox mini. 12.75:1 -- 14:50 and 14:50 10.71:1 -- 14:50
* and 16:48 8.45:1 -- 14:50 and 19:45 7.31:1 -- 14:50 and 21:43 5.95:1 -- 14:50 and 24:40
*/
public enum KitbotGearing {
/** Gear ratio of 12.75:1. */
Expand Down Expand Up @@ -154,21 +152,14 @@ public enum KitbotWheelSize {
/**
* Creates a simulated differential drivetrain.
*
* @param plant The linear system that represents the drivetrain.
* @param wheel A {@link Wheel} representing one of the
* drivetrain's wheel.
* @param trackWidth The robot's track width, or distance between left
* and right wheels.
* @param measurementStdDevs Standard deviations for measurements, in the form
* [x, y, heading,
* left velocity, right velocity, left distance, right
* distance]ᵀ. Can be null if no noise is
* desired. Gyro standard deviations of 0.0001
* radians, velocity standard deviations of 0.05
* m/s, and position measurement standard deviations
* of 0.005 meters are a reasonable starting
* point. If present must have 7 elements matching the
* aforementioned measurements.
* @param plant The linear system that represents the drivetrain.
* @param wheel A {@link Wheel} representing one of the drivetrain's wheel.
* @param trackWidth The robot's track width, or distance between left and right wheels.
* @param measurementStdDevs Standard deviations for measurements, in the form [x, y, heading,
* left velocity, right velocity, left distance, right distance]ᵀ. Can be null if no noise is
* desired. Gyro standard deviations of 0.0001 radians, velocity standard deviations of 0.05
* m/s, and position measurement standard deviations of 0.005 meters are a reasonable starting
* point. If present must have 7 elements matching the aforementioned measurements.
*/
public DifferentialDrivetrainSimBase(
LinearSystem<N4, N2, N4> plant,
Expand All @@ -180,12 +171,13 @@ public DifferentialDrivetrainSimBase(
m_trackWidth = trackWidth;
double A0 = plant.getA(0, 0);
double A1 = plant.getA(1, 0);
var C1 = -wheel.gearbox.numMotors
* Math.pow(wheel.gearbox.reduction, 2)
* wheel.gearbox.motorType.KtNMPerAmp
/ (wheel.gearbox.motorType.KvRadPerSecPerVolt
* wheel.gearbox.motorType.rOhms
* Math.pow(wheel.radiusMeters, 2));
var C1 =
-wheel.gearbox.numMotors
* Math.pow(wheel.gearbox.reduction, 2)
* wheel.gearbox.motorType.KtNMPerAmp
/ (wheel.gearbox.motorType.KvRadPerSecPerVolt
* wheel.gearbox.motorType.rOhms
* Math.pow(wheel.radiusMeters, 2));
double a0massJPart = A0 / C1;
double a1massJPart = A1 / C1;
double halfMassRecip = a0massJPart + a1massJPart;
Expand All @@ -207,7 +199,7 @@ public double getCurrentGearing() {
/**
* Sets the position of the left and right encoders.
*
* @param leftPositionMeters The new left encoder position in meters.
* @param leftPositionMeters The new left encoder position in meters.
* @param rightPositionMeters The new right encoder position in meters.
*/
public void setEncoderPositions(double leftPositionMeters, double rightPositionMeters) {
Expand All @@ -218,7 +210,7 @@ public void setEncoderPositions(double leftPositionMeters, double rightPositionM
/**
* Sets the position of the left and right encoders.
*
* @param leftPosition The new left encoder position.
* @param leftPosition The new left encoder position.
* @param rightPosition The new right encoder position.
*/
public void setEncoderPositions(Distance leftPosition, Distance rightPosition) {
Expand Down Expand Up @@ -264,10 +256,8 @@ public double getRightPositionMeters() {
/**
* Sets the velocity of the left and right encoders.
*
* @param leftVelocityMetersPerSecond The new left encoder velocity in meters
* per second.
* @param rightVelocityMetersPerSecond The new right encoder velocity in meters
* per second.
* @param leftVelocityMetersPerSecond The new left encoder velocity in meters per second.
* @param rightVelocityMetersPerSecond The new right encoder velocity in meters per second.
*/
public void setEncoderVelocities(
double leftVelocityMetersPerSecond, double rightVelocityMetersPerSecond) {
Expand All @@ -278,7 +268,7 @@ public void setEncoderVelocities(
/**
* Sets the position of the left and right encoders.
*
* @param leftVelocity The new left encoder velocity.
* @param leftVelocity The new left encoder velocity.
* @param rightVelocity The new right encoder velocity.
*/
public void setEncoderVelocities(LinearVelocity leftVelocity, LinearVelocity rightVelocity) {
Expand Down Expand Up @@ -340,11 +330,9 @@ public Mass getMass() {
}

/**
* Returns the moment of inertia in kilograms meters squared around the
* drivetrain's center.
* Returns the moment of inertia in kilograms meters squared around the drivetrain's center.
*
* @return The moment of inertia in kilograms meters squared around the
* drivetrain's center.
* @return The moment of inertia in kilograms meters squared around the drivetrain's center.
*/
public double getJKgMetersSquared() {
return m_J.in(KilogramSquareMeters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@ void testModelStability() {

assertTrue(Math.abs(sim.getPose().getTranslation().getNorm()) < 100);
}
}
}
Loading

0 comments on commit 2ec0101

Please sign in to comment.