-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from FRC6334/wip/oob1
after first comp
- Loading branch information
Showing
23 changed files
with
886 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/main/java/frc/robot/commands/AutoNavXBalanceClimb.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/*----------------------------------------------------------------------------*/ | ||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */ | ||
/* Open Source Software - may be modified and shared by FRC teams. The code */ | ||
/* must be accompanied by the FIRST BSD license file in the root directory of */ | ||
/* the project. */ | ||
/*----------------------------------------------------------------------------*/ | ||
|
||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj.Joystick; | ||
import frc.robot.OI; | ||
|
||
public class AutoNavXBalanceClimb extends CommandBase { | ||
|
||
Joystick rightStick; | ||
|
||
public AutoNavXBalanceClimb() { | ||
super("navxautobalance"); | ||
// Use requires() here to declare subsystem dependencies | ||
requires(climber); | ||
rightStick = OI.getRightDriveStick(); | ||
} | ||
|
||
// Called just before this Command runs the first time | ||
@Override | ||
protected void initialize() { | ||
System.out.println("auto balance navx started"); | ||
} | ||
|
||
// Called repeatedly when this Command is scheduled to run | ||
@Override | ||
protected void execute() { | ||
balance(); | ||
} | ||
|
||
public void balance() { | ||
double roll = climber.getRoll(); | ||
if (Math.abs(roll) < 2) | ||
roll = 0; | ||
if (roll == 0) { | ||
if (climber.getFrontClimbEncoder() > -65) { | ||
climber.driveFrontClimber(-0.35); | ||
} else climber.driveFrontClimber(0); | ||
if (climber.getBackClimbEncoder() > -65) { | ||
climber.driveBackClimber(-0.35); | ||
} else climber.driveBackClimber(0); | ||
} | ||
; | ||
if (roll > 0 && Math.ceil(climber.getFrontClimbEncoder()) >= -65) { | ||
System.out.println("I'm leaning forwards... adjusting"); | ||
if (climber.getFrontClimbEncoder() > -65) { | ||
climber.driveFrontClimber(-0.20); | ||
climber.driveBackClimber(0); | ||
} else { | ||
climber.driveFrontClimber(0); | ||
climber.driveBackClimber(0); | ||
} | ||
} else if (roll < 0) { | ||
System.out.println("I'm leaning backwards... adjusting"); | ||
if (climber.getBackClimbEncoder() > -65) { | ||
climber.driveBackClimber(-0.20); | ||
climber.driveFrontClimber(0); | ||
} else { | ||
climber.driveBackClimber(0); | ||
climber.driveFrontClimber(0); | ||
} | ||
} | ||
if (rightStick.getRawButton(4)) { | ||
climber.driveBothClimbAxleWheels(0.50); | ||
} | ||
if (rightStick.getRawButton(5)) { | ||
climber.driveBothClimbAxleWheels(-0.50); | ||
} | ||
} | ||
|
||
// Make this return true when this Command no longer needs to run execute() | ||
@Override | ||
public boolean isFinished() { | ||
return Math.ceil(climber.getFrontClimbEncoder()) <= -65 && Math.ceil(climber.getBackClimbEncoder()) <= -65; | ||
} | ||
|
||
// Called once after isFinished returns true | ||
@Override | ||
protected void end() { | ||
System.out.println("auto balance is done."); | ||
climber.driveClimbBoth(0); | ||
climber.driveBothClimbAxleWheels(0); | ||
} | ||
|
||
// Called when another command which requires one or more of the same | ||
// subsystems is scheduled to run | ||
@Override | ||
protected void interrupted() { | ||
System.out.println("auto balance interrupt"); | ||
climber.driveClimbBoth(0); | ||
climber.driveBackClimber(0); | ||
climber.driveBothClimbAxleWheels(0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/*----------------------------------------------------------------------------*/ | ||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */ | ||
/* Open Source Software - may be modified and shared by FRC teams. The code */ | ||
/* must be accompanied by the FIRST BSD license file in the root directory of */ | ||
/* the project. */ | ||
/*----------------------------------------------------------------------------*/ | ||
|
||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj.Joystick; | ||
import frc.robot.OI; | ||
import frc.robot.RobotMap.rightStick; | ||
|
||
public class DriveBackClimberX extends CommandBase { | ||
|
||
Joystick rightStick, arcadeStick; | ||
|
||
public DriveBackClimberX() { | ||
super("drivebackclimberx"); | ||
// Use requires() here to declare subsystem dependencies | ||
requires(climber); | ||
requires(driveTrain); | ||
rightStick = OI.getRightDriveStick(); | ||
arcadeStick = OI.getLeftDriveStick(); | ||
} | ||
|
||
// Called just before this Command runs the first time | ||
@Override | ||
protected void initialize() { | ||
System.out.println("back climber drive init"); | ||
} | ||
|
||
// Called repeatedly when this Command is scheduled to run | ||
@Override | ||
protected void execute() { | ||
if (rightStick.getRawButton(2)) { | ||
if (climber.getBackClimbEncoder() < 0.5) { | ||
climber.driveBackClimber(0.2); | ||
} | ||
} else { | ||
climber.driveBackClimber(0); | ||
} | ||
if (rightStick.getRawButton(4)) { | ||
climber.driveBothClimbAxleWheels(0.50); | ||
} else { | ||
climber.driveBothClimbAxleWheels(0); | ||
} | ||
if (Math.abs(arcadeStick.getY()) < 0.05) { | ||
driveTrain.arcadeDrive(0, 0); | ||
} else { | ||
driveTrain.arcadeDrive(arcadeStick.getX(), arcadeStick.getY()); | ||
} | ||
} | ||
|
||
// Make this return true when this Command no longer needs to run execute() | ||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
|
||
// Called once after isFinished returns true | ||
@Override | ||
protected void end() { | ||
System.out.println("front climber done"); | ||
climber.driveBackClimber(0); | ||
} | ||
|
||
// Called when another command which requires one or more of the same | ||
// subsystems is scheduled to run | ||
@Override | ||
protected void interrupted() { | ||
climber.driveBackClimber(0); | ||
System.out.println("back climber drive interrupt"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.