[wpilib] Remove Shuffleboard API (#7730)

This commit is contained in:
Peter Johnson
2025-01-24 23:47:42 -08:00
committed by GitHub
parent 01e71e73ce
commit adbe95e610
82 changed files with 60 additions and 6776 deletions

View File

@@ -4,7 +4,7 @@
#include "RobotContainer.h"
#include <frc/shuffleboard/Shuffleboard.h>
#include <frc/smartdashboard/SmartDashboard.h>
RobotContainer::RobotContainer() {
// Initialize all of your commands and subsystems here
@@ -15,36 +15,10 @@ RobotContainer::RobotContainer() {
m_chooser.AddOption("Complex Auto", m_complexAuto.get());
// Put the chooser on the dashboard
frc::Shuffleboard::GetTab("Autonomous").Add(m_chooser);
frc::SmartDashboard::PutData("Autonomous", &m_chooser);
// Put subsystems to dashboard.
frc::Shuffleboard::GetTab("Drivetrain").Add(m_drive);
frc::Shuffleboard::GetTab("HatchSubsystem").Add(m_hatch);
// Log Shuffleboard events for command initialize, execute, finish, interrupt
frc2::CommandScheduler::GetInstance().OnCommandInitialize(
[](const frc2::Command& command) {
frc::Shuffleboard::AddEventMarker(
"Command initialized", command.GetName(),
frc::ShuffleboardEventImportance::kNormal);
});
frc2::CommandScheduler::GetInstance().OnCommandExecute(
[](const frc2::Command& command) {
frc::Shuffleboard::AddEventMarker(
"Command executed", command.GetName(),
frc::ShuffleboardEventImportance::kNormal);
});
frc2::CommandScheduler::GetInstance().OnCommandFinish(
[](const frc2::Command& command) {
frc::Shuffleboard::AddEventMarker(
"Command finished", command.GetName(),
frc::ShuffleboardEventImportance::kNormal);
});
frc2::CommandScheduler::GetInstance().OnCommandInterrupt(
[](const frc2::Command& command) {
frc::Shuffleboard::AddEventMarker(
"Command interrupted", command.GetName(),
frc::ShuffleboardEventImportance::kNormal);
});
frc::SmartDashboard::PutData("Drivetrain", &m_drive);
frc::SmartDashboard::PutData("HatchSubsystem", &m_hatch);
// Configure the button bindings
ConfigureButtonBindings();

View File

@@ -4,7 +4,7 @@
#include "RobotContainer.h"
#include <frc/shuffleboard/Shuffleboard.h>
#include <frc/smartdashboard/SmartDashboard.h>
#include <frc2/command/button/JoystickButton.h>
#include "commands/DefaultDrive.h"
@@ -20,36 +20,10 @@ RobotContainer::RobotContainer() {
m_chooser.AddOption("Complex Auto", &m_complexAuto);
// Put the chooser on the dashboard
frc::Shuffleboard::GetTab("Autonomous").Add(m_chooser);
frc::SmartDashboard::PutData("Autonomous", &m_chooser);
// Put subsystems to dashboard.
frc::Shuffleboard::GetTab("Drivetrain").Add(m_drive);
frc::Shuffleboard::GetTab("HatchSubsystem").Add(m_hatch);
// Log Shuffleboard events for command initialize, execute, finish, interrupt
frc2::CommandScheduler::GetInstance().OnCommandInitialize(
[](const frc2::Command& command) {
frc::Shuffleboard::AddEventMarker(
"Command initialized", command.GetName(),
frc::ShuffleboardEventImportance::kNormal);
});
frc2::CommandScheduler::GetInstance().OnCommandExecute(
[](const frc2::Command& command) {
frc::Shuffleboard::AddEventMarker(
"Command executed", command.GetName(),
frc::ShuffleboardEventImportance::kNormal);
});
frc2::CommandScheduler::GetInstance().OnCommandFinish(
[](const frc2::Command& command) {
frc::Shuffleboard::AddEventMarker(
"Command finished", command.GetName(),
frc::ShuffleboardEventImportance::kNormal);
});
frc2::CommandScheduler::GetInstance().OnCommandInterrupt(
[](const frc2::Command& command) {
frc::Shuffleboard::AddEventMarker(
"Command interrupted", command.GetName(),
frc::ShuffleboardEventImportance::kNormal);
});
frc::SmartDashboard::PutData("Drivetrain", &m_drive);
frc::SmartDashboard::PutData("HatchSubsystem", &m_hatch);
// Configure the button bindings
ConfigureButtonBindings();

View File

@@ -8,7 +8,6 @@
#include <frc/controller/PIDController.h>
#include <frc/geometry/Translation2d.h>
#include <frc/shuffleboard/Shuffleboard.h>
#include <frc/trajectory/Trajectory.h>
#include <frc/trajectory/TrajectoryGenerator.h>
#include <frc/trajectory/constraint/MecanumDriveKinematicsConstraint.h>

View File

@@ -1,88 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <frc/AnalogPotentiometer.h>
#include <frc/Encoder.h>
#include <frc/Joystick.h>
#include <frc/TimedRobot.h>
#include <frc/drive/DifferentialDrive.h>
#include <frc/motorcontrol/PWMSparkMax.h>
#include <frc/shuffleboard/Shuffleboard.h>
#include <frc/shuffleboard/ShuffleboardLayout.h>
#include <frc/shuffleboard/ShuffleboardTab.h>
#include <networktables/GenericEntry.h>
#include <networktables/NetworkTableInstance.h>
/**
* This sample program provides an example for ShuffleBoard, an alternative
* to SmartDashboard for displaying values and properties of different robot
* parts.
*
* ShuffleBoard can use pre-programmed widgets to display various values, such
* as Boolean Boxes, Sliders, Graphs, and more. In addition, they can display
* things in various Tabs.
*
* For more information on how to create personal layouts and more in
* ShuffleBoard, feel free to reference the official FIRST WPILib documentation
* online.
*/
class Robot : public frc::TimedRobot {
public:
Robot() {
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_left);
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_right);
// Add a widget titled 'Max Speed' with a number slider.
m_maxSpeed = frc::Shuffleboard::GetTab("Configuration")
.Add("Max Speed", 1)
.WithWidget("Number Slider")
.GetEntry();
// Create a 'DriveBase' tab and add the drivetrain object to it.
frc::ShuffleboardTab& driveBaseTab = frc::Shuffleboard::GetTab("DriveBase");
driveBaseTab.Add("TankDrive", m_robotDrive);
// Put encoders in a list layout.
frc::ShuffleboardLayout& encoders =
driveBaseTab.GetLayout("Encoders", frc::BuiltInLayouts::kList)
.WithPosition(0, 0)
.WithSize(2, 2);
encoders.Add("Left Encoder", m_leftEncoder);
encoders.Add("Right Encoder", m_rightEncoder);
// Create a 'Elevator' tab and add the potentiometer and elevator motor to
// it.
frc::ShuffleboardTab& elevatorTab = frc::Shuffleboard::GetTab("Elevator");
elevatorTab.Add("Motor", m_elevatorMotor);
elevatorTab.Add("Potentiometer", m_ElevatorPot);
}
void AutonomousInit() override {
// Update the Max Output for the drivetrain.
m_robotDrive.SetMaxOutput(m_maxSpeed->GetDouble(1.0));
}
private:
frc::PWMSparkMax m_left{0};
frc::PWMSparkMax m_right{1};
frc::PWMSparkMax m_elevatorMotor{2};
frc::DifferentialDrive m_robotDrive{
[&](double output) { m_left.Set(output); },
[&](double output) { m_right.Set(output); }};
frc::Joystick m_stick{0};
frc::Encoder m_leftEncoder{0, 1};
frc::Encoder m_rightEncoder{2, 3};
frc::AnalogPotentiometer m_ElevatorPot{0};
nt::GenericEntry* m_maxSpeed;
};
#ifndef RUNNING_FRC_TESTS
int main() {
return frc::StartRobot<Robot>();
}
#endif

View File

@@ -4,41 +4,35 @@
#include "Robot.h"
#include <frc/shuffleboard/Shuffleboard.h>
#include <frc/smartdashboard/SmartDashboard.h>
#include <units/pressure.h>
Robot::Robot() {
// Publish elements to shuffleboard.
frc::ShuffleboardTab& tab = frc::Shuffleboard::GetTab("Pneumatics");
tab.Add("Single Solenoid", m_solenoid);
tab.Add("Double Solenoid", m_doubleSolenoid);
tab.Add("Compressor", m_compressor);
// Also publish some raw data
tab.AddDouble("PH Pressure [PSI]", [&] {
// Get the pressure (in PSI) from the analog sensor connected to the PH.
// This function is supported only on the PH!
// On a PCM, this function will return 0.
units::pounds_per_square_inch_t pressure = m_compressor.GetPressure();
return pressure.value();
});
tab.AddDouble("Compressor Current", [&] {
// Get compressor current draw.
units::ampere_t compressorCurrent = m_compressor.GetCurrent();
return compressorCurrent.value();
});
tab.AddBoolean("Compressor Active", [&] {
// Get whether the compressor is active.
return m_compressor.IsEnabled();
});
tab.AddBoolean("Pressure Switch", [&] {
// Get the digital pressure switch connected to the PCM/PH.
// The switch is open when the pressure is over ~120 PSI.
return m_compressor.GetPressureSwitchValue();
});
frc::SmartDashboard::PutData("Single Solenoid", &m_solenoid);
frc::SmartDashboard::PutData("Double Solenoid", &m_doubleSolenoid);
frc::SmartDashboard::PutData("Compressor", &m_compressor);
}
void Robot::TeleopPeriodic() {
// Publish some raw data
// Get the pressure (in PSI) from the analog sensor connected to the PH.
// This function is supported only on the PH!
// On a PCM, this function will return 0.
frc::SmartDashboard::PutNumber("PH Pressure [PSI]",
m_compressor.GetPressure().value());
// Get compressor current draw.
frc::SmartDashboard::PutNumber("Compressor Current",
m_compressor.GetCurrent().value());
// Get whether the compressor is active.
frc::SmartDashboard::PutBoolean("Compressor Active",
m_compressor.IsEnabled());
// Get the digital pressure switch connected to the PCM/PH.
// The switch is open when the pressure is over ~120 PSI.
frc::SmartDashboard::PutBoolean("Pressure Switch",
m_compressor.GetPressureSwitchValue());
/*
* The output of GetRawButton is true/false depending on whether
* the button is pressed; Set takes a boolean for whether

View File

@@ -8,7 +8,6 @@
#include <frc/controller/PIDController.h>
#include <frc/geometry/Translation2d.h>
#include <frc/shuffleboard/Shuffleboard.h>
#include <frc/trajectory/Trajectory.h>
#include <frc/trajectory/TrajectoryGenerator.h>
#include <frc2/command/Commands.h>

View File

@@ -4,14 +4,13 @@
#include "Robot.h"
#include <frc/shuffleboard/Shuffleboard.h>
#include <frc/smartdashboard/SmartDashboard.h>
#include <units/length.h>
Robot::Robot() {
// Add the ultrasonic on the "Sensors" tab of the dashboard
// Data will update automatically
frc::Shuffleboard::GetTab("Sensors").Add(m_rangeFinder);
frc::SmartDashboard::PutData("Sensors", &m_rangeFinder);
}
void Robot::TeleopPeriodic() {

View File

@@ -46,7 +46,6 @@
"tags": [
"Hardware",
"Joystick",
"Shuffleboard",
"Pneumatics"
],
"foldername": "Solenoid",
@@ -119,8 +118,7 @@
"tags": [
"Hardware",
"Ultrasonic",
"SmartDashboard",
"Shuffleboard"
"SmartDashboard"
],
"foldername": "Ultrasonic",
"gradlebase": "cpp",
@@ -318,21 +316,6 @@
"gradlebase": "c",
"commandversion": 2
},
{
"name": "Shuffleboard",
"description": "Present various data via the Shuffleboard API.",
"tags": [
"Basic Robot",
"Differential Drive",
"Elevator",
"Analog",
"Encoder",
"Shuffleboard"
],
"foldername": "ShuffleBoard",
"gradlebase": "cpp",
"commandversion": 2
},
{
"name": "'Traditional' Hatchbot",
"description": "A fully-functional command-based hatchbot for the 2019 game, written in the 'traditional' style, i.e. commands are given their own classes.",
@@ -341,7 +324,6 @@
"Command-based",
"Differential Drive",
"Encoder",
"Shuffleboard",
"Sendable",
"DataLog",
"Pneumatics",
@@ -359,7 +341,6 @@
"Command-based",
"Differential Drive",
"Encoder",
"Shuffleboard",
"Sendable",
"DataLog",
"Pneumatics",