Guest User

Untitled

a guest
Jan 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. package org.usfirst.frc.team6657.robot;
  2.  
  3. import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
  4.  
  5. import edu.wpi.first.wpilibj.IterativeRobot;
  6. import edu.wpi.first.wpilibj.Joystick;
  7. import edu.wpi.first.wpilibj.SpeedControllerGroup;
  8. import edu.wpi.first.wpilibj.drive.DifferentialDrive;
  9.  
  10. public class Robot extends IterativeRobot {
  11.  
  12. // New Talon objects are passed a CAN bus ID (the IDs set in the web config)
  13. WPI_TalonSRX motorFrontLeft = new WPI_TalonSRX(1); // Front left
  14. WPI_TalonSRX motorBackLeft = new WPI_TalonSRX(2); // Back left
  15. // Controller groups put motor controllers together for easy access and control
  16. SpeedControllerGroup controllersLeft = new SpeedControllerGroup(motorFrontLeft, motorBackLeft);
  17.  
  18. WPI_TalonSRX motorFrontRight = new WPI_TalonSRX(3); // Front right
  19. WPI_TalonSRX motorBackRight = new WPI_TalonSRX(4); // Back right
  20. SpeedControllerGroup controllersRight = new SpeedControllerGroup(motorFrontRight, motorBackRight);
  21.  
  22. // Create new drive instance using the controller groups
  23. DifferentialDrive drive = new DifferentialDrive(controllersLeft, controllersRight);
  24.  
  25. Joystick joy = new Joystick(0); // Grab joystick on port 0
  26.  
  27. // Executed every few ms
  28. @Override
  29. public void teleopPeriodic() {
  30. double speed = joy.getX(); // Gets X (forward and back)
  31. double rotation = joy.getTwist(); // Gets the value of the twist axis
  32.  
  33. drive.arcadeDrive(speed, rotation); // Preset drive function
  34. }
  35. }
Add Comment
Please, Sign In to add comment