mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
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:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <HAL/HAL.h>
|
||||
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "SpeedController.h"
|
||||
|
||||
using namespace frc;
|
||||
@@ -23,7 +24,13 @@ using namespace frc;
|
||||
*/
|
||||
DifferentialDrive::DifferentialDrive(SpeedController& leftMotor,
|
||||
SpeedController& rightMotor)
|
||||
: m_leftMotor(leftMotor), m_rightMotor(rightMotor) {}
|
||||
: m_leftMotor(leftMotor), m_rightMotor(rightMotor) {
|
||||
AddChild(&m_leftMotor);
|
||||
AddChild(&m_rightMotor);
|
||||
static int instances = 0;
|
||||
++instances;
|
||||
SetName("DifferentialDrive", instances);
|
||||
}
|
||||
|
||||
/**
|
||||
* Arcade drive method for differential drive platform.
|
||||
@@ -249,3 +256,13 @@ void DifferentialDrive::StopMotor() {
|
||||
void DifferentialDrive::GetDescription(llvm::raw_ostream& desc) const {
|
||||
desc << "DifferentialDrive";
|
||||
}
|
||||
|
||||
void DifferentialDrive::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("DifferentialDrive");
|
||||
builder.AddDoubleProperty("Left Motor Speed",
|
||||
[=]() { return m_leftMotor.Get(); },
|
||||
[=](double value) { m_leftMotor.Set(value); });
|
||||
builder.AddDoubleProperty("Right Motor Speed",
|
||||
[=]() { return m_rightMotor.Get(); },
|
||||
[=](double value) { m_rightMotor.Set(value); });
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <HAL/HAL.h>
|
||||
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "SpeedController.h"
|
||||
|
||||
using namespace frc;
|
||||
@@ -62,6 +63,12 @@ KilloughDrive::KilloughDrive(SpeedController& leftMotor,
|
||||
std::sin(rightMotorAngle * (kPi / 180.0))};
|
||||
m_backVec = {std::cos(backMotorAngle * (kPi / 180.0)),
|
||||
std::sin(backMotorAngle * (kPi / 180.0))};
|
||||
AddChild(&m_leftMotor);
|
||||
AddChild(&m_rightMotor);
|
||||
AddChild(&m_backMotor);
|
||||
static int instances = 0;
|
||||
++instances;
|
||||
SetName("KilloughDrive", instances);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,3 +153,16 @@ void KilloughDrive::StopMotor() {
|
||||
void KilloughDrive::GetDescription(llvm::raw_ostream& desc) const {
|
||||
desc << "KilloughDrive";
|
||||
}
|
||||
|
||||
void KilloughDrive::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("KilloughDrive");
|
||||
builder.AddDoubleProperty("Left Motor Speed",
|
||||
[=]() { return m_leftMotor.Get(); },
|
||||
[=](double value) { m_leftMotor.Set(value); });
|
||||
builder.AddDoubleProperty("Right Motor Speed",
|
||||
[=]() { return m_rightMotor.Get(); },
|
||||
[=](double value) { m_rightMotor.Set(value); });
|
||||
builder.AddDoubleProperty("Back Motor Speed",
|
||||
[=]() { return m_backMotor.Get(); },
|
||||
[=](double value) { m_backMotor.Set(value); });
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <HAL/HAL.h>
|
||||
|
||||
#include "Drive/Vector2d.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "SpeedController.h"
|
||||
|
||||
using namespace frc;
|
||||
@@ -31,7 +32,15 @@ MecanumDrive::MecanumDrive(SpeedController& frontLeftMotor,
|
||||
: m_frontLeftMotor(frontLeftMotor),
|
||||
m_rearLeftMotor(rearLeftMotor),
|
||||
m_frontRightMotor(frontRightMotor),
|
||||
m_rearRightMotor(rearRightMotor) {}
|
||||
m_rearRightMotor(rearRightMotor) {
|
||||
AddChild(&m_frontLeftMotor);
|
||||
AddChild(&m_rearLeftMotor);
|
||||
AddChild(&m_frontRightMotor);
|
||||
AddChild(&m_rearRightMotor);
|
||||
static int instances = 0;
|
||||
++instances;
|
||||
SetName("MecanumDrive", instances);
|
||||
}
|
||||
|
||||
/**
|
||||
* Drive method for Mecanum platform.
|
||||
@@ -118,3 +127,19 @@ void MecanumDrive::StopMotor() {
|
||||
void MecanumDrive::GetDescription(llvm::raw_ostream& desc) const {
|
||||
desc << "MecanumDrive";
|
||||
}
|
||||
|
||||
void MecanumDrive::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("MecanumDrive");
|
||||
builder.AddDoubleProperty("Front Left Motor Speed",
|
||||
[=]() { return m_frontLeftMotor.Get(); },
|
||||
[=](double value) { m_frontLeftMotor.Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Front Right Motor Speed", [=]() { return m_frontRightMotor.Get(); },
|
||||
[=](double value) { m_frontRightMotor.Set(value); });
|
||||
builder.AddDoubleProperty("Rear Left Motor Speed",
|
||||
[=]() { return m_rearLeftMotor.Get(); },
|
||||
[=](double value) { m_rearLeftMotor.Set(value); });
|
||||
builder.AddDoubleProperty("Rear Right Motor Speed",
|
||||
[=]() { return m_rearRightMotor.Get(); },
|
||||
[=](double value) { m_rearRightMotor.Set(value); });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user