Advertisement
Tambo

Untitled

Jan 22nd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. package org.usfirst.frc.team193.robot;
  2.  
  3. import edu.wpi.first.wpilibj.Talon;
  4. import edu.wpi.first.wpilibj.IterativeRobot;
  5. import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
  6. import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
  7. import edu.wpi.first.wpilibj.Joystick;
  8. /**
  9. * The VM is configured to automatically run this class, and to call the
  10. * functions corresponding to each mode, as described in the IterativeRobot
  11. * documentation. If you change the name of this class or the package after
  12. * creating this project, you must also update the manifest file in the resource
  13. * directory.
  14. */
  15. public class Robot extends IterativeRobot {
  16.  
  17. final String defaultAuto = "Default";
  18. final String customAuto = "My Auto";
  19. String autoSelected;
  20. SendableChooser<String> chooser = new SendableChooser<>();
  21. //New motor object for left driver
  22. Talon leftDrive = new Talon(0);
  23.  
  24. //New motor object for right motor
  25. Talon rightDrive = new Talon(1);
  26.  
  27. //New joystick object for driving
  28. Joystick leftJoy = new Joystick(1);
  29.  
  30.  
  31. /**
  32. * This function is run when the robot is first started up and should be
  33. * used for any initialization code.
  34. */
  35. @Override
  36. public void robotInit() {
  37. chooser.addDefault("Default Auto", defaultAuto);
  38. chooser.addObject("My Auto", customAuto);
  39. SmartDashboard.putData("Auto choices", chooser);
  40.  
  41.  
  42.  
  43. }
  44.  
  45. /**
  46. * This autonomous (along with the chooser code above) shows how to select
  47. * between different autonomous modes using the dashboard. The sendable
  48. * chooser code works with the Java SmartDashboard. If you prefer the
  49. * LabVIEW Dashboard, remove all of the chooser code and uncomment the
  50. * getString line to get the auto name from the text box below the Gyro
  51. *
  52. * You can add additional auto modes by adding additional comparisons to the
  53. * switch structure below with additional strings. If using the
  54. * SendableChooser make sure to add them to the chooser code above as well.
  55. */
  56. @Override
  57. public void autonomousInit() {
  58. autoSelected = chooser.getSelected();
  59. // autoSelected = SmartDashboard.getString("Auto Selector",
  60. // defaultAuto);
  61. System.out.println("Auto selected: " + autoSelected);
  62.  
  63. leftDrive.set(0.3);
  64. }
  65.  
  66. /**
  67. * This function is called periodically during autonomous
  68. */
  69. @Override
  70. public void autonomousPeriodic() {
  71. switch (autoSelected) {
  72. case customAuto:
  73. // Put custom auto code here
  74. break;
  75. case defaultAuto:
  76. default:
  77. // Put default auto code here
  78. break;
  79. }
  80.  
  81. }
  82.  
  83. /**
  84. * This function is called periodically during operator control
  85. */
  86. @Override
  87. public void teleopPeriodic() {
  88.  
  89. //Getting joystick in port 1 values
  90. double value;
  91. value = leftJoy.getX();
  92. value = leftJoy.getY();
  93. value = leftJoy.getZ();
  94. value = leftJoy.getThrottle();
  95. value = leftJoy.getTwist();
  96.  
  97.  
  98.  
  99.  
  100.  
  101. }
  102.  
  103. /**
  104. * This function is called periodically during test mode
  105. */
  106. @Override
  107. public void testPeriodic() {
  108. }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement