Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
Unit updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel1464 committed Jan 9, 2024
1 parent dc1da73 commit 5b2ff9f
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ configurations.configureEach {

kotlin {
explicitApi()
//jvmToolchain(17)
//jvmToolchain(21)

compileKotlin {
compilerOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ public final class ChargerLibBuildConstants {
public static final String MAVEN_GROUP = "frc.chargers";
public static final String MAVEN_NAME = "ChargerLib";
public static final String VERSION = "1.0.0";
public static final int GIT_REVISION = 260;
public static final String GIT_SHA = "d05f31b80fc224b4c9522cbbd9c14e0bacb362b9";
public static final String GIT_DATE = "2024-01-07T18:34:00Z";
public static final int GIT_REVISION = 261;
public static final String GIT_SHA = "dc1da73de4a09c1eae729551160a95126f179563";
public static final String GIT_DATE = "2024-01-09T12:51:49Z";
public static final String GIT_BRANCH = "master";
public static final String BUILD_DATE = "2024-01-07T20:26:19Z";
public static final long BUILD_UNIX_TIME = 1704677179102L;
public static final String BUILD_DATE = "2024-01-09T13:45:32Z";
public static final long BUILD_UNIX_TIME = 1704825932597L;
public static final int DIRTY = 1;

private ChargerLibBuildConstants(){}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ public class EncoderDifferentialDrivetrain(
getInput = {leftVelocity},
target = AngularVelocity(0.0),
setpointSupplier = SetpointSupplier.Default(
feedforward = Feedforward(controlData.leftFF)
// leftFF stores the left feedforward constants.
Feedforward(controlData.leftFF)
),
selfSustain = true,
)
Expand All @@ -142,7 +143,8 @@ public class EncoderDifferentialDrivetrain(
getInput = {rightVelocity},
target = AngularVelocity(0.0),
setpointSupplier = SetpointSupplier.Default(
feedforward = Feedforward(controlData.rightFF)
// rightff stores the right feedforward constants.
Feedforward(controlData.rightFF)
),
selfSustain = true,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import frc.chargers.hardware.subsystems.swervedrive.module.*
import frc.chargers.hardware.subsystems.swervedrive.module.lowlevel.*
import frc.chargers.pathplannerextensions.asPathPlannerConstants
import frc.chargers.utils.math.inputModulus
import frc.chargers.utils.math.units.pow
import frc.chargers.utils.math.units.sqrt
import frc.chargers.wpilibextensions.geometry.ofUnit
import frc.chargers.wpilibextensions.geometry.twodimensional.UnitPose2d
import frc.chargers.wpilibextensions.geometry.twodimensional.UnitTranslation2d
Expand Down Expand Up @@ -338,7 +336,7 @@ public class EncoderHolonomicDrivetrain(
*/
public val velocity: Velocity get(){
val speeds = currentSpeeds
return sqrt(speeds.xVelocity.pow(2.0) + speeds.yVelocity.pow(2.0))
return hypot(speeds.xVelocity, speeds.yVelocity)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ import kotlin.internal.LowPriorityInOverloadResolution
/**
* Represents a kV gain for an angular velocity targeting feedforward.
*/
public typealias VoltagePerAngularVelocity = Quantity<VoltagePerAngularVelocityDimension>
public typealias VoltagePerAngularVelocity = KmeasureUnit<VoltagePerAngularVelocityDimension>

/**
* Represents a kV gain for a linear velocity targeting feedforward.
*/
public typealias VoltagePerVelocity = Quantity<VoltagePerVelocityDimension>
public typealias VoltagePerVelocity = KmeasureUnit<VoltagePerVelocityDimension>

/**
* Represents a kA gain for an angular velocity targeting feedforward.
*/
public typealias VoltagePerAngularAcceleration = Quantity<VoltagePerAngularAccelerationDimension>
public typealias VoltagePerAngularAcceleration = KmeasureUnit<VoltagePerAngularAccelerationDimension>

/**
* Represents a kA gain for a linear velocity targeting feedforward.
*/
public typealias VoltagePerAcceleration = Quantity<VoltagePerAccelerationDimension>
public typealias VoltagePerAcceleration = KmeasureUnit<VoltagePerAccelerationDimension>


public typealias VoltagePerAngularVelocityDimension = MagneticFluxDimension
Expand All @@ -39,6 +39,9 @@ public typealias VoltagePerAngularAccelerationDimension = Dimension<Mass1, Lengt
public typealias VoltagePerAccelerationDimension = Dimension<Mass1, Length1, TimeN1, CurrentN1>





@JvmName("KvMultipliedAngular")
@LowPriorityInOverloadResolution
public operator fun VoltagePerAngularVelocity.times(other: Time): VoltagePerAngularAcceleration =
Expand Down
20 changes: 0 additions & 20 deletions src/main/kotlin/frc/chargers/utils/math/units/Operations.kt

This file was deleted.

12 changes: 12 additions & 0 deletions src/main/kotlin/frc/chargers/utils/math/units/Rem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package frc.chargers.utils.math.units

import com.batterystaple.kmeasure.dimensions.*
import com.batterystaple.kmeasure.quantities.*


public operator fun <D: AnyDimension> Quantity<D>.rem(other: Quantity<D>): Quantity<D> =
Quantity(siValue % other.siValue)




0 comments on commit 5b2ff9f

Please sign in to comment.