Update LiveWindow to provide continuous telemetry. (#771)

LiveWindow.updateValues() is now called from IterativeRobotBase on every
loop iteration.  Telemetry for all WPILib classes is enabled by default;
it can be disabled for specific classes using LiveWindow.disableTelemetry(),
or all telemetry can be disabled using LiveWindow.disableAllTelemetry().

This necessitated changing the hook methodology into other classes to
be more property-based rather than each class providing multiple functions.
This had the benefit of reducing boilerplate and increasing consistency.

- Remove NamedSendable, add name to Sendable.

- Provide SendableBase abstract class.

- Deprecate LiveWindow addSensor/addActuator interfaces.

- Add LiveWindow support to drive classes.

- Add addChild() helper functions to Subsystem.

- Fix inheritance hierarchy.  Now only sensors inherit from SensorBase.
  Other devices inherit from some combination of SendableBase, ErrorBase, or
  nothing.
This commit is contained in:
Peter Johnson
2017-12-04 23:28:33 -08:00
committed by GitHub
parent 3befc7015b
commit f9bece2ffb
213 changed files with 3704 additions and 3758 deletions

View File

@@ -45,8 +45,6 @@ void Robot::TeleopPeriodic() {
frc::Scheduler::GetInstance()->Run();
}
void Robot::TestPeriodic() {
m_lw.Run();
}
void Robot::TestPeriodic() {}
START_ROBOT_CLASS(Robot)

View File

@@ -8,8 +8,10 @@
#pragma once
#include <Commands/Command.h>
#include <Commands/Scheduler.h>
#include <IterativeRobot.h>
#include <LiveWindow/LiveWindow.h>
#include <SmartDashboard/SmartDashboard.h>
#include "Commands/Autonomous.h"
#include "OI.h"

View File

@@ -7,12 +7,10 @@
#include "Claw.h"
#include <LiveWindow/LiveWindow.h>
Claw::Claw()
: frc::Subsystem("Claw") {
// Let's show everything on the LiveWindow
// frc::LiveWindow::GetInstance()->AddActuator("Claw", "Motor", &motor);
AddChild("Motor", m_motor);
}
void Claw::InitDefaultCommand() {}

View File

@@ -8,7 +8,7 @@
#include "DriveTrain.h"
#include <Joystick.h>
#include <LiveWindow/LiveWindow.h>
#include <SmartDashboard/SmartDashboard.h>
#include "../Commands/TankDriveWithJoystick.h"
@@ -31,25 +31,14 @@ DriveTrain::DriveTrain()
#endif
// Let's show everything on the LiveWindow
// frc::LiveWindow::GetInstance()->AddActuator("Drive Train",
// "Front_Left Motor", &m_frontLeft);
// frc::LiveWindow::GetInstance()->AddActuator("Drive Train",
// "Rear Left Motor", &m_rearLeft);
// frc::LiveWindow::GetInstance()->AddActuator("Drive Train",
// "Front Right Motor", &m_frontRight);
// frc::LiveWindow::GetInstance()->AddActuator("Drive Train",
// "Rear Right Motor", &m_rearRight);
// frc::LiveWindow::GetInstance()->AddSensor("Drive Train", "Left
// Encoder",
// &m_leftEncoder);
// frc::LiveWindow::GetInstance()->AddSensor("Drive Train", "Right
// Encoder",
// &m_rightEncoder);
// frc::LiveWindow::GetInstance()->AddSensor("Drive Train",
// "Rangefinder",
// &m_rangefinder);
// frc::LiveWindow::GetInstance()->AddSensor("Drive Train", "Gyro",
// &m_gyro);
// AddChild("Front_Left Motor", m_frontLeft);
// AddChild("Rear Left Motor", m_rearLeft);
// AddChild("Front Right Motor", m_frontRight);
// AddChild("Rear Right Motor", m_rearRight);
AddChild("Left Encoder", m_leftEncoder);
AddChild("Right Encoder", m_rightEncoder);
AddChild("Rangefinder", m_rangefinder);
AddChild("Gyro", m_gyro);
}
/**

View File

@@ -18,11 +18,8 @@ Elevator::Elevator()
SetAbsoluteTolerance(0.005);
// Let's show everything on the LiveWindow
// frc::LiveWindow::GetInstance()->AddActuator("Elevator", "Motor",
// &m_motor);
// frc::LiveWindow::GetInstance()->AddSensor("Elevator", "Pot", &m_pot);
// frc::LiveWindow::GetInstance()->AddActuator("Elevator", "PID",
// GetPIDController());
AddChild("Motor", m_motor);
AddChild("Pot", &m_pot);
}
void Elevator::InitDefaultCommand() {}

View File

@@ -7,7 +7,6 @@
#include "Wrist.h"
#include <LiveWindow/LiveWindow.h>
#include <SmartDashboard/SmartDashboard.h>
Wrist::Wrist()
@@ -18,11 +17,8 @@ Wrist::Wrist()
SetAbsoluteTolerance(2.5);
// Let's show everything on the LiveWindow
// frc::LiveWindow::GetInstance()->AddActuator("Wrist", "Motor",
// &motor);
// frc::LiveWindow::GetInstance()->AddSensor("Wrist", "Pot", &pot);
frc::LiveWindow::GetInstance()->AddActuator(
"Wrist", "PID", GetPIDController());
AddChild("Motor", m_motor);
AddChild("Pot", m_pot);
}
void Wrist::InitDefaultCommand() {}

View File

@@ -42,7 +42,7 @@ public:
m_robotDrive.ArcadeDrive(m_stick.GetY(), m_stick.GetX());
}
void TestPeriodic() override { m_lw.Run(); }
void TestPeriodic() override {}
private:
// Robot drive system

View File

@@ -13,6 +13,7 @@
#include "Commands/SetCollectionSpeed.h"
#include "Commands/SetPivotSetpoint.h"
#include "Commands/Shoot.h"
#include "SmartDashboard/SmartDashboard.h"
#include "Subsystems/Collector.h"
#include "Subsystems/Pivot.h"

View File

@@ -9,6 +9,8 @@
#include <iostream>
#include <Commands/Scheduler.h>
#include <LiveWindow/LiveWindow.h>
#include <SmartDashboard/SmartDashboard.h>
DriveTrain Robot::drivetrain;
@@ -60,9 +62,7 @@ void Robot::TeleopPeriodic() {
Log();
}
void Robot::TestPeriodic() {
frc::LiveWindow::GetInstance()->Run();
}
void Robot::TestPeriodic() {}
void Robot::DisabledInit() {
shooter.Unlatch();

View File

@@ -12,14 +12,10 @@
Collector::Collector()
: frc::Subsystem("Collector") {
// Put everything to the LiveWindow for testing.
// XXX: LiveWindow::GetInstance()->AddActuator("Collector", "Roller
// Motor", &m_rollerMotor);
LiveWindow::GetInstance()->AddSensor(
"Collector", "Ball Detector", &m_ballDetector);
LiveWindow::GetInstance()->AddSensor(
"Collector", "Claw Open Detector", &m_openDetector);
LiveWindow::GetInstance()->AddActuator(
"Collector", "Piston", &m_piston);
AddChild("Roller Motor", m_rollerMotor);
AddChild("Ball Detector", m_ballDetector);
AddChild("Claw Open Detector", m_openDetector);
AddChild("Piston", m_piston);
}
bool Collector::HasBall() {

View File

@@ -10,20 +10,15 @@
#include <cmath>
#include <Joystick.h>
#include <LiveWindow/LiveWindow.h>
#include "../Commands/DriveWithJoystick.h"
DriveTrain::DriveTrain()
: frc::Subsystem("DriveTrain") {
// frc::LiveWindow::GetInstance()->AddActuator("DriveTrain", "Front Left
// CIM", &m_frontLeftCIM);
// frc::LiveWindow::GetInstance()->AddActuator("DriveTrain", "Front
// Right CIM", &m_frontRightCIM);
// frc::LiveWindow::GetInstance()->AddActuator("DriveTrain", "Back Left
// CIM", &m_backLeftCIM);
// frc::LiveWindow::GetInstance()->AddActuator("DriveTrain", "Back Right
// CIM", &m_backRightCIM);
// AddChild("Front Left CIM", m_frontLeftCIM);
// AddChild("Front Right CIM", m_frontRightCIM);
// AddChild("Back Left CIM", m_backLeftCIM);
// AddChild("Back Right CIM", m_backRightCIM);
// Configure the DifferentialDrive to reflect the fact that all our
// motors are wired backwards and our drivers sensitivity preferences.
@@ -49,16 +44,14 @@ DriveTrain::DriveTrain()
(4.0 /*in*/ * M_PI) / (360.0 * 12.0 /*in/ft*/));
#endif
LiveWindow::GetInstance()->AddSensor(
"DriveTrain", "Right Encoder", m_rightEncoder);
LiveWindow::GetInstance()->AddSensor(
"DriveTrain", "Left Encoder", m_leftEncoder);
AddChild("Right Encoder", m_rightEncoder);
AddChild("Left Encoder", m_leftEncoder);
// Configure gyro
#ifndef SIMULATION
m_gyro.SetSensitivity(0.007); // TODO: Handle more gracefully?
#endif
LiveWindow::GetInstance()->AddSensor("DriveTrain", "Gyro", &m_gyro);
AddChild("Gyro", m_gyro);
}
void DriveTrain::InitDefaultCommand() {

View File

@@ -7,8 +7,6 @@
#include "Pivot.h"
#include <LiveWindow/LiveWindow.h>
Pivot::Pivot()
: frc::PIDSubsystem("Pivot", 7.0, 0.0, 8.0) {
SetAbsoluteTolerance(0.005);
@@ -20,16 +18,10 @@ Pivot::Pivot()
#endif
// Put everything to the LiveWindow for testing.
frc::LiveWindow::GetInstance()->AddSensor(
"Pivot", "Upper Limit Switch", &m_upperLimitSwitch);
frc::LiveWindow::GetInstance()->AddSensor(
"Pivot", "Lower Limit Switch", &m_lowerLimitSwitch);
// XXX: frc::LiveWindow::GetInstance()->AddSensor("Pivot", "Pot",
// &m_pot);
// XXX: frc::LiveWindow::GetInstance()->AddActuator("Pivot", "Motor",
// &m_motor);
frc::LiveWindow::GetInstance()->AddActuator(
"Pivot", "PIDSubsystem Controller", GetPIDController());
AddChild("Upper Limit Switch", m_upperLimitSwitch);
AddChild("Lower Limit Switch", m_lowerLimitSwitch);
AddChild("Pot", m_pot);
AddChild("Motor", m_motor);
}
void InitDefaultCommand() {}

View File

@@ -7,12 +7,11 @@
#include "Pneumatics.h"
#include <LiveWindow/LiveWindow.h>
#include <SmartDashboard/SmartDashboard.h>
Pneumatics::Pneumatics()
: frc::Subsystem("Pneumatics") {
frc::LiveWindow::GetInstance()->AddSensor(
"Pneumatics", "Pressure Sensor", m_pressureSensor);
AddChild("Pressure Sensor", m_pressureSensor);
}
/**

View File

@@ -7,20 +7,13 @@
#include "Shooter.h"
#include <LiveWindow/LiveWindow.h>
Shooter::Shooter()
: Subsystem("Shooter") {
// Put everything to the LiveWindow for testing.
frc::LiveWindow::GetInstance()->AddSensor(
"Shooter", "Hot Goal Sensor", &m_hotGoalSensor);
frc::LiveWindow::GetInstance()->AddSensor("Shooter",
"Piston1 Reed Switch Front ",
&m_piston1ReedSwitchFront);
frc::LiveWindow::GetInstance()->AddSensor("Shooter",
"Piston1 Reed Switch Back ", &m_piston1ReedSwitchBack);
frc::LiveWindow::GetInstance()->AddActuator(
"Shooter", "Latch Piston", &m_latchPiston);
AddChild("Hot Goal Sensor", m_hotGoalSensor);
AddChild("Piston1 Reed Switch Front ", m_piston1ReedSwitchFront);
AddChild("Piston1 Reed Switch Back ", m_piston1ReedSwitchBack);
AddChild("Latch Piston", m_latchPiston);
}
void Shooter::InitDefaultCommand() {

View File

@@ -83,7 +83,7 @@ public:
void TeleopPeriodic() override { frc::Scheduler::GetInstance()->Run(); }
void TestPeriodic() override { frc::LiveWindow::GetInstance()->Run(); }
void TestPeriodic() override {}
private:
// Have it null by default so that if testing teleop it

View File

@@ -60,7 +60,7 @@ public:
void TeleopPeriodic() {}
void TestPeriodic() { m_lw.Run(); }
void TestPeriodic() {}
private:
frc::LiveWindow& m_lw = *LiveWindow::GetInstance();

View File

@@ -59,7 +59,7 @@ public:
void TeleopPeriodic() {}
void TestPeriodic() { m_lw.Run(); }
void TestPeriodic() {}
private:
frc::LiveWindow& m_lw = *LiveWindow::GetInstance();