电压闭环的shooter 双操均可触发autoaim intaker已验证
This commit is contained in:
@@ -15,14 +15,14 @@ public final class Constants {
|
||||
CrossingTrench
|
||||
}
|
||||
public class Shooter {
|
||||
public static final double conveyorSpeed = 20;
|
||||
public static final double conveyorSpeed = 25;
|
||||
public static final Slot0Configs flyWheelSlot0Configs = new Slot0Configs()
|
||||
.withKP(0.0).withKI(0).withKD(0)
|
||||
.withKV(0.0088).withKA(0.0).withKS(0.0);
|
||||
.withKV(0.099).withKA(0.0).withKS(0.0);
|
||||
|
||||
public static final Slot0Configs conveyorSlot0Configs = new Slot0Configs()
|
||||
.withKP(0.0).withKI(0).withKD(0)
|
||||
.withKV(0.02).withKA(0.15).withKS(0);
|
||||
.withKV(0.16).withKA(0.15).withKS(0);
|
||||
|
||||
public static final Slot0Configs backboardSlot0Configs = new Slot0Configs()
|
||||
.withKP(0.01).withKI(0).withKD(0)
|
||||
|
||||
@@ -9,6 +9,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.Commands;
|
||||
import edu.wpi.first.wpilibj2.command.InstantCommand;
|
||||
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||
import edu.wpi.first.wpilibj2.command.button.RobotModeTriggers;
|
||||
import edu.wpi.first.wpilibj2.command.button.Trigger;
|
||||
@@ -58,7 +59,7 @@ public class RobotContainer {
|
||||
private final DriveControls driveControls = new DriveControls(drivetrain, controllerlower, robotStatusManager );
|
||||
private final ShooterControls shooterControls = new ShooterControls(shooterSubsystem, controllerupper,robotStatusManager);
|
||||
private final ClimberControls climberControls = new ClimberControls(climberSubsystem, controllerupper);
|
||||
private final IntakerControls intakerControls = new IntakerControls(IntakerSubsystem, controllerupper);
|
||||
private final IntakerControls intakerControls = new IntakerControls(IntakerSubsystem, shooterSubsystem, controllerupper);
|
||||
private final DriveGainsTuner driveGainsTuner = new DriveGainsTuner(drivetrain);
|
||||
private ConfigTalonFXMotorTuner configFlywheelTuner = new ConfigTalonFXMotorTuner(shooterSubsystem.flywheelMotorLeft, "flywheel", Constants.Shooter.flyWheelSlot0Configs);
|
||||
private ConfigTalonFXMotorTuner configConveyorTuner = new ConfigTalonFXMotorTuner(shooterSubsystem.conveyorMotor, "conveyor", Constants.Shooter.conveyorSlot0Configs);
|
||||
@@ -118,9 +119,14 @@ public class RobotContainer {
|
||||
// Start:强行使用metaTag2全场定位
|
||||
controllerlower.start().whileTrue(drivetrain.run(drivetrain::forceUsingLimelightMT2));
|
||||
|
||||
//LM 按下时autoaimming
|
||||
controllerlower.leftStick().onTrue(robotStatusManager.setStatusCommand(RobotStatus.AutoAimming));
|
||||
controllerlower.leftStick().onFalse(robotStatusManager.setStatusCommand(RobotStatus.AllTelop));
|
||||
//LM 按下时autoaimming,松开时alltelop
|
||||
// controllerlower.leftStick().onTrue(robotStatusManager.setStatusCommand(RobotStatus.AutoAimming));
|
||||
// controllerlower.leftStick().onFalse(robotStatusManager.setStatusCommand(RobotStatus.AllTelop));
|
||||
|
||||
//双操均可触发autoaimming
|
||||
Trigger autoAim = controllerupper.rightBumper().or(controllerlower.leftStick());
|
||||
autoAim.onTrue(robotStatusManager.setStatusCommand(RobotStatus.AutoAimming));
|
||||
autoAim.onFalse(robotStatusManager.setStatusCommand(RobotStatus.AllTelop));
|
||||
|
||||
controllerlower.leftTrigger()
|
||||
.onTrue(robotStatusManager.setStatusCommand(RobotStatus.CrossingTrench))
|
||||
|
||||
@@ -24,9 +24,9 @@ public class ClimberControls {
|
||||
return Commands.run(()->{
|
||||
//climber.climbUp();
|
||||
if(controller.getRightY() < -0.5){
|
||||
climber.climbDownNonStop();
|
||||
} else if(controller.getRightY() > 0.5){
|
||||
climber.climbUpNonStop();
|
||||
} else if(controller.getRightY() > 0.5){
|
||||
climber.climbDownNonStop();
|
||||
} else if (controller.y().getAsBoolean()) {
|
||||
climber.climbUp();
|
||||
} else if (controller.x().getAsBoolean()) {
|
||||
|
||||
@@ -6,16 +6,19 @@ import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.Commands;
|
||||
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||
import frc.robot.subsystems.IntakerSubsystem;
|
||||
import frc.robot.subsystems.ShooterSubsystem;
|
||||
import frc.robot.Constants;
|
||||
|
||||
|
||||
public class IntakerControls {
|
||||
private final IntakerSubsystem IntakerSubsystem;
|
||||
private final CommandXboxController controller;
|
||||
private final ShooterSubsystem ShooterSubsystem;
|
||||
|
||||
//private static final double ROTATER_STEP_PER_CYCLE = 0.00;
|
||||
|
||||
public IntakerControls(IntakerSubsystem Intaker, CommandXboxController controller) {
|
||||
public IntakerControls(IntakerSubsystem Intaker, ShooterSubsystem Shooter, CommandXboxController controller) {
|
||||
this.ShooterSubsystem = Shooter;
|
||||
this.IntakerSubsystem = Intaker;
|
||||
this.controller = controller;
|
||||
}
|
||||
@@ -70,10 +73,13 @@ public class IntakerControls {
|
||||
public Command defaultIntakerCommand() {
|
||||
return Commands.run(() -> {
|
||||
double getterspeed = controller.getLeftTriggerAxis() * Constants.Intaker.IntakeGetterK + Constants.Intaker.Getterminspeed;
|
||||
double conveyoyspeedforintake = 10;
|
||||
if (controller.getLeftTriggerAxis() < 0.1) {
|
||||
getterspeed = 0;
|
||||
conveyoyspeedforintake = 0;
|
||||
}
|
||||
IntakerSubsystem.setIntakerGetterSpeed(getterspeed);
|
||||
ShooterSubsystem.setConveyorSpeedByRPS(conveyoyspeedforintake);
|
||||
|
||||
if(controller.getLeftY() < -0.5){
|
||||
IntakerSubsystem.IntakerUpNonStop();
|
||||
|
||||
@@ -8,6 +8,7 @@ import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||
import frc.robot.Constants;
|
||||
import frc.robot.RobotStatusManager;
|
||||
import frc.robot.Constants.Intaker;
|
||||
import frc.robot.Constants.RobotStatus;
|
||||
import frc.robot.subsystems.IntakerSubsystem;
|
||||
import frc.robot.subsystems.ShooterSubsystem;
|
||||
|
||||
@@ -78,12 +79,9 @@ public class ShooterControls {
|
||||
flywheelSpeed = 0;
|
||||
conveyorSpeed = 0;
|
||||
}
|
||||
if(shooterSubsystem.flywheelMotorLeft.getVelocity().getValueAsDouble()<flywheelSpeed*0.7){
|
||||
if(shooterSubsystem.flywheelMotorLeft.getVelocity().getValueAsDouble()<flywheelSpeed*0.95){
|
||||
conveyorSpeed = 0;
|
||||
}
|
||||
// flywheelSpeed = calculateFlywheelSpeedOnlywithOffset(60);
|
||||
// double flywheelSpeed = calculateFlywheelSpeed(0);
|
||||
// double BackboardPosition = calculateBackboardPosition(0);
|
||||
shooterControlTable.getEntry("flywheelTargetSpeed").setDouble(flywheelSpeed);
|
||||
shooterControlTable.getEntry("conveyerTargetSpeed").setDouble(conveyorSpeed);
|
||||
shooterControlTable.getEntry("backboardTargetPosition").setDouble(backboardPosition);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.ctre.phoenix6.configs.MotorOutputConfigs;
|
||||
import com.ctre.phoenix6.configs.Slot0Configs;
|
||||
import com.ctre.phoenix6.controls.Follower;
|
||||
import com.ctre.phoenix6.controls.VelocityDutyCycle;
|
||||
import com.ctre.phoenix6.controls.VelocityVoltage;
|
||||
import com.ctre.phoenix6.hardware.TalonFX;
|
||||
import com.ctre.phoenix6.hardware.TalonFXS;
|
||||
import com.ctre.phoenix6.signals.InvertedValue;
|
||||
@@ -31,7 +32,7 @@ public class ShooterSubsystem extends SubsystemBase {
|
||||
|
||||
private NetworkTable shooterNetworkTable;
|
||||
|
||||
private final VelocityDutyCycle velocityRequest = new VelocityDutyCycle(0);
|
||||
private final VelocityVoltage velocityRequest = new VelocityVoltage(0);
|
||||
|
||||
|
||||
// 初始化各个部件
|
||||
|
||||
Reference in New Issue
Block a user