-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added JoystickUtils, Created a wrapper for neo 550
- Loading branch information
1 parent
14eac30
commit 1086153
Showing
9 changed files
with
150 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/com/ThePinkAlliance/core/logger/CommandLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.ThePinkAlliance.core.logger; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.sql.Timestamp; | ||
import java.util.Date; | ||
|
||
public class CommandLogger { | ||
|
||
private String commandName; | ||
private String filename; | ||
private String directory = "/home/lvuser/pink/logger/"; | ||
|
||
public CommandLogger(String commandName) { | ||
this.commandName = commandName; | ||
this.filename = commandName + ".command.csv"; | ||
} | ||
|
||
public void recordWithTime(String[] rows, Object... objects) { | ||
String timestamp = new Timestamp(new Date().getTime()).toString(); | ||
File file = new File( | ||
directory + commandName + "-" + timestamp + ".command.csv" | ||
); | ||
FileWriter writer; | ||
|
||
try { | ||
writer = new FileWriter(file); | ||
|
||
if (!file.exists()) { | ||
file.createNewFile(); | ||
} | ||
} catch (IOException err) { | ||
err.printStackTrace(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.ThePinkAlliance.core.rev; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.CANSparkMaxLowLevel; | ||
|
||
public class RevNeo550 extends CANSparkMax { | ||
|
||
/** | ||
* This will configure a rev neo with amperage limit's by default. | ||
* @param channel | ||
*/ | ||
public RevNeo550(final int channel) { | ||
super(channel, CANSparkMaxLowLevel.MotorType.kBrushless); | ||
this.setSmartCurrentLimit(20); | ||
} | ||
} |
11 changes: 7 additions & 4 deletions
11
src/main/java/com/ThePinkAlliance/core/shooter/TargetPackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package com.ThePinkAlliance.core.shooter; | ||
|
||
public interface TargetPackage { | ||
public double kP = 0; | ||
public double kFF = 0; | ||
public double rpm = 0; | ||
public double hoodPosition = 0; | ||
public double getKP(); | ||
|
||
public double getKFF(); | ||
|
||
public double getRpm(); | ||
|
||
public double getHoodPosition(); | ||
} |
25 changes: 0 additions & 25 deletions
25
src/main/java/com/ThePinkAlliance/core/shooter/TargetPackageFactory.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
src/main/java/com/ThePinkAlliance/core/shooter/TargetPackageHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.ThePinkAlliance.core.shooter; | ||
|
||
public class TargetPackageHelper { | ||
|
||
public TargetPackage create( | ||
double ff, | ||
double kP, | ||
double rpm, | ||
double hoodPosition | ||
) { | ||
return new TargetPackage() { | ||
@Override | ||
public double getKFF() { | ||
return ff; | ||
} | ||
|
||
@Override | ||
public double getKP() { | ||
return kP; | ||
} | ||
|
||
@Override | ||
public double getRpm() { | ||
return rpm; | ||
} | ||
|
||
@Override | ||
public double getHoodPosition() { | ||
return hoodPosition; | ||
} | ||
}; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/com/ThePinkAlliance/core/util/JoystickUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.ThePinkAlliance.core.util; | ||
|
||
public class JoystickUtils { | ||
|
||
public static double deadband(double value, double deadband) { | ||
if (Math.abs(value) > deadband) { | ||
if (value > 0.0) { | ||
return (value - deadband) / (1.0 - deadband); | ||
} else { | ||
return (value + deadband) / (1.0 - deadband); | ||
} | ||
} else { | ||
return 0.0; | ||
} | ||
} | ||
|
||
/** | ||
* Apply deadband to the joystick input and Cube the output | ||
* @param value is the raw joystick input | ||
* @return the filtered joystick input | ||
*/ | ||
public static double modifyAxisCubed(double value) { | ||
// Deadband | ||
value = deadband(value, 0.05); | ||
|
||
// Cubing due to raw power until robot reaches competition weight. | ||
value = Math.copySign(value * value * value, value); | ||
|
||
return value; | ||
} | ||
|
||
/** | ||
* Apply deadband to the joystick input and Cube the output | ||
* @param value is the raw joystick input | ||
* @param deadband is the wanted deadband applied | ||
* @return the filtered joystick input | ||
*/ | ||
public static double modifyAxisCubed(double value, double deadband) { | ||
// Deadband | ||
value = deadband(value, deadband); | ||
|
||
// Cubing due to raw power until robot reaches competition weight. | ||
value = Math.copySign(value * value * value, value); | ||
|
||
return value; | ||
} | ||
} |