mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilibc] Fix C++ MechanisimRoot2D to use same NT entries as Java/Glass (#3582)
Fixes #3578
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user