Using Shuffleboard to Test a Command

Commands are easily tested by adding a button to Shuffleboard/SmartDashboard to trigger the command. In this way, no integration with the rest of the robot program is necessary and commands can easily be independently tested. This is the easiest way to verify commands since with a single line of code in your program, a button can be created on Shuffleboard that will run the command. These buttons can then be left in place to verify subsystems and command operations in the future.

这个带来的额外好处是它能够更好地协调数个同时在给出指令的程序部分。当代码被写入机器的主程序项目后,每个指令都可以被拉出来单独调试。

Creating the Button on Shuffleboard

To create a button in Shuffleboard ensure the "Button on SmartDashboard" checkbox is checked.

通过将机器人命令的实例放置到仪表板上,可以在SmartDashboard上创建按钮。这是一种非常常见的操作,因此已将其作为复选框添加到RobotBuilder。编写命令时,请确保已选中该复选框,然后按钮将自动生成。

操作按钮

Each of the created buttons has its own widget in Shuffleboard.

The buttons will be generated automatically and will appear on the dashboard screen. You can rearrange the buttons on Shuffleboard. In this example there are a number of commands, each with an associated button for testing. Pressing the commands button will run the command. Once it is pressed, pressing again it will interrupt the command causing the Interrupted() method to be called.

手动添加命令

SmartDashboard.putData("Autonomous Command", new AutonomousCommand());
SmartDashboard.putData("Open Claw", new OpenClaw(m_claw);
SmartDashboard.putData("Close Claw", new CloseClaw(m_claw));

Commands can be added to the Shuffleboard manually by writing the code yourself. This is done by passing instances of the command to the PutData method along with the name that should be associated with the button on the Shuffleboard. These instances are scheduled whenever the button is pressed. The result is exactly the same as RobotBuilder generated code, although clicking the checkbox in RobotBuilder is much easier than writing all the code by hand.