This repository was archived by the owner on Jun 9, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathDriveWithJoystickCommand.java
More file actions
78 lines (64 loc) · 2.26 KB
/
Copy pathDriveWithJoystickCommand.java
File metadata and controls
78 lines (64 loc) · 2.26 KB
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
// 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 frc.robot.Robot;
import frc.robot.RobotContainer;
import frc.robot.subsystems.DrivetrainSubsystem;
import edu.wpi.first.wpilibj2.command.CommandBase;
/** An example command that uses an example subsystem. */
public class DriveWithJoystickCommand extends CommandBase {
@SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" })
private final DrivetrainSubsystem drivetrainSubsystem;
//private JoystickButton intake1;
/**
* Creates a new ExampleCommand.
*
* @param subsystem The subsystem used by this command.
*/
public DriveWithJoystickCommand(DrivetrainSubsystem drivetrainSubsystem) {
this.drivetrainSubsystem = drivetrainSubsystem;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(drivetrainSubsystem);
}
// Called when the command is initially scheduled.
@Override
public void initialize() {
//System.out.println("Starting joystick drive command");
}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
double forwardSpeed = RobotContainer.joystick.getRawAxis(1);// * Math.abs(RobotContainer.joystick.getRawAxis(1));
double turningSpeed = RobotContainer.joystick.getRawAxis(4);
if (turningSpeed > 0.75){
turningSpeed = 0.75;
}
// * Math.abs(RobotContainer.joystick.getRawAxis(4));
DrivetrainSubsystem.arcadeDrive((forwardSpeed * Robot.multiple), (turningSpeed * Robot.multiple));
// if(RobotContainer.joystick.getRawButtonPressed (4)){
// Intake.intake(-0.6);
// }
// if(RobotContainer.joystick.getRawButtonPressed(3)){
// Intake.intake(-0);
// }
/*else{
Robot.intake.set(0);
}
if(RobotContainer.joystick.getRawButtonPressed(6)){
Robot.intake.set(-0.5);
}
else{
Robot.intake.set(0);
}*/
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}