-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAutoDriveFromCornerCmd.java
94 lines (76 loc) · 2.66 KB
/
AutoDriveFromCornerCmd.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// 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 com.kauailabs.navx.frc.AHRS;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.DriveSubsystem;
import frc.robot.subsystems.FeederSubsystem;
import frc.robot.subsystems.IntakeSubsystem;
import frc.robot.subsystems.ShooterSubsystem;
import frc.robot.Constants;
public class AutoDriveFromCornerCmd extends CommandBase {
DriveSubsystem driveSubsystem;
IntakeSubsystem intakeSubsystem;
FeederSubsystem feederSubsystem;
ShooterSubsystem shooterSubsystem;
//public AHRS navx = new AHRS(Constants.DRIVE_CONSTANTS.NAVX_SPI_PORT);
Timer timer = new Timer();
/** Creates a new AutoDriveFromCornerCmd. */
public AutoDriveFromCornerCmd(DriveSubsystem driveSubsystem, IntakeSubsystem intakeSubsystem,
FeederSubsystem feederSubsystem, ShooterSubsystem shooterSubsystem) {
this.driveSubsystem = driveSubsystem;
this.intakeSubsystem = intakeSubsystem;
this.feederSubsystem = feederSubsystem;
this.shooterSubsystem = shooterSubsystem;
addRequirements(driveSubsystem, intakeSubsystem, feederSubsystem, shooterSubsystem);
}
// Called when the command is initially scheduled.
@Override
public void initialize() {
timer.reset();
timer.start();
navx.reset();
navx.calibrate();
navx.setAngleAdjustment(0);
}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
SmartDashboard.putNumber("Gyro:", navx.getAngle());
intakeSubsystem.getOutChassis();
if(timer.get() < 3){
shooterSubsystem.shoot(-0.65, 0.40);
}
else if(timer.get() <= 6){
feederSubsystem.getIn();
}
else if(timer.get() <= 9){
intakeSubsystem.getIn();
shooterSubsystem.shoot(-0.7, 0.45); // First argument: Rear, Second: Front
driveSubsystem.autoDrive(0, 0.5); // Angle - Speed
}
else if(timer.get() <= 12){
intakeSubsystem.getIn();
feederSubsystem.getIn();
}
}
// Called once the command ends or is interrupted.0
@Override
public void end(boolean interrupted) {
driveSubsystem.stop();
intakeSubsystem.stopMotor();
feederSubsystem.stopMotor();
shooterSubsystem.stopMotor();
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
if(timer.get() > 12){
return true;
}
return false;
}
}