Basic Motor Control Activity Reference - hammerheads5000/Team-Documentation GitHub Wiki
RobotContainer.java
Define motor controllers
private TalonSRX talon1 = new TalonSRX(3);
private TalonSRX talon2 = new TalonSRX(11);
Define Xbox Controller
private CommandXboxController controller = new CommandXboxController(0);
Example button trigger
private Trigger exampleTrigger = controller.someButton();
If it is an axis (sticks, etc), pass controller as argument to command constructor
Also define commands and subsystems:
private ExampleSubsystem sub_example = new ExampleSubsystem(/*some arguments*/);
private ExampleCommand cmd_example = new ExampleCommand(sub_example, /*some other arguments*/);
In configureBindings:
someTrigger.whileTrue(someCommand); // run command while trigger is on (button is held down)
anotherTrigger.onTrue(anotherCommand); // run when trigger becomes true (button pressed)
thirdTrigger.onFalse(thirdCommand); // run when trigger becomes false (button released)
Other Things (For use in commands or subsystems)
Set motor speed:
motor.set(TalonSRXControlMode.PercentOutput, 0.5); // set to 50% power
motor.set(TalonSRXControlMode.Velocity, 2); // set to 2 m/s
motor.set(TalonSRXControlMode.Position, 0); // set motor to 0 position
motor.set(TalonSRXControlMode.Current, 0.7); // set to 0.7 amps current
motor.set(TalonSRXControlMode.MotionMagic, 0); // set to position 0, but with *magic*