[wpilib] Move Field2d to SmartDashboard

This commit is contained in:
Peter Johnson
2020-10-30 13:55:38 -07:00
parent 8cd42478e1
commit 727940d847
13 changed files with 631 additions and 226 deletions

View File

@@ -12,6 +12,7 @@
#include <frc/geometry/Rotation2d.h>
#include <frc/kinematics/DifferentialDriveWheelSpeeds.h>
#include <frc/simulation/SimDeviceSim.h>
#include <frc/smartdashboard/SmartDashboard.h>
using namespace DriveConstants;
@@ -53,6 +54,7 @@ void DriveSubsystem::SimulationPeriodic() {
-m_drivetrainSimulator.GetHeading().Degrees().to<double>());
m_fieldSim.SetRobotPose(m_odometry.GetPose());
frc::SmartDashboard::PutData("Field", &m_fieldSim);
}
units::ampere_t DriveSubsystem::GetCurrentDraw() const {

View File

@@ -17,7 +17,7 @@
#include <frc/simulation/AnalogGyroSim.h>
#include <frc/simulation/DifferentialDrivetrainSim.h>
#include <frc/simulation/EncoderSim.h>
#include <frc/simulation/Field2d.h>
#include <frc/smartdashboard/Field2d.h>
#include <frc2/command/SubsystemBase.h>
#include <units/voltage.h>
@@ -169,7 +169,6 @@ class DriveSubsystem : public frc2::SubsystemBase {
frc::sim::EncoderSim m_rightEncoderSim{m_rightEncoder};
frc::sim::AnalogGyroSim m_gyroAngleSim{m_gyro};
// The Field2d class simulates the field in the sim GUI. Note that we can have
// only one instance!
// The Field2d class shows the field in the sim GUI.
frc::Field2d m_fieldSim;
};