Updating Joysticks in a Command

I want to make a command that when hold a button it sets two motors speeds to the value of the throttle of a joystick(we’re using the Logitech ATK3). I’m running into an issue where it doesn’t like updating the value of the joystick when I hold the button(It crashes the robot and the driver station gives me the Robots don’t quit message). When the command is constantly running there’s no issue, but I would like it to not constantly run. I can make the command’s parameters request a double and then in OI put in the joysticks throttle value there but it doesn’t update after the init of the robot.

Any help is appreciated :]

It’s really hard to understand what’s wrong if you don’t post code.

Here’s the GitHub page.
The code I’m talking about would be in these classes:

  • Robot
  • OI
  • subsystems/Shooter
  • commands/ShooterArcade
  • commands/ShooterIdle.

Here’s a part of the ShooterArcade class:

public class ShooterArcade extends Command {
	OI oi;
	Shooter shooter;
    public ShooterArcade() {
    	requires(Robot.shooter);
    	shooter = Robot.shooter;
    	oi = Robot.oi;
    }

    // Called just before this Command runs the first time
    protected void initialize() {
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
    	double shooterSpeed = oi.getShooterThrottle();
    	
    	shooter.shooterArcade(shooterSpeed);
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return true;
    }

If you need more info feel free to ask. :slight_smile:

Our team doesn’t use the Command-based template, but I’m guessing that having isFinished() always return true immediately is a problem. I think that you are starting and stopping the command over and over. Try changing isFinished() to return false and see if that helps.

Here is a good thread to read for a bit more:

Thanks for linking me to that thread, it really helped me out.:slight_smile:

the other part of information that is helpful is the lines above “robots don’t quit”. Those lines tell people trying to help you where your code was when it had trouble.