Skip to content

Commit

Permalink
Fix Java Interop with default methods in DifferentialTrackerDriveBase
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePrimedTNT committed Jan 9, 2019
1 parent 31bf852 commit 56ecff0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
16 changes: 13 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import edu.wpi.first.toolchain.NativePlatforms
import org.gradle.api.publish.maven.MavenPublication
import io.gitlab.arturbosch.detekt.detekt
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.3.11"
Expand Down Expand Up @@ -57,6 +58,15 @@ detekt {
}
}

tasks.withType<Wrapper>().configureEach {
gradleVersion = "5.0"
}
tasks {
withType<Wrapper>().configureEach {
gradleVersion = "5.0"
}
withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += "-Xjvm-default=compatibility"
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ interface DifferentialTrackerDriveBase : TrajectoryTrackerDriveBase {

val differentialDrive: DifferentialDrive

@JvmDefault
override fun setOutput(output: TrajectoryTrackerOutput) {
setOutputFromDynamics(
output.differentialDriveVelocity,
output.differentialDriveAcceleration
)
}

@JvmDefault
fun setOutputFromKinematics(chassisVelocity: DifferentialDrive.ChassisState) {
val wheelVelocities = differentialDrive.solveInverseKinematics(chassisVelocity)
val feedForwardVoltages = differentialDrive.getVoltagesFromkV(wheelVelocities)

setOutput(wheelVelocities, feedForwardVoltages)
}

@JvmDefault
fun setOutputFromDynamics(
chassisVelocity: DifferentialDrive.ChassisState,
chassisAcceleration: DifferentialDrive.ChassisState
Expand All @@ -31,6 +34,7 @@ interface DifferentialTrackerDriveBase : TrajectoryTrackerDriveBase {
setOutput(dynamics.wheelVelocity, dynamics.voltage)
}

@JvmDefault
fun setOutput(
wheelVelocities: DifferentialDrive.WheelState,
wheelVoltages: DifferentialDrive.WheelState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface TrajectoryTrackerDriveBase {

fun setOutput(output: TrajectoryTrackerOutput)

@JvmDefault
fun zeroOutputs() {
leftMotor.percentOutput = 0.0
rightMotor.percentOutput = 0.0
Expand Down

0 comments on commit 56ecff0

Please sign in to comment.