[wpilibc] Fix C++ MechanisimRoot2D to use same NT entries as Java/Glass (#3582)

Fixes #3578
This commit is contained in:
sciencewhiz
2021-09-17 12:13:36 -07:00
committed by GitHub
parent 9359431bad
commit 5c88685495
2 changed files with 9 additions and 6 deletions

View File

@@ -8,8 +8,6 @@
using namespace frc;
static constexpr char kPosition[] = "pos";
MechanismRoot2d::MechanismRoot2d(std::string_view name, double x, double y,
const private_init&)
: MechanismObject2d(name), m_x{x}, m_y{y} {}
@@ -22,12 +20,16 @@ void MechanismRoot2d::SetPosition(double x, double y) {
}
void MechanismRoot2d::UpdateEntries(std::shared_ptr<nt::NetworkTable> table) {
m_posEntry = table->GetEntry(kPosition);
m_xEntry = table->GetEntry("x");
m_yEntry = table->GetEntry("y");
Flush();
}
inline void MechanismRoot2d::Flush() {
if (m_posEntry) {
m_posEntry.SetDoubleArray({m_x, m_y});
if (m_xEntry) {
m_xEntry.SetDouble(m_x);
}
if (m_yEntry) {
m_yEntry.SetDouble(m_y);
}
}