mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[glass, wpilib] Rewrite Mechanism2d (#3281)
Substantially improves Mechanism2d by moving it to NetworkTables and adding a robot API to create the mechanism elements, instead of requiring a JSON file. Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "glass/networktables/NTField2D.h"
|
||||
#include "glass/networktables/NTGyro.h"
|
||||
#include "glass/networktables/NTMecanumDrive.h"
|
||||
#include "glass/networktables/NTMechanism2D.h"
|
||||
#include "glass/networktables/NTPIDController.h"
|
||||
#include "glass/networktables/NTSpeedController.h"
|
||||
#include "glass/networktables/NTStringChooser.h"
|
||||
@@ -117,6 +118,18 @@ void glass::AddStandardNetworkTablesViews(NetworkTablesProvider& provider) {
|
||||
return MakeFunctionView(
|
||||
[=] { DisplayDrive(static_cast<NTMecanumDriveModel*>(model)); });
|
||||
});
|
||||
provider.Register(
|
||||
NTMechanism2DModel::kType,
|
||||
[](NT_Inst inst, const char* path) {
|
||||
return std::make_unique<NTMechanism2DModel>(inst, path);
|
||||
},
|
||||
[=](Window* win, Model* model, const char* path) {
|
||||
win->SetDefaultPos(400, 400);
|
||||
win->SetDefaultSize(200, 200);
|
||||
win->SetPadding(0, 0);
|
||||
return std::make_unique<Mechanism2DView>(
|
||||
static_cast<NTMechanism2DModel*>(model));
|
||||
});
|
||||
provider.Register(
|
||||
NTPIDControllerModel::kType,
|
||||
[](NT_Inst inst, const char* path) {
|
||||
|
||||
Reference in New Issue
Block a user