Code is not detected by Driver Station

Yep, remove it and your code should finish startup. It’s not crashing, it’s hanging. The right way to do something like this is to have an if() statement in a periodic() function.

1 Like

Ok. Would the if statement go in a periodic function inside the same subsystem?

That’s one option, or put it in teleopPeriodic in Robot.java (and move the XboxController there). It starts getting into code structure decisions very quickly.

Ok, I will implement this tomorrow and test it out. I thank everyone for their help in this issue.

I have gotten a lot of errors that I don’t understand the meaning of. Is anyone able to make sense of these?

You are trying to allocate a new XBox controller every periodic (20ms). You should be moving all startup allocation/instantiation all during the init.

The TurretHead subsystem doesn’t have an init function. Where do you reccomend I put the xbox controller code? When I move the Potentiometer and controller stuff outside of the periodic function, it creates errors inside the if statement

Nevermind. Thank you for your assistance.

To get you past your immediate problem, you should move them to member variables. Something like:

class TurretHead extends SubsystemBase {
    final private AnalogPotentiometer m_pot = new AnalogPotentiometer(...);
    final private Controller m_controller = new XBoxController(...);
    …
    @Override
    public void periodic() {
        if(m_pot.get() > 0.36) {
            Dart.set(m_controller.getRightY());
        }
    }
}

In the long term, you’ll want to move your controller to RobotController so it can be shared by multiple subsystems.

1 Like

Thank you

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.