Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

37 create a basic intake subsystem #59

Merged
merged 7 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,46 +1,91 @@
package org.jmhsrobotics.frc2024.subsystems.drive.commands;

import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import com.revrobotics.CANSparkMax;

import org.jmhsrobotics.frc2024.subsystems.drive.DriveSubsystem;

import edu.wpi.first.wpilibj.Timer;
import com.revrobotics.CANSparkBase.IdleMode;
import com.revrobotics.CANSparkLowLevel.MotorType;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.PneumaticsModuleType;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj2.command.Command;

public class IntakeCommand extends Command {
private DriveSubsystem drive;
private double speed;
private Timer timer;

public IntakeCommand(DriveSubsystem drive, double speed) {
this.drive = drive;
this.speed = speed;
this.timer = new Timer();
addRequirements(this.drive);
}

@Override
public void initialize() {
// TODO Auto-generated method stub
this.timer.reset();
this.timer.start();
}

@Override
public void execute() {
// TODO Auto-generated method stub
SmartDashboard.putNumber("Intakecommand/intakespeed", this.speed);
}

@Override
public boolean isFinished() {
// TODO Auto-generated method stub
return timer.hasElapsed(5);
}

@Override
public void end(boolean interrupted) {
// TODO Auto-generated method stub
SmartDashboard.putNumber("Intakecommand/intakespeed", Double.NaN);
}
}
protected CANSparkMax innerIntakeMotor;
m10653 marked this conversation as resolved.
Show resolved Hide resolved
protected Solenoid intakeArmsVirtualSolenoidA;
protected Solenoid intakeArmsVirtualSolenoidB;
protected CANSparkMax intakeArmsMotor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our intake only will have a single motor. We probably will not have any pneumatics.

protected DigitalInput intakeSwitch;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use private access modifier.


// protected boolean isClimbing;
public IntakeCommand(DriveSubsystem driveSubsystem, int i) {
innerIntakeMotor = new CANSparkMax(IntakeConstants.innerIntakeMotor, MotorType.kBrushless);
innerIntakeMotor.restoreFactoryDefaults();
innerIntakeMotor.setInverted(true);
innerIntakeMotor.setIdleMode(IdleMode.kBrake);

innerIntakeMotor.setSmartCurrentLimit(35);

intakeArmsVirtualSolenoidA = new Solenoid(PneumaticsModuleType.CTREPCM, 3);
intakeArmsVirtualSolenoidB = new Solenoid(PneumaticsModuleType.CTREPCM, 4);
intakeArmsVirtualSolenoidA.set(false);
intakeArmsVirtualSolenoidB.set(false);

intakeArmsMotor = new CANSparkMax(IntakeConstants.intakeArmsMotor, MotorType.kBrushless);
intakeArmsMotor.restoreFactoryDefaults();
intakeArmsMotor.setInverted(true);

intakeArmsMotor.setSmartCurrentLimit(35);

intakeSwitch = new DigitalInput(IntakeConstants.intakeSwitch);
}
public void enableInnerIntakeMotor() {
innerIntakeMotor.set(1);
}
public void reverseInnerIntakeMotor() {
innerIntakeMotor.set(-1);
}
public void disableInnerIntakeMotor() {
innerIntakeMotor.set(0);
}
public void setInnerIntakeMotor(double speed) {
this.innerIntakeMotor.set(speed);
}

// implementing 836's idea
public void extendIntakeArms() {
intakeArmsVirtualSolenoidA.set(true);
intakeArmsVirtualSolenoidB.set(true);
}

// implementing 836's idea
public void retractIntakeArms() {
intakeArmsVirtualSolenoidA.set(false);
intakeArmsVirtualSolenoidB.set(false);
}

// implementing 836's idea
public void floatIntakeArms() {
intakeArmsVirtualSolenoidA.set(false);
intakeArmsVirtualSolenoidB.set(true);
}

public void enableIntakeArmsMotor() {
intakeArmsMotor.set(-0.6);
}
public void disableIntakeArmsMotor() {
intakeArmsMotor.set(0);
}
public void reverseIntakeArmsMotor() {
intakeArmsMotor.set(0.6);
}
public double extendedIntakeArmsSpeed() {
return intakeArmsMotor.get();
}

public boolean getIntakeSwitch() {
return intakeSwitch.get();
}
m10653 marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.jmhsrobotics.frc2024.subsystems.drive.commands;

public final class IntakeConstants {
static int innerIntakeMotor = 1;
static int intakeArmsMotor = 1;
static int intakeSwitch = 1;
}
m10653 marked this conversation as resolved.
Show resolved Hide resolved