Skip to content

Commit

Permalink
Added IR sensor and limitswitches for ampertest
Browse files Browse the repository at this point in the history
  • Loading branch information
hahafoot committed Feb 17, 2024
1 parent 8def4da commit 376ff68
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 18 deletions.
Binary file added ctre_sim/CANCoder vers. H - 01 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/CANCoder vers. H - 02 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/CANCoder vers. H - 03 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/CANCoder vers. H - 04 - 0 - ext.dat
Binary file not shown.
1 change: 1 addition & 0 deletions networktables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
92 changes: 92 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"keyboardJoysticks": [
{
"axisConfig": [
{
"decKey": 65,
"incKey": 68
},
{
"decKey": 87,
"incKey": 83
},
{
"decKey": 69,
"decayRate": 0.0,
"incKey": 82,
"keyRate": 0.009999999776482582
}
],
"axisCount": 3,
"buttonCount": 4,
"buttonKeys": [
90,
88,
67,
86
],
"povConfig": [
{
"key0": 328,
"key135": 323,
"key180": 322,
"key225": 321,
"key270": 324,
"key315": 327,
"key45": 329,
"key90": 326
}
],
"povCount": 1
},
{
"axisConfig": [
{
"decKey": 74,
"incKey": 76
},
{
"decKey": 73,
"incKey": 75
}
],
"axisCount": 2,
"buttonCount": 4,
"buttonKeys": [
77,
44,
46,
47
],
"povCount": 0
},
{
"axisConfig": [
{
"decKey": 263,
"incKey": 262
},
{
"decKey": 265,
"incKey": 264
}
],
"axisCount": 2,
"buttonCount": 6,
"buttonKeys": [
260,
268,
266,
261,
269,
267
],
"povCount": 0
},
{
"axisCount": 0,
"buttonCount": 0,
"povCount": 0
}
]
}
11 changes: 11 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"NTProvider": {
"types": {
"/FMSInfo": "FMSInfo",
"/SmartDashboard/SendableChooser[1]": "String Chooser"
}
},
"NetworkTables Info": {
"visible": true
}
}
9 changes: 5 additions & 4 deletions src/main/java/com/stuypulse/robot/constants/Ports.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public interface Climber {
int LEFT_MOTOR = 60;
int RIGHT_MOTOR = 61;

int TOP_RIGHT_LIMIT = 8;
int TOP_LEFT_LIMIT = 7;
int BOTTOM_RIGHT_LIMIT = 6;
int BOTTOM_LEFT_LIMIT = 5;
int TOP_RIGHT_LIMIT = 9;
int TOP_LEFT_LIMIT = 8;
int BOTTOM_RIGHT_LIMIT = 7;
int BOTTOM_LEFT_LIMIT = 6;
}

