How to call new commands from SmartDashboard?

How do you invoke one of the new Commands from a Smartdashboard button?

Usage like

SmartDashboard.putData("TurnRightGyro", new TurnRightGyro(drivetrain, 0.5, 90));

TurnRightGyro is a new command. The button appears on the Smartdashboard but when it is clicked, the command does not execute. This has worked in the past.

What’s weird is that I can get it to work with inline commands, like so:

SmartDashboard.putData("Move Command", new StartEndCommand(
        // start driving forward
        () -> drivetrain.driveForward(.25),
        // stop driving
        () -> drivetrain.stop(),
        // subsystem requirements here
            // this is a command decorator; a convenience method

I’ve read the doc page on Triggers and Buttons, but that doesn’t seem to apply.

If you put the drivetrain subsystem on the Dashboard do you see it scheduling the command at all?

If you use Shuffleboard (which I recommend) you can also just add the CommandScheduler widget and see what the scheduler thinks should be working.

Also, I have seen similar things like this, depending on how the project was generated, where the template code that is generated doesn’t included in the robotPeriodic() method.

Perhaps the withTimeout() factory method for the parallel racegroup is calling the .schedule() or start() method which is why it’s working with the in-lined commands rather than the plane Sendable() instantation for the turnrightgyro command.

Thanks for replying. I couldn’t find the CommandScheduler widget on the Shuffleboard. But I was able to see the individual command we added to the Shuffleboard button being invoked, and the running flag set to true. So it’s another issue. We’re experimenting with PIDSubsystems and Commands with this and it looks like the getMeasurement() method of our PIDSubsystem isn’t being called, which seems really weird. I’ll search for that a bit and probably make a separate post about that.

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