mirror of
https://github.com/Team4388/2023WayOfTheRobot.git
synced 2026-06-09 00:37:59 -06:00
defualt command and soft limits
This commit is contained in:
@@ -104,6 +104,16 @@ public final class Constants {
|
|||||||
public static final class GyroConstants {
|
public static final class GyroConstants {
|
||||||
public static final int ID = -1; // TODO: find the actual ID
|
public static final int ID = -1; // TODO: find the actual ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final class ArmConstants {
|
||||||
|
public static final double PIVOT_FORWARD_SOFT_LIMIT = -1.0; // TODO: find actual value
|
||||||
|
public static final double PIVOT_REVERSE_SOFT_LIMIT = -1.0; // TODO: find actual value
|
||||||
|
|
||||||
|
public static final double TELE_FORWARD_SOFT_LIMIT = -1.0; // TODO: find actual value
|
||||||
|
public static final double TELE_REVERSE_SOFT_LIMIT = -1.0; // TODO: find actual value
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static final class LEDConstants {
|
public static final class LEDConstants {
|
||||||
public static final int LED_SPARK_ID = 0;
|
public static final int LED_SPARK_ID = 0;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import edu.wpi.first.wpilibj2.command.InstantCommand;
|
|||||||
import edu.wpi.first.wpilibj2.command.RunCommand;
|
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||||
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
|
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
|
||||||
import frc4388.robot.Constants.*;
|
import frc4388.robot.Constants.*;
|
||||||
|
import frc4388.robot.subsystems.Arm;
|
||||||
import frc4388.robot.subsystems.LED;
|
import frc4388.robot.subsystems.LED;
|
||||||
import frc4388.robot.subsystems.SwerveDrive;
|
import frc4388.robot.subsystems.SwerveDrive;
|
||||||
import frc4388.utility.LEDPatterns;
|
import frc4388.utility.LEDPatterns;
|
||||||
@@ -33,7 +34,9 @@ public class RobotContainer {
|
|||||||
|
|
||||||
/* Subsystems */
|
/* Subsystems */
|
||||||
private final SwerveDrive m_robotSwerveDrive = new SwerveDrive(m_robotMap.leftFront, m_robotMap.rightFront, m_robotMap.leftBack, m_robotMap.rightBack, m_robotMap.gyro);
|
private final SwerveDrive m_robotSwerveDrive = new SwerveDrive(m_robotMap.leftFront, m_robotMap.rightFront, m_robotMap.leftBack, m_robotMap.rightBack, m_robotMap.gyro);
|
||||||
|
private final Arm m_robotArm = new Arm(m_robotMap.pivot, m_robotMap.tele);
|
||||||
private final LED m_robotLED = new LED(m_robotMap.LEDController);
|
private final LED m_robotLED = new LED(m_robotMap.LEDController);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Controllers */
|
/* Controllers */
|
||||||
@@ -58,6 +61,11 @@ public class RobotContainer {
|
|||||||
getDriverController().getLeftYAxis(),
|
getDriverController().getLeftYAxis(),
|
||||||
-getDriverController().getRightXAxis(), false), m_robotSwerveDrive)
|
-getDriverController().getRightXAxis(), false), m_robotSwerveDrive)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
m_robotArm.setDefaultCommand(new RunCommand(() -> m_robotArm.runPivotAndTele(
|
||||||
|
getOperatorController().getLeftYAxis(),
|
||||||
|
getOperatorController().getLeftXAxis()), m_robotArm)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,11 +7,13 @@
|
|||||||
|
|
||||||
package frc4388.robot;
|
package frc4388.robot;
|
||||||
|
|
||||||
|
import com.ctre.phoenix.motorcontrol.NeutralMode;
|
||||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
|
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
|
||||||
import com.ctre.phoenix.sensors.CANCoder;
|
import com.ctre.phoenix.sensors.CANCoder;
|
||||||
import com.ctre.phoenix.sensors.WPI_Pigeon2;
|
import com.ctre.phoenix.sensors.WPI_Pigeon2;
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.motorcontrol.Spark;
|
import edu.wpi.first.wpilibj.motorcontrol.Spark;
|
||||||
|
import frc4388.robot.Constants.ArmConstants;
|
||||||
import frc4388.robot.Constants.LEDConstants;
|
import frc4388.robot.Constants.LEDConstants;
|
||||||
import frc4388.robot.Constants.SwerveDriveConstants;
|
import frc4388.robot.Constants.SwerveDriveConstants;
|
||||||
import frc4388.robot.subsystems.SwerveModule;
|
import frc4388.robot.subsystems.SwerveModule;
|
||||||
@@ -145,5 +147,20 @@ public class RobotMap {
|
|||||||
// config closed loop ramp
|
// config closed loop ramp
|
||||||
pivot.configClosedloopRamp(SwerveDriveConstants.Configurations.CLOSED_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
pivot.configClosedloopRamp(SwerveDriveConstants.Configurations.CLOSED_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
||||||
tele.configClosedloopRamp(SwerveDriveConstants.Configurations.CLOSED_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
tele.configClosedloopRamp(SwerveDriveConstants.Configurations.CLOSED_LOOP_RAMP_RATE, SwerveDriveConstants.TIMEOUT_MS);
|
||||||
|
|
||||||
|
// config neutral mode to brake
|
||||||
|
pivot.setNeutralMode(NeutralMode.Brake);
|
||||||
|
tele.setNeutralMode(NeutralMode.Brake);
|
||||||
|
|
||||||
|
// soft limits
|
||||||
|
pivot.configForwardSoftLimitThreshold(ArmConstants.PIVOT_FORWARD_SOFT_LIMIT);
|
||||||
|
pivot.configReverseSoftLimitThreshold(ArmConstants.PIVOT_REVERSE_SOFT_LIMIT);
|
||||||
|
pivot.configForwardSoftLimitEnable(false);
|
||||||
|
pivot.configReverseSoftLimitEnable(false);
|
||||||
|
|
||||||
|
tele.configForwardSoftLimitThreshold(ArmConstants.TELE_FORWARD_SOFT_LIMIT);
|
||||||
|
tele.configReverseSoftLimitThreshold(ArmConstants.TELE_REVERSE_SOFT_LIMIT);
|
||||||
|
tele.configForwardSoftLimitEnable(false);
|
||||||
|
tele.configReverseSoftLimitEnable(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,23 @@ public class Arm extends SubsystemBase {
|
|||||||
pivot.set(output);
|
pivot.set(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runTelescope(double output) {
|
public void runTele(double output) {
|
||||||
tele.set(output);
|
tele.set(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runPivotAndTele(double pOutput, double tOutput) {
|
||||||
|
pivot.set(pOutput);
|
||||||
|
tele.set(tOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPivotPos() {
|
||||||
|
return pivot.getSelectedSensorPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getTelePos() {
|
||||||
|
return tele.getSelectedSensorPosition();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void periodic() {
|
public void periodic() {
|
||||||
// This method will be called once per scheduler run
|
// This method will be called once per scheduler run
|
||||||
|
|||||||
Reference in New Issue
Block a user