Skip to content

Commit

Permalink
update funnel simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexaDaniels25 committed Feb 1, 2025
1 parent d96a3e9 commit 8b5bac0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
6 changes: 6 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,11 @@
"buttonCount": 0,
"povCount": 0
}
],
"robotJoysticks": [
{
"guid": "78696e70757401000000000000000000",
"useGamepad": true
}
]
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public static enum Mode {
public static class Funnel {
public static int winchID = 51;
public static double winchSpeed = 0.50; // Clockwise = positive, holds funnel down in position
public static int limit = 10;
public static double limit = 1;
}
}
4 changes: 1 addition & 3 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import static frc.robot.subsystems.vision.VisionConstants.*;

import java.sql.Driver;

import com.pathplanner.lib.auto.AutoBuilder;
import com.pathplanner.lib.auto.NamedCommands;
import edu.wpi.first.math.geometry.Pose2d;
Expand Down Expand Up @@ -173,7 +171,7 @@ private void configureButtonBindings() {
// Lock to 0° when A button is held

JoystickButton a = new JoystickButton(driver, XboxController.Button.kA.value);
a.whileTrue(new LiftFunnel(funnel));
a.onTrue(new LiftFunnel(funnel));

controller
.a()
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/frc/robot/subsystems/Funnel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.revrobotics.spark.SparkMax;
import com.revrobotics.spark.config.SparkBaseConfig.IdleMode;
import com.revrobotics.spark.config.SparkMaxConfig;

import edu.wpi.first.math.system.plant.DCMotor;
import edu.wpi.first.wpilibj.simulation.RoboRioSim;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
Expand All @@ -29,7 +28,7 @@ public class Funnel extends SubsystemBase {
private SparkMaxSim motorWinchSim;

public Funnel() {
if(Constants.currentMode == Constants.Mode.SIM){
if (Constants.currentMode == Constants.Mode.SIM) {
motorWinchSim = new SparkMaxSim(motorWinch, DCMotor.getNEO(1));
}
encoderWinch = motorWinch.getEncoder();
Expand All @@ -38,7 +37,6 @@ public Funnel() {
motorWinch.configure(
configWinch, ResetMode.kResetSafeParameters, PersistMode.kNoPersistParameters);
encoderWinch.setPosition(0); // improve later if time, possibly set when enabled

}

public void wind() {
Expand All @@ -55,9 +53,12 @@ public void stop() {

public Boolean limitReached() {
double position = encoderWinch.getPosition();
System.out.println("Value:" + position);
if (position > Constants.Funnel.limit) {
System.out.println("Limit Reached");
return true;
} else if (position < -Constants.Funnel.limit) {
System.out.println("Limit Reached");
return true;
}
return false;
Expand All @@ -73,7 +74,7 @@ public void periodic() {
SmartDashboard.putNumber("Funnel-Pos", encoderWinch.getPosition());
}

public void simulationPeriodic(){
public void simulationPeriodic() {
double velo = motorWinch.get() * 1.0;
double voltage = RoboRioSim.getVInVoltage();
motorWinchSim.iterate(velo, voltage, Constants.simCycleTime);
Expand Down

0 comments on commit 8b5bac0

Please sign in to comment.