generated from StuyPulse/Phil
-
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.
finished TestProject for testing motors on the robot. Done logging w/…
… encodrs and did sweeve. yay !!!!!! :3 Co-authored-by: naveed1117 <naveed1117@users.noreply.github.com> Co-authored-by: jopy-man <jopy-man@users.noreply.github.com> Co-authored-by: Lapcas <Lapcas@users.noreply.github.com>
- Loading branch information
1 parent
c91b602
commit 3be59ec
Showing
10 changed files
with
181 additions
and
14 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
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
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
src/main/java/com/stuypulse/robot/subsystems/swervetests/SwerveTest.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,43 @@ | ||
package com.stuypulse.robot.subsystems.swervetests; | ||
|
||
import com.stuypulse.robot.subsystems.swervetests.module.SwerveModuleTest; | ||
import com.stuypulse.robot.constants.Ports.Swerve.FrontRight; | ||
import com.stuypulse.robot.subsystems.swervetests.module.SwerveModule; | ||
|
||
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class SwerveTest extends SubsystemBase{ | ||
private final SwerveModuleTest[] modules; | ||
|
||
SendableChooser<SwerveModuleTest> moduleChooser = new SendableChooser<SwerveModuleTest>(); | ||
public SwerveTest(SwerveModuleTest... modules) { | ||
|
||
new SwerveModuleTest("FrontRight", 10, 11, 1); | ||
new SwerveModuleTest("FrontLeft", 12, 13, 2); | ||
new SwerveModuleTest("BackLeft", 14, 15, 3); | ||
new SwerveModuleTest("BackRight", 16, 17, 4); | ||
|
||
this.modules = modules; | ||
|
||
for (var module : modules){ | ||
moduleChooser.addOption(module.getID(), module); | ||
} | ||
|
||
SmartDashboard.putData(moduleChooser); | ||
} | ||
|
||
public void setDriveVoltage(double voltage){ | ||
moduleChooser.getSelected().setDriveVoltage(voltage); | ||
} | ||
public void setTurnVoltage(double voltage){ | ||
moduleChooser.getSelected().setTurnMotor(voltage); | ||
} | ||
|
||
@Override | ||
public void periodic(){ | ||
SmartDashboard.putNumber("Turn Encoder Raw Vel", moduleChooser.getSelected().getTurnRawVelocity()); | ||
SmartDashboard.putNumber("Drive Encoder RPM", moduleChooser.getSelected().getDriveEncoderRPM()); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/stuypulse/robot/subsystems/swervetests/module/SwerveModule.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,9 @@ | ||
package com.stuypulse.robot.subsystems.swervetests.module; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public abstract class SwerveModule extends SubsystemBase{ | ||
public abstract String getID(); | ||
|
||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/stuypulse/robot/subsystems/swervetests/module/SwerveModuleTest.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,48 @@ | ||
package com.stuypulse.robot.subsystems.swervetests.module; | ||
|
||
import com.ctre.phoenix6.StatusSignal; | ||
import com.ctre.phoenix6.hardware.CANcoder; | ||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.RelativeEncoder; | ||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
|
||
|
||
public class SwerveModuleTest extends SwerveModule{ | ||
private final CANSparkMax turnMotor; | ||
private final CANSparkMax driveMotor; | ||
private final String id; | ||
|
||
private final RelativeEncoder driveEncoder; | ||
private final CANcoder turnEncoder; | ||
|
||
public SwerveModuleTest(String id, int driveID, int turnID, int encoderID) { | ||
turnMotor = new CANSparkMax(turnID, MotorType.kBrushless); | ||
driveMotor = new CANSparkMax(driveID, MotorType.kBrushless); | ||
|
||
driveEncoder = driveMotor.getEncoder(); | ||
turnEncoder = new CANcoder(encoderID); | ||
|
||
this.id = id; | ||
} | ||
|
||
public void setTurnMotor(double voltage){ | ||
turnMotor.set(voltage); | ||
} | ||
|
||
public void setDriveVoltage(double voltage) { | ||
driveMotor.set(voltage); | ||
} | ||
|
||
public double getDriveEncoderRPM() { | ||
return driveEncoder.getVelocity(); | ||
} | ||
|
||
public double getTurnRawVelocity() { | ||
return turnEncoder.getVelocity().getValueAsDouble(); | ||
} | ||
|
||
@Override | ||
public String getID(){ | ||
return id; | ||
} | ||
} |