-
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.
Merge pull request #33 from 4201VitruvianBots/End-Effector
Basic Endeffector outline
- Loading branch information
Showing
7 changed files
with
250 additions
and
29 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
45 changes: 45 additions & 0 deletions
45
src/main/java/frc/robot/commands/RunEndEffectorIntake.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,45 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.EndEffector; | ||
|
||
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ | ||
public class RunEndEffectorIntake extends Command { | ||
|
||
private final EndEffector m_EndEffector; | ||
private final double m_speed; | ||
|
||
/** Creates a new SetAlgaeIntakeSpeed. */ | ||
public RunEndEffectorIntake(EndEffector endeffector, double speed) { | ||
m_EndEffector = endeffector; | ||
m_speed = speed; | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
addRequirements(m_EndEffector); | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() {} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() { | ||
m_EndEffector.setPercentOutput(m_speed); | ||
} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) { | ||
m_EndEffector.setPercentOutput(0); | ||
} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
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,39 @@ | ||
package frc.robot.constants; | ||
|
||
public class ENDEFFECTOR { | ||
public static final double kP = 0.0; | ||
public static final double kI = 0.0; | ||
public static final double kD = 0.0; | ||
public static final double endEffectorGearRatio = 1.0; | ||
|
||
// Pivot motor stuff | ||
public static final double minAngleDegrees = 270; | ||
public static final double maxAngleDegrees = 3; | ||
|
||
public static final double kPivotP = 0.0; | ||
public static final double kPivotI = 0.0; | ||
public static final double kPivotD = 0.0; | ||
|
||
public static final double endEffectorPivotGearRatio = 70.0; | ||
|
||
public enum WRIST_SETPOINT { | ||
STOWED(0), | ||
L4(0), | ||
L3_L2(0); | ||
|
||
private final double angle; | ||
|
||
WRIST_SETPOINT(double angle) { | ||
this.angle = angle; | ||
} | ||
|
||
public double get() { | ||
return angle; | ||
} | ||
} | ||
|
||
public enum STATE { | ||
STILL, | ||
MOVING | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.subsystems; | ||
|
||
import com.ctre.phoenix6.configs.TalonFXConfiguration; | ||
import com.ctre.phoenix6.hardware.TalonFX; | ||
import com.ctre.phoenix6.signals.NeutralModeValue; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.constants.ENDEFFECTOR; | ||
import frc.robot.constants.V2CAN; | ||
import frc.robot.utils.CtreUtils; | ||
|
||
public class EndEffector extends SubsystemBase { | ||
private final TalonFX m_endEffectorMotor = new TalonFX(V2CAN.endEffectorOuttakeMotor); | ||
|
||
/** Creates a new EndEffector. */ | ||
public EndEffector() { | ||
TalonFXConfiguration m_endEffectorMotorconfig = new TalonFXConfiguration(); | ||
m_endEffectorMotorconfig.Slot0.kP = ENDEFFECTOR.kP; | ||
m_endEffectorMotorconfig.Slot0.kI = ENDEFFECTOR.kI; | ||
m_endEffectorMotorconfig.Slot0.kD = ENDEFFECTOR.kD; | ||
m_endEffectorMotorconfig.MotorOutput.NeutralMode = NeutralModeValue.Coast; | ||
m_endEffectorMotorconfig.Feedback.SensorToMechanismRatio = ENDEFFECTOR.endEffectorGearRatio; | ||
CtreUtils.configureTalonFx(m_endEffectorMotor, m_endEffectorMotorconfig); | ||
} | ||
|
||
public void setPercentOutput(double output) { | ||
m_endEffectorMotor.set(output); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
// This method will be called once per scheduler run | ||
} | ||
} |
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,67 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.subsystems; | ||
|
||
import com.ctre.phoenix6.configs.TalonFXConfiguration; | ||
import com.ctre.phoenix6.hardware.CANcoder; | ||
import com.ctre.phoenix6.hardware.TalonFX; | ||
import com.ctre.phoenix6.signals.NeutralModeValue; | ||
import edu.wpi.first.math.MathUtil; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.constants.ENDEFFECTOR; | ||
import frc.robot.constants.V2CAN; | ||
|
||
public class EndEffectorWrist extends SubsystemBase { | ||
|
||
private final TalonFX m_pivotMotor = new TalonFX(V2CAN.endEffectorPivotMotor); | ||
private final CANcoder m_pivotEncoder = new CANcoder(V2CAN.endEffecotrPivotCanCoder); | ||
|
||
private final NeutralModeValue m_neutralMode = NeutralModeValue.Brake; | ||
|
||
// private final MotionMagicTorqueCurrentFOC m_request = new MotionMagicTorqueCurrentFOC(); | ||
|
||
private double m_desiredRotations; | ||
private boolean m_pivotState; | ||
|
||
/** Creates a nepw EndEffectorWrist. */ | ||
public EndEffectorWrist() { | ||
TalonFXConfiguration configuration = new TalonFXConfiguration(); | ||
configuration.Slot0.kP = ENDEFFECTOR.kP; | ||
configuration.Slot0.kI = ENDEFFECTOR.kI; | ||
configuration.Slot0.kD = ENDEFFECTOR.kD; | ||
configuration.MotorOutput.NeutralMode = m_neutralMode; | ||
configuration.Feedback.RotorToSensorRatio = ENDEFFECTOR.endEffectorPivotGearRatio; | ||
} | ||
|
||
public void setState(boolean state) { | ||
m_pivotState = state; | ||
} | ||
|
||
public boolean getState() { | ||
return m_pivotState; | ||
} | ||
|
||
public void setPosition(double rotations) { | ||
m_desiredRotations = | ||
MathUtil.clamp(rotations, ENDEFFECTOR.minAngleDegrees, ENDEFFECTOR.maxAngleDegrees); | ||
} | ||
|
||
public double getPosition() { | ||
return m_desiredRotations; | ||
} | ||
|
||
public void setPercentOutput(double speed) { | ||
m_pivotMotor.set(speed); | ||
} | ||
|
||
public double getPercentOutput() { | ||
return m_pivotMotor.get(); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
// This method will be called once per scheduler run | ||
} | ||
} |
Oops, something went wrong.