Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. package org.usfirst.frc.team6353.robot;
  2.  
  3. import edu.wpi.first.wpilibj.IterativeRobot;
  4. import edu.wpi.first.wpilibj.Joystick;
  5. import edu.wpi.first.wpilibj.RobotDrive;
  6. import edu.wpi.first.wpilibj.Timer;
  7. import edu.wpi.first.wpilibj.livewindow.LiveWindow;
  8.  
  9. /**
  10. * The VM is configured to automatically run this class, and to call the
  11. * functions corresponding to each mode, as described in the IterativeRobot
  12. * documentation. If you change the name of this class or the package after
  13. * creating this project, you must also update the manifest file in the resource
  14. * directory.
  15. */
  16. public class Robot extends IterativeRobot {
  17. RobotDrive myRobot = new RobotDrive(0, 2, 1, 3);
  18. Joystick stick = new Joystick(0);
  19. Timer timer = new Timer();
  20. /**
  21. * This function is run when the robot is first started up and should be
  22. * used for any initialization code.
  23. */
  24. @Override
  25. public void robotInit() {
  26. System.out.println("Start my robot");
  27. }
  28.  
  29. /**
  30. * This function is run once each time the robot enters autonomous mode
  31. */
  32. @Override
  33. public void autonomousInit() {
  34. timer.reset();
  35. timer.start();
  36. }
  37.  
  38. /**
  39. * This function is called periodically during autonomous
  40. */
  41. @Override
  42. public void autonomousPeriodic() {
  43. // Drive for 2 seconds
  44. if (timer.get() < 50.0) {
  45. myRobot.drive(-0.5, 0.0); // drive forwards half speed
  46. } else {
  47. myRobot.drive(0.0, 0.0); // stop robot
  48. }
  49. }
  50.  
  51. /**
  52. * This function is called once each time the robot enters tele-operated
  53. * mode
  54. */
  55. @Override
  56. public void teleopInit() {
  57. }
  58.  
  59. /**
  60. * This function is called periodically during operator control
  61. */
  62. @Override
  63. public void teleopPeriodic() {
  64. myRobot.arcadeDrive(stick);
  65. }
  66.  
  67. /**
  68. * This function is called periodically during test mode
  69. */
  70. @Override
  71. public void testPeriodic() {
  72. LiveWindow.run();
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement