Allow video sources to be added to Shuffleboard (#1453)

Add a Sendable wrapper for VideoSource objects.

Add convenience methods for adding video sources directly to containers
so users won't have to manually wrap video sources.
This commit is contained in:
Sam Carlberg
2018-12-30 14:45:41 -05:00
committed by Peter Johnson
parent a2368a6199
commit 80f87ff8ad
6 changed files with 219 additions and 0 deletions

View File

@@ -11,6 +11,7 @@
#include <wpi/raw_ostream.h>
#include "frc/shuffleboard/ComplexWidget.h"
#include "frc/shuffleboard/SendableCameraWrapper.h"
#include "frc/shuffleboard/ShuffleboardComponent.h"
#include "frc/shuffleboard/ShuffleboardLayout.h"
#include "frc/shuffleboard/SimpleWidget.h"
@@ -62,6 +63,11 @@ ComplexWidget& ShuffleboardContainer::Add(const wpi::Twine& title,
return *ptr;
}
ComplexWidget& ShuffleboardContainer::Add(const wpi::Twine& title,
const cs::VideoSource& video) {
return Add(title, SendableCameraWrapper::Wrap(video));
}
ComplexWidget& ShuffleboardContainer::Add(Sendable& sendable) {
if (sendable.GetName().empty()) {
wpi::outs() << "Sendable must have a name\n";
@@ -69,6 +75,10 @@ ComplexWidget& ShuffleboardContainer::Add(Sendable& sendable) {
return Add(sendable.GetName(), sendable);
}
ComplexWidget& ShuffleboardContainer::Add(const cs::VideoSource& video) {
return Add(SendableCameraWrapper::Wrap(video));
}
SimpleWidget& ShuffleboardContainer::Add(
const wpi::Twine& title, std::shared_ptr<nt::Value> defaultValue) {
CheckTitle(title);