public interface Amper {
Expand All @@ -29,6 +29,7 @@ public interface Amper {

int ALIGNED_BUMP_SWITCH = 3;
int LIFT_BOTTOM_LIMIT = 4;
int LIFT_TOP_LIMIT = 5;
int AMP_IR = 2;
}

Expand Down
24 changes: 23 additions & 1 deletion src/main/java/com/stuypulse/robot/subsystems/AmperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.stuypulse.robot.constants.Ports;
import com.stuypulse.robot.constants.Settings;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

Expand All @@ -16,7 +17,9 @@ public class AmperTest extends SubsystemBase {
private final RelativeEncoder liftEncoder;
private final RelativeEncoder scoreEncoder;


private final DigitalInput minSwitch;
private final DigitalInput maxSwitch;
private final DigitalInput ampIRSensor;

public AmperTest(){
scoreMotor = new CANSparkMax(Ports.Amper.SCORE, MotorType.kBrushless);
Expand All @@ -28,6 +31,10 @@ public AmperTest(){

liftEncoder.setPositionConversionFactor(Settings.AmperTest.Lift.Encoder.POSITION_CONVERSION);
liftEncoder.setVelocityConversionFactor(Settings.AmperTest.Lift.Encoder.VELOCITY_CONVERSION);

minSwitch = new DigitalInput(Ports.Amper.LIFT_BOTTOM_LIMIT);
maxSwitch = new DigitalInput(Ports.Amper.LIFT_TOP_LIMIT);
ampIRSensor = new DigitalInput(Ports.Amper.AMP_IR);
}

public void setAmperVoltage(double voltage){
Expand All @@ -46,12 +53,24 @@ public void stop(){
public double getScorePosition() {
return scoreEncoder.getPosition();
}

public double getLiftPosition() {
return liftEncoder.getPosition();
}

public double getLiftVelocity() {
return liftEncoder.getVelocity();
}

public boolean liftAtBottom() {
return !minSwitch.get();
}

public boolean liftAtTop() {
return !maxSwitch.get();
}


@Override
public void periodic() {
SmartDashboard.putNumber("Amper/Intake Speed", scoreMotor.get());
Expand All @@ -60,5 +79,8 @@ public void periodic() {
SmartDashboard.putNumber("Amper/Lift Current", liftMotor.getOutputCurrent());
SmartDashboard.putNumber("Amper/Lift Position", liftEncoder.getPosition());
SmartDashboard.putNumber("Amper/Score Position", scoreEncoder.getPosition());
SmartDashboard.putBoolean("Amper/Lift at Bottom", liftAtBottom());
SmartDashboard.putBoolean("Amper/Lift at Top", liftAtTop());
SmartDashboard.putBoolean("Amper/IR has note", !ampIRSensor.get());
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/stuypulse/robot/subsystems/ClimberTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.revrobotics.CANSparkMax;
import com.revrobotics.RelativeEncoder;
import com.revrobotics.CANSparkLowLevel.MotorType;
import com.stuypulse.robot.constants.Motors;
import com.stuypulse.robot.constants.Ports;
import com.stuypulse.robot.constants.Settings;

Expand All @@ -28,6 +29,9 @@ public ClimberTest(){
rightEncoder.setVelocityConversionFactor(Settings.ClimberTest.Encoder.VELOCITY_CONVERSION);
leftEncoder.setVelocityConversionFactor(Settings.ClimberTest.Encoder.VELOCITY_CONVERSION);

// Motors.Climber.LEFT_MOTOR.configure(leftMotor);
// Motors.Climber.RIGHT_MOTOR.configure(rightMotor);

}
public void setLeftVoltage(double voltage){
leftMotor.set(voltage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class SwerveTest extends SubsystemBase{
private final SwerveModuleTest[] modules;
private final SwerveModuleTest[] modules;

SendableChooser<SwerveModuleTest> moduleChooser = new SendableChooser<SwerveModuleTest>();
public SwerveTest(SwerveModuleTest... modules) {
SendableChooser<SwerveModuleTest> moduleChooser = new SendableChooser<SwerveModuleTest>();

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;
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);
}
for (var module : modules){
moduleChooser.addOption(module.getID(), module);
}

SmartDashboard.putData(moduleChooser);
SmartDashboard.putData(moduleChooser);
}

public void setDriveVoltage(double voltage){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.revrobotics.CANSparkFlex;
import com.revrobotics.CANSparkMax;
import com.revrobotics.RelativeEncoder;
import com.stuypulse.robot.constants.Motors;
import com.revrobotics.CANSparkLowLevel.MotorType;


Expand All @@ -23,6 +24,9 @@ public SwerveModuleTest(String id, int driveID, int turnID, int encoderID) {
turnEncoder = new CANcoder(encoderID);

this.id = id;

// Motors.Swerve.DRIVE_CONFIG.configure(driveMotor);
// Motors.Swerve.TURN_CONFIG.configure(turnMotor);
}

public void setTurnMotor(double voltage){
Expand Down

0 comments on commit 376ff68

Please sign in to comment.