mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +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,9 +11,10 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -44,16 +45,16 @@ class Subsystem;
|
||||
* @see CommandGroup
|
||||
* @see Subsystem
|
||||
*/
|
||||
class Command : public ErrorBase, public NamedSendable {
|
||||
class Command : public ErrorBase, public SendableBase {
|
||||
friend class CommandGroup;
|
||||
friend class Scheduler;
|
||||
|
||||
public:
|
||||
Command();
|
||||
explicit Command(const std::string& name);
|
||||
explicit Command(const llvm::Twine& name);
|
||||
explicit Command(double timeout);
|
||||
Command(const std::string& name, double timeout);
|
||||
virtual ~Command();
|
||||
Command(const llvm::Twine& name, double timeout);
|
||||
~Command() override = default;
|
||||
double TimeSinceInitialized() const;
|
||||
void Requires(Subsystem* s);
|
||||
bool IsCanceled() const;
|
||||
@@ -76,6 +77,7 @@ class Command : public ErrorBase, public NamedSendable {
|
||||
bool IsTimedOut() const;
|
||||
bool AssertUnlocked(const std::string& message);
|
||||
void SetParent(CommandGroup* parent);
|
||||
bool IsParented() const;
|
||||
void ClearRequirements();
|
||||
|
||||
virtual void Initialize();
|
||||
@@ -116,9 +118,6 @@ class Command : public ErrorBase, public NamedSendable {
|
||||
void StartRunning();
|
||||
void StartTiming();
|
||||
|
||||
// The name of this command
|
||||
std::string m_name;
|
||||
|
||||
// The time since this command was initialized
|
||||
double m_startTime = -1;
|
||||
|
||||
@@ -153,14 +152,7 @@ class Command : public ErrorBase, public NamedSendable {
|
||||
static int m_commandCounter;
|
||||
|
||||
public:
|
||||
std::string GetName() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
|
||||
private:
|
||||
nt::NetworkTableEntry m_runningEntry;
|
||||
nt::NetworkTableEntry m_isParentedEntry;
|
||||
NT_EntryListener m_runningListener = 0;
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -54,8 +54,7 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource {
|
||||
std::shared_ptr<PIDController> m_controller;
|
||||
|
||||
public:
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -35,7 +35,7 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
PIDSubsystem(double p, double i, double d);
|
||||
PIDSubsystem(double p, double i, double d, double f);
|
||||
PIDSubsystem(double p, double i, double d, double f, double period);
|
||||
virtual ~PIDSubsystem() = default;
|
||||
~PIDSubsystem() override = default;
|
||||
|
||||
void Enable();
|
||||
void Disable();
|
||||
@@ -66,10 +66,6 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
private:
|
||||
// The internal PIDController
|
||||
std::shared_ptr<PIDController> m_controller;
|
||||
|
||||
public:
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "SmartDashboard/SmartDashboard.h"
|
||||
#include "networktables/NetworkTable.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -26,7 +24,7 @@ namespace frc {
|
||||
class ButtonScheduler;
|
||||
class Subsystem;
|
||||
|
||||
class Scheduler : public ErrorBase, public NamedSendable {
|
||||
class Scheduler : public ErrorBase, public SendableBase {
|
||||
public:
|
||||
static Scheduler* GetInstance();
|
||||
|
||||
@@ -39,15 +37,11 @@ class Scheduler : public ErrorBase, public NamedSendable {
|
||||
void ResetAll();
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
void UpdateTable();
|
||||
std::string GetSmartDashboardType() const;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable);
|
||||
std::string GetName() const;
|
||||
std::string GetType() const;
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
Scheduler();
|
||||
virtual ~Scheduler() = default;
|
||||
~Scheduler() override = default;
|
||||
|
||||
void ProcessCommandAddition(Command* command);
|
||||
|
||||
|
||||
@@ -8,49 +8,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class Command;
|
||||
|
||||
class Subsystem : public ErrorBase, public NamedSendable {
|
||||
class Subsystem : public ErrorBase, public SendableBase {
|
||||
friend class Scheduler;
|
||||
|
||||
public:
|
||||
explicit Subsystem(const std::string& name);
|
||||
virtual ~Subsystem() = default;
|
||||
explicit Subsystem(const llvm::Twine& name);
|
||||
|
||||
void SetDefaultCommand(Command* command);
|
||||
Command* GetDefaultCommand();
|
||||
llvm::StringRef GetDefaultCommandName();
|
||||
void SetCurrentCommand(Command* command);
|
||||
Command* GetCurrentCommand() const;
|
||||
llvm::StringRef GetCurrentCommandName() const;
|
||||
virtual void Periodic();
|
||||
virtual void InitDefaultCommand();
|
||||
|
||||
void AddChild(const llvm::Twine& name, std::shared_ptr<Sendable> child);
|
||||
void AddChild(const llvm::Twine& name, Sendable* child);
|
||||
void AddChild(const llvm::Twine& name, Sendable& child);
|
||||
void AddChild(std::shared_ptr<Sendable> child);
|
||||
void AddChild(Sendable* child);
|
||||
void AddChild(Sendable& child);
|
||||
|
||||
private:
|
||||
void ConfirmCommand();
|
||||
|
||||
Command* m_currentCommand = nullptr;
|
||||
bool m_currentCommandChanged = true;
|
||||
Command* m_defaultCommand = nullptr;
|
||||
std::string m_name;
|
||||
bool m_initializedDefaultCommand = false;
|
||||
|
||||
public:
|
||||
std::string GetName() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
|
||||
protected:
|
||||
nt::NetworkTableEntry m_hasDefaultEntry;
|
||||
nt::NetworkTableEntry m_defaultEntry;
|
||||
nt::NetworkTableEntry m_hasCommandEntry;
|
||||
nt::NetworkTableEntry m_commandEntry;
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
Reference in New Issue
Block a user