mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
[wpilib] Give Field2d a default Sendable name (#2953)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "frc/smartdashboard/Field2d.h"
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -15,14 +16,17 @@ Field2d::Field2d() {
|
||||
m_objects.emplace_back(
|
||||
std::make_unique<FieldObject2d>("Robot", FieldObject2d::private_init{}));
|
||||
m_objects[0]->SetPose(Pose2d{});
|
||||
SendableRegistry::GetInstance().Add(this, "Field");
|
||||
}
|
||||
|
||||
Field2d::Field2d(Field2d&& rhs) {
|
||||
Field2d::Field2d(Field2d&& rhs) : SendableHelper(std::move(rhs)) {
|
||||
std::swap(m_table, rhs.m_table);
|
||||
std::swap(m_objects, rhs.m_objects);
|
||||
}
|
||||
|
||||
Field2d& Field2d::operator=(Field2d&& rhs) {
|
||||
SendableHelper::operator=(std::move(rhs));
|
||||
|
||||
std::swap(m_table, rhs.m_table);
|
||||
std::swap(m_objects, rhs.m_objects);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "frc/geometry/Rotation2d.h"
|
||||
#include "frc/smartdashboard/FieldObject2d.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -41,7 +42,7 @@ namespace frc {
|
||||
* also be shown by using the GetObject() function. Other objects can
|
||||
* also have multiple poses (which will show the object at multiple locations).
|
||||
*/
|
||||
class Field2d : public Sendable {
|
||||
class Field2d : public Sendable, public SendableHelper<Field2d> {
|
||||
public:
|
||||
using Entry = size_t;
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ public class Field2d implements Sendable {
|
||||
FieldObject2d obj = new FieldObject2d("Robot");
|
||||
obj.setPose(new Pose2d());
|
||||
m_objects.add(obj);
|
||||
SendableRegistry.add(this, "Field");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user