Created
January 24, 2013 21:01
-
-
Save nimdahk/4627695 to your computer and use it in GitHub Desktop.
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
/*----------------------------------------------------------------------------*/ | |
/* Copyright (c) FIRST 2008. 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 edu.wpi.first.wpilibj.templates; | |
import edu.wpi.first.wpilibj.DriverStationLCD; | |
import edu.wpi.first.wpilibj.IterativeRobot; | |
import edu.wpi.first.wpilibj.Jaguar; | |
import edu.wpi.first.wpilibj.Joystick; | |
import edu.wpi.first.wpilibj.Solenoid; | |
import edu.wpi.first.wpilibj.Victor; | |
import edu.wpi.first.wpilibj.camera.AxisCamera; | |
/** | |
* The VM is configured to automatically run this class, and to call the | |
* functions corresponding to each mode, as described in the IterativeRobot | |
* documentation. If you change the name of this class or the package after | |
* creating this project, you must also update the manifest file in the resource | |
* directory. | |
*/ | |
public class RobotTemplate extends IterativeRobot { | |
Jaguar Shooter1; | |
//Jaguar Shooter2; | |
Victor Shooter3; | |
Joystick Joystick1; | |
double shootValue1 = 0; | |
double shootValue2 = 0; | |
double motorSpeed1, motorSpeed2; | |
Solenoid s1; | |
Solenoid s2; | |
AxisCamera camera; | |
/** | |
* This function is run when the robot is first started up and should be | |
* used for any initialization code. | |
*/ | |
public void robotInit() { | |
Shooter1 = new Jaguar(1); | |
//Shooter2 = new Jaguar(2); | |
Shooter3 = new Victor(3); | |
Joystick1 = new Joystick(1); | |
s1 = new Solenoid(1); | |
s2 = new Solenoid(2); | |
//Camera | |
camera = AxisCamera.getInstance(); | |
camera.writeResolution(AxisCamera.ResolutionT.k320x240); | |
camera.writeBrightness(0); | |
} | |
/** | |
* This function is called periodically during autonomous | |
*/ | |
public void autonomousPeriodic() { | |
} | |
/** | |
* This function is called periodically during operator control | |
*/ | |
public void teleopPeriodic() { | |
change(); | |
shoot(); | |
getValue(); | |
} | |
/** | |
* This function is called periodically during test mode | |
*/ | |
public void testPeriodic() { | |
} | |
private void shoot(){ | |
Shooter1.set(shootValue1); | |
Shooter3.set(shootValue2); | |
if (Joystick1.getRawButton(8)){ | |
s1.set(true); | |
}else{ | |
s1.set(false); | |
} | |
if (Joystick1.getRawButton(9)){ | |
s2.set(true); | |
}else{ | |
s2.set(false); | |
} | |
} | |
private void change(){ | |
if (Joystick1.getRawButton(2)) { | |
shootValue1 -= .01; | |
} | |
else if (Joystick1.getRawButton(3)) { | |
shootValue1 += .01; | |
} | |
if (Joystick1.getRawButton(4)) { | |
shootValue2 -= .01; | |
} | |
else if (Joystick1.getRawButton(5)) { | |
shootValue2 += .01; | |
} | |
} | |
private void getValue(){ | |
motorSpeed1 = Shooter1.get(); | |
motorSpeed2 = Shooter3.get(); | |
DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser1, 1, motorSpeed1+""); | |
DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser2, 1, motorSpeed2+""); | |
DriverStationLCD.getInstance().updateLCD(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment