In this section we will be going over
1) Create a new Subsystem called Telemetry
2) Create a constructor for the Telemetry class
3) Inside type:
SmartDashboard.putData(“Reset Drive Encoder”, new DriveResetEncoder()); 4) Create a public method called update
5) Inside type:
SmartDashboard.putNumber(“Drivetrain Encoder Count”, Robot.m_drivetrain.getDriveEncoderCount()); 6) Do the same for the getDriveEncoderDistance method
7) Try adding the Shooter Subsystem commands and sensor methods where they should be
Your full Telemetry.java should look like this
package frc.robot.subsystems;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.Robot;
import frc.robot.commands.*;
/**
* Add your docs here.
*/
public class Telemetry extends Subsystem {
// Put methods for controlling this subsystem
// here. Call these from Commands.
public Telemetry() {
// Drivetrain
SmartDashboard.putData("Reset Drive Encoder", new DriveResetEncoder());
// Shooter
SmartDashboard.putData("Shooter Up", new ShooterUp());
SmartDashboard.putData("Shooter Down", new ShooterDown());
SmartDashboard.putData("Shooter Up Auto", new ShooterUpAuto());
}
public void update() {
// Drivetrain
SmartDashboard.putNumber("Drive Encoder Count", Robot.m_drivetrain.getDriveEncoderCount());
// Shooter
SmartDashboard.putBoolean("Shooter Switch", Robot.m_shooter.isShooterSwitchClosed());
}
@Override
public void initDefaultCommand() {
// Set the default command for a subsystem here.
// setDefaultCommand(new MySpecialCommand());
}
} 1) When adding Telemetry to Robot.java, in robotInit we must add Telemetry after the other subsystems
2) It is important that we add the update method to disabledPeriodic, autonomousPeriodic, and teleopPeriodic so that the Shuffleboard is always being updated with information on our sensors.
The code you typed before robotInit should be this
public static Telemetry m_telemetry; The code you typed in robotInit should be this
m_telemetry = new Telemetry(); //This must be initialized after all other robot subsystems The code you typed in disabledPeriodic, autonomousPeriodic, and teleopPeriodic should be this
Robot.m_telemetry.update();