From d47beae933134c2008e3b1f393de8871b085df34 Mon Sep 17 00:00:00 2001 From: Piyush Kancharlawar Date: Wed, 14 Jan 2015 19:52:51 -0500 Subject: [PATCH 1/6] removed some unessacary comments --- PiyushOMatic/bin/.gitignore | 1 - .../org/usfirst/frc2974/PiyushOMatic/OI.java | 27 ------------------- 2 files changed, 28 deletions(-) delete mode 100644 PiyushOMatic/bin/.gitignore diff --git a/PiyushOMatic/bin/.gitignore b/PiyushOMatic/bin/.gitignore deleted file mode 100644 index cf1db2e..0000000 --- a/PiyushOMatic/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/org/ diff --git a/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java b/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java index 7fa8c43..f657bf7 100644 --- a/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java +++ b/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java @@ -23,33 +23,6 @@ */ @SuppressWarnings("unused") public class OI { - //// CREATING BUTTONS - // One type of button is a joystick button which is any button on a joystick. - // You create one by telling it which joystick it's on and which button - // number it is. - // Joystick stick = new Joystick(port); - // Button button = new JoystickButton(stick, buttonNumber); - - // There are a few additional built in buttons you can use. Additionally, - // by subclassing Button you can create custom triggers and bind those to - // commands the same as any other Button. - - //// TRIGGERING COMMANDS WITH BUTTONS - // Once you have a button, it's trivial to bind it to a button in one of - // three ways: - - // Start the command when the button is pressed and let it run the command - // until it is finished as determined by it's isFinished method. - // button.whenPressed(new ExampleCommand()); - - // Run the command while the button is being held down and interrupt it once - // the button is released. - // button.whileHeld(new ExampleCommand()); - - // Start the command when the button is released and let it run the command - // until it is finished as determined by it's isFinished method. - // button.whenReleased(new ExampleCommand()); - // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS public Joystick left; From 1c0e00c32e62a0a98544fefc61414cb72010facb Mon Sep 17 00:00:00 2001 From: Piyush K Date: Sun, 18 Jan 2015 12:21:37 -0500 Subject: [PATCH 2/6] Update OI.java --- .../org/usfirst/frc2974/PiyushOMatic/OI.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java b/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java index f657bf7..def1967 100644 --- a/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java +++ b/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java @@ -23,6 +23,32 @@ */ @SuppressWarnings("unused") public class OI { + //// CREATING BUTTONS +- // One type of button is a joystick button which is any button on a joystick. +- // You create one by telling it which joystick it's on and which button +- // number it is. +- // Joystick stick = new Joystick(port); +- // Button button = new JoystickButton(stick, buttonNumber); +- +- // There are a few additional built in buttons you can use. Additionally, +- // by subclassing Button you can create custom triggers and bind those to +- // commands the same as any other Button. +- +- //// TRIGGERING COMMANDS WITH BUTTONS +- // Once you have a button, it's trivial to bind it to a button in one of +- // three ways: +- +- // Start the command when the button is pressed and let it run the command +- // until it is finished as determined by it's isFinished method. +- // button.whenPressed(new ExampleCommand()); +- +- // Run the command while the button is being held down and interrupt it once +- // the button is released. +- // button.whileHeld(new ExampleCommand()); +- +- // Start the command when the button is released and let it run the command +- // until it is finished as determined by it's isFinished method. +- // button.whenReleased(new ExampleCommand()); // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS public Joystick left; From 32ed19de127507ab6612e097b9e33f55acd17f8b Mon Sep 17 00:00:00 2001 From: Piyush K Date: Sun, 18 Jan 2015 12:23:13 -0500 Subject: [PATCH 3/6] Update OI.java --- .../org/usfirst/frc2974/PiyushOMatic/OI.java | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java b/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java index def1967..d320194 100644 --- a/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java +++ b/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java @@ -24,31 +24,32 @@ @SuppressWarnings("unused") public class OI { //// CREATING BUTTONS -- // One type of button is a joystick button which is any button on a joystick. -- // You create one by telling it which joystick it's on and which button -- // number it is. -- // Joystick stick = new Joystick(port); -- // Button button = new JoystickButton(stick, buttonNumber); -- -- // There are a few additional built in buttons you can use. Additionally, -- // by subclassing Button you can create custom triggers and bind those to -- // commands the same as any other Button. -- -- //// TRIGGERING COMMANDS WITH BUTTONS -- // Once you have a button, it's trivial to bind it to a button in one of -- // three ways: -- -- // Start the command when the button is pressed and let it run the command -- // until it is finished as determined by it's isFinished method. -- // button.whenPressed(new ExampleCommand()); -- -- // Run the command while the button is being held down and interrupt it once -- // the button is released. -- // button.whileHeld(new ExampleCommand()); -- -- // Start the command when the button is released and let it run the command -- // until it is finished as determined by it's isFinished method. -- // button.whenReleased(new ExampleCommand()); + // One type of button is a joystick button which is any button on a joystick. + // You create one by telling it which joystick it's on and which button + // number it is. + // Joystick stick = new Joystick(port); + // Button button = new JoystickButton(stick, buttonNumber); + + // There are a few additional built in buttons you can use. Additionally, + // by subclassing Button you can create custom triggers and bind those to + // commands the same as any other Button. + + //// TRIGGERING COMMANDS WITH BUTTONS + // Once you have a button, it's trivial to bind it to a button in one of + // three ways: + + // Start the command when the button is pressed and let it run the command + // until it is finished as determined by it's isFinished method. + // button.whenPressed(new ExampleCommand()); + + // Run the command while the button is being held down and interrupt it once + // the button is released. + // button.whileHeld(new ExampleCommand()); + + // Start the command when the button is released and let it run the command + // until it is finished as determined by it's isFinished method. + // button.whenReleased(new ExampleCommand()); + // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS public Joystick left; From f8d7a2a9244261f57405a6b9feb115bd146beea4 Mon Sep 17 00:00:00 2001 From: Piyush Kancharlawar Date: Sun, 18 Jan 2015 12:51:08 -0500 Subject: [PATCH 4/6] Revert "removed some unessacary comments" This reverts commit d47beae933134c2008e3b1f393de8871b085df34. Conflicts: PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/OI.java Revert "Update OI.java" This reverts commit 32ed19de127507ab6612e097b9e33f55acd17f8b. --- PiyushOMatic/bin/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 PiyushOMatic/bin/.gitignore diff --git a/PiyushOMatic/bin/.gitignore b/PiyushOMatic/bin/.gitignore new file mode 100644 index 0000000..cf1db2e --- /dev/null +++ b/PiyushOMatic/bin/.gitignore @@ -0,0 +1 @@ +/org/ From cf997d3a251e3955a3cd88c7aa469e6d9979aa64 Mon Sep 17 00:00:00 2001 From: Piyush Kancharlawar Date: Sun, 18 Jan 2015 13:02:37 -0500 Subject: [PATCH 5/6] Add Camera Add the camera code for a simple USB camera that broadcasts to the smart dashboard --- .../usfirst/frc2974/PiyushOMatic/Robot.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/Robot.java b/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/Robot.java index 1ac2cee..cf0e318 100644 --- a/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/Robot.java +++ b/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/Robot.java @@ -11,7 +11,9 @@ package org.usfirst.frc2974.PiyushOMatic; +import edu.wpi.first.wpilibj.CameraServer; import edu.wpi.first.wpilibj.IterativeRobot; +import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.command.Command; import edu.wpi.first.wpilibj.command.Scheduler; import edu.wpi.first.wpilibj.livewindow.LiveWindow; @@ -33,6 +35,10 @@ public class Robot extends IterativeRobot { public Command autonomousCommand; + + //camera + CameraServer server; + public static OI oi; // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS public static DriveTrain driveTrain; @@ -61,6 +67,12 @@ public void robotInit() { // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS // autonomousCommand = new ForwardForFeet(5); // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS + + //camera + server = CameraServer.getInstance(); + server.setQuality(50); + //the camera name (ex "cam0") can be found through the roborio web interface + server.startAutomaticCapture("cam0"); } /** @@ -116,4 +128,17 @@ public void teleopPeriodic() { public void testPeriodic() { LiveWindow.run(); } + + + /** + * start up automatic capture you should see the video stream from the + * webcam in your FRC PC Dashboard. + */ + public void operatorControl() { + + while (isOperatorControl() && isEnabled()) { + /** robot code here! **/ + Timer.delay(0.005); // wait for a motor update time + } + } } From 5d81a6056793b2141ef974c3002f8d7e4350d19b Mon Sep 17 00:00:00 2001 From: Piyush Kancharlawar Date: Sun, 18 Jan 2015 13:22:49 -0500 Subject: [PATCH 6/6] Robot Auton drive forward Made robot end parallel to its start position --- .../autonomous/ForwardForFeet.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/autonomous/ForwardForFeet.java b/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/autonomous/ForwardForFeet.java index fdb1b19..e6af857 100644 --- a/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/autonomous/ForwardForFeet.java +++ b/PiyushOMatic/src/org/usfirst/frc2974/PiyushOMatic/autonomous/ForwardForFeet.java @@ -20,14 +20,33 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run protected void execute() { - Robot.driveTrain.set(1, 1); + //makes the robot end up parallel to it's start position + if(!isFinishedLeft()) + { + if(!isFinishedRight()) + Robot.driveTrain.set(1, 1); + else + Robot.driveTrain.set(1,0); + } + else if(!isFinishedRight()) + Robot.driveTrain.set(0, 1); + } // Make this return true when this Command no longer needs to run execute() protected boolean isFinished() { - return Robot.driveTrain.getDistanceTravelled()>=feetToTravel*12; + return isFinishedLeft() && isFinishedRight(); + } + protected boolean isFinishedLeft() + { + return Robot.driveTrain.getDistanceTravelledLeft()>=feetToTravel*12; + } + + protected boolean isFinishedRight() + { + return Robot.driveTrain.getDistanceTravelledRight()>=feetToTravel*12; } boolean isDead=false;