mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[wpilib] Use IsSimulation() consistently (#3534)
This commit is contained in:
@@ -13,7 +13,7 @@ std::string frc::filesystem::GetLaunchDirectory() {
|
||||
}
|
||||
|
||||
std::string frc::filesystem::GetOperatingDirectory() {
|
||||
if constexpr (RobotBase::IsReal()) {
|
||||
if constexpr (!RobotBase::IsSimulation()) {
|
||||
return "/home/lvuser";
|
||||
} else {
|
||||
return frc::filesystem::GetLaunchDirectory();
|
||||
@@ -21,7 +21,7 @@ std::string frc::filesystem::GetOperatingDirectory() {
|
||||
}
|
||||
|
||||
std::string frc::filesystem::GetDeployDirectory() {
|
||||
if constexpr (RobotBase::IsReal()) {
|
||||
if constexpr (!RobotBase::IsSimulation()) {
|
||||
return "/home/lvuser/deploy";
|
||||
} else {
|
||||
return (fs::current_path() / "src" / "main" / "deploy").string();
|
||||
|
||||
@@ -231,11 +231,11 @@ RobotBase::RobotBase() {
|
||||
auto inst = nt::NetworkTableInstance::GetDefault();
|
||||
// subscribe to "" to force persistent values to propagate to local
|
||||
nt::SubscribeMultiple(inst.GetHandle(), {{std::string_view{}}});
|
||||
#ifdef __FRC_ROBORIO__
|
||||
inst.StartServer("/home/lvuser/networktables.json");
|
||||
#else
|
||||
inst.StartServer();
|
||||
#endif
|
||||
if constexpr (!IsSimulation()) {
|
||||
inst.StartServer("/home/lvuser/networktables.json");
|
||||
} else {
|
||||
inst.StartServer();
|
||||
}
|
||||
|
||||
// wait for the NT server to actually start
|
||||
int count = 0;
|
||||
@@ -251,7 +251,7 @@ RobotBase::RobotBase() {
|
||||
|
||||
SmartDashboard::init();
|
||||
|
||||
if (IsReal()) {
|
||||
if constexpr (!IsSimulation()) {
|
||||
std::FILE* file = nullptr;
|
||||
file = std::fopen("/tmp/frc_versions/FRC_Lib_Version.ini", "w");
|
||||
|
||||
|
||||
@@ -227,7 +227,13 @@ class RobotBase {
|
||||
*
|
||||
* @return If the robot is running in simulation.
|
||||
*/
|
||||
static constexpr bool IsSimulation() { return !IsReal(); }
|
||||
static constexpr bool IsSimulation() {
|
||||
#ifdef __FRC_ROBORIO__
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for a generic robot program.
|
||||
|
||||
Reference in New Issue
Block a user