Skip to content

Commit b340a9d

Browse files
authored
added creep function (#45)
* added creep function * version
1 parent db54978 commit b340a9d

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies {
3535
}
3636

3737
group = 'org.team5499'
38-
version = '2.7.4'
38+
version = '2.7.5'
3939

4040
task sourcesJar(type: Jar) {
4141
from sourceSets.main.allJava
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
package org.team5499.monkeyLib.input
22

3-
public class SpaceDriveHelper(deadband: Double, turnMult: Double) : DriveHelper() {
3+
public class SpaceDriveHelper(deadband: Double, turnMult: Double, slowMult: Double) : DriveHelper() {
44

55
private val mDeadband: Double
66
private val mTurnMult: Double
7+
private val mSlowMult: Double
78

89
init {
910
mDeadband = deadband
1011
mTurnMult = turnMult
12+
mSlowMult = slowMult
1113
}
1214

1315
public override fun calculateOutput(
1416
throttle: Double,
1517
wheel: Double,
1618
isQuickTurn: Boolean,
17-
notUsed: Boolean
19+
creep: Boolean
1820
): DriveSignal {
1921
val newThottle = super.handleDeadband(throttle, mDeadband)
2022
var newWheel = super.handleDeadband(wheel, mDeadband)
2123
val mult = if (!isQuickTurn) mTurnMult else 1.0
2224
newWheel *= mult
23-
return DriveSignal(newThottle + newWheel, newThottle - newWheel)
25+
val slow = if (creep) mSlowMult else 1.0
26+
return DriveSignal(slow * (newThottle + newWheel), slow * (newThottle - newWheel))
2427
}
2528
}

src/test/kotlin/tests/input/DriveHelperTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class DriveHelperTest {
9292
@Suppress("LongMethod")
9393
@Test
9494
fun testSpaceDriveHelper() {
95-
val helper = SpaceDriveHelper(0.02, 0.4)
95+
val helper = SpaceDriveHelper(0.02, 0.4, 0.5)
9696
var output = helper.calculateOutput(0.01, 0.01, false)
9797
assertEquals(output.left, 0.0, Epsilon.EPSILON)
9898
assertEquals(output.right, 0.0, Epsilon.EPSILON)

0 commit comments

Comments
 (0)