Skip to content

Commit eaa94b2

Browse files
Tony Brarsentientspud
authored andcommitted
Separate DriveTank multipliers and use ips instead of power
Inches per second -- set speed directly, not a power from 0 to 1
1 parent 3480721 commit eaa94b2

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

config/commands.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
DriveTank:
22
deadzone: .05
3-
multiplier: 1.0
3+
leftMultiplier: 120.0
4+
rightMultiplier: 120.0
45
exponent: 2.0
56

67
PickerToHome:
@@ -110,4 +111,4 @@ AutoInit:
110111
commands:
111112
- PickerToCheval
112113
- PickerToHome
113-
- PickerToPick
114+
- PickerToPick

config/subsystems.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Drive:
1212
maxIError: 24.0
1313
# dataLogging: true
1414
driveMode: CONTROLLER
15-
maxSpeed: 156.0
15+
maxSpeed: 120.0
1616
Picker:
1717
pickMotor: { channel: 6, inverted: false }
1818
longCylinder: 4

core/src/main/java/org/teamtators/rotator/commands/DriveTank.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ protected boolean step() {
4141
double leftPower = -driverJoystick.getAxisValue(LogitechF310.Axis.LEFT_STICK_Y);
4242
double rightPower = -driverJoystick.getAxisValue(LogitechF310.Axis.RIGHT_STICK_Y);
4343
leftPower = DriveUtils.applyDriveModifiers(leftPower,
44-
config.deadzone, config.multiplier, config.exponent);
44+
config.deadzone, config.leftMultiplier, config.exponent);
4545
rightPower = DriveUtils.applyDriveModifiers(rightPower,
46-
config.deadzone, config.multiplier, config.exponent);
46+
config.deadzone, config.rightMultiplier, config.exponent);
4747

4848
drive.setSpeeds(leftPower, rightPower);
4949

@@ -52,7 +52,8 @@ protected boolean step() {
5252

5353
static class Config {
5454
public double deadzone;
55-
public double multiplier;
55+
public double leftMultiplier;
56+
public double rightMultiplier;
5657
public double exponent;
5758
}
5859
}

core/src/main/java/org/teamtators/rotator/subsystems/AbstractDrive.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,42 @@ public AbstractDrive() {
2222
/**
2323
* It sets the power to the drivetrain motors
2424
*
25-
* @param leftSpeed power for the left motor, between 0 and 1
26-
* @param rightSpeed power for the right motor, btwn 0 and 1
25+
* @param leftSpeed speed for the left motor in inches per second
26+
* @param rightSpeed speed for the right motor in inches per second
2727
*/
2828
public void setSpeeds(double leftSpeed, double rightSpeed) {
2929
setLeftSpeed(leftSpeed);
3030
setRightSpeed(rightSpeed);
3131
}
3232

33+
/**
34+
* Set the speed of the left half of the drivetrain
35+
*
36+
* @param leftSpeed Left motor speed in inches per second
37+
*/
3338
public void setLeftSpeed(double leftSpeed) {
3439
switch (driveMode) {
3540
case DIRECT:
36-
setLeftPower(leftSpeed);
41+
setLeftPower(leftSpeed / maxSpeed);
3742
break;
3843
case CONTROLLER:
39-
leftController.setSetpoint(leftSpeed * maxSpeed);
44+
leftController.setSetpoint(leftSpeed);
4045
break;
4146
}
4247
}
4348

49+
/**
50+
* Set the speed of the right half of the drivetrain
51+
*
52+
* @param rightSpeed Right motor speed in inches per second
53+
*/
4454
public void setRightSpeed(double rightSpeed) {
4555
switch (driveMode) {
4656
case DIRECT:
47-
setRightPower(rightSpeed);
57+
setRightPower(rightSpeed / maxSpeed);
4858
break;
4959
case CONTROLLER:
50-
rightController.setSetpoint(rightSpeed * maxSpeed);
60+
rightController.setSetpoint(rightSpeed);
5161
break;
5262
}
5363
}

0 commit comments

Comments
 (0)