From 85118a023dc1e63e08149d3fdd8090b9b18cbc74 Mon Sep 17 00:00:00 2001 From: Jeremy White Date: Sun, 22 Jul 2018 02:58:42 -0500 Subject: [PATCH] Minor fixes required to enable the simulated robots to run (#1181) * Fix bugs in PacGoat Java example that prevent it from working. We have conflicting ports in use, each of which causes a crash at startup. These changes fix those issues. * Change to avoid a crash in Visual C++ when running simulated code. Without this change, we would get a crash in SendableRobotBase when constructing a Twine from the 'kOptions' constant string; we'd get an unable to access memory exception. --- .../main/native/cpp/SmartDashboard/SendableChooserBase.cpp | 4 ---- .../native/include/SmartDashboard/SendableChooserBase.h | 6 +++--- .../wpilibj/examples/pacgoat/subsystems/DriveTrain.java | 2 +- .../first/wpilibj/examples/pacgoat/subsystems/Shooter.java | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/wpilibc/src/main/native/cpp/SmartDashboard/SendableChooserBase.cpp b/wpilibc/src/main/native/cpp/SmartDashboard/SendableChooserBase.cpp index dfae89b18f..5452c2065b 100644 --- a/wpilibc/src/main/native/cpp/SmartDashboard/SendableChooserBase.cpp +++ b/wpilibc/src/main/native/cpp/SmartDashboard/SendableChooserBase.cpp @@ -9,8 +9,4 @@ using namespace frc; -const char* SendableChooserBase::kDefault = "default"; -const char* SendableChooserBase::kOptions = "options"; -const char* SendableChooserBase::kSelected = "selected"; - SendableChooserBase::SendableChooserBase() : SendableBase(false) {} diff --git a/wpilibc/src/main/native/include/SmartDashboard/SendableChooserBase.h b/wpilibc/src/main/native/include/SmartDashboard/SendableChooserBase.h index c996ee3c73..6c4ec2d9ea 100644 --- a/wpilibc/src/main/native/include/SmartDashboard/SendableChooserBase.h +++ b/wpilibc/src/main/native/include/SmartDashboard/SendableChooserBase.h @@ -27,9 +27,9 @@ class SendableChooserBase : public SendableBase { ~SendableChooserBase() override = default; protected: - static const char* kDefault; - static const char* kOptions; - static const char* kSelected; + static constexpr const char* kDefault = "default"; + static constexpr const char* kOptions = "options"; + static constexpr const char* kSelected = "selected"; std::string m_defaultChoice; nt::NetworkTableEntry m_selectedEntry; diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/DriveTrain.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/DriveTrain.java index a1e74691a6..d27347d070 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/DriveTrain.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/DriveTrain.java @@ -38,7 +38,7 @@ public class DriveTrain extends Subsystem { private final DifferentialDrive m_drive; private final Encoder m_rightEncoder = new Encoder(1, 2, true, EncodingType.k4X); private final Encoder m_leftEncoder = new Encoder(3, 4, false, EncodingType.k4X); - private final AnalogGyro m_gyro = new AnalogGyro(2); + private final AnalogGyro m_gyro = new AnalogGyro(0); /** * Create a new drive train subsystem. diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Shooter.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Shooter.java index c5306ad481..5c70e71f00 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Shooter.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Shooter.java @@ -31,7 +31,7 @@ public class Shooter extends Subsystem { DigitalInput m_piston1ReedSwitchFront = new DigitalInput(9); DigitalInput m_piston1ReedSwitchBack = new DigitalInput(11); //NOTE: currently ignored in simulation - DigitalInput m_hotGoalSensor = new DigitalInput(3); + DigitalInput m_hotGoalSensor = new DigitalInput(7); /** * Create a new shooter subsystem.