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

@@ -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() {