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

make intake #6

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/main/java/org/wildstang/year2023/robot/WSOutputs.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public enum WSOutputs implements Outputs {
DRIVE4("Module 4 Drive Motor", new WsSparkMaxConfig(CANConstants.DRIVE4, true)),
ANGLE4("Module 4 Angle Motor", new WsSparkMaxConfig(CANConstants.ANGLE4, true)),


INTAKE_MOTOR("Intake Motor", new WsSparkMaxConfig(CANConstants.INTAKE, true)),
// ---------------------------------
// Servos
// ---------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/wildstang/year2023/robot/WSSubsystems.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.wildstang.year2023.subsystems.SampleSubsystem;
import org.wildstang.year2023.subsystems.swerve.SwerveDrive;
import org.wildstang.year2023.subsystems.targeting.AimHelper;
import org.wildstang.year2023.subsystems.intake.intake;

/**
* All subsystems are enumerated here.
Expand All @@ -13,6 +14,7 @@ public enum WSSubsystems implements Subsystems {

// enumerate subsystems
SWERVE_DRIVE("Swerve Drive", SwerveDrive.class),
INTAKE("Intake", intake.class),
//AIM_HELPER("Aim Helper", AimHelper.class),
//SAMPLE("Sample", SampleSubsystem.class)
;
Expand Down
74 changes: 74 additions & 0 deletions src/main/java/org/wildstang/year2023/subsystems/intake/intake.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package org.wildstang.year2023.subsystems.intake;

import org.wildstang.framework.core.Core;
import org.wildstang.framework.io.inputs.DigitalInput;
import org.wildstang.framework.io.inputs.AnalogInput;
import org.wildstang.framework.io.inputs.Input;
import org.wildstang.framework.subsystems.Subsystem;
import org.wildstang.hardware.roborio.inputs.WsJoystickAxis;
import org.wildstang.year2023.robot.WSInputs;

import org.wildstang.framework.subsystems.Subsystem;

import org.wildstang.hardware.roborio.outputs.WsSparkMax;
import org.wildstang.year2023.robot.WSOutputs;

/**
* Sample Subsystem that controls a motor with a joystick.
* @author Liam
jwannebo3524 marked this conversation as resolved.
Show resolved Hide resolved
*/
public class intake implements Subsystem {
// inputs

// outputs
private WsSparkMax intakeMotor;
private AnalogInput ingest, expel;


// states
private static final double ingestSpeed = 1;
private static final double expelSpeed = -1;
private static final double deadband = 0.05;

private double speed;
@Override
public void init() {

intakeMotor = (WsSparkMax) Core.getOutputManager().getOutput(WSOutputs.INTAKE_MOTOR);
ingest = (AnalogInput) Core.getInputManager().getInput(WSInputs.MANIPULATOR_LEFT_TRIGGER);
ingest.addInputListener(this);
expel = (AnalogInput) Core.getInputManager().getInput(WSInputs.MANIPULATOR_RIGHT_TRIGGER);
expel.addInputListener(this);
fruzyna marked this conversation as resolved.
Show resolved Hide resolved
speed = 0;
}

@Override
public void resetState() {
speed = 0;
}

@Override
public void update() {
intakeMotor.setValue(speed);
}

@Override
public void inputUpdate(Input source) {
if (ingest.getValue()>deadband) {
speed = ingestSpeed*ingest.getValue();
} else if (expel.getValue()>deadband) {
speed = expelSpeed*expel.getValue();
} else {
speed = 0;
}
jwannebo3524 marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
public String getName() {
return "Intake";
}

@Override
public void selfTest() {
}
}