summaryrefslogtreecommitdiff
path: root/src/main/java/frc/robot/subsystems/Hooks.java
blob: 6e4232277145f4ef62c45a1f2797ddafe3985774 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package frc.robot.subsystems;

import org.littletonrobotics.junction.Logger;

import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkLowLevel.MotorType;

import frc.robot.Constants;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class Hooks extends SubsystemBase 
{
    // initial angle 237
    private final CANSparkMax m_hookL = new CANSparkMax(Constants.hookL_ID, MotorType.kBrushed);
    private final CANSparkMax m_hookR = new CANSparkMax(Constants.hookR_ID, MotorType.kBrushed);

    private final Encoder m_hookL_encoder = new Encoder(Constants.hookL_PINS[0], Constants.hookL_PINS[1]);
    private final Encoder m_hookR_encoder = new Encoder(Constants.hookR_PINS[0], Constants.hookR_PINS[1]);
    
    public Hooks() 
    { 
        // TODO: possibly invert to move forward upon positive votage
        m_hookL.setInverted(true);
        m_hookL_encoder.setReverseDirection(true);
    }

    public void atPercentage(double percL, double percR)
    {
        m_hookL.set(percL);
        m_hookR.set(percR);
    }

    @Override
    public void periodic()
    {
        Logger.recordOutput(getName() + "/encoderL", m_hookL_encoder.getDistance());
        Logger.recordOutput(getName() + "/encoderR", m_hookR_encoder.getDistance());
    }
}