手动完成版(待测试)
This commit is contained in:
@@ -4,7 +4,10 @@ import edu.wpi.first.networktables.NetworkTable;
|
||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||
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.RunCommand;
|
||||
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
||||
import frc.robot.subsystems.ClimberSubsystem;
|
||||
import frc.robot.RobotStatusManager;
|
||||
import frc.robot.subsystems.IntakerSubsystem;
|
||||
@@ -13,5 +16,27 @@ import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||
import frc.robot.Constants;
|
||||
import frc.robot.Constants.RobotStatus;
|
||||
|
||||
public class Autocommand extends SequentialCommandGroup{
|
||||
public static Command climb_up(ClimberSubsystem climber) {
|
||||
return new RunCommand(() -> {
|
||||
climber.climbUp(); // 控制爬升器上升
|
||||
}, climber).withTimeout(1.0) //
|
||||
.andThen(new InstantCommand(() -> {
|
||||
climber.holdPosition(); // 停止并锁定当前爬升器位置
|
||||
}, climber));
|
||||
}
|
||||
public static Command climb_down(ClimberSubsystem climber) {
|
||||
return new RunCommand(() -> {
|
||||
climber.climbDown(); // 控制爬升器下降
|
||||
}, climber).withTimeout(1.0) //
|
||||
.andThen(new InstantCommand(() -> {
|
||||
climber.holdPosition(); // 停止并锁定当前爬升器位置
|
||||
}, climber));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ public class ClimberControls {
|
||||
public Command defaultClimberCommand() {
|
||||
return Commands.run(()->{
|
||||
//climber.climbUp();
|
||||
// 优先级:如果同时按,优先上升(你也可以反过来)
|
||||
if(controller.y().getAsBoolean()&&controller.x().getAsBoolean()){
|
||||
if(controller.getRightY() < -0.5){
|
||||
climber.climbDownNonStop();
|
||||
}
|
||||
else if (controller.y().getAsBoolean()) {
|
||||
} else if(controller.getRightY() > 0.5){
|
||||
climber.climbUpNonStop();
|
||||
} else if (controller.y().getAsBoolean()) {
|
||||
climber.climbUp();
|
||||
} else if (controller.x().getAsBoolean()) {
|
||||
climber.climbDown();
|
||||
@@ -50,4 +50,7 @@ public class ClimberControls {
|
||||
.withTimeout(0.5)
|
||||
.andThen(Commands.runOnce(climber::zeroEncoder, climber));
|
||||
}
|
||||
public Command resetClimberEncoderCommand(ClimberSubsystem climber) {
|
||||
return Commands.runOnce(climber::zeroEncoder, climber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ import frc.robot.Constants;
|
||||
|
||||
|
||||
public class IntakerControls {
|
||||
private final IntakerSubsystem intakerSubsystem;
|
||||
private final IntakerSubsystem IntakerSubsystem;
|
||||
private final CommandXboxController controller;
|
||||
|
||||
private static final double ROTATER_STEP_PER_CYCLE = 0.00; // 需要你按实际速度调:越大越快(fromAI)
|
||||
private static final double ROTATER_STEP_PER_CYCLE = 0.00;
|
||||
|
||||
public IntakerControls(IntakerSubsystem intakerSubsystem, CommandXboxController controller) {
|
||||
this.intakerSubsystem = intakerSubsystem;
|
||||
public IntakerControls(IntakerSubsystem Intaker, CommandXboxController controller) {
|
||||
this.IntakerSubsystem = Intaker;
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
@@ -73,8 +73,18 @@ public class IntakerControls {
|
||||
if (controller.getLeftTriggerAxis() < 0.1) {
|
||||
getterspeed = 0;
|
||||
}
|
||||
intakerSubsystem.setIntakerGetterSpeed(getterspeed);
|
||||
|
||||
}, intakerSubsystem);
|
||||
IntakerSubsystem.setIntakerGetterSpeed(getterspeed);
|
||||
|
||||
if(controller.getLeftY() < -0.5){
|
||||
IntakerSubsystem.IntakerDownNonStop();
|
||||
} else if(controller.getLeftY() > 0.5){
|
||||
IntakerSubsystem.IntakerUpNonStop();
|
||||
} else {
|
||||
IntakerSubsystem.stopIntakerotater();
|
||||
}
|
||||
}, IntakerSubsystem);
|
||||
}
|
||||
}
|
||||
public Command resetIntakerRotaterEncoderCommand(IntakerSubsystem intakerSubsystem) {
|
||||
return Commands.runOnce(intakerSubsystem::zeroEncoder, intakerSubsystem);
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,6 @@ public class ShooterControls {
|
||||
var xP = shooterSubsystem.getDistance();
|
||||
//xP = Math.max(1.2, Math.min(4.5, xP));
|
||||
flywheelSpeed = 0.6956596811733782*xP*xP*xP*xP*xP*xP*xP-14.164408860183267*xP*xP*xP*xP*xP*xP+119.7115375240918*xP*xP*xP*xP*xP-543.0984876677477*xP*xP*xP*xP+1425.1928543240738*xP*xP*xP-2156.199296490315*xP*xP+1736.568139600292*xP-516.097598057351;
|
||||
|
||||
flywheelSpeed += flywheelSpeedOffset;
|
||||
backboardPosition = xP*xP;//todo:实测传球的时候的背板位置 打表
|
||||
backboardPosition += backboardPositionOffset;
|
||||
|
||||
Reference in New Issue
Block a user