[examples] Replace usages of SIMULATION macro with constexpr if (#6899)

This commit is contained in:
Ryan Blue
2024-08-03 11:14:17 -04:00
committed by GitHub
parent 1a0efcf948
commit 5a6dd02ce9
5 changed files with 42 additions and 40 deletions

View File

@@ -5,6 +5,7 @@
#pragma once
#include <frc/AnalogPotentiometer.h>
#include <frc/RobotBase.h>
#include <frc/motorcontrol/PWMSparkMax.h>
#include <frc2/command/PIDSubsystem.h>
@@ -41,14 +42,12 @@ class Wrist : public frc2::PIDSubsystem {
private:
frc::PWMSparkMax m_motor{6};
// Conversion value of potentiometer varies between the real world and
// simulation
#ifndef SIMULATION
frc::AnalogPotentiometer m_pot{3, -270.0 / 5};
#else
frc::AnalogPotentiometer m_pot{3}; // Defaults to degrees
#endif
// Conversion value of potentiometer varies between the real world and
// simulation
frc::AnalogPotentiometer m_pot =
frc::RobotBase::IsReal()
? frc::AnalogPotentiometer{3, -270.0 / 5}
: frc::AnalogPotentiometer{3}; // Defaults to degrees
static constexpr double kP = 1;
};