Changement reset gyro
This commit is contained in:
parent
3ac1697bb4
commit
ed8f05fc64
@ -7,6 +7,7 @@ import edu.wpi.first.wpilibj.GenericHID;
|
|||||||
import edu.wpi.first.wpilibj.XboxController;
|
import edu.wpi.first.wpilibj.XboxController;
|
||||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
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.SequentialCommandGroup;
|
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
||||||
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
|
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
|
||||||
@ -73,7 +74,12 @@ public class RobotContainer {
|
|||||||
JoystickButton buttonX = new JoystickButton(manette, XboxController.Button.kX.value);
|
JoystickButton buttonX = new JoystickButton(manette, XboxController.Button.kX.value);
|
||||||
buttonX.whenPressed(ActiverBlockeur);
|
buttonX.whenPressed(ActiverBlockeur);
|
||||||
JoystickButton buttonstart = new JoystickButton(manette, XboxController.Button.kStart.value);
|
JoystickButton buttonstart = new JoystickButton(manette, XboxController.Button.kStart.value);
|
||||||
buttonstart.whenPressed(resetGyro);
|
buttonstart.whenPressed(
|
||||||
|
new InstantCommand(
|
||||||
|
() -> basePilotable.resetgyro(),
|
||||||
|
basePilotable
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
package frc.robot.commands;
|
package frc.robot.commands;
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.DriverStation;
|
|
||||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||||
import frc.robot.subsystems.BasePilotable;
|
import frc.robot.subsystems.BasePilotable;
|
||||||
|
|
||||||
@ -20,11 +19,6 @@ public class ResetGyro extends CommandBase {
|
|||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
try {
|
|
||||||
basePilotable.resetgyro();
|
|
||||||
} catch( Exception e) {
|
|
||||||
DriverStation.reportError("Samuel", e.getStackTrace());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,12 @@ public void drive(double y, double x, double rot){
|
|||||||
mecanum.driveCartesian(y, rot, x, -getangle());
|
mecanum.driveCartesian(y, rot, x, -getangle());
|
||||||
}
|
}
|
||||||
public void resetgyro(){
|
public void resetgyro(){
|
||||||
gyroscope.zeroYaw();
|
try {
|
||||||
|
gyroscope.zeroYaw();
|
||||||
|
} catch( Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/** Creates a new BasePilotable. */
|
/** Creates a new BasePilotable. */
|
||||||
public BasePilotable() {
|
public BasePilotable() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user