Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. package org.usfirst.frc.team7128.robot.subsystems;
  2.  
  3. import edu.wpi.first.wpilibj.AnalogInput;
  4. import edu.wpi.first.wpilibj.Encoder;
  5. import edu.wpi.first.wpilibj.Joystick;
  6. import edu.wpi.first.wpilibj.RobotBase;
  7. import edu.wpi.first.wpilibj.Spark;
  8. import edu.wpi.first.wpilibj.SpeedController;
  9. import edu.wpi.first.wpilibj.SpeedControllerGroup;
  10. import edu.wpi.first.wpilibj.command.Subsystem;
  11. import edu.wpi.first.wpilibj.drive.DifferentialDrive;
  12. import edu.wpi.first.wpilibj.interfaces.Gyro;
  13. import org.usfirst.frc.team7128.robot.Robot;
  14. import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
  15.  
  16. /*
  17. * Incorporates the encoders, gyro sensor and the 4 motors attached to the chassis
  18. */
  19.  
  20. public class DriveTrain extends Subsystem {
  21. private SpeedController leftMotor
  22. = new SpeedControllerGroup(new Spark(0), new Spark(1)); //will have to change these, don't remember the ports
  23. private SpeedController rightMotor
  24. = new SpeedControllerGroup(new Spark(2), new Spark(3)); //see line 13 comments
  25.  
  26. private DifferentialDrive drive
  27. = new DifferentialDrive(leftMotor, rightMotor);
  28.  
  29. Encoder encRight = new Encoder(0,1,false,Encoder.EncodingType.k4X); //0 and 1 are the digital port numbers, false tells the encoder not to invert the direction, and k4X im not so sure about but like just use it and if doesn't work change it to 1X or 2X...something about counting edges...
  30. Encoder encLeft = new Encoder(2,3,true,Encoder.EncodingType.k4X); //maybe change port numbers??? maybe change reversedirection???
  31. Gyro gyro;
  32.  
  33. public DriveTrain {
  34. super();
  35.  
  36. if(RobotBase.isReal()) {
  37. encRight.setDistancePerPulse(18.849556/800);
  38. encLeft.setDistancePerPulse(18.849556/800);
  39.  
  40. }
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement