Team5830 / 2022-Rapid-React

Team 5830's robot code for FIRST Rapid React (2022)
MIT License
0 stars 0 forks source link

Add the intake subsystem and commands to use it #4

Closed asteele11 closed 2 years ago

asteele11 commented 2 years ago

Description

The intake subsystem is expected to be motor driven. There may be another control added later to extend the ball pickup. For the moment we will assume that we just need to add a motor to turn the intake pickup, but we need to be able to reverse this motor.
The subsystem should be a new file in the subsystem folder. Because we are testing on the existing robot (Infinite Recharge) we will use the first intake motor as an example.
The CAN bus id for this motor is listed as 9 and it should be a Talon SRX, but this should be verified by checking the label on the motor controllers of the robot. Once verified add the correct address into the Constants.

public static final int firstintakeMotor = 9; //Talon SRX

If the drivers are installed on your computer the motor drive can be imported with:

import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;

The Infinite Recharge code can be used as an example, but it has more than we need to do at the moment. Just use the startFirstIntake, reverseFirstIntake and stopFirstIntake methods and use booleans to track the status. The booleans can be used to display the status on the SmartDashboard. The speed that the motor runs at should be set in Constants.java

https://github.com/Team5830/Infinite-Recharge-Robot/blob/pidmod/src/main/java/frc/robot/subsystems/Intake.java

To add the command to toggle the Intake on and off add a new file under commands:

https://github.com/Team5830/Infinite-Recharge-Robot/blob/pidmod/src/main/java/frc/robot/commands/FirstintakeToggle.java

To connect this command to a button on the joystick and something like:

Button intake_a_button = new JoystickButton(m_rightJoy,3).whenPressed(new FirstintakeToggle());

Into RobotContainer in the configureButtonBindings method. You will also need to add the instantiation of the subsystem into RobotContainer, this should be similar to what is done for the DriveTrain, something like:

private static final Intake m_intake = new Intake();

asteele11 commented 2 years ago

Done in Intake branch