From 6798b3d8f8fd7cbdc1ab320e94174e0586da7b1b Mon Sep 17 00:00:00 2001 From: Stephen Just Date: Sat, 30 Sep 2023 13:36:26 -0700 Subject: [PATCH] Clear branch --- .checkstyle | 10 - .gitignore | 44 - .vscode/extensions.json | 7 - .vscode/launch.json | 36 - .vscode/settings.json | 19 - .wpilib/wpilib_preferences.json | 6 - 488license.txt | 18 - README.md | 41 - azure-pipelines.yml | 30 - build.gradle | 136 - checkstyle_suppressions.xml | 15 - gradle/wrapper/gradle-wrapper.jar | Bin 59536 -> 0 bytes gradle/wrapper/gradle-wrapper.properties | 5 - gradlew | 234 - gradlew.bat | 89 - lib/log4jConfig/log4j.xml | 48 - lib/log4jConfig/log4j4unitTesting.xml | 39 - settings.gradle | 31 - .../wpi/first/wpilibj/MockAnalogInput.java | 58 - .../edu/wpi/first/wpilibj/MockCompressor.java | 36 - .../wpi/first/wpilibj/MockDigitalInput.java | 52 - .../wpi/first/wpilibj/MockDigitalOutput.java | 53 - .../wpi/first/wpilibj/MockDistanceSensor.java | 29 - .../first/wpilibj/MockDistanceSensorPair.java | 33 - .../edu/wpi/first/wpilibj/MockLidarLite.java | 40 - .../java/edu/wpi/first/wpilibj/MockPWM.java | 53 - .../wpilibj/MockPowerDistributionPanel.java | 37 - .../java/edu/wpi/first/wpilibj/MockServo.java | 32 - .../edu/wpi/first/wpilibj/MockSolenoid.java | 46 - .../first/wpilibj/MockSpeedController.java | 37 - .../java/edu/wpi/first/wpilibj/MockTimer.java | 46 - .../wpilibj/MockXboxControllerAdapter.java | 152 - .../java/xbot/common/command/BaseCommand.java | 70 - .../common/command/BaseMaintainerCommand.java | 180 - .../java/xbot/common/command/BaseRobot.java | 328 - .../common/command/BaseSetpointCommand.java | 15 - .../common/command/BaseSetpointSubsystem.java | 42 - .../xbot/common/command/BaseSubsystem.java | 19 - .../command/BaseWaitForMaintainerCommand.java | 42 - .../command/DelayViaSupplierCommand.java | 35 - .../MockSmartDashboardCommandPutter.java | 22 - .../common/command/NamedInstantCommand.java | 15 - .../xbot/common/command/NamedRunCommand.java | 22 - .../RealSmartDashboardCommandPutter.java | 23 - .../SimpleWaitForMaintainerCommand.java | 36 - .../command/SmartDashboardCommandPutter.java | 6 - .../common/command/SupportsSetpointLock.java | 8 - .../java/xbot/common/command/XScheduler.java | 67 - .../java/xbot/common/controls/XBaseIO.java | 5 - .../controls/actuators/XCANSparkMax.java | 742 --- .../actuators/XCANSparkMaxPIDProperties.java | 33 - .../common/controls/actuators/XCANTalon.java | 394 -- .../controls/actuators/XCANVictorSPX.java | 17 - .../controls/actuators/XCompressor.java | 12 - .../controls/actuators/XDigitalOutput.java | 35 - .../controls/actuators/XDoubleSolenoid.java | 116 - .../xbot/common/controls/actuators/XPWM.java | 44 - .../common/controls/actuators/XRelay.java | 48 - .../common/controls/actuators/XServo.java | 25 - .../common/controls/actuators/XSolenoid.java | 40 - .../controls/actuators/XSpeedController.java | 42 - .../mock_adapters/MockCANSparkMax.java | 674 -- .../actuators/mock_adapters/MockCANTalon.java | 891 --- .../mock_adapters/MockCANVictorSPX.java | 630 -- .../mock_adapters/MockLegacyCANTalon.java | 669 -- .../actuators/mock_adapters/MockRelay.java | 35 - .../wpi_adapters/CANSparkMaxWpiAdapter.java | 599 -- .../wpi_adapters/CANTalonWPIAdapter.java | 580 -- .../wpi_adapters/CANVictorSPXWpiAdapter.java | 975 --- .../wpi_adapters/CompressorWPIAdapter.java | 37 - .../wpi_adapters/DigitalOutputWPIAdapter.java | 58 - .../actuators/wpi_adapters/PWMWPIAdapter.java | 56 - .../wpi_adapters/RelayWPIAdapter.java | 31 - .../wpi_adapters/ServoWPIAdapter.java | 30 - .../wpi_adapters/SolenoidWPIAdapter.java | 43 - .../SpeedControllerWPIAdapter.java | 37 - .../VictorAppearingAsTalonWPIAdapter.java | 725 --- .../sensors/AnalogDistanceSensor.java | 76 - .../controls/sensors/DistanceSensor.java | 8 - .../controls/sensors/DistanceSensorPair.java | 8 - .../common/controls/sensors/IGamepad.java | 15 - .../sensors/MultiplexedLidarPair.java | 100 - .../SimulatedAnalogDistanceSensor.java | 65 - .../controls/sensors/TalonCurrentMonitor.java | 44 - .../xbot/common/controls/sensors/XAS5600.java | 41 - .../controls/sensors/XAbsoluteEncoder.java | 23 - .../sensors/XAnalogDistanceSensor.java | 42 - .../common/controls/sensors/XAnalogInput.java | 27 - .../common/controls/sensors/XCANCoder.java | 27 - .../controls/sensors/XDigitalInput.java | 32 - .../controls/sensors/XDutyCycleEncoder.java | 58 - .../common/controls/sensors/XEncoder.java | 68 - .../common/controls/sensors/XFTCGamepad.java | 76 - .../xbot/common/controls/sensors/XGyro.java | 120 - .../common/controls/sensors/XJoystick.java | 183 - .../common/controls/sensors/XLidarLite.java | 93 - .../sensors/XPowerDistributionPanel.java | 10 - .../controls/sensors/XSettableTimerImpl.java | 17 - .../xbot/common/controls/sensors/XTimer.java | 26 - .../common/controls/sensors/XTimerImpl.java | 7 - .../controls/sensors/XXboxController.java | 159 - .../AdvancedJoystickButtonTrigger.java | 35 - .../buttons/AdvancedPovButtonTrigger.java | 34 - .../sensors/buttons/AdvancedTrigger.java | 26 - .../buttons/AdvancedXboxAxisTrigger.java | 36 - .../buttons/AdvancedXboxButtonTrigger.java | 64 - .../buttons/AnalogHIDButtonConfiguration.java | 33 - .../buttons/AnalogHIDButtonTrigger.java | 109 - .../sensors/buttons/ChordTrigger.java | 25 - .../buttons/InvertingBooleanSupplier.java | 29 - .../buttons/SettableBooleanSuppler.java | 26 - .../sensors/buttons/VirtualTrigger.java | 42 - .../mock_adapters/MockAbsoluteEncoder.java | 98 - .../sensors/mock_adapters/MockCANCoder.java | 133 - .../mock_adapters/MockDutyCycleEncoder.java | 39 - .../sensors/mock_adapters/MockEncoder.java | 62 - .../sensors/mock_adapters/MockFTCGamepad.java | 108 - .../sensors/mock_adapters/MockGyro.java | 165 - .../sensors/mock_adapters/MockJoystick.java | 90 - .../wpi_adapters/AnalogInputWPIAdapater.java | 53 - .../sensors/wpi_adapters/CANCoderAdapter.java | 146 - .../wpi_adapters/DigitalInputWPIAdapter.java | 50 - .../DutyCycleEncoderWpiAdapter.java | 31 - .../wpi_adapters/EncoderWPIAdapter.java | 47 - .../wpi_adapters/FTCGamepadWpiAdapter.java | 66 - .../InertialMeasurementUnitAdapter.java | 115 - .../wpi_adapters/JoystickWPIAdapter.java | 66 - .../wpi_adapters/LidarLiteWpiAdapter.java | 38 - .../PowerDistributionPanelWPIAdapter.java | 28 - .../sensors/wpi_adapters/TimerWpiAdapter.java | 39 - .../XboxControllerWpiAdapter.java | 84 - .../xbot/common/injection/BaseWPITest.java | 44 - .../xbot/common/injection/DevicePolice.java | 120 - .../injection/MockPermanentStorage.java | 52 - .../injection/components/BaseComponent.java | 184 - .../components/PurePursuitTestComponent.java | 19 - .../components/SimulationComponent.java | 18 - .../electrical_contract/CANTalonInfo.java | 33 - .../electrical_contract/DeviceInfo.java | 21 - .../injection/modules/MockControlsModule.java | 33 - .../injection/modules/MockDevicesModule.java | 135 - .../injection/modules/RealControlsModule.java | 33 - .../injection/modules/RealDevicesModule.java | 134 - .../common/injection/modules/RobotModule.java | 56 - .../injection/modules/SimulationModule.java | 54 - .../injection/modules/UnitTestModule.java | 54 - .../modules/UnitTestRobotModule.java | 21 - .../common/logging/DriverStationAppender.java | 38 - .../logging/IntermittentConsoleLogger.java | 18 - .../xbot/common/logging/LoggingLatch.java | 28 - .../logging/LoudRobotAssertionManager.java | 25 - .../OneLogFilePerRunRollingFileAppender.java | 32 - .../logging/RobotAssertionException.java | 8 - .../common/logging/RobotAssertionManager.java | 44 - .../xbot/common/logging/RobotSession.java | 59 - .../logging/SilentRobotAssertionManager.java | 24 - .../java/xbot/common/logging/TimeLogger.java | 54 - .../xbot/common/logging/WordGenerator.java | 53 - .../xbot/common/logic/CalibrationDecider.java | 47 - .../common/logic/HumanVsMachineDecider.java | 72 - src/main/java/xbot/common/logic/Latch.java | 43 - .../java/xbot/common/logic/StallDetector.java | 116 - .../common/logic/TimeStableValidator.java | 61 - .../common/logic/VelocityThrottleModule.java | 50 - .../java/xbot/common/logic/WatchdogTimer.java | 68 - .../xbot/common/math/ContiguousDouble.java | 228 - src/main/java/xbot/common/math/FieldPose.java | 156 - .../common/math/FieldPosePropertyManager.java | 48 - .../math/InterpolatingFieldPoseBuffer.java | 37 - .../math/InterpolatingHistoryBuffer.java | 110 - src/main/java/xbot/common/math/MathUtils.java | 68 - src/main/java/xbot/common/math/PID.java | 270 - .../java/xbot/common/math/PIDManager.java | 196 - .../xbot/common/math/PIDPropertyManager.java | 199 - .../java/xbot/common/math/PlanarEngine.java | 60 - .../common/math/PlanarTestVisualizer.java | 80 - .../common/math/PlanarVisualizationPanel.java | 119 - .../xbot/common/math/PurePursuitTest.java | 136 - .../xbot/common/math/WrappedRotation2d.java | 52 - src/main/java/xbot/common/math/XYPair.java | 184 - .../common/networking/MockZeromqListener.java | 38 - .../common/networking/XZeromqListener.java | 13 - .../common/networking/ZeromqListener.java | 138 - .../common/properties/BooleanProperty.java | 92 - .../ConfigurePropertiesCommand.java | 40 - .../properties/DatabaseStorageBase.java | 225 - .../xbot/common/properties/DebugFlag.java | 16 - .../common/properties/DoubleProperty.java | 94 - .../common/properties/IPropertySupport.java | 5 - .../xbot/common/properties/ITableProxy.java | 31 - .../properties/MockPermamentStorage.java | 12 - .../common/properties/PermanentStorage.java | 5 - .../common/properties/PreferenceStorage.java | 87 - .../java/xbot/common/properties/Property.java | 115 - .../common/properties/PropertyFactory.java | 205 - .../SmartDashboardTableWrapper.java | 100 - .../common/properties/StringProperty.java | 76 - .../xbot/common/properties/TableProxy.java | 76 - .../common/properties/XPropertyManager.java | 90 - .../xbot/common/resiliency/DeviceHealth.java | 6 - .../common/simulation/BaseSimulationTest.java | 68 - .../common/simulation/ExampleSensorData.json | 28 - .../common/simulation/ISimulatableMotor.java | 16 - .../common/simulation/ISimulatableSensor.java | 7 - .../simulation/ISimulatableSolenoid.java | 22 - .../ResetSimulatorPositionCommand.java | 62 - .../SimulationPayloadDistributor.java | 71 - .../xbot/common/simulation/WebotsClient.java | 240 - ...XCANTalonPairSpeedControlledSubsystem.java | 42 - ...BaseXCANTalonSpeedControlledSubsystem.java | 160 - .../autonomous/AutonomousCommandSelector.java | 59 - .../autonomous/SetAutonomousCommand.java | 45 - .../compressor/CompressorSubsystem.java | 48 - .../subsystems/drive/BaseDriveSubsystem.java | 187 - .../drive/ConfigurablePurePursuitCommand.java | 59 - .../subsystems/drive/MockDriveSubsystem.java | 118 - .../subsystems/drive/PurePursuitCommand.java | 513 -- .../common/subsystems/drive/RabbitPoint.java | 60 - .../subsystems/drive/RabbitPointBuilder.java | 46 - .../drive/SimulatedPurePursuitCommand.java | 58 - .../control_logic/HeadingAssistModule.java | 166 - .../drive/control_logic/HeadingModule.java | 75 - .../common/subsystems/feedback/IRumbler.java | 5 - .../subsystems/feedback/RumbleManager.java | 71 - .../subsystems/feedback/XRumbleManager.java | 33 - .../subsystems/pose/BasePoseSubsystem.java | 290 - .../pose/MockBasePoseSubsystem.java | 52 - .../pose/commands/ResetDistanceCommand.java | 37 - .../pose/commands/SetRobotHeadingCommand.java | 48 - .../simplemotor/SimpleMotorSubsystem.java | 69 - src/main/resources/10k.txt | 5460 ----------------- src/main/resources/log4j4unitTesting.xml | 39 - .../xbot/common/command/BaseCommandTest.java | 16 - .../BaseWaitForMaintainerCommandTest.java | 40 - .../java/xbot/common/command/MockCommand.java | 11 - .../common/command/MockSetpointCommand.java | 19 - .../common/command/MockSetpointSubsystem.java | 35 - .../command/MockWaitForMaintainerCommand.java | 13 - .../common/command/SetpointSystemTest.java | 58 - .../xbot/common/command/XSchedulerTest.java | 98 - .../controls/actuators/MockCANTalonTest.java | 56 - .../actuators/XDoubleSolenoidTest.java | 55 - .../sensors/AnalogDistanceSensorTest.java | 22 - .../sensors/DutyCycleEncoderTest.java | 29 - .../sensors/JoystickButtonManagerTest.java | 61 - .../common/controls/sensors/JoystickTest.java | 28 - .../sensors/TalonCurrentMonitorTest.java | 86 - .../controls/sensors/XboxControllerTest.java | 20 - .../common/injection/BaseCommonLibTest.java | 17 - .../xbot/common/injection/MockTimerTest.java | 55 - .../common/injection/TestDevicePolice.java | 52 - .../components/CommonLibTestComponent.java | 31 - .../factories/TestAllFactoryClasses.java | 72 - .../xbot/common/logging/RobotSessionTest.java | 58 - .../logging/SafeRobotAssertionTest.java | 48 - .../xbot/common/logging/TimeLoggerTest.java | 52 - .../common/logging/WordGeneratorTest.java | 30 - .../logic/HumanVsMachineDeciderTest.java | 31 - .../java/xbot/common/logic/LatchTest.java | 174 - .../xbot/common/logic/StallDetectorTest.java | 97 - .../common/logic/TimeStableValidatorTest.java | 79 - .../logic/VelocityThrottleModuleTest.java | 57 - .../xbot/common/logic/WatchdogTimerTest.java | 128 - .../common/math/ContiguousDoubleTest.java | 91 - .../common/math/FieldPoseManagerTest.java | 19 - .../java/xbot/common/math/FieldPoseTest.java | 167 - .../xbot/common/math/HistoryBufferTests.java | 41 - .../java/xbot/common/math/MathUtilsTest.java | 25 - .../java/xbot/common/math/PIDManagerTest.java | 263 - .../java/xbot/common/math/XYPairTest.java | 139 - .../common/networking/ZeromqListenerTest.java | 52 - .../common/networking/ZeromqTestServer.java | 40 - .../properties/PropertyFactoryTest.java | 19 - .../xbot/common/properties/PropertyTest.java | 139 - .../simulation/SimulateMockCANTalonTest.java | 44 - .../SimulatedDistanceSensorTest.java | 35 - .../common/simulation/SimulatedIMUTest.java | 36 - .../SimulatedMockAbsoluteEncoderTest.java | 41 - .../simulation/SimulatedSolenoidTest.java | 41 - .../common/simulation/SimulatedTimerTest.java | 63 - .../SimulationPayloadDistributorTest.java | 50 - .../subsystems/drive/DriveSubsystemTest.java | 152 - .../drive/HeadingAssistModuleTest.java | 158 - .../subsystems/drive/HeadingModuleTest.java | 67 - .../drive/PurePursuitCommandTest.java | 215 - .../feedback/RumbleManagerTest.java | 51 - .../common/subsystems/pose/BasePoseTest.java | 49 - .../subsystems/pose/PoseSubsystemTest.java | 121 - .../commands/ResetDistanceCommandTest.java | 80 - .../commands/SetRobotHeadingCommandTest.java | 51 - vendordeps/NavX.json | 39 - vendordeps/Phoenix.json | 423 -- vendordeps/REVLib.json | 73 - vendordeps/WPILibNewCommands.json | 38 - xbotcheckstyle.xml | 103 - xboteclipseprofile.xml | 295 - 296 files changed, 31667 deletions(-) delete mode 100644 .checkstyle delete mode 100644 .gitignore delete mode 100644 .vscode/extensions.json delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/settings.json delete mode 100644 .wpilib/wpilib_preferences.json delete mode 100644 488license.txt delete mode 100644 README.md delete mode 100644 azure-pipelines.yml delete mode 100644 build.gradle delete mode 100644 checkstyle_suppressions.xml delete mode 100644 gradle/wrapper/gradle-wrapper.jar delete mode 100644 gradle/wrapper/gradle-wrapper.properties delete mode 100755 gradlew delete mode 100644 gradlew.bat delete mode 100644 lib/log4jConfig/log4j.xml delete mode 100644 lib/log4jConfig/log4j4unitTesting.xml delete mode 100644 settings.gradle delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockAnalogInput.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockCompressor.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockDigitalInput.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockDigitalOutput.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockDistanceSensor.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockDistanceSensorPair.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockLidarLite.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockPWM.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockPowerDistributionPanel.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockServo.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockSolenoid.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockSpeedController.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockTimer.java delete mode 100644 src/main/java/edu/wpi/first/wpilibj/MockXboxControllerAdapter.java delete mode 100644 src/main/java/xbot/common/command/BaseCommand.java delete mode 100644 src/main/java/xbot/common/command/BaseMaintainerCommand.java delete mode 100644 src/main/java/xbot/common/command/BaseRobot.java delete mode 100644 src/main/java/xbot/common/command/BaseSetpointCommand.java delete mode 100644 src/main/java/xbot/common/command/BaseSetpointSubsystem.java delete mode 100644 src/main/java/xbot/common/command/BaseSubsystem.java delete mode 100644 src/main/java/xbot/common/command/BaseWaitForMaintainerCommand.java delete mode 100644 src/main/java/xbot/common/command/DelayViaSupplierCommand.java delete mode 100644 src/main/java/xbot/common/command/MockSmartDashboardCommandPutter.java delete mode 100644 src/main/java/xbot/common/command/NamedInstantCommand.java delete mode 100644 src/main/java/xbot/common/command/NamedRunCommand.java delete mode 100644 src/main/java/xbot/common/command/RealSmartDashboardCommandPutter.java delete mode 100644 src/main/java/xbot/common/command/SimpleWaitForMaintainerCommand.java delete mode 100644 src/main/java/xbot/common/command/SmartDashboardCommandPutter.java delete mode 100644 src/main/java/xbot/common/command/SupportsSetpointLock.java delete mode 100644 src/main/java/xbot/common/command/XScheduler.java delete mode 100644 src/main/java/xbot/common/controls/XBaseIO.java delete mode 100644 src/main/java/xbot/common/controls/actuators/XCANSparkMax.java delete mode 100644 src/main/java/xbot/common/controls/actuators/XCANSparkMaxPIDProperties.java delete mode 100644 src/main/java/xbot/common/controls/actuators/XCANTalon.java delete mode 100644 src/main/java/xbot/common/controls/actuators/XCANVictorSPX.java delete mode 100644 src/main/java/xbot/common/controls/actuators/XCompressor.java delete mode 100644 src/main/java/xbot/common/controls/actuators/XDigitalOutput.java delete mode 100644 src/main/java/xbot/common/controls/actuators/XDoubleSolenoid.java delete mode 100644 src/main/java/xbot/common/controls/actuators/XPWM.java delete mode 100644 src/main/java/xbot/common/controls/actuators/XRelay.java delete mode 100644 src/main/java/xbot/common/controls/actuators/XServo.java delete mode 100644 src/main/java/xbot/common/controls/actuators/XSolenoid.java delete mode 100644 src/main/java/xbot/common/controls/actuators/XSpeedController.java delete mode 100644 src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANSparkMax.java delete mode 100644 src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANTalon.java delete mode 100644 src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANVictorSPX.java delete mode 100644 src/main/java/xbot/common/controls/actuators/mock_adapters/MockLegacyCANTalon.java delete mode 100644 src/main/java/xbot/common/controls/actuators/mock_adapters/MockRelay.java delete mode 100644 src/main/java/xbot/common/controls/actuators/wpi_adapters/CANSparkMaxWpiAdapter.java delete mode 100644 src/main/java/xbot/common/controls/actuators/wpi_adapters/CANTalonWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/actuators/wpi_adapters/CANVictorSPXWpiAdapter.java delete mode 100644 src/main/java/xbot/common/controls/actuators/wpi_adapters/CompressorWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/actuators/wpi_adapters/DigitalOutputWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/actuators/wpi_adapters/PWMWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/actuators/wpi_adapters/RelayWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/actuators/wpi_adapters/ServoWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/actuators/wpi_adapters/SolenoidWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/actuators/wpi_adapters/SpeedControllerWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/actuators/wpi_adapters/VictorAppearingAsTalonWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/sensors/AnalogDistanceSensor.java delete mode 100644 src/main/java/xbot/common/controls/sensors/DistanceSensor.java delete mode 100644 src/main/java/xbot/common/controls/sensors/DistanceSensorPair.java delete mode 100644 src/main/java/xbot/common/controls/sensors/IGamepad.java delete mode 100644 src/main/java/xbot/common/controls/sensors/MultiplexedLidarPair.java delete mode 100644 src/main/java/xbot/common/controls/sensors/SimulatedAnalogDistanceSensor.java delete mode 100644 src/main/java/xbot/common/controls/sensors/TalonCurrentMonitor.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XAS5600.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XAbsoluteEncoder.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XAnalogDistanceSensor.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XAnalogInput.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XCANCoder.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XDigitalInput.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XDutyCycleEncoder.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XEncoder.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XFTCGamepad.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XGyro.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XJoystick.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XLidarLite.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XPowerDistributionPanel.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XSettableTimerImpl.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XTimer.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XTimerImpl.java delete mode 100644 src/main/java/xbot/common/controls/sensors/XXboxController.java delete mode 100644 src/main/java/xbot/common/controls/sensors/buttons/AdvancedJoystickButtonTrigger.java delete mode 100644 src/main/java/xbot/common/controls/sensors/buttons/AdvancedPovButtonTrigger.java delete mode 100644 src/main/java/xbot/common/controls/sensors/buttons/AdvancedTrigger.java delete mode 100644 src/main/java/xbot/common/controls/sensors/buttons/AdvancedXboxAxisTrigger.java delete mode 100644 src/main/java/xbot/common/controls/sensors/buttons/AdvancedXboxButtonTrigger.java delete mode 100644 src/main/java/xbot/common/controls/sensors/buttons/AnalogHIDButtonConfiguration.java delete mode 100644 src/main/java/xbot/common/controls/sensors/buttons/AnalogHIDButtonTrigger.java delete mode 100644 src/main/java/xbot/common/controls/sensors/buttons/ChordTrigger.java delete mode 100644 src/main/java/xbot/common/controls/sensors/buttons/InvertingBooleanSupplier.java delete mode 100644 src/main/java/xbot/common/controls/sensors/buttons/SettableBooleanSuppler.java delete mode 100644 src/main/java/xbot/common/controls/sensors/buttons/VirtualTrigger.java delete mode 100644 src/main/java/xbot/common/controls/sensors/mock_adapters/MockAbsoluteEncoder.java delete mode 100644 src/main/java/xbot/common/controls/sensors/mock_adapters/MockCANCoder.java delete mode 100644 src/main/java/xbot/common/controls/sensors/mock_adapters/MockDutyCycleEncoder.java delete mode 100644 src/main/java/xbot/common/controls/sensors/mock_adapters/MockEncoder.java delete mode 100644 src/main/java/xbot/common/controls/sensors/mock_adapters/MockFTCGamepad.java delete mode 100644 src/main/java/xbot/common/controls/sensors/mock_adapters/MockGyro.java delete mode 100644 src/main/java/xbot/common/controls/sensors/mock_adapters/MockJoystick.java delete mode 100644 src/main/java/xbot/common/controls/sensors/wpi_adapters/AnalogInputWPIAdapater.java delete mode 100644 src/main/java/xbot/common/controls/sensors/wpi_adapters/CANCoderAdapter.java delete mode 100644 src/main/java/xbot/common/controls/sensors/wpi_adapters/DigitalInputWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/sensors/wpi_adapters/DutyCycleEncoderWpiAdapter.java delete mode 100644 src/main/java/xbot/common/controls/sensors/wpi_adapters/EncoderWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/sensors/wpi_adapters/FTCGamepadWpiAdapter.java delete mode 100644 src/main/java/xbot/common/controls/sensors/wpi_adapters/InertialMeasurementUnitAdapter.java delete mode 100644 src/main/java/xbot/common/controls/sensors/wpi_adapters/JoystickWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/sensors/wpi_adapters/LidarLiteWpiAdapter.java delete mode 100644 src/main/java/xbot/common/controls/sensors/wpi_adapters/PowerDistributionPanelWPIAdapter.java delete mode 100644 src/main/java/xbot/common/controls/sensors/wpi_adapters/TimerWpiAdapter.java delete mode 100644 src/main/java/xbot/common/controls/sensors/wpi_adapters/XboxControllerWpiAdapter.java delete mode 100644 src/main/java/xbot/common/injection/BaseWPITest.java delete mode 100644 src/main/java/xbot/common/injection/DevicePolice.java delete mode 100644 src/main/java/xbot/common/injection/MockPermanentStorage.java delete mode 100644 src/main/java/xbot/common/injection/components/BaseComponent.java delete mode 100644 src/main/java/xbot/common/injection/components/PurePursuitTestComponent.java delete mode 100644 src/main/java/xbot/common/injection/components/SimulationComponent.java delete mode 100644 src/main/java/xbot/common/injection/electrical_contract/CANTalonInfo.java delete mode 100644 src/main/java/xbot/common/injection/electrical_contract/DeviceInfo.java delete mode 100644 src/main/java/xbot/common/injection/modules/MockControlsModule.java delete mode 100644 src/main/java/xbot/common/injection/modules/MockDevicesModule.java delete mode 100644 src/main/java/xbot/common/injection/modules/RealControlsModule.java delete mode 100644 src/main/java/xbot/common/injection/modules/RealDevicesModule.java delete mode 100644 src/main/java/xbot/common/injection/modules/RobotModule.java delete mode 100644 src/main/java/xbot/common/injection/modules/SimulationModule.java delete mode 100644 src/main/java/xbot/common/injection/modules/UnitTestModule.java delete mode 100644 src/main/java/xbot/common/injection/modules/UnitTestRobotModule.java delete mode 100644 src/main/java/xbot/common/logging/DriverStationAppender.java delete mode 100644 src/main/java/xbot/common/logging/IntermittentConsoleLogger.java delete mode 100644 src/main/java/xbot/common/logging/LoggingLatch.java delete mode 100644 src/main/java/xbot/common/logging/LoudRobotAssertionManager.java delete mode 100644 src/main/java/xbot/common/logging/OneLogFilePerRunRollingFileAppender.java delete mode 100644 src/main/java/xbot/common/logging/RobotAssertionException.java delete mode 100644 src/main/java/xbot/common/logging/RobotAssertionManager.java delete mode 100644 src/main/java/xbot/common/logging/RobotSession.java delete mode 100644 src/main/java/xbot/common/logging/SilentRobotAssertionManager.java delete mode 100644 src/main/java/xbot/common/logging/TimeLogger.java delete mode 100644 src/main/java/xbot/common/logging/WordGenerator.java delete mode 100644 src/main/java/xbot/common/logic/CalibrationDecider.java delete mode 100644 src/main/java/xbot/common/logic/HumanVsMachineDecider.java delete mode 100644 src/main/java/xbot/common/logic/Latch.java delete mode 100644 src/main/java/xbot/common/logic/StallDetector.java delete mode 100644 src/main/java/xbot/common/logic/TimeStableValidator.java delete mode 100644 src/main/java/xbot/common/logic/VelocityThrottleModule.java delete mode 100644 src/main/java/xbot/common/logic/WatchdogTimer.java delete mode 100644 src/main/java/xbot/common/math/ContiguousDouble.java delete mode 100644 src/main/java/xbot/common/math/FieldPose.java delete mode 100644 src/main/java/xbot/common/math/FieldPosePropertyManager.java delete mode 100644 src/main/java/xbot/common/math/InterpolatingFieldPoseBuffer.java delete mode 100644 src/main/java/xbot/common/math/InterpolatingHistoryBuffer.java delete mode 100644 src/main/java/xbot/common/math/MathUtils.java delete mode 100644 src/main/java/xbot/common/math/PID.java delete mode 100644 src/main/java/xbot/common/math/PIDManager.java delete mode 100644 src/main/java/xbot/common/math/PIDPropertyManager.java delete mode 100644 src/main/java/xbot/common/math/PlanarEngine.java delete mode 100644 src/main/java/xbot/common/math/PlanarTestVisualizer.java delete mode 100644 src/main/java/xbot/common/math/PlanarVisualizationPanel.java delete mode 100644 src/main/java/xbot/common/math/PurePursuitTest.java delete mode 100644 src/main/java/xbot/common/math/WrappedRotation2d.java delete mode 100644 src/main/java/xbot/common/math/XYPair.java delete mode 100644 src/main/java/xbot/common/networking/MockZeromqListener.java delete mode 100644 src/main/java/xbot/common/networking/XZeromqListener.java delete mode 100644 src/main/java/xbot/common/networking/ZeromqListener.java delete mode 100644 src/main/java/xbot/common/properties/BooleanProperty.java delete mode 100644 src/main/java/xbot/common/properties/ConfigurePropertiesCommand.java delete mode 100644 src/main/java/xbot/common/properties/DatabaseStorageBase.java delete mode 100644 src/main/java/xbot/common/properties/DebugFlag.java delete mode 100644 src/main/java/xbot/common/properties/DoubleProperty.java delete mode 100644 src/main/java/xbot/common/properties/IPropertySupport.java delete mode 100644 src/main/java/xbot/common/properties/ITableProxy.java delete mode 100644 src/main/java/xbot/common/properties/MockPermamentStorage.java delete mode 100644 src/main/java/xbot/common/properties/PermanentStorage.java delete mode 100644 src/main/java/xbot/common/properties/PreferenceStorage.java delete mode 100644 src/main/java/xbot/common/properties/Property.java delete mode 100644 src/main/java/xbot/common/properties/PropertyFactory.java delete mode 100644 src/main/java/xbot/common/properties/SmartDashboardTableWrapper.java delete mode 100644 src/main/java/xbot/common/properties/StringProperty.java delete mode 100644 src/main/java/xbot/common/properties/TableProxy.java delete mode 100644 src/main/java/xbot/common/properties/XPropertyManager.java delete mode 100644 src/main/java/xbot/common/resiliency/DeviceHealth.java delete mode 100644 src/main/java/xbot/common/simulation/BaseSimulationTest.java delete mode 100644 src/main/java/xbot/common/simulation/ExampleSensorData.json delete mode 100644 src/main/java/xbot/common/simulation/ISimulatableMotor.java delete mode 100644 src/main/java/xbot/common/simulation/ISimulatableSensor.java delete mode 100644 src/main/java/xbot/common/simulation/ISimulatableSolenoid.java delete mode 100644 src/main/java/xbot/common/simulation/ResetSimulatorPositionCommand.java delete mode 100644 src/main/java/xbot/common/simulation/SimulationPayloadDistributor.java delete mode 100644 src/main/java/xbot/common/simulation/WebotsClient.java delete mode 100644 src/main/java/xbot/common/subsystems/BaseXCANTalonPairSpeedControlledSubsystem.java delete mode 100644 src/main/java/xbot/common/subsystems/BaseXCANTalonSpeedControlledSubsystem.java delete mode 100644 src/main/java/xbot/common/subsystems/autonomous/AutonomousCommandSelector.java delete mode 100644 src/main/java/xbot/common/subsystems/autonomous/SetAutonomousCommand.java delete mode 100644 src/main/java/xbot/common/subsystems/compressor/CompressorSubsystem.java delete mode 100644 src/main/java/xbot/common/subsystems/drive/BaseDriveSubsystem.java delete mode 100644 src/main/java/xbot/common/subsystems/drive/ConfigurablePurePursuitCommand.java delete mode 100644 src/main/java/xbot/common/subsystems/drive/MockDriveSubsystem.java delete mode 100644 src/main/java/xbot/common/subsystems/drive/PurePursuitCommand.java delete mode 100644 src/main/java/xbot/common/subsystems/drive/RabbitPoint.java delete mode 100644 src/main/java/xbot/common/subsystems/drive/RabbitPointBuilder.java delete mode 100644 src/main/java/xbot/common/subsystems/drive/SimulatedPurePursuitCommand.java delete mode 100644 src/main/java/xbot/common/subsystems/drive/control_logic/HeadingAssistModule.java delete mode 100644 src/main/java/xbot/common/subsystems/drive/control_logic/HeadingModule.java delete mode 100644 src/main/java/xbot/common/subsystems/feedback/IRumbler.java delete mode 100644 src/main/java/xbot/common/subsystems/feedback/RumbleManager.java delete mode 100644 src/main/java/xbot/common/subsystems/feedback/XRumbleManager.java delete mode 100644 src/main/java/xbot/common/subsystems/pose/BasePoseSubsystem.java delete mode 100644 src/main/java/xbot/common/subsystems/pose/MockBasePoseSubsystem.java delete mode 100644 src/main/java/xbot/common/subsystems/pose/commands/ResetDistanceCommand.java delete mode 100644 src/main/java/xbot/common/subsystems/pose/commands/SetRobotHeadingCommand.java delete mode 100644 src/main/java/xbot/common/subsystems/simplemotor/SimpleMotorSubsystem.java delete mode 100644 src/main/resources/10k.txt delete mode 100644 src/main/resources/log4j4unitTesting.xml delete mode 100644 src/test/java/xbot/common/command/BaseCommandTest.java delete mode 100644 src/test/java/xbot/common/command/BaseWaitForMaintainerCommandTest.java delete mode 100644 src/test/java/xbot/common/command/MockCommand.java delete mode 100644 src/test/java/xbot/common/command/MockSetpointCommand.java delete mode 100644 src/test/java/xbot/common/command/MockSetpointSubsystem.java delete mode 100644 src/test/java/xbot/common/command/MockWaitForMaintainerCommand.java delete mode 100644 src/test/java/xbot/common/command/SetpointSystemTest.java delete mode 100644 src/test/java/xbot/common/command/XSchedulerTest.java delete mode 100644 src/test/java/xbot/common/controls/actuators/MockCANTalonTest.java delete mode 100644 src/test/java/xbot/common/controls/actuators/XDoubleSolenoidTest.java delete mode 100644 src/test/java/xbot/common/controls/sensors/AnalogDistanceSensorTest.java delete mode 100644 src/test/java/xbot/common/controls/sensors/DutyCycleEncoderTest.java delete mode 100644 src/test/java/xbot/common/controls/sensors/JoystickButtonManagerTest.java delete mode 100644 src/test/java/xbot/common/controls/sensors/JoystickTest.java delete mode 100644 src/test/java/xbot/common/controls/sensors/TalonCurrentMonitorTest.java delete mode 100644 src/test/java/xbot/common/controls/sensors/XboxControllerTest.java delete mode 100644 src/test/java/xbot/common/injection/BaseCommonLibTest.java delete mode 100644 src/test/java/xbot/common/injection/MockTimerTest.java delete mode 100644 src/test/java/xbot/common/injection/TestDevicePolice.java delete mode 100644 src/test/java/xbot/common/injection/components/CommonLibTestComponent.java delete mode 100644 src/test/java/xbot/common/injection/factories/TestAllFactoryClasses.java delete mode 100644 src/test/java/xbot/common/logging/RobotSessionTest.java delete mode 100644 src/test/java/xbot/common/logging/SafeRobotAssertionTest.java delete mode 100644 src/test/java/xbot/common/logging/TimeLoggerTest.java delete mode 100644 src/test/java/xbot/common/logging/WordGeneratorTest.java delete mode 100644 src/test/java/xbot/common/logic/HumanVsMachineDeciderTest.java delete mode 100644 src/test/java/xbot/common/logic/LatchTest.java delete mode 100644 src/test/java/xbot/common/logic/StallDetectorTest.java delete mode 100644 src/test/java/xbot/common/logic/TimeStableValidatorTest.java delete mode 100644 src/test/java/xbot/common/logic/VelocityThrottleModuleTest.java delete mode 100644 src/test/java/xbot/common/logic/WatchdogTimerTest.java delete mode 100644 src/test/java/xbot/common/math/ContiguousDoubleTest.java delete mode 100644 src/test/java/xbot/common/math/FieldPoseManagerTest.java delete mode 100644 src/test/java/xbot/common/math/FieldPoseTest.java delete mode 100644 src/test/java/xbot/common/math/HistoryBufferTests.java delete mode 100644 src/test/java/xbot/common/math/MathUtilsTest.java delete mode 100644 src/test/java/xbot/common/math/PIDManagerTest.java delete mode 100644 src/test/java/xbot/common/math/XYPairTest.java delete mode 100644 src/test/java/xbot/common/networking/ZeromqListenerTest.java delete mode 100644 src/test/java/xbot/common/networking/ZeromqTestServer.java delete mode 100644 src/test/java/xbot/common/properties/PropertyFactoryTest.java delete mode 100644 src/test/java/xbot/common/properties/PropertyTest.java delete mode 100644 src/test/java/xbot/common/simulation/SimulateMockCANTalonTest.java delete mode 100644 src/test/java/xbot/common/simulation/SimulatedDistanceSensorTest.java delete mode 100644 src/test/java/xbot/common/simulation/SimulatedIMUTest.java delete mode 100644 src/test/java/xbot/common/simulation/SimulatedMockAbsoluteEncoderTest.java delete mode 100644 src/test/java/xbot/common/simulation/SimulatedSolenoidTest.java delete mode 100644 src/test/java/xbot/common/simulation/SimulatedTimerTest.java delete mode 100644 src/test/java/xbot/common/simulation/SimulationPayloadDistributorTest.java delete mode 100644 src/test/java/xbot/common/subsystems/drive/DriveSubsystemTest.java delete mode 100644 src/test/java/xbot/common/subsystems/drive/HeadingAssistModuleTest.java delete mode 100644 src/test/java/xbot/common/subsystems/drive/HeadingModuleTest.java delete mode 100644 src/test/java/xbot/common/subsystems/drive/PurePursuitCommandTest.java delete mode 100644 src/test/java/xbot/common/subsystems/feedback/RumbleManagerTest.java delete mode 100644 src/test/java/xbot/common/subsystems/pose/BasePoseTest.java delete mode 100644 src/test/java/xbot/common/subsystems/pose/PoseSubsystemTest.java delete mode 100644 src/test/java/xbot/common/subsystems/pose/commands/ResetDistanceCommandTest.java delete mode 100644 src/test/java/xbot/common/subsystems/pose/commands/SetRobotHeadingCommandTest.java delete mode 100644 vendordeps/NavX.json delete mode 100644 vendordeps/Phoenix.json delete mode 100644 vendordeps/REVLib.json delete mode 100644 vendordeps/WPILibNewCommands.json delete mode 100644 xbotcheckstyle.xml delete mode 100644 xboteclipseprofile.xml diff --git a/.checkstyle b/.checkstyle deleted file mode 100644 index ea955143..00000000 --- a/.checkstyle +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 4c5f320e..00000000 --- a/.gitignore +++ /dev/null @@ -1,44 +0,0 @@ -*.class - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -./*.jar -#*.war -#*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -# binary dir -bin/ -build/ -dist/ - -# git diff files -*.orig - -# test logs -derby.log -/TeamDatabase -/488Logs - -# dynamically generated properties files -netconsole-host.properties -WPI_Native_Libraries.properties - -# JetBrains -.idea/ -/*.iml - -#Gradle -.gradle/ - -#Eclipse (build tools used by VS Code) -.settings/ -.classpath -.factorypath -.project -.apt_generated* -*.dll diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 1ff6da79..00000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "recommendations": [ - "ryanluker.vscode-coverage-gutters", - "vscjava.vscode-java-test", - "shengchen.vscode-checkstyle" - ] - } \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index aace7433..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "java", - "name": "Debug (Launch)", - "request": "launch", - "cwd": "${workspaceFolder}", - "console": "internalConsole", - "stopOnEntry": false, - "mainClass": "", - "args": "" - }, - { - "type": "java", - "name": "Debug (Launch)-PlanarTestVisualizer", - "request": "launch", - "cwd": "${workspaceFolder}", - "console": "internalConsole", - "stopOnEntry": false, - "mainClass": "xbot.common.math.PlanarTestVisualizer", - "args": "", - "projectName": "SeriouslyCommonLib" - }, - { - "type": "java", - "name": "Debug (Attach)", - "request": "attach", - "hostName": "localhost", - "port": "" - } - ] -} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index c7fd0cb8..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "java.configuration.updateBuildConfiguration": "automatic", - "java.test.defaultConfig": "SeriouslyCommonLib", - "java.test.config": [ - { - "name": "SeriouslyCommonLib", - "workingDirectory": "${workspaceFolder}/build/jni/release", - "vmargs": [ "-Djava.library.path=${workspaceFolder}/build/jni/release" ], - "env": { "LD_LIBRARY_PATH": "${workspaceFolder}/build/jni/release" , - "DYLD_LIBRARY_PATH": "${workspaceFolder}/build/jni/release" } - }, - ], - "coverage-gutters.coverageReportFileName": "html/index.html", - "coverage-gutters.coverageBaseDir": "build/reports/jacoco/test", - "coverage-gutters.coverageFileNames": [ - "jacocoTestReport.xml" - ], - "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m" -} diff --git a/.wpilib/wpilib_preferences.json b/.wpilib/wpilib_preferences.json deleted file mode 100644 index 1d03e955..00000000 --- a/.wpilib/wpilib_preferences.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "enableCppIntellisense": false, - "currentLanguage": "java", - "projectYear": "2023", - "teamNumber": 488 -} \ No newline at end of file diff --git a/488license.txt b/488license.txt deleted file mode 100644 index 137febe7..00000000 --- a/488license.txt +++ /dev/null @@ -1,18 +0,0 @@ -Copyright 2019 Team Xbot - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - -License for portions of this library (InterpolatingHistoryBuffer.java) are as follows : -Copyright (C) 2017 FRC Team 1736 Robot Casserole - www.robotcasserole.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 71f36dfa..00000000 --- a/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Seriously Common Lib for FRC [![Build Status](https://dev.azure.com/Team488/Team%20488%20Builds/_apis/build/status/Team488.SeriouslyCommonLib?branchName=main)](https://dev.azure.com/Team488/Team%20488%20Builds/_build/latest?definitionId=1?branchName=main) - -## Up-Front Warning - -This repository is still very much a work in progress! There are chunks of code and build steps missing here that would probably block you from directly integrating this into your robot. - -It's getting more complete every week, but as it stands, we recommend that you use parts of this repository rather than the whole of it - taking individual classes, or using the design as inspiration, rather than seeing it as a stable platform for robot development. - -## What is it? - -Seriously Common Lib is a collection of common solutions to robot problems that FRC teams face while using WPILib and Java. It attempts to streamline basic functionality, provide the framework for more advanced programs, and promote clean and well-written code. It functions primarily as a wrapper around WPILib which allows the robot code to run separately from the robot-specific library and HAL, enabling unit tests that can be run on a PC or CI server. - -For new teams that are haven't done much advanced programming before, this library has all the core code that is needed to get a robot running with advanced functionality without having to write the core systems from scratch. For more advanced teams, the common lib gives you a solid foundation of all the basics to start building your robot code on top of. You don't need to use the pre-built drive system or any of the other parts of the library if you don't want to; it's all modular. - -## Who's working on it? -SeriouslyCommonLib started as a separation of the commonly-written sections of code from FRC team 488 Xbot. We wanted to write re-usable code that could significantly decrease the time it took to get started in subsequent years. We had also been looking for a way to write unit tests for our robot code, which required us to write a fairly large amount of code that we didn't want to re-write each year. In doing so, we developed loads of useful utilities and wrappers and kept them separate from our season code so that we could publish it when we had the time. - -We plan to continue maintaining this codebase throughout upcoming years as we develop new functionality and find areas to fix and improve. - -## What does it do? -### Main features -- **Fully testable** We have wrappers for the robot-specific classes that WPILib provies. This means that every class can be run on a development PC, using mock implementations and factories. Your tests run all the same code that gets deployed to the robot. -- **Persistent, configurable properties** We have utilities and extra interfaces which provide an easily-accessable property framework. When you use our classes to create a property, supplying a flag makes it automatically persist in a database on the robot as well as on the Smart Dashboard. Perfect for configuration and settings. -- **Detailed logging** Every class logs with a specific message and error level when something important happens (using log4j). You can modify the logging priority threshold for the program as a whole or for specific classes, depending on the verbosity of the desired logging. -- **Re-usable utilities** Our math utilities, logic helpers, and various number containers (such as the `XYPair`for vectors or points) contain loads of re-usable logic that's useful throughout a robot program. -- **Robots never give up** It's always painful when your robot code crashes in a competition and you lose control of your robot. Although it's always best to write safe code, our scheduler wrapper keeps commands running even after an exception is thrown. -- **Pre-written drive system** We have written a drive system implementation and included it in the commom lib to make it as easy as possible to get started writing code with minimal effort. -- **Tilt detection** The common lib includes drive system helpers to attempt to counteract the acceleration of a tilting robot. If it's enabled and the robot starts to fall over, the tilt detection will kick in and attempt to right itself. -- **Enhanced autonomous capabilities** We're working on the infrastructure required to allow you to write JavaScript code which executes as a WPILib command. This means that you can write small snippets of code that execute synchronously from their point of view while still allowing the scheduler and other robot functionality to run as normal. - -## How do I get started? - -If you want to jump in, a good place to start is our [robot template](https://github.com/Team488/FRCRobotTemplate). It includes all the configuration, build scripts, and boilerplate needed to start adding functionality. We hope to develop full documentation, but in the mean time, feel free to open issues on this repo to ask us questions and provide feedback. - -## How's development going? - -We are currently in the process of modifying this library to get it ready as a robot platform. We plan to build on top of it in upcoming seasons to add functionality and fix bugs. Currently, it should be fully functional for testing using the template project, but there isn't much documentation available. More to come soon! - -### We'd love some help! - -Although we do plan to maintain this library for use in our own robots, we'd love to recieve help with fixing bugs, adding new features, and finding issues that we need to look at. If your team uses the library, we'd love for you to open issues on GitHub as you find them. And if you're feeling adventurous, we welcome PRs too. diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 0d80c56d..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Gradle -# Build your Java project and run tests with Gradle using a Gradle wrapper script. -# Add steps that analyze code, save build artifacts, deploy, and more: -# https://docs.microsoft.com/azure/devops/pipelines/languages/java - -jobs: - - job: Windows_64_Bit - pool: - vmImage: 'windows-latest' - steps: - - task: JavaToolInstaller@0 - inputs: - versionSpec: '11' - jdkArchitectureOption: 'x64' - jdkSourceOption: 'PreInstalled' - - task: Gradle@2 - inputs: - workingDirectory: '' - gradleWrapperFile: 'gradlew' - gradleOptions: '-Xmx3072m' - publishJUnitResults: true - testResultsFiles: '**/TEST-*.xml' - tasks: 'build --stacktrace --info' - # checkStyleRunAnalysis: true - # pmdRunAnalysis: true - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: 'JaCoCo' - summaryFileLocation: 'build/reports/jacoco/test/jacocoTestReport.xml' - reportDirectory: 'build/reports/jacoco/test/html' diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 51b7a4a0..00000000 --- a/build.gradle +++ /dev/null @@ -1,136 +0,0 @@ -import edu.wpi.first.gradlerio.deploy.roborio.RoboRIO -/* - * This build file was auto generated by running the Gradle 'init' task - * by 'John' at '1/7/18 10:12 PM' with Gradle 2.14.1 - * - * This generated file contains a sample Java project to get you started. - * For more details take a look at the Java Quickstart chapter in the Gradle - * user guide available at https://docs.gradle.org/2.14.1/userguide/tutorial_java_projects.html - */ - -plugins { - id "edu.wpi.first.GradleRIO" version "2023.4.2" - id 'scala' - id 'checkstyle' - id 'jacoco' -} - -sourceCompatibility = JavaVersion.VERSION_11 -targetCompatibility = JavaVersion.VERSION_11 - -// In this section you declare where to find the dependencies of your project -repositories { - // Use 'mavenCentral' for resolving your dependencies. - // You can declare any Maven/Ivy/file repository here. - mavenCentral() - - maven { url "https://mvnrepository.com/artifact/com.google.dagger/dagger" } - maven { url "https://mvnrepository.com/artifact/com.google.dagger/dagger-compiler" } - maven { url "https://mvnrepository.com/artifact/org.zeromq/jeromq" } - - maven { url uri ("../SeriouslyCommonLib/lib/")} -} - -configurations { - nativeBundle -} - -// In this section you declare the dependencies for your production and test code -dependencies { - implementation wpi.java.deps.wpilib() - implementation wpi.java.vendor.java() - - nativeDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.desktop) - nativeDebug wpi.java.vendor.jniDebug(wpi.platforms.desktop) - simulationDebug wpi.sim.enableDebug() - - nativeRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.desktop) - nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop) - simulationRelease wpi.sim.enableRelease() - - testImplementation 'junit:junit:4.12' - - // The production code uses the SLF4J logging API at compile time - implementation 'org.slf4j:slf4j-api:1.7.21' - - // In future, sync with WPILib, using junit 5 - implementation 'junit:junit:4.12' - - implementation 'com.google.dagger:dagger:2.44.2' - annotationProcessor 'com.google.dagger:dagger-compiler:2.44.2' - testAnnotationProcessor 'com.google.dagger:dagger-compiler:2.44.2' - - implementation group: 'log4j', name: 'log4j', version: '1.2.17' - - implementation group: 'org.json', name:'json', version: '20220924' - - implementation group: 'org.zeromq', name: 'jeromq', version: '0.5.3' - - implementation 'org.scala-lang:scala-library:2.11.12' - testImplementation 'org.scalatest:scalatest_2.11:3.0.0' -} - -sourceSets { - main { - resources { - srcDirs = ["src/main/resources"] - } - } -} - -task jarSources(type:Jar){ - from sourceSets.main.allSource - classifier = 'source' -} - -test { - reports { - junitXml.required = true - } -} - -// Configure string concat to always inline compile -tasks.withType(JavaCompile) { - options.compilerArgs.add '-XDstringConcat=inline' -} - -tasks.withType(Test) { - testLogging.showStandardStreams = true - - afterTest { desc, result -> - logger.quiet "Executed test ${desc.name} [${desc.className}] with result: ${result.resultType}" - } - - afterSuite { desc, result -> - if (!desc.parent) { // will match the outermost suite - println "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" - } - } -} - -checkstyle { - toolVersion = '10.6.0' - configFile = file('./xbotcheckstyle.xml') -} - -task checkstyle(type: Checkstyle) { - source 'src/main/java' - configProperties.basedir = file('.') - - // Empty classpath - classpath = files() -} - -jacocoTestReport { - dependsOn test - reports { - xml.required = true - } -} - -// always generate the coverage report after the tests run -test.finalizedBy { jacocoTestReport } - -// Configure jar and deploy tasks -wpi.java.configureExecutableTasks(jar) -wpi.java.configureTestTasks(test) \ No newline at end of file diff --git a/checkstyle_suppressions.xml b/checkstyle_suppressions.xml deleted file mode 100644 index 0f89c5ce..00000000 --- a/checkstyle_suppressions.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7454180f2ae8848c63b8b4dea2cb829da983f2fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 59536 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 QuEJmfE|#`Dqx|px0L@K;Y5)KL diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index c23a1b31..00000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=permwrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=permwrapper/dists diff --git a/gradlew b/gradlew deleted file mode 100755 index c53aefaa..00000000 --- a/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index 107acd32..00000000 --- a/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/lib/log4jConfig/log4j.xml b/lib/log4jConfig/log4j.xml deleted file mode 100644 index 643aefb2..00000000 --- a/lib/log4jConfig/log4j.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/log4jConfig/log4j4unitTesting.xml b/lib/log4jConfig/log4j4unitTesting.xml deleted file mode 100644 index 768a4648..00000000 --- a/lib/log4jConfig/log4j4unitTesting.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 7bcf1c17..00000000 --- a/settings.gradle +++ /dev/null @@ -1,31 +0,0 @@ -import org.gradle.internal.os.OperatingSystem - -pluginManagement { - repositories { - mavenLocal() - gradlePluginPortal() - String frcYear = '2023' - File frcHome - if (OperatingSystem.current().isWindows()) { - String publicFolder = System.getenv('PUBLIC') - if (publicFolder == null) { - publicFolder = "C:\\Users\\Public" - } - def homeRoot = new File(publicFolder, "wpilib") - frcHome = new File(homeRoot, frcYear) - } else { - def userFolder = System.getProperty("user.home") - def homeRoot = new File(userFolder, "wpilib") - frcHome = new File(homeRoot, frcYear) - } - def frcHomeMaven = new File(frcHome, 'maven') - maven { - name 'frcHome' - url frcHomeMaven - } - } -} - - -rootProject.name = 'SeriouslyCommonLib' - diff --git a/src/main/java/edu/wpi/first/wpilibj/MockAnalogInput.java b/src/main/java/edu/wpi/first/wpilibj/MockAnalogInput.java deleted file mode 100644 index 17d8e891..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockAnalogInput.java +++ /dev/null @@ -1,58 +0,0 @@ -package edu.wpi.first.wpilibj; - -import org.json.JSONObject; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.sensors.XAnalogInput; -import xbot.common.injection.DevicePolice; -import xbot.common.simulation.ISimulatableSensor; - -public class MockAnalogInput extends XAnalogInput implements ISimulatableSensor { - int channel; - double voltage; - - @AssistedFactory - public abstract static class MockAnalogInputFactory implements XAnalogInputFactory { - public abstract MockAnalogInput create(@Assisted("channel") int channel); - } - - @AssistedInject - public MockAnalogInput(@Assisted("channel") int channel, DevicePolice police) { - super(channel, police); - this.channel = channel; - } - - public void setVoltage(double voltage) { - this.voltage = voltage; - } - - public double getVoltage() { - return voltage; - } - - public double getAverageVoltage() { - return voltage; - } - - public void setAverageBits(int bits) { - // Nothing to do here. - } - - @Override - public int getChannel() { - return channel; - } - - @Override - public boolean getAsDigital(double threshold) { - return getVoltage() >= threshold; - } - - @Override - public void ingestSimulationData(JSONObject payload) { - setVoltage(payload.getDouble("Voltage")); - } -} diff --git a/src/main/java/edu/wpi/first/wpilibj/MockCompressor.java b/src/main/java/edu/wpi/first/wpilibj/MockCompressor.java deleted file mode 100644 index 9235c21c..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockCompressor.java +++ /dev/null @@ -1,36 +0,0 @@ -package edu.wpi.first.wpilibj; - -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.actuators.XCompressor; - -public class MockCompressor extends XCompressor { - - private boolean isEnabled = true; - - @AssistedFactory - public abstract static class MockCompressorFactory implements XCompressorFactory { - public abstract MockCompressor create(); - } - - @AssistedInject - public MockCompressor() { - - } - - @Override - public void disable() { - isEnabled = false; - } - - @Override - public void enable() { - isEnabled = true; - } - - @Override - public boolean isEnabled() { - return isEnabled; - } -} diff --git a/src/main/java/edu/wpi/first/wpilibj/MockDigitalInput.java b/src/main/java/edu/wpi/first/wpilibj/MockDigitalInput.java deleted file mode 100644 index 7b55173b..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockDigitalInput.java +++ /dev/null @@ -1,52 +0,0 @@ -package edu.wpi.first.wpilibj; - -import org.json.JSONObject; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.sensors.XDigitalInput; -import xbot.common.injection.DevicePolice; -import xbot.common.simulation.ISimulatableSensor; - -public class MockDigitalInput extends XDigitalInput implements ISimulatableSensor { - - protected boolean value; - final int channel; - - @AssistedFactory - public abstract static class MockDigitalInputFactory implements XDigitalInputFactory - { - public abstract MockDigitalInput create(@Assisted("channel") int channel); - } - - @AssistedInject - public MockDigitalInput(@Assisted("channel") int channel, DevicePolice police) { - super(police, channel); - this.channel = channel; - } - - public void setValue(boolean value) { - this.value = value ^ getInverted(); - } - - @Override - public void setInverted(boolean inverted) { - super.setInverted(inverted); - value = !value; - } - - public boolean getRaw() { - return value; - } - - public int getChannel() { - return this.channel; - } - - @Override - public void ingestSimulationData(JSONObject payload) { - setValue(payload.getBoolean("Triggered")); - } -} diff --git a/src/main/java/edu/wpi/first/wpilibj/MockDigitalOutput.java b/src/main/java/edu/wpi/first/wpilibj/MockDigitalOutput.java deleted file mode 100644 index 150e8d39..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockDigitalOutput.java +++ /dev/null @@ -1,53 +0,0 @@ -package edu.wpi.first.wpilibj; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.actuators.XDigitalOutput; -import xbot.common.injection.DevicePolice; - -public class MockDigitalOutput extends XDigitalOutput { - protected int channel; - protected boolean value; - - @AssistedFactory - public abstract static class MockDigitalOutputFactory implements XDigitalOutputFactory { - public abstract MockDigitalOutput create(@Assisted("channel") int channel); - } - - @AssistedInject - public MockDigitalOutput(@Assisted("channel") int channel, DevicePolice police) { - super(channel, police); - } - - @Override - public void set(boolean value) { - this.value = value; - } - - @Override - public void setPWMRate(double frequency) { - // Unsupported in mock implementation. - } - - @Override - public void enablePWM(double initialDutyCycle) { - // Unsupported in mock implementation. - } - - @Override - public void updateDutyCycle(double dutyCycle) { - // Unsupported in mock implementation. - } - - @Override - public void disablePWM() { - // Unsupported in mock implementation. - } - - @Override - public boolean get() { - return value; - } -} diff --git a/src/main/java/edu/wpi/first/wpilibj/MockDistanceSensor.java b/src/main/java/edu/wpi/first/wpilibj/MockDistanceSensor.java deleted file mode 100644 index 996079b2..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockDistanceSensor.java +++ /dev/null @@ -1,29 +0,0 @@ -package edu.wpi.first.wpilibj; - -import xbot.common.controls.sensors.DistanceSensor; - -public class MockDistanceSensor implements DistanceSensor { - - double distance; - - public MockDistanceSensor() { - } - - public double getDistance() { - return distance; - } - - public void setDistance(double distance) { - this.distance = distance; - } - - public void incrementDistance(double delta) { - this.distance += delta; - } - - @Override - public void setAveraging(boolean shouldAverage) { - // Nothing to do in mock implementation - } - -} diff --git a/src/main/java/edu/wpi/first/wpilibj/MockDistanceSensorPair.java b/src/main/java/edu/wpi/first/wpilibj/MockDistanceSensorPair.java deleted file mode 100644 index 523b268e..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockDistanceSensorPair.java +++ /dev/null @@ -1,33 +0,0 @@ -package edu.wpi.first.wpilibj; - -import javax.inject.Inject; - -import xbot.common.controls.sensors.DistanceSensor; -import xbot.common.controls.sensors.DistanceSensorPair; - -public class MockDistanceSensorPair implements DistanceSensorPair { - - private DistanceSensor sensorA; - private DistanceSensor sensorB; - - @Inject - public MockDistanceSensorPair() { - sensorA = new MockDistanceSensor(); - sensorB = new MockDistanceSensor(); - } - - @Override - public DistanceSensor getSensorA() { - return sensorA; - } - - @Override - public DistanceSensor getSensorB() { - return sensorB; - } - - @Override - public void update() { - // Intentionally left blank - } -} diff --git a/src/main/java/edu/wpi/first/wpilibj/MockLidarLite.java b/src/main/java/edu/wpi/first/wpilibj/MockLidarLite.java deleted file mode 100644 index 1b1c6845..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockLidarLite.java +++ /dev/null @@ -1,40 +0,0 @@ -package edu.wpi.first.wpilibj; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.I2C.Port; -import xbot.common.controls.sensors.XLidarLite; -import xbot.common.injection.DevicePolice; -import xbot.common.properties.PropertyFactory; - -public class MockLidarLite extends XLidarLite { - - @AssistedFactory - public abstract static class MockLidarLiteFactory implements XLidarLiteFactory { - public abstract MockLidarLite create(@Assisted("port") Port port, @Assisted("prefix") String prefix); - } - - @AssistedInject - public MockLidarLite(@Assisted("port") Port port, PropertyFactory propMan, DevicePolice police, @Assisted("prefix") String prefix) { - super(port, propMan, police, prefix); - } - - @Override - protected void update() { - // no-op, but still need to delay to prevent high speed loop - try { - Thread.sleep(5); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - public void setTestDistance(int testDistance) { - byte[] fakeDistance = new byte[2]; - fakeDistance[0] = (byte)(testDistance >> 8); - fakeDistance[1] = (byte)(testDistance % 256); - } - -} diff --git a/src/main/java/edu/wpi/first/wpilibj/MockPWM.java b/src/main/java/edu/wpi/first/wpilibj/MockPWM.java deleted file mode 100644 index 80b4812b..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockPWM.java +++ /dev/null @@ -1,53 +0,0 @@ -package edu.wpi.first.wpilibj; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.actuators.XPWM; -import xbot.common.injection.DevicePolice; - -public class MockPWM extends XPWM { - protected int channel; - protected double value; - - @AssistedFactory - public abstract static class MockPWMFactory implements XPWMFactory { - public abstract MockPWM create(@Assisted("channel") int channel); - } - - @AssistedInject - public MockPWM(@Assisted("channel") int channel, DevicePolice police) { - super(channel, police); - } - - @Override - public void setRaw(int value) { - this.value = value / 255d; - } - - @Override - public int getRaw() { - return (int)(value * 255); - } - - @Override - public void setSigned(double value) { - this.value = value; - } - - @Override - public double getSigned() { - return value; - } - - @Override - public void setUnsigned(double value) { - this.value = value; - } - - @Override - public double getUnsigned() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/edu/wpi/first/wpilibj/MockPowerDistributionPanel.java b/src/main/java/edu/wpi/first/wpilibj/MockPowerDistributionPanel.java deleted file mode 100644 index 39c233d9..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockPowerDistributionPanel.java +++ /dev/null @@ -1,37 +0,0 @@ -package edu.wpi.first.wpilibj; - -import java.util.HashMap; - -import org.apache.log4j.Logger; - -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.sensors.XPowerDistributionPanel; - -public class MockPowerDistributionPanel extends XPowerDistributionPanel { - private HashMap outputCurrents; - - private static Logger log = Logger.getLogger(MockPowerDistributionPanel.class); - - @AssistedFactory - public abstract static class MockPowerDistributionPanelFactory implements XPowerDistributionPanelFactory { - @Override - public abstract MockPowerDistributionPanel create(); - } - - @AssistedInject - public MockPowerDistributionPanel() { - log.info("Creating PDP"); - outputCurrents = new HashMap<>(); - } - - public void setCurrent(int channel, double current) { - outputCurrents.put(channel, current); - } - - @Override - public double getCurrent(int channel) { - return outputCurrents.getOrDefault(channel, 0d); - } -} diff --git a/src/main/java/edu/wpi/first/wpilibj/MockServo.java b/src/main/java/edu/wpi/first/wpilibj/MockServo.java deleted file mode 100644 index 9bf45ead..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockServo.java +++ /dev/null @@ -1,32 +0,0 @@ -package edu.wpi.first.wpilibj; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.actuators.XServo; -import xbot.common.injection.DevicePolice; - -public class MockServo extends XServo { - - protected double value; - - @AssistedFactory - public abstract static class MockServoFactory implements XServoFactory { - public abstract MockServo create(@Assisted("channel") int channel); - } - - @AssistedInject - public MockServo(@Assisted("channel") int channel, DevicePolice police) { - super(channel, police); - } - - @Override - public void set(double value) { - this.value = value; - } - - public double getValue(){ - return value; - } -} diff --git a/src/main/java/edu/wpi/first/wpilibj/MockSolenoid.java b/src/main/java/edu/wpi/first/wpilibj/MockSolenoid.java deleted file mode 100644 index 43d6d513..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockSolenoid.java +++ /dev/null @@ -1,46 +0,0 @@ -package edu.wpi.first.wpilibj; - -import org.json.JSONObject; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.actuators.XSolenoid; -import xbot.common.injection.DevicePolice; -import xbot.common.simulation.ISimulatableSolenoid; - -public class MockSolenoid extends XSolenoid implements ISimulatableSolenoid { - final int channel; - protected boolean on; - - @AssistedFactory - public abstract static class MockSolenoidFactory implements XSolenoidFactory { - public abstract MockSolenoid create(@Assisted("channel") int channel); - } - - @AssistedInject - public MockSolenoid(@Assisted("channel") int channel, DevicePolice police) { - super(channel, police); - this.channel = channel; - } - - @Override - public void set(boolean on) { - this.on = on; - } - - public boolean get() { - return on; - } - - @Override - public int getMaxSupportedChannel() { - return 15; - } - - @Override - public JSONObject getSimulationData() { - return buildMotorObject(channel, get()); - } -} diff --git a/src/main/java/edu/wpi/first/wpilibj/MockSpeedController.java b/src/main/java/edu/wpi/first/wpilibj/MockSpeedController.java deleted file mode 100644 index e0f0fc29..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockSpeedController.java +++ /dev/null @@ -1,37 +0,0 @@ -package edu.wpi.first.wpilibj; - -import org.apache.log4j.Logger; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.actuators.XSpeedController; -import xbot.common.injection.DevicePolice; - -public class MockSpeedController extends XSpeedController { - - private static Logger log = Logger.getLogger(MockSpeedController.class); - protected double value; - - @AssistedFactory - public abstract static class MockSpeedControllerFactory implements XSpeedControllerFactory { - public abstract MockSpeedController create(@Assisted("channel") int channel); - } - - @AssistedInject - public MockSpeedController(@Assisted("channel") int channel, DevicePolice police) { - super(channel, police); - log.info("Creating speed controller on channel:" + channel); - } - - @Override - public double get() { - return value; - } - - @Override - public void set(double output) { - value = output; - } -} diff --git a/src/main/java/edu/wpi/first/wpilibj/MockTimer.java b/src/main/java/edu/wpi/first/wpilibj/MockTimer.java deleted file mode 100644 index 0630c6f1..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockTimer.java +++ /dev/null @@ -1,46 +0,0 @@ -package edu.wpi.first.wpilibj; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import xbot.common.controls.sensors.XSettableTimerImpl; - -@Singleton -public class MockTimer implements XSettableTimerImpl { - - @Inject - public MockTimer() {} - - double timeInSeconds; - - @Override - public void setTimeInSeconds(double time) { - timeInSeconds = time; - } - - @Override - public void advanceTimeInSecondsBy(double time) { - timeInSeconds += time; - } - - /** - * Return the system clock time in seconds. Return the time from the FPGA hardware clock in seconds since the FPGA - * started. - * - * @return Robot running time in seconds. - */ - @Override - public double getFPGATimestamp() { - return timeInSeconds; - } - - @Override - public double getMatchTime() { - return timeInSeconds; - } - - @Override - public void delay(double seconds) { - - } -} \ No newline at end of file diff --git a/src/main/java/edu/wpi/first/wpilibj/MockXboxControllerAdapter.java b/src/main/java/edu/wpi/first/wpilibj/MockXboxControllerAdapter.java deleted file mode 100644 index 6b16740d..00000000 --- a/src/main/java/edu/wpi/first/wpilibj/MockXboxControllerAdapter.java +++ /dev/null @@ -1,152 +0,0 @@ -package edu.wpi.first.wpilibj; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import xbot.common.controls.sensors.XXboxController; -import xbot.common.controls.sensors.buttons.AdvancedJoystickButtonTrigger.AdvancedJoystickButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AdvancedPovButtonTrigger.AdvancedPovButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger.AnalogHIDButtonTriggerFactory; -import xbot.common.injection.DevicePolice; -import xbot.common.logging.RobotAssertionManager; -import xbot.common.math.XYPair; -import xbot.common.subsystems.feedback.XRumbleManager; -import xbot.common.subsystems.feedback.XRumbleManager.XRumbleManagerFactory; - -public class MockXboxControllerAdapter extends XXboxController { - - private XYPair leftStick; - private XYPair rightStick; - - private double leftTrigger; - private double rightTrigger; - - private final XRumbleManager rumbleManager; - - @AssistedFactory - public abstract static class MockXboxControllerFactory implements XXboxControllerFactory { - public abstract MockXboxControllerAdapter create(@Assisted("port") int port); - } - - @AssistedInject - public MockXboxControllerAdapter(@Assisted("port") int port, - AdvancedJoystickButtonTriggerFactory joystickButtonFactory, - AdvancedPovButtonTriggerFactory povButtonFactory, - AnalogHIDButtonTriggerFactory analogHidButtonFactory, XRumbleManagerFactory rumbleManagerFactory, - RobotAssertionManager manager, DevicePolice police) { - super(port, joystickButtonFactory, povButtonFactory, analogHidButtonFactory, rumbleManagerFactory, manager, - police); - leftStick = new XYPair(); - rightStick = new XYPair(); - this.rumbleManager = rumbleManagerFactory.create(this); - } - - public void setLeftStick(double x, double y) { - leftStick.x = x * (leftXInversion ? -1 : 1); - leftStick.y = y * (leftYInversion ? -1 : 1); - } - - public void setLeftStick(XYPair xy) { - setLeftStick(xy.x, xy.y); - } - - public void setRightStick(double x, double y) { - rightStick.x = x * (rightXInversion ? -1 : 1); - rightStick.y = y * (rightYInversion ? -1 : 1); - } - - public void setRightStick(XYPair xy) { - setRightStick(xy.x, xy.y); - } - - /** - * Needed for a few scenarios where we want to emulate the underlying joystick - * behavior - * and not the intent after inversion. - * - * @param xy XYPair to directly set. (Remember that by default, most joysticks - * have an inverted Y axis!) - */ - public void setRawLeftStick(XYPair xy) { - leftStick.x = xy.x; - leftStick.y = xy.y; - } - - /** - * Needed for a few scenarios where we want to emulate the underlying joystick - * behavior - * and not the intent after inversion. - * - * @param xy XYPair to directly set. (Remember that by default, most joysticks - * have an inverted Y axis!) - */ - public void setRawRightStick(XYPair xy) { - rightStick.x = xy.x; - rightStick.y = xy.y; - } - - public void setLeftTrigger(double left) { - leftTrigger = left; - } - - public void setRightTrigger(double right) { - rightTrigger = right; - } - - @Override - public boolean getButton(int button) { - return false; - } - - @Override - public double getRawAxis(int axis) { - return 0; - } - - @Override - public int getPOV() { - return 0; - } - - @Override - public GenericHID getGenericHID() { - // We don't have the HID. - return null; - } - - @Override - public XRumbleManager getRumbleManager() { - return this.rumbleManager; - } - - @Override - protected double getLeftRawTriggerAxis() { - return leftTrigger; - } - - @Override - protected double getRightRawTriggerAxis() { - return rightTrigger; - } - - @Override - protected double getLeftRawX() { - return leftStick.x; - } - - @Override - protected double getLeftRawY() { - return leftStick.y; - } - - @Override - protected double getRightRawX() { - return rightStick.x; - } - - @Override - protected double getRightRawY() { - return rightStick.y; - } - -} diff --git a/src/main/java/xbot/common/command/BaseCommand.java b/src/main/java/xbot/common/command/BaseCommand.java deleted file mode 100644 index 0fc26f63..00000000 --- a/src/main/java/xbot/common/command/BaseCommand.java +++ /dev/null @@ -1,70 +0,0 @@ -package xbot.common.command; - -import javax.inject.Inject; - -import org.apache.log4j.Logger; - -import edu.wpi.first.wpilibj2.command.CommandBase; -import xbot.common.logging.TimeLogger; -import xbot.common.properties.IPropertySupport; - -/** - * Enhanced version of WPILib's Command that allows for extension of existing - * functionality. - */ -public abstract class BaseCommand extends CommandBase implements IPropertySupport { - - protected Logger log; - protected TimeLogger monitor; - private boolean configurableRunWhenDisabled; - - @Inject - SmartDashboardCommandPutter commandPutter; - - public BaseCommand() { - log = Logger.getLogger(this.getName()); - monitor = new TimeLogger(this.getName(), 20); - } - - @Override - public boolean runsWhenDisabled() { - return configurableRunWhenDisabled; - } - - public void setRunsWhenDisabled(boolean value) { - configurableRunWhenDisabled = value; - } - - public String getPrefix() { - return this.getName() + "/"; - } - - @Override - public abstract void initialize(); - - @Override - public abstract void execute(); - - public void includeOnSmartDashboard() { - if (commandPutter != null) { - commandPutter.addCommandToSmartDashboard(this); - } - } - - public void includeOnSmartDashboard(String label) { - if (commandPutter != null) { - commandPutter.addCommandToSmartDashboard(label, this); - } - } - - /** - * @deprecated - * Suggest use {@link #addRequirements(edu.wpi.first.wpilibj2.command.Subsystem...)} instead. - * @param subsystem Requirement to add - */ - @Deprecated - public void requires(BaseSubsystem subsystem) { - this.addRequirements(subsystem); - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/command/BaseMaintainerCommand.java b/src/main/java/xbot/common/command/BaseMaintainerCommand.java deleted file mode 100644 index b2e0dedc..00000000 --- a/src/main/java/xbot/common/command/BaseMaintainerCommand.java +++ /dev/null @@ -1,180 +0,0 @@ -package xbot.common.command; - -import edu.wpi.first.wpilibj.DriverStation; -import xbot.common.logic.HumanVsMachineDecider; -import xbot.common.logic.HumanVsMachineDecider.HumanVsMachineDeciderFactory; -import xbot.common.logic.HumanVsMachineDecider.HumanVsMachineMode; -import xbot.common.logic.TimeStableValidator; -import xbot.common.properties.BooleanProperty; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.Property; -import xbot.common.properties.PropertyFactory; -import xbot.common.properties.StringProperty; - -public abstract class BaseMaintainerCommand extends BaseCommand { - - BaseSetpointSubsystem subsystemToMaintan; - - protected final BooleanProperty errorWithinToleranceProp; - protected final DoubleProperty errorToleranceProp; - protected final BooleanProperty errorIsTimeStableProp; - protected final DoubleProperty errorTimeStableWindowProp; - protected final BooleanProperty subsystemReportsReadyProp; - - protected final TimeStableValidator timeStableValidator; - protected final HumanVsMachineDecider decider; - - private final StringProperty currentModeProp; - - public BaseMaintainerCommand(BaseSetpointSubsystem subsystemToMaintain, PropertyFactory pf, - HumanVsMachineDeciderFactory humanVsMachineDeciderFactory, - double defaultErrorTolerance, double defaultTimeStableWindow) { - this.subsystemToMaintan = subsystemToMaintain; - this.addRequirements(subsystemToMaintain); - - pf.setPrefix(this); - errorToleranceProp = pf.createPersistentProperty("Error Tolerance", defaultErrorTolerance); - errorTimeStableWindowProp = pf.createPersistentProperty("Error Time Stable Window", defaultTimeStableWindow); - - pf.setDefaultLevel(Property.PropertyLevel.Debug); - errorWithinToleranceProp = pf.createEphemeralProperty("Error Within Tolerance", false); - errorIsTimeStableProp = pf.createEphemeralProperty("Error Is Time Stable", false); - currentModeProp = pf.createEphemeralProperty("Current Mode", "Not Yet Run"); - subsystemReportsReadyProp = pf.createEphemeralProperty("Subsystem Ready", false); - - timeStableValidator = new TimeStableValidator(() -> errorTimeStableWindowProp.get()); - decider = humanVsMachineDeciderFactory.create(this.getPrefix()); - } - - protected void resetDecider(boolean startInAutomaticMode) { - decider.reset(startInAutomaticMode); - } - - @Override - public void execute() { - maintain(); - subsystemToMaintan.setMaintainerIsAtGoal(isMaintainerAtGoal()); - } - - /** - * Contains all the logic associated with keeping the subsystem - * at its goal. - */ - protected void maintain() { - double humanInput = getHumanInputMagnitude(); - HumanVsMachineMode mode = decider.getRecommendedMode(humanInput); - currentModeProp.set(mode.toString()); - - switch (mode) { - case Coast: - coastAction(); - break; - case HumanControl: - humanControlAction(); - break; - case InitializeMachineControl: - initializeMachineControlAction(); - break; - case MachineControl: - if (subsystemToMaintan.isCalibrated()) { - calibratedMachineControlAction(); - } else { - uncalibratedMachineControlAction(); - } - break; - default: - // How did you get here?!?! - break; - } - } - - // Typically do nothing. - protected abstract void coastAction(); - - protected void humanControlAction() { - // Typically simply assign human input - subsystemToMaintan.setPower(getHumanInput()); - } - - protected void initializeMachineControlAction() { - // When we re-initialize machine control, we need to briefly "take" the setpoint - // lock. In practice, - // we can't require and then un-require a subsystem, so instead we just cancel - // any running command that - // is trying to maniuplate the setpoint. - if (subsystemToMaintan.getSetpointLock().getCurrentCommand() != null && !DriverStation.isAutonomous()) { - subsystemToMaintan.getSetpointLock().getCurrentCommand().cancel(); - } - - // Typically set the goal to the current position, to avoid sudden extreme - // changes - // as soon as Coast is complete. - subsystemToMaintan.setTargetValue(subsystemToMaintan.getCurrentValue()); - } - - protected abstract void calibratedMachineControlAction(); - - protected void uncalibratedMachineControlAction() { - // Typically default to human control, although this is a good candidate - // for being overwritten by an auto-calibrating feature. - humanControlAction(); - } - - protected boolean isMaintainerAtGoal() { - // Are we near our goal? - boolean withinErrorTolerance = getErrorWithinTolerance(); - // Check for any other conditions other than total error. - boolean totalAtGoal = additionalAtGoalChecks() && withinErrorTolerance; - - boolean isStable = timeStableValidator.checkStable(totalAtGoal); - // Let everybody know - errorWithinToleranceProp.set(withinErrorTolerance); - errorIsTimeStableProp.set(isStable); - subsystemReportsReadyProp.set(subsystemToMaintan.isMaintainerAtGoal()); - return isStable; - } - - /** - * Maintainer systems already check for error tolerance and time stability. If - * there - * are any other checks that should be made, override this method and place them - * here. - * - * @return true by default, can be overridden by child classes. - */ - protected boolean additionalAtGoalChecks() { - return true; - } - - /** - * Performs a simple difference between goal and target in order to see if we - * are close. - * if your subsystem needs to do something more complicated (for example, if you - * needed to - * compute difference via a ContiguousDouble) then override this method with a - * better - * computation. - */ - protected boolean getErrorWithinTolerance() { - if (Math.abs(getErrorMagnitude()) < errorToleranceProp - .get()) { - return true; - } - return false; - } - - protected abstract double getErrorMagnitude(); - - protected abstract T getHumanInput(); - - protected abstract double getHumanInputMagnitude(); - - @Override - public String getPrefix() { - return subsystemToMaintan.getPrefix() + getName() + "/"; - } - - protected void setErrorTolerance(double tolerance) { - errorToleranceProp.set(tolerance); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/command/BaseRobot.java b/src/main/java/xbot/common/command/BaseRobot.java deleted file mode 100644 index fa805f9a..00000000 --- a/src/main/java/xbot/common/command/BaseRobot.java +++ /dev/null @@ -1,328 +0,0 @@ -package xbot.common.command; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.apache.log4j.xml.DOMConfigurator; -import org.json.JSONObject; - -import edu.wpi.first.wpilibj.DriverStation; -import edu.wpi.first.wpilibj.RobotController; -import edu.wpi.first.wpilibj.TimedRobot; -import edu.wpi.first.wpilibj.livewindow.LiveWindow; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import edu.wpi.first.wpilibj2.command.Command; -import edu.wpi.first.wpilibj2.command.CommandScheduler; -import xbot.common.controls.sensors.XTimer; -import xbot.common.controls.sensors.XTimerImpl; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.components.BaseComponent; -import xbot.common.logging.RobotSession; -import xbot.common.logging.TimeLogger; -import xbot.common.logic.Latch; -import xbot.common.logic.Latch.EdgeType; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; -import xbot.common.properties.XPropertyManager; -import xbot.common.simulation.ISimulatableMotor; -import xbot.common.simulation.ISimulatableSolenoid; -import xbot.common.simulation.SimulationPayloadDistributor; -import xbot.common.simulation.WebotsClient; -import xbot.common.subsystems.autonomous.AutonomousCommandSelector; - -/** - * Core Robot class which configures logging, properties, - * scheduling, and the injector. Required for a fair amount - * of CommonLib functionality. - */ -public abstract class BaseRobot extends TimedRobot { - - Logger log; - Latch brownoutLatch; - - protected XPropertyManager propertyManager; - protected XScheduler xScheduler; - - // Other than initially creating required systems, you should never use the injector again - private BaseComponent injectorComponent; - - protected Command autonomousCommand; - protected AutonomousCommandSelector autonomousCommandSelector; - - protected DoubleProperty batteryVoltage; - protected DoubleProperty frequencyReportInterval; - protected double lastFreqCounterResetTime = -1; - protected int loopCycleCounter = 0; - - protected WebotsClient webots; - protected DevicePolice devicePolice; - protected SimulationPayloadDistributor simulationPayloadDistributor; - - TimeLogger schedulerMonitor; - TimeLogger outsidePeriodicMonitor; - - protected RobotSession robotSession; - - public BaseRobot() { - // The IterativeRobot uses the period below to trigger some timeouts. We find these to be more annoying - // than helpful, so we set the period (typically 0.02) to something dramatically larger (10 seconds). - super(10); - // However, we want to make sure that we actually do call the loopFunc quickly and periodically at - // 50hz, so we make this call to addPeriodic. - addPeriodic(super::loopFunc, 0.02); - brownoutLatch = new Latch(false, EdgeType.Both, edge -> { - if(edge == EdgeType.RisingEdge) { - log.warn("Entering brownout"); - } - else if(edge == EdgeType.FallingEdge) { - log.info("Leaving brownout"); - } - }); - - } - - @Override - protected void loopFunc() { - // Do nothing. This is part of some shenanigans to avoid loop overrun notifications. - } - - @Override - public double getPeriod() { - // In case anything was depending on reading the period, we use the typical 50hz value. - return 0.02; - } - - /** - * Override if you need a different module - */ - protected void setupInjectionModule() { - injectorComponent = createDaggerComponent(); - } - - /** - * Returns the {@link BaseComponent} instance used for dependency injection - */ - protected abstract BaseComponent createDaggerComponent(); - - /** - * Get the dependency injection component - * @return an implementation of BaseComponent that will be used throughout the robot. - */ - protected BaseComponent getInjectorComponent() { - return injectorComponent; - } - - /** - * This function is run when the robot is first started up and should be used for any initialization code. - */ - public void robotInit() { - - // Get our logging config - try { - if(BaseRobot.isReal()) { - DOMConfigurator.configure("/home/lvuser/deploy/log4j.xml"); - } else { - DOMConfigurator.configure("SeriouslyCommonLib/lib/log4jConfig/log4j4unitTesting.xml"); - } - } catch (Exception e) { - // Had a problem loading the config. Robot should continue! - final String errorString = "Couldn't configure logging - file probably missing or malformed"; - System.out.println(errorString); - DriverStation.reportError(errorString, false); - } - - log = Logger.getLogger(BaseRobot.class); - log.info("========== BASE ROBOT INITIALIZING =========="); - setupInjectionModule(); - log.info("========== INJECTOR CREATED =========="); - this.initializeSystems(); - log.info("========== SYSTEMS INITIALIZED =========="); - SmartDashboard.putData(CommandScheduler.getInstance()); - - if (this.isReal()) { - // We're just so tired of seeing these in logs. We may re-enable this at competition time. - DriverStation.silenceJoystickConnectionWarning(true); - } - PropertyFactory pf = injectorComponent.propertyFactory(); - pf.setTopLevelPrefix(); - frequencyReportInterval = pf.createPersistentProperty("Robot loop frequency report interval", 20); - batteryVoltage = pf.createEphemeralProperty("Battery Voltage", 0); - schedulerMonitor = new TimeLogger("XScheduler", (int)frequencyReportInterval.get()); - outsidePeriodicMonitor = new TimeLogger("OutsidePeriodic", 20); - robotSession = injectorComponent.robotSession(); - devicePolice = injectorComponent.devicePolice(); - simulationPayloadDistributor = injectorComponent.simulationPayloadDistributor(); - LiveWindow.disableAllTelemetry(); - } - - protected String getEnableTypeString() { - if (!DriverStation.isEnabled()) { - return "disabled"; - } - - if (DriverStation.isAutonomous()) { - return "auto"; - } - - if (DriverStation.isTeleop()) { - return "teleop"; - } - - if (DriverStation.isTest()) { - return "test"; - } - - return "enabled/unknown"; - } - - protected void updateLoggingContext() { - String dsStatus = DriverStation.isDSAttached() ? "DS" : "no DS"; - String fmsStatus = DriverStation.isFMSAttached() ? "FMS" : "no FMS"; - String matchStatus = DriverStation.getMatchType().toString() + " " + DriverStation.getMatchNumber() + " " + DriverStation.getReplayNumber(); - String enableStatus = getEnableTypeString(); - String matchContext = dsStatus + ", " + fmsStatus + ", " + enableStatus + ", " + matchStatus; - org.apache.log4j.MDC.put("matchContext", matchContext); - } - - protected void initializeSystems() { - updateLoggingContext(); - // override with additional systems (but call this one too) - XTimerImpl timerimpl = injectorComponent.timerImplementation(); - XTimer.setImplementation(timerimpl); - - // Get the property manager and get all properties from the robot disk - propertyManager = injectorComponent.propertyManager(); - xScheduler = injectorComponent.scheduler(); - // All this does is set the timeout period for the scheduler - the actual loop still runs at 50hz. - CommandScheduler.getInstance().setPeriod(0.05); - autonomousCommandSelector = injectorComponent.autonomousCommandSelector(); - } - - @Override - public void disabledInit() { - updateLoggingContext(); - log.info("Disabled init (" + getMatchContextString() + ")"); - propertyManager.saveOutAllProperties(); - } - - public void disabledPeriodic() { - this.sharedPeriodic(); - } - - protected String getMatchContextString() { - return DriverStation.getAlliance().toString() + DriverStation.getLocation() + ", " - + DriverStation.getMatchTime() + "s, " - + (DriverStation.isDSAttached() ? "DS connected" : "DS disconnected") + ", " - + (DriverStation.isFMSAttached() ? "FMS connected" : "FMS disconnected") + ", " - + "Is disabled: " + DriverStation.isDisabled() + ", " - + "Is enabled: " + DriverStation.isEnabled() + ", " - + "Is auto: " + DriverStation.isAutonomous() + ", " - + "Is teleop: " + DriverStation.isTeleop() + ", " - + "Is test: " + DriverStation.isTest() + ", " - + "Is browned out: " + RobotController.isBrownedOut() + ", " - + "Is output enabled: " + RobotController.isSysActive() + ", " - + "Battery voltage: " + RobotController.getBatteryVoltage(); - } - - public void autonomousInit() { - robotSession.autoInit(); - updateLoggingContext(); - log.info("Autonomous init (" + getMatchContextString() + ")"); - this.autonomousCommand = this.autonomousCommandSelector.getCurrentAutonomousCommand(); - if(this.autonomousCommand != null) { - log.info("Starting autonomous command: " + this.autonomousCommand); - this.autonomousCommand.schedule(); - } else { - log.warn("No autonomous command set."); - } - } - - /** - * This function is called periodically during autonomous - */ - public void autonomousPeriodic() { - this.sharedPeriodic(); - } - - public void teleopInit() { - robotSession.teleopInit(); - updateLoggingContext(); - log.info("Teleop init (" + getMatchContextString() + ")"); - if(this.autonomousCommand != null) { - log.info("Cancelling autonomousCommand."); - this.autonomousCommand.cancel(); - } - } - - /** - * This function is called periodically during operator control - */ - public void teleopPeriodic() { - this.sharedPeriodic(); - } - - /** - * This function is called periodically during test mode - */ - public void testPeriodic() { - } - - protected void sharedPeriodic() { - outsidePeriodicMonitor.stop(); - schedulerMonitor.start(); - xScheduler.run(); - schedulerMonitor.stop(); - - batteryVoltage.set(RobotController.getBatteryVoltage()); - - brownoutLatch.setValue(RobotController.isBrownedOut()); - - loopCycleCounter++; - double timeSinceLastLog = XTimer.getFPGATimestamp() - lastFreqCounterResetTime; - if(lastFreqCounterResetTime <= 0) { - lastFreqCounterResetTime = XTimer.getFPGATimestamp(); - } - else if(timeSinceLastLog >= frequencyReportInterval.get()) { - double loopsPerSecond = loopCycleCounter / timeSinceLastLog; - - loopCycleCounter = 0; - lastFreqCounterResetTime = XTimer.getFPGATimestamp(); - - log.info("Robot loops per second: " + loopsPerSecond); - } - - outsidePeriodicMonitor.start(); - } - - - @Override - public void simulationInit() { - /* - webots = injectorComponent.webotsClient(); - webots.initialize(); - - */ - } - - @Override - public void simulationPeriodic() { - /* - // find all simulatable motors - List motors = new ArrayList(); - - for (String deviceId: devicePolice.registeredChannels.keySet()) { - Object device = devicePolice.registeredChannels.get(deviceId); - if (device instanceof ISimulatableMotor) { - motors.add(((ISimulatableMotor)device).getSimulationData()); - } - if (device instanceof ISimulatableSolenoid) { - motors.add(((ISimulatableSolenoid)device).getSimulationData()); - } - } - JSONObject response = webots.sendMotors(motors); - - simulationPayloadDistributor.distributeSimulationPayload(response); - */ - } -} diff --git a/src/main/java/xbot/common/command/BaseSetpointCommand.java b/src/main/java/xbot/common/command/BaseSetpointCommand.java deleted file mode 100644 index 19e11c8f..00000000 --- a/src/main/java/xbot/common/command/BaseSetpointCommand.java +++ /dev/null @@ -1,15 +0,0 @@ -package xbot.common.command; - -public abstract class BaseSetpointCommand extends BaseCommand { - - public BaseSetpointCommand(SupportsSetpointLock... systems) { - for (SupportsSetpointLock system : systems) { - this.addRequirements(system.getSetpointLock()); - } - } - - @Override - public boolean isFinished() { - return false; - } -} diff --git a/src/main/java/xbot/common/command/BaseSetpointSubsystem.java b/src/main/java/xbot/common/command/BaseSetpointSubsystem.java deleted file mode 100644 index ddb1c36b..00000000 --- a/src/main/java/xbot/common/command/BaseSetpointSubsystem.java +++ /dev/null @@ -1,42 +0,0 @@ -package xbot.common.command; - -import edu.wpi.first.wpilibj2.command.Subsystem; -import xbot.common.controls.sensors.XTimer; - -public abstract class BaseSetpointSubsystem extends BaseSubsystem implements SupportsSetpointLock { - - private Subsystem setpointLock; - private double lastUpdateTimeFromMaintainer; - protected boolean atGoal; - - public BaseSetpointSubsystem() { - setpointLock = new Subsystem() {}; - } - - @Override - public Subsystem getSetpointLock() { - return setpointLock; - } - - public boolean isMaintainerAtGoal() { - // If we haven't heard from the maintainer within the last 0.5 seconds, - // then assume the system is not ready. - double gap = XTimer.getFPGATimestamp() - lastUpdateTimeFromMaintainer; - return atGoal && Math.abs(gap) < 0.5; - } - - public void setMaintainerIsAtGoal(boolean atGoal) { - lastUpdateTimeFromMaintainer = XTimer.getFPGATimestamp(); - this.atGoal = atGoal; - } - - public abstract T getCurrentValue(); - - public abstract T getTargetValue(); - - public abstract void setTargetValue(T value); - - public abstract void setPower(T power); - - public abstract boolean isCalibrated(); -} diff --git a/src/main/java/xbot/common/command/BaseSubsystem.java b/src/main/java/xbot/common/command/BaseSubsystem.java deleted file mode 100644 index f1c5979d..00000000 --- a/src/main/java/xbot/common/command/BaseSubsystem.java +++ /dev/null @@ -1,19 +0,0 @@ -package xbot.common.command; - -import org.apache.log4j.Logger; - -import edu.wpi.first.wpilibj2.command.SubsystemBase; -import xbot.common.properties.IPropertySupport; - -public abstract class BaseSubsystem extends SubsystemBase implements IPropertySupport { - - protected Logger log; - - public BaseSubsystem() { - log = Logger.getLogger(this.getName()); - } - - public String getPrefix() { - return this.getName() + "/"; - } -} diff --git a/src/main/java/xbot/common/command/BaseWaitForMaintainerCommand.java b/src/main/java/xbot/common/command/BaseWaitForMaintainerCommand.java deleted file mode 100644 index f3e98fe6..00000000 --- a/src/main/java/xbot/common/command/BaseWaitForMaintainerCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -package xbot.common.command; - -import xbot.common.controls.sensors.XTimer; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; - -/** - * Command that waits for a setpoint subsystem to reach its goal - */ -public abstract class BaseWaitForMaintainerCommand extends BaseCommand { - - private final BaseSetpointSubsystem system; - private final DoubleProperty timeoutProperty; - - private double startTime; - - public BaseWaitForMaintainerCommand(BaseSetpointSubsystem system, PropertyFactory pf, double defaultTimeout) { - this.system = system; - - pf.setPrefix(this); - this.timeoutProperty = pf.createPersistentProperty("Timeout Seconds", defaultTimeout); - } - - @Override - public void initialize() { - this.startTime = XTimer.getFPGATimestamp(); - } - - @Override - public void execute() { - // this command doesn't do anything in the execute phase - } - - @Override - public boolean isFinished() { - return (this.system.isMaintainerAtGoal() || isTimeoutExpired()); - } - - private boolean isTimeoutExpired() { - return XTimer.getFPGATimestamp() > this.startTime + this.timeoutProperty.get(); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/command/DelayViaSupplierCommand.java b/src/main/java/xbot/common/command/DelayViaSupplierCommand.java deleted file mode 100644 index 8c862c1c..00000000 --- a/src/main/java/xbot/common/command/DelayViaSupplierCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package xbot.common.command; - -import java.util.function.Supplier; - -import xbot.common.controls.sensors.XTimer; - -public class DelayViaSupplierCommand extends BaseCommand { - - protected double startTime; - protected Supplier delaySupplier; - - public DelayViaSupplierCommand(Supplier delaySupplier) { - this.delaySupplier = delaySupplier; - } - - @Override - public void initialize() { - this.startTime = XTimer.getFPGATimestamp(); - log.info("Initializing with intial time: " + startTime + " and waiting for " + delaySupplier.get() + " seconds"); - } - - @Override - public void execute() { - // Do nothing - } - - @Override - public boolean isFinished() { - return isTimeoutExpired(); - } - - private boolean isTimeoutExpired() { - return XTimer.getFPGATimestamp() > startTime + delaySupplier.get(); - } -} diff --git a/src/main/java/xbot/common/command/MockSmartDashboardCommandPutter.java b/src/main/java/xbot/common/command/MockSmartDashboardCommandPutter.java deleted file mode 100644 index 5fda03e4..00000000 --- a/src/main/java/xbot/common/command/MockSmartDashboardCommandPutter.java +++ /dev/null @@ -1,22 +0,0 @@ -package xbot.common.command; - -import javax.inject.Inject; - -public class MockSmartDashboardCommandPutter implements SmartDashboardCommandPutter { - - @Inject - public MockSmartDashboardCommandPutter() {} - - @Override - public void addCommandToSmartDashboard(BaseCommand command) { - // intentionally left blank as the SmartDashboard isn't available off the robot right now - - } - - @Override - public void addCommandToSmartDashboard(String label, BaseCommand command) { - // intentionally left blank as the SmartDashboard isn't available off the robot right now - - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/command/NamedInstantCommand.java b/src/main/java/xbot/common/command/NamedInstantCommand.java deleted file mode 100644 index 6383c08d..00000000 --- a/src/main/java/xbot/common/command/NamedInstantCommand.java +++ /dev/null @@ -1,15 +0,0 @@ -package xbot.common.command; - -import edu.wpi.first.wpilibj2.command.InstantCommand; -import edu.wpi.first.wpilibj2.command.Subsystem; - -/** - * Convenience wrapper of InstantCommand that allows setting a human readable name for - * smartdashboard/logging readability. - */ -public class NamedInstantCommand extends InstantCommand { - public NamedInstantCommand(String name, Runnable toRun, Subsystem... requirements) { - super(toRun, requirements); - this.setName(name); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/command/NamedRunCommand.java b/src/main/java/xbot/common/command/NamedRunCommand.java deleted file mode 100644 index cc1042f3..00000000 --- a/src/main/java/xbot/common/command/NamedRunCommand.java +++ /dev/null @@ -1,22 +0,0 @@ -package xbot.common.command; - -import org.apache.log4j.Logger; - -import edu.wpi.first.wpilibj2.command.RunCommand; -import edu.wpi.first.wpilibj2.command.Subsystem; - -public class NamedRunCommand extends RunCommand { - protected Logger log; - - public NamedRunCommand(String name, Runnable toRun, Subsystem... requirements) { - super(toRun, requirements); - this.setName(name); - log = Logger.getLogger(this.getName()); - } - - @Override - public void initialize() { - super.initialize(); - log.info("Initializing"); - } -} diff --git a/src/main/java/xbot/common/command/RealSmartDashboardCommandPutter.java b/src/main/java/xbot/common/command/RealSmartDashboardCommandPutter.java deleted file mode 100644 index f55e9c2e..00000000 --- a/src/main/java/xbot/common/command/RealSmartDashboardCommandPutter.java +++ /dev/null @@ -1,23 +0,0 @@ -package xbot.common.command; - -import javax.inject.Inject; - -//import edu.wpi.first.wpilibj2.command.Command; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; - -public class RealSmartDashboardCommandPutter implements SmartDashboardCommandPutter { - - @Inject - public RealSmartDashboardCommandPutter() {} - - @Override - public void addCommandToSmartDashboard(BaseCommand command) { - SmartDashboard.putData(command); - } - - @Override - public void addCommandToSmartDashboard(String label, BaseCommand command) { - SmartDashboard.putData(label, command); - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/command/SimpleWaitForMaintainerCommand.java b/src/main/java/xbot/common/command/SimpleWaitForMaintainerCommand.java deleted file mode 100644 index 8209f513..00000000 --- a/src/main/java/xbot/common/command/SimpleWaitForMaintainerCommand.java +++ /dev/null @@ -1,36 +0,0 @@ -package xbot.common.command; - -import java.util.function.Supplier; - -import xbot.common.controls.sensors.XTimer; - -public class SimpleWaitForMaintainerCommand extends BaseCommand { - - private final BaseSetpointSubsystem subsystem; - private double startTime; - private Supplier delaySupplier; - - public SimpleWaitForMaintainerCommand(BaseSetpointSubsystem subsystem, Supplier delaySupplier) { - this.subsystem = subsystem; - this.delaySupplier = delaySupplier; - } - - @Override - public void initialize() { - this.startTime = XTimer.getFPGATimestamp(); - } - - @Override - public void execute() { - // Do nothing - } - - @Override - public boolean isFinished() { - return isTimeoutExpired() || subsystem.isMaintainerAtGoal(); - } - - private boolean isTimeoutExpired() { - return XTimer.getFPGATimestamp() > startTime + delaySupplier.get(); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/command/SmartDashboardCommandPutter.java b/src/main/java/xbot/common/command/SmartDashboardCommandPutter.java deleted file mode 100644 index af222a11..00000000 --- a/src/main/java/xbot/common/command/SmartDashboardCommandPutter.java +++ /dev/null @@ -1,6 +0,0 @@ -package xbot.common.command; - -public interface SmartDashboardCommandPutter { - public void addCommandToSmartDashboard(BaseCommand command); - public void addCommandToSmartDashboard(String label, BaseCommand command); -} \ No newline at end of file diff --git a/src/main/java/xbot/common/command/SupportsSetpointLock.java b/src/main/java/xbot/common/command/SupportsSetpointLock.java deleted file mode 100644 index db0d8cfd..00000000 --- a/src/main/java/xbot/common/command/SupportsSetpointLock.java +++ /dev/null @@ -1,8 +0,0 @@ -package xbot.common.command; - -import edu.wpi.first.wpilibj2.command.Subsystem; - -public interface SupportsSetpointLock { - - public Subsystem getSetpointLock(); -} diff --git a/src/main/java/xbot/common/command/XScheduler.java b/src/main/java/xbot/common/command/XScheduler.java deleted file mode 100644 index e5eefb2b..00000000 --- a/src/main/java/xbot/common/command/XScheduler.java +++ /dev/null @@ -1,67 +0,0 @@ -package xbot.common.command; - -import java.util.Arrays; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.apache.log4j.Logger; - -import edu.wpi.first.wpilibj2.command.Command; -import edu.wpi.first.wpilibj2.command.CommandScheduler; -import edu.wpi.first.wpilibj2.command.Subsystem; - -/** - * Wrapper for base Scheduler which intelligently manages exceptions. - */ -@Singleton -public class XScheduler { - - private static Logger log = Logger.getLogger(XScheduler.class); - - boolean crashedPreviously = false; - - int numberOfCrashes = 0; - - CommandScheduler scheduler; - - @Inject - public XScheduler() { - this.scheduler = CommandScheduler.getInstance(); - } - - public int getNumberOfCrashes() - { - return numberOfCrashes; - } - - public void run() { - try { - scheduler.run(); - crashedPreviously = false; - } catch(Throwable t) { - log.error(String.format( - "Unhandled exception in Scheduler %s at %s", - t.toString(), - Arrays.toString(t.getStackTrace()))); - if(crashedPreviously) { - log.error("Due to repeated exceptions, clearing Scheduler queue completely"); - scheduler.cancelAll(); - } - crashedPreviously = true; - numberOfCrashes++; - } - } - - public void removeAll() { - scheduler.cancelAll(); - } - - public void registerSubsystem(Subsystem... subsystems) { - scheduler.registerSubsystem(subsystems); - } - - public void setDefaultCommand(Subsystem subsystem, Command defaultCommand) { - scheduler.setDefaultCommand(subsystem, defaultCommand); - } -} diff --git a/src/main/java/xbot/common/controls/XBaseIO.java b/src/main/java/xbot/common/controls/XBaseIO.java deleted file mode 100644 index a4f27e73..00000000 --- a/src/main/java/xbot/common/controls/XBaseIO.java +++ /dev/null @@ -1,5 +0,0 @@ -package xbot.common.controls; - -public interface XBaseIO { - public int getChannel(); -} diff --git a/src/main/java/xbot/common/controls/actuators/XCANSparkMax.java b/src/main/java/xbot/common/controls/actuators/XCANSparkMax.java deleted file mode 100644 index 2ff3099b..00000000 --- a/src/main/java/xbot/common/controls/actuators/XCANSparkMax.java +++ /dev/null @@ -1,742 +0,0 @@ -package xbot.common.controls.actuators; - -import com.revrobotics.CANSparkMax; -import com.revrobotics.CANSparkMax.ControlType; -import com.revrobotics.CANSparkMax.ExternalFollower; -import com.revrobotics.CANSparkMax.FaultID; -import com.revrobotics.CANSparkMax.IdleMode; -import com.revrobotics.CANSparkMax.SoftLimitDirection; -import com.revrobotics.REVLibError; -import com.revrobotics.SparkMaxPIDController.ArbFFUnits; - -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; -import xbot.common.injection.electrical_contract.DeviceInfo; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.Property; -import xbot.common.properties.PropertyFactory; - -public abstract class XCANSparkMax { - - protected int deviceId; - protected String prefix = ""; - PropertyFactory propertyFactory; - protected boolean usesPropertySystem = true; - - DoubleProperty kPprop; - DoubleProperty kIprop; - DoubleProperty kDprop; - DoubleProperty kIzProp; - DoubleProperty kFFprop; - DoubleProperty kMaxOutputProp; - DoubleProperty kMinOutoutProp; - - DoubleProperty percentProp; - DoubleProperty voltageProp; - DoubleProperty currentProp; - - protected final String policeTicket; - - protected boolean firstPeriodicCall = true; - - public abstract static class XCANSparkMaxFactory { - public abstract XCANSparkMax create( - DeviceInfo deviceInfo, - String owningSystemPrefix, - String name, - XCANSparkMaxPIDProperties defaultPIDProperties); - - public XCANSparkMax create(DeviceInfo deviceInfo, String owningSystemPrefix, String name) { - return create(deviceInfo, owningSystemPrefix, name, new XCANSparkMaxPIDProperties()); - } - - public XCANSparkMax createWithoutProperties(DeviceInfo deviceInfo, String owningSystemPrefix, String name) { - return create(deviceInfo, owningSystemPrefix, name, null); - } - } - - protected XCANSparkMax( - DeviceInfo deviceInfo, - String owningSystemPrefix, - String name, - PropertyFactory pf, - DevicePolice police, - XCANSparkMaxPIDProperties defaultPIDProperties) { - this.deviceId = deviceInfo.channel; - this.propertyFactory = pf; - this.propertyFactory.setPrefix(owningSystemPrefix); - this.propertyFactory.appendPrefix(name); - prefix = pf.getPrefix(); - policeTicket = police.registerDevice(DeviceType.CAN, deviceId, this); - - if (defaultPIDProperties == null) { - usesPropertySystem = false; - } else { - kPprop = pf.createPersistentProperty("kP", defaultPIDProperties.p); - kIprop = pf.createPersistentProperty("kI", defaultPIDProperties.i); - kDprop = pf.createPersistentProperty("kD", defaultPIDProperties.d); - - pf.setDefaultLevel(Property.PropertyLevel.Debug); - percentProp = pf.createEphemeralProperty("Percent", 0); - voltageProp = pf.createEphemeralProperty("Voltage", 0); - currentProp = pf.createEphemeralProperty("Current", 0); - kIzProp = pf.createPersistentProperty("kIzone", defaultPIDProperties.iZone); - kFFprop = pf.createPersistentProperty("kFeedForward", defaultPIDProperties.feedForward); - kMaxOutputProp = pf.createPersistentProperty("kMaxOutput", defaultPIDProperties.maxOutput); - kMinOutoutProp = pf.createPersistentProperty("kMinOutput", defaultPIDProperties.minOutput); - } - } - - /// - // Our own methods - /// - - public String getPrefix() { - return prefix; - } - - private void setAllProperties() { - if (usesPropertySystem) { - setP(kPprop.get()); - setI(kIprop.get()); - setD(kDprop.get()); - setIZone(kIzProp.get()); - setFF(kFFprop.get()); - setOutputRange(kMinOutoutProp.get(), kMaxOutputProp.get()); - } - } - - public void periodic() { - if (usesPropertySystem) { - if (firstPeriodicCall) { - setAllProperties(); - firstPeriodicCall = false; - } - kPprop.hasChangedSinceLastCheck((value) -> setP(value)); - kIprop.hasChangedSinceLastCheck((value) -> setI(value)); - kDprop.hasChangedSinceLastCheck((value) -> setD(value)); - kIzProp.hasChangedSinceLastCheck((value) -> setIZone(value)); - kFFprop.hasChangedSinceLastCheck((value) -> setFF(value)); - kMaxOutputProp.hasChangedSinceLastCheck((value) -> setOutputRange(kMinOutoutProp.get(), value)); - kMinOutoutProp.hasChangedSinceLastCheck((value) -> setOutputRange(value, kMaxOutputProp.get())); - - percentProp.set(getAppliedOutput()); - voltageProp.set(getAppliedOutput() * getBusVoltage()); - currentProp.set(getOutputCurrent()); - } - } - - /**** Speed Controller Interface ****/ - /** - * Common interface for setting the speed of a speed controller. - * - * @param speed The speed to set. Value should be between -1.0 and 1.0. - */ - public abstract void set(double speed); - - /** - * Sets the voltage output of the SpeedController. This is equivillant to a call - * to SetReference(output, rev::ControlType::kVoltage). The behavior of this - * call differs slightly from the WPILib documetation for this call since the - * device internally sets the desired voltage (not a compensation value). That - * means that this *can* be a 'set-and-forget' call. - * - * @param outputVolts The voltage to output. - */ - public abstract void setVoltage(double outputVolts); - - /** - * Common interface for getting the current set speed of a speed controller. - * - * @return The current set speed. Value is between -1.0 and 1.0. - */ - public abstract double get(); - - /** - * Common interface for inverting direction of a speed controller. - * - * This call has no effect if the controller is a follower. - * - * @param isInverted The state of inversion, true is inverted. - */ - public abstract void setInverted(boolean isInverted); - - /** - * Common interface for returning the inversion state of a speed controller. - * - * This call has no effect if the controller is a follower. - * - * @return isInverted The state of inversion, true is inverted. - */ - public abstract boolean getInverted(); - - /** - * Common interface for disabling a motor. - */ - public abstract void disable(); - - public abstract void stopMotor(); - - /** - * Sets the current limit in Amps. - * - * The motor controller will reduce the controller voltage output to avoid - * surpassing this limit. This limit is enabled by default and used for - * brushless only. This limit is highly recommended when using the NEO brushless - * motor. - * - * The NEO Brushless Motor has a low internal resistance, which can mean large - * current spikes that could be enough to cause damage to the motor and - * controller. This current limit provides a smarter strategy to deal with high - * current draws and keep the motor and controller operating in a safe region. - * - * @param limit The current limit in Amps. - * - * @return REVLibError Set to REVLibError.kOK if successful - * - */ - public abstract REVLibError setSmartCurrentLimit(int limit); - - /** - * Sets the current limit in Amps. - * - * The motor controller will reduce the controller voltage output to avoid - * surpassing this limit. This limit is enabled by default and used for - * brushless only. This limit is highly recommended when using the NEO brushless - * motor. - * - * The NEO Brushless Motor has a low internal resistance, which can mean large - * current spikes that could be enough to cause damage to the motor and - * controller. This current limit provides a smarter strategy to deal with high - * current draws and keep the motor and controller operating in a safe region. - * - * The controller can also limit the current based on the RPM of the motor in a - * linear fashion to help with controllability in closed loop control. For a - * response that is linear the entire RPM range leave limit RPM at 0. - * - * @param stallLimit The current limit in Amps at 0 RPM. - * @param freeLimit The current limit at free speed (5700RPM for NEO). - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError setSmartCurrentLimit(int stallLimit, int freeLimit); - - /** - * Sets the current limit in Amps. - * - * The motor controller will reduce the controller voltage output to avoid - * surpassing this limit. This limit is enabled by default and used for - * brushless only. This limit is highly recommended when using the NEO brushless - * motor. - * - * The NEO Brushless Motor has a low internal resistance, which can mean large - * current spikes that could be enough to cause damage to the motor and - * controller. This current limit provides a smarter strategy to deal with high - * current draws and keep the motor and controller operating in a safe region. - * - * The controller can also limit the current based on the RPM of the motor in a - * linear fashion to help with controllability in closed loop control. For a - * response that is linear the entire RPM range leave limit RPM at 0. - * - * @param stallLimit The current limit in Amps at 0 RPM. - * @param freeLimit The current limit at free speed (5700RPM for NEO). - * @param limitRPM RPM less than this value will be set to the stallLimit, RPM - * values greater than limitRPM will scale linearly to - * freeLimit - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError setSmartCurrentLimit(int stallLimit, int freeLimit, int limitRPM); - - /** - * Sets the secondary current limit in Amps. - * - * The motor controller will disable the output of the controller briefly if the - * current limit is exceeded to reduce the current. This limit is a simplified - * 'on/off' controller. This limit is enabled by default but is set higher than - * the default Smart Current Limit. - * - * The time the controller is off after the current limit is reached is - * determined by the parameter limitCycles, which is the number of PWM cycles - * (20kHz). The recommended value is the default of 0 which is the minimum time - * and is part of a PWM cycle from when the over current is detected. This - * allows the controller to regulate the current close to the limit value. - * - * The total time is set by the equation - * - * - * t = (50us - t0) + 50us * limitCycles - * t = total off time after over current - * t0 = time from the start of the PWM cycle until over current is detected - * - * - * - * @param limit The current limit in Amps. - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError setSecondaryCurrentLimit(double limit); - - /** - * Sets the secondary current limit in Amps. - * - * The motor controller will disable the output of the controller briefly if the - * current limit is exceeded to reduce the current. This limit is a simplified - * 'on/off' controller. This limit is enabled by default but is set higher than - * the default Smart Current Limit. - * - * The time the controller is off after the current limit is reached is - * determined by the parameter limitCycles, which is the number of PWM cycles - * (20kHz). The recommended value is the default of 0 which is the minimum time - * and is part of a PWM cycle from when the over current is detected. This - * allows the controller to regulate the current close to the limit value. - * - * The total time is set by the equation - * - * - * t = (50us - t0) + 50us * limitCycles - * t = total off time after over current - * t0 = time from the start of the PWM cycle until over current is detected - * - * - * - * @param limit The current limit in Amps. - * @param chopCycles The number of additional PWM cycles to turn the driver off - * after overcurrent is detected. - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError setSecondaryCurrentLimit(double limit, int chopCycles); - - /** - * Sets the idle mode setting for the SPARK MAX. - * - * @param mode Idle mode (coast or brake). - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError setIdleMode(IdleMode mode); - - /** - * Gets the idle mode setting for the SPARK MAX. - * - * This uses the Get Parameter API and should be used infrequently. This - * function uses a non-blocking call and will return a cached value if the - * parameter is not returned by the timeout. The timeout can be changed by - * calling SetCANTimeout(int milliseconds) - * - * @return IdleMode Idle mode setting - */ - public abstract IdleMode getIdleMode(); - - /** - * Sets the voltage compensation setting for all modes on the SPARK MAX and - * enables voltage compensation. - * - * @param nominalVoltage Nominal voltage to compensate output to - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError enableVoltageCompensation(double nominalVoltage); - - /** - * Disables the voltage compensation setting for all modes on the SPARK MAX. - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError disableVoltageCompensation(); - - /** - * Get the configured voltage compensation nominal voltage value - * - * @return The nominal voltage for voltage compensation mode. - */ - public abstract double getVoltageCompensationNominalVoltage(); - - /** - * Sets the ramp rate for open loop control modes. - * - * This is the maximum rate at which the motor controller's output is allowed to - * change. - * - * @param rate Time in seconds to go from 0 to full throttle. - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError setOpenLoopRampRate(double rate); - - /** - * Sets the ramp rate for closed loop control modes. - * - * This is the maximum rate at which the motor controller's output is allowed to - * change. - * - * @param rate Time in seconds to go from 0 to full throttle. - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError setClosedLoopRampRate(double rate); - - /** - * Get the configured open loop ramp rate - * - * This is the maximum rate at which the motor controller's output is allowed to - * change. - * - * @return ramp rate time in seconds to go from 0 to full throttle. - */ - public abstract double getOpenLoopRampRate(); - - /** - * Get the configured closed loop ramp rate - * - * This is the maximum rate at which the motor controller's output is allowed to - * change. - * - * @return ramp rate time in seconds to go from 0 to full throttle. - */ - public abstract double getClosedLoopRampRate(); - - /** - * Causes this controller's output to mirror the provided leader. - * - * Only voltage output is mirrored. Settings changed on the leader do not affect - * the follower. - * - * The motor will spin in the same direction as the leader. This can be changed - * by passing a true constant after the leader parameter. - * - * Following anything other than a CAN SPARK MAX is not officially supported. - * - * @param leader The motor controller to follow. - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError follow(final XCANSparkMax leader); - - /** - * Causes this controller's output to mirror the provided leader. - * - * Only voltage output is mirrored. Settings changed on the leader do not affect - * the follower. - * - * Following anything other than a CAN SPARK MAX is not officially supported. - * - * @param leader The motor controller to follow. - * @param invert Set the follower to output opposite of the leader - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError follow(final XCANSparkMax leader, boolean invert); - - /** - * Causes this controller's output to mirror the provided leader. - * - * Only voltage output is mirrored. Settings changed on the leader do not affect - * the follower. - * - * The motor will spin in the same direction as the leader. This can be changed - * by passing a true constant after the deviceID parameter. - * - * Following anything other than a CAN SPARK MAX is not officially supported. - * - * @param leader The type of motor controller to follow (Talon SRX, Spark Max, - * etc.). - * @param deviceID The CAN ID of the device to follow. - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError follow(ExternalFollower leader, int deviceID); - - /** - * Causes this controller's output to mirror the provided leader. - * - * Only voltage output is mirrored. Settings changed on the leader do not affect - * the follower. - * - * Following anything other than a CAN SPARK MAX is not officially supported. - * - * @param leader The type of motor controller to follow (Talon SRX, Spark Max, - * etc.). - * @param deviceID The CAN ID of the device to follow. - * - * @param invert Set the follower to output opposite of the leader - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError follow(ExternalFollower leader, int deviceID, boolean invert); - - /** - * Returns whether the controller is following another controller - * - * @return True if this device is following another controller false otherwise - */ - public abstract boolean isFollower(); - - /** - * @return All fault bits as a short - */ - public abstract short getFaults(); - - /** - * @return All sticky fault bits as a short - */ - public abstract short getStickyFaults(); - - /** - * Get the value of a specific fault - * - * @param faultID The ID of the fault to retrive - * - * @return True if the fault with the given ID occurred. - */ - public abstract boolean getFault(FaultID faultID); - - /** - * Get the value of a specific sticky fault - * - * @param faultID The ID of the sticky fault to retrive - * - * @return True if the sticky fault with the given ID occurred. - */ - public abstract boolean getStickyFault(FaultID faultID); - - /** - * @return The voltage fed into the motor controller. - */ - public abstract double getBusVoltage(); - - /** - * @return The motor controller's applied output duty cycle. - */ - public abstract double getAppliedOutput(); - - /** - * @return The motor controller's output current in Amps. - */ - public abstract double getOutputCurrent(); - - /** - * @return The motor temperature in Celsius. - */ - public abstract double getMotorTemperature(); - - /** - * Clears all sticky faults. - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError clearFaults(); - - /** - * Writes all settings to flash. - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError burnFlash(); - - /** - * Sets timeout for sending CAN messages with SetParameter* and GetParameter* - * calls. These calls will block for up to this amoutn of time before returning - * a timeout erro. A timeout of 0 will make the SetParameter* calls - * non-blocking, and instead will check the response in a separate thread. With - * this configuration, any error messages will appear on the drivestration but - * will not be returned by the GetLastError() call. - * - * @param milliseconds The timeout in milliseconds. - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError setCANTimeout(int milliseconds); - - /** - * Enable soft limits - * - * @param direction the direction of motion to restrict - * - * @param enable set true to enable soft limits - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError enableSoftLimit(SoftLimitDirection direction, boolean enable); - - /** - * Set the soft limit based on position. The default unit is rotations, but will - * match the unit scaling set by the user. - * - * Note that this value is not scaled internally so care must be taken to make - * sure these units match the desired conversion - * - * @param direction the direction of motion to restrict - * - * @param limit position soft limit of the controller - * - * @return REVLibError Set to REVLibError.kOK if successful - */ - public abstract REVLibError setSoftLimit(SoftLimitDirection direction, float limit); - - /** - * Get the soft limit setting in the controller - * - * @param direction the direction of motion to restrict - * - * @return position soft limit setting of the controller - */ - public abstract double getSoftLimit(SoftLimitDirection direction); - - /** - * @param direction The direction of the motion to restrict - * - * @return true if the soft limit is enabled. - */ - public abstract boolean isSoftLimitEnabled(SoftLimitDirection direction); - - /** - * All device errors are tracked on a per thread basis for all devices in that - * thread. This is meant to be called immediately following another call that - * has the possibility of returning an error to validate if an error has - * occurred. - * - * @return the last error that was generated. - */ - public abstract REVLibError getLastError(); - - public abstract REVLibError restoreFactoryDefaults(); - - /// - // CAN Encoder Block - /// - public abstract double getPosition(); - - public abstract double getVelocity(); - - public abstract REVLibError setPosition(double position); - - public abstract REVLibError setPositionConversionFactor(double factor); - - public abstract REVLibError setVelocityConversionFactor(double factor); - - public abstract double getPositionConversionFactor(); - - public abstract double getVelocityConversionFactor(); - - public abstract REVLibError setAverageDepth(int depth); - - public abstract int getAverageDepth(); - - public abstract REVLibError setMeasurementPeriod(int period_us); - - public abstract int getMeasurementPeriod(); - - public abstract int getCountsPerRevolution(); - - public abstract REVLibError setEncoderInverted(boolean inverted); - - /// - // CAN PID Controller - /// - - public abstract REVLibError setP(double gain); - - public abstract REVLibError setP(double gain, int slotID); - - public abstract REVLibError setI(double gain); - - public abstract REVLibError setI(double gain, int slotID); - - public abstract REVLibError setD(double gain); - - public abstract REVLibError setD(double gain, int slotID); - - public abstract REVLibError setDFilter(double gain); - - public abstract REVLibError setDFilter(double gain, int slotID); - - public abstract REVLibError setFF(double gain); - - public abstract REVLibError setFF(double gain, int slotID); - - // CHECKSTYLE:OFF - public abstract REVLibError setIZone(double iZone); - - public abstract REVLibError setIZone(double iZone, int slotID); - - // CHECKSTYLE:ON - public abstract REVLibError setOutputRange(double min, double max); - - public abstract REVLibError setOutputRange(double min, double max, int slotID); - - public abstract double getP(); - - public abstract double getP(int slotID); - - public abstract double getI(); - - public abstract double getI(int slotID); - - public abstract double getD(); - - public abstract double getD(int slotID); - - public abstract double getDFilter(int slotID); - - public abstract double getFF(); - - public abstract double getFF(int slotID); - - public abstract double getIZone(); - - public abstract double getIZone(int slotID); - - public abstract double getOutputMin(); - - public abstract double getOutputMin(int slotID); - - public abstract double getOutputMax(); - - public abstract double getOutputMax(int slotID); - - public abstract REVLibError setSmartMotionMaxVelocity(double maxVel, int slotID); - - public abstract REVLibError setSmartMotionMaxAccel(double maxAccel, int slotID); - - public abstract REVLibError setSmartMotionMinOutputVelocity(double minVel, int slotID); - - public abstract REVLibError setSmartMotionAllowedClosedLoopError(double allowedErr, int slotID); - - public abstract double getSmartMotionMaxVelocity(int slotID); - - public abstract double getSmartMotionMaxAccel(int slotID); - - public abstract double getSmartMotionMinOutputVelocity(int slotID); - - public abstract double getSmartMotionAllowedClosedLoopError(int slotID); - - public abstract REVLibError setIMaxAccum(double iMaxAccum, int slotID); - - public abstract double getIMaxAccum(int slotID); - - public abstract REVLibError setIAccum(double iAccum); - - public abstract double getIAccum(); - - public abstract REVLibError setReference(double value, ControlType ctrl); - - public abstract REVLibError setReference(double value, ControlType ctrl, int pidSlot); - - public abstract REVLibError setReference(double value, ControlType ctrl, int pidSlot, double arbFeedforward); - - public abstract REVLibError setReference(double value, ControlType ctrl, int pidSlot, double arbFeedforward, - ArbFFUnits arbFFUnits); - - /// Get true value. Should not be called in competition code. - public abstract CANSparkMax getInternalSparkMax(); - - public abstract void setForwardLimitSwitch(com.revrobotics.SparkMaxLimitSwitch.Type switchType, boolean enabled); - - public abstract void setReverseLimitSwitch(com.revrobotics.SparkMaxLimitSwitch.Type switchType, boolean enabled); - - public abstract boolean getForwardLimitSwitchPressed(com.revrobotics.SparkMaxLimitSwitch.Type switchType); - - public abstract boolean getReverseLimitSwitchPressed(com.revrobotics.SparkMaxLimitSwitch.Type switchType); -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/actuators/XCANSparkMaxPIDProperties.java b/src/main/java/xbot/common/controls/actuators/XCANSparkMaxPIDProperties.java deleted file mode 100644 index 1681d413..00000000 --- a/src/main/java/xbot/common/controls/actuators/XCANSparkMaxPIDProperties.java +++ /dev/null @@ -1,33 +0,0 @@ -package xbot.common.controls.actuators; - -public class XCANSparkMaxPIDProperties { - public double p = 0; - public double i = 0; - public double d = 0; - public double iZone = 0; - public double feedForward = 0; - public double maxOutput = 1; - public double minOutput = -1; - - public XCANSparkMaxPIDProperties( - double p, - double i, - double d, - double iZone, - double feedForward, - double maxOutput, - double minOutput - ) { - this.p = p; - this.i = i; - this.d = d; - this.iZone = iZone; - this.feedForward = feedForward; - this.maxOutput = maxOutput; - this.minOutput = minOutput; - } - - public XCANSparkMaxPIDProperties() { } - - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/actuators/XCANTalon.java b/src/main/java/xbot/common/controls/actuators/XCANTalon.java deleted file mode 100644 index a790a864..00000000 --- a/src/main/java/xbot/common/controls/actuators/XCANTalon.java +++ /dev/null @@ -1,394 +0,0 @@ -package xbot.common.controls.actuators; - -import com.ctre.phoenix.ErrorCode; -import com.ctre.phoenix.ParamEnum; -import com.ctre.phoenix.motion.MotionProfileStatus; -import com.ctre.phoenix.motion.TrajectoryPoint; -import com.ctre.phoenix.motorcontrol.ControlFrame; -import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.Faults; -import com.ctre.phoenix.motorcontrol.FeedbackDevice; -import com.ctre.phoenix.motorcontrol.IMotorController; -import com.ctre.phoenix.motorcontrol.IMotorControllerEnhanced; -import com.ctre.phoenix.motorcontrol.LimitSwitchNormal; -import com.ctre.phoenix.motorcontrol.LimitSwitchSource; -import com.ctre.phoenix.motorcontrol.NeutralMode; -import com.ctre.phoenix.motorcontrol.RemoteFeedbackDevice; -import com.ctre.phoenix.motorcontrol.RemoteLimitSwitchSource; -import com.ctre.phoenix.motorcontrol.RemoteSensorSource; -import com.ctre.phoenix.motorcontrol.SensorTerm; -import com.ctre.phoenix.motorcontrol.StatusFrame; -import com.ctre.phoenix.motorcontrol.StatusFrameEnhanced; -import com.ctre.phoenix.motorcontrol.StickyFaults; -import com.ctre.phoenix.sensors.SensorVelocityMeasPeriod; - -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; -import xbot.common.injection.electrical_contract.CANTalonInfo; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; - - -public abstract class XCANTalon implements IMotorControllerEnhanced { - /* - * Functions currently omitted: - * - * - enableControl/disableControl - * - delete - * - motion control frame mode - * - "expiration" and other MotorSafety members - * - getPinStateQuad* - * - getPulseWidth* - * - setPID w/ special args - * - setParameter/getParameter - */ - - protected int deviceId; - protected PropertyFactory propMan; - - private DoubleProperty currentProperty = null; - private DoubleProperty outVoltageProperty = null; - private DoubleProperty temperatureProperty = null; - private DoubleProperty positionProperty = null; - private DoubleProperty velocityProperty = null; - - protected String policeTicket; - - public interface XCANTalonFactory { - XCANTalon create(CANTalonInfo deviceInfo); - } - - public XCANTalon(int deviceId, PropertyFactory propMan, DevicePolice police) { - this.deviceId = deviceId; - this.propMan = propMan; - policeTicket = police.registerDevice(DeviceType.CAN, deviceId, this); - } - - - - public void createTelemetryProperties(String callingSystemPrefix, String deviceName) { - // Creates nice prefixes for the SmartDashboard. - propMan.setPrefix(callingSystemPrefix + "/" + deviceName); - currentProperty = propMan.createEphemeralProperty("current", 0); - outVoltageProperty = propMan.createEphemeralProperty("voltage", 0); - temperatureProperty = propMan.createEphemeralProperty("temperature", 0); - positionProperty = propMan.createEphemeralProperty("position", 0); - velocityProperty = propMan.createEphemeralProperty("velocity", 0); - } - - public void updateTelemetryProperties() { - if(currentProperty == null - || outVoltageProperty == null - || temperatureProperty == null - || positionProperty == null - || velocityProperty == null) { - return; - } - - currentProperty.set(this.getOutputCurrent()); - outVoltageProperty.set(this.getMotorOutputVoltage()); - temperatureProperty.set(this.getTemperature()); - - positionProperty.set(this.getSelectedSensorPosition(0)); - velocityProperty.set(this.getSelectedSensorVelocity(0)); - } - /* - @Override - public int hashCode() { - return this.deviceId; - }*/ - /* - @Override - public boolean equals(Object obj) { - if (obj instanceof XCANTalon) { - // This works since our hash code IS our device ID. - return ((XCANTalon)obj).hashCode() == this.hashCode(); - } - return false; - }*/ - - // ------ Set output routines. ----------// - public abstract void set(ControlMode Mode, double demand); - - public void set(ControlMode mode, double demand1, double demand2) { - // Deliberately do nothing. - } - - public abstract void neutralOutput(); - - public abstract void setNeutralMode(NeutralMode neutralMode); - - // ------ Invert behavior ----------// - public abstract void setSensorPhase(boolean PhaseSensor); - - public abstract void setInverted(boolean invert); - - public abstract boolean getInverted(); - - // ----- general output shaping ------------------// - public abstract ErrorCode configOpenloopRamp(double secondsFromNeutralToFull, int timeoutMs); - - public abstract ErrorCode configClosedloopRamp(double secondsFromNeutralToFull, int timeoutMs); - - public abstract ErrorCode configPeakOutputForward(double percentOut, int timeoutMs); - - public abstract ErrorCode configPeakOutputReverse(double percentOut, int timeoutMs); - - public abstract ErrorCode configNominalOutputForward(double percentOut, int timeoutMs); - - public abstract ErrorCode configNominalOutputReverse(double percentOut, int timeoutMs); - - public abstract ErrorCode configNeutralDeadband(double percentDeadband, int timeoutMs); - - // ------ Voltage Compensation ----------// - public abstract ErrorCode configVoltageCompSaturation(double voltage, int timeoutMs); - - public abstract ErrorCode configVoltageMeasurementFilter(int filterWindowSamples, int timeoutMs); - - public abstract void enableVoltageCompensation(boolean enable); - - // ------ General Status ----------// - public abstract double getBusVoltage() ; - - public abstract double getMotorOutputPercent() ; - - public abstract double getMotorOutputVoltage() ; - - public abstract double getOutputCurrent() ; - - public abstract double getTemperature() ; - - // ------ sensor selection ----------// - public abstract ErrorCode configSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx, int timeoutMs); - - public abstract ErrorCode configRemoteFeedbackFilter(int deviceID, RemoteSensorSource remoteSensorSource, int remoteOrdinal, - int timeoutMs); - - public abstract ErrorCode configSensorTerm(SensorTerm sensorTerm, FeedbackDevice feedbackDevice, int timeoutMs); - - public abstract ErrorCode configSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx, int timeoutMs ); - - // ------- sensor status --------- // - public abstract double getSelectedSensorPosition(int pidIdx); - - public abstract double getSelectedSensorVelocity(int pidIdx); - - public abstract ErrorCode setSelectedSensorPosition(int sensorPos, int pidIdx, int timeoutMs); - - // ------ status frame period changes ----------// - public abstract ErrorCode setControlFramePeriod(ControlFrame frame, int periodMs); - - public abstract ErrorCode setStatusFramePeriod(StatusFrame frame, int periodMs, int timeoutMs); - public abstract ErrorCode setStatusFramePeriod(StatusFrameEnhanced frame, int periodMs, int timeoutMs ); - - public abstract int getStatusFramePeriod(StatusFrame frame, int timeoutMs); - public abstract int getStatusFramePeriod(StatusFrameEnhanced frame, int timeoutMs ); - - //----- velocity signal conditionaing ------// - public abstract ErrorCode configVelocityMeasurementPeriod(SensorVelocityMeasPeriod period, int timeoutMs ); - public abstract ErrorCode configVelocityMeasurementWindow(int windowSize, int timeoutMs ); - - //------ remote limit switch ----------// - public abstract ErrorCode configForwardLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID, int timeoutMs); - - public abstract ErrorCode configReverseLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID, int timeoutMs); - - public abstract void overrideLimitSwitchesEnable(boolean enable); - - // ------ local limit switch ----------// - public abstract ErrorCode configForwardLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int timeoutMs ); - public abstract ErrorCode configReverseLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int timeoutMs ); - - public abstract boolean isFwdLimitSwitchClosed(); - public abstract boolean isRevLimitSwitchClosed(); - - // ------ soft limit ----------// - public abstract ErrorCode configForwardSoftLimitThreshold(int forwardSensorLimit, int timeoutMs); - - public abstract ErrorCode configReverseSoftLimitThreshold(int reverseSensorLimit, int timeoutMs); - - public abstract ErrorCode configForwardSoftLimitEnable(boolean enable, int timeoutMs); - - public abstract ErrorCode configReverseSoftLimitEnable(boolean enable, int timeoutMs); - - public abstract void overrideSoftLimitsEnable(boolean enable); - - // ------ Current Lim ----------// - public abstract ErrorCode configPeakCurrentLimit(int amps, int timeoutMs ); - public abstract ErrorCode configPeakCurrentDuration(int milliseconds, int timeoutMs ); - public abstract ErrorCode configContinuousCurrentLimit(int amps, int timeoutMs ); - public abstract void enableCurrentLimit(boolean enable); - - // ------ General Close loop ----------// - public abstract ErrorCode config_kP(int slotIdx, double value, int timeoutMs); - - public abstract ErrorCode config_kI(int slotIdx, double value, int timeoutMs); - - public abstract ErrorCode config_kD(int slotIdx, double value, int timeoutMs); - - public abstract ErrorCode config_kF(int slotIdx, double value, int timeoutMs); - - public abstract ErrorCode config_IntegralZone(int slotIdx, int izone, int timeoutMs); - - public abstract ErrorCode configAllowableClosedloopError(int slotIdx, int allowableCloseLoopError, int timeoutMs); - - public abstract ErrorCode configMaxIntegralAccumulator(int slotIdx, double iaccum, int timeoutMs); - - //------ Close loop State ----------// - public abstract ErrorCode setIntegralAccumulator(double iaccum, int pidIdx, int timeoutMs); - - public abstract double getClosedLoopError(int pidIdx); - - public abstract double getIntegralAccumulator(int pidIdx) ; - - public abstract double getErrorDerivative(int pidIdx) ; - - public abstract void selectProfileSlot(int slotIdx, int pidIdx); - - //public abstract int getClosedLoopTarget(int pidIdx); // will be added to JNI - - public abstract double getActiveTrajectoryPosition(); - - public abstract double getActiveTrajectoryVelocity(); - - public abstract double getActiveTrajectoryHeading(); - - // ------ Motion Profile Settings used in Motion Magic and Motion Profile - public abstract ErrorCode configMotionCruiseVelocity(int sensorUnitsPer100ms, int timeoutMs); - - public abstract ErrorCode configMotionAcceleration(int sensorUnitsPer100msPerSec, int timeoutMs); - - // ------ Motion Profile Buffer ----------// - public abstract ErrorCode clearMotionProfileTrajectories(); - public abstract int getMotionProfileTopLevelBufferCount(); - public abstract ErrorCode pushMotionProfileTrajectory(TrajectoryPoint trajPt); - public abstract boolean isMotionProfileTopLevelBufferFull(); - public abstract void processMotionProfileBuffer(); - public abstract ErrorCode getMotionProfileStatus(MotionProfileStatus statusToFill); - public abstract ErrorCode clearMotionProfileHasUnderrun(int timeoutMs); - public abstract ErrorCode changeMotionControlFramePeriod(int periodMs); - - // ------ error ----------// - public abstract ErrorCode getLastError(); - - // ------ Faults ----------// - public abstract ErrorCode getFaults(Faults toFill) ; - - public abstract ErrorCode getStickyFaults(StickyFaults toFill) ; - - public abstract ErrorCode clearStickyFaults(int timeoutMs); - - // ------ Firmware ----------// - public abstract int getFirmwareVersion(); - - public abstract boolean hasResetOccurred(); - - // ------ Custom Persistent Params ----------// - public abstract ErrorCode configSetCustomParam(int newValue, int paramIndex, int timeoutMs); - - public abstract int configGetCustomParam(int paramIndex, int timoutMs); - - //------ Generic Param API, typically not used ----------// - public abstract ErrorCode configSetParameter(ParamEnum param, double value, int subValue, int ordinal, int timeoutMs); - public abstract ErrorCode configSetParameter(int param, double value, int subValue, int ordinal, int timeoutMs); - - public abstract double configGetParameter(ParamEnum paramEnum, int ordinal, int timeoutMs) ; - public abstract double configGetParameter(int paramEnum, int ordinal, int timeoutMs) ; - - //------ Misc. ----------// - public abstract int getBaseID(); - public abstract int getDeviceID(); - - // ----- Follower ------// - public abstract void follow(IMotorController masterToFollow); - public abstract void valueUpdated(); - - public void simpleSet(double percentInput) { - set(ControlMode.PercentOutput, percentInput); - } - - public void stopMotor() { - neutralOutput(); - } - - /*** - * Convenience function to rapidly configure two CANTalons to work in tandem; often used for drive motors. - * @param prefix Prefix for network tables; typically, fill this with getPrefix() if calling this from a Subsystem or Command. - * @param masterName Motor name for network tables - * @param master Talon that will control overall operations - * @param follower Talon that will follow the master - * @param masterInverted Should the master be inverted? - * @param followerInverted Should the follower be inverted RELATIVE TO THE MASTER? - * @param sensorPhase Is the encoder in phase with the master? - */ - public static void configureMotorTeam(String prefix, String masterName, XCANTalon master, XCANTalon follower, boolean masterInverted, - boolean followerInverted, boolean sensorPhase) { - master.configureAsMasterMotor(prefix, masterName, masterInverted, sensorPhase); - follower.configureAsFollowerMotor(master, followerInverted); - } - - public static void configureMotorTeam(String prefix, String masterName, XCANTalon master, XCANTalon follower1, XCANTalon follower2, boolean masterInverted, - boolean follower1Inverted, boolean follower2Inverted, boolean sensorPhase) { - master.configureAsMasterMotor(prefix, masterName, masterInverted, sensorPhase); - follower1.configureAsFollowerMotor(master, follower1Inverted); - follower2.configureAsFollowerMotor(master, follower2Inverted); - } - - public static void configureMotorTeam(String prefix, String masterName, XCANTalon master, XCANTalon follower1, XCANTalon follower2, XCANTalon follower3, boolean masterInverted, - boolean follower1Inverted, boolean follower2Inverted, boolean follower3Inverted, boolean sensorPhase) { - master.configureAsMasterMotor(prefix, masterName, masterInverted, sensorPhase); - follower1.configureAsFollowerMotor(master, follower1Inverted); - follower2.configureAsFollowerMotor(master, follower2Inverted); - follower3.configureAsFollowerMotor(master, follower3Inverted); - } - - /** - * Convenience function to rapidly configure a CANTalon as a Master motor. Uses some typical configurations that can be - * overriden later (for example, it sets typical maximum/minimum output values to 1 and -1) - * @param prefix Prefix for network tables; typically, fill this with getPrefix() if calling this from a Subsystem or Command. - * @param masterName Motor name for network tables - * @param masterInverted Should the master be inverted? - * @param sensorPhase Is the encoder in phase with the master? - */ - public void configureAsMasterMotor(String prefix, String masterName, boolean masterInverted, boolean sensorPhase) { - this.setInverted(masterInverted); - this.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative, 0, 0); - this.setSensorPhase(sensorPhase); - this.createTelemetryProperties(prefix, masterName); - - this.setNeutralMode(NeutralMode.Coast); - this.configForwardLimitSwitchSource(LimitSwitchSource.Deactivated, LimitSwitchNormal.Disabled, 0); - this.configReverseLimitSwitchSource(LimitSwitchSource.Deactivated, LimitSwitchNormal.Disabled, 0); - - this.configPeakOutputForward(1, 0); - this.configPeakOutputReverse(-1, 0); - - this.configForwardSoftLimitEnable(false, 0); - this.configReverseSoftLimitEnable(false, 0); - } - - /** - * Convenience function to rapidly configure a XCANTalon to follow another XCANTalon. Uses some typical configurations that can be - * overriden later (for example, it sets typical maximum/minimum output values to 1 and -1) - * @param master The master XCANTalon that this should follow - * @param followerInverted Should the follower be inverted RELATIVE TO THE MASTER? - */ - public void configureAsFollowerMotor(XCANTalon master, boolean followerInverted) { - this.follow(master); - this.setInverted(followerInverted); - - this.setNeutralMode(NeutralMode.Coast); - this.configPeakOutputForward(1, 0); - this.configPeakOutputReverse(-1, 0); - - this.configForwardLimitSwitchSource(LimitSwitchSource.Deactivated, LimitSwitchNormal.Disabled, 0); - this.configReverseLimitSwitchSource(LimitSwitchSource.Deactivated, LimitSwitchNormal.Disabled, 0); - - this.configForwardSoftLimitEnable(false, 0); - this.configReverseSoftLimitEnable(false, 0); - } - - public abstract int getPulseWidthRiseToFallUs(); -} diff --git a/src/main/java/xbot/common/controls/actuators/XCANVictorSPX.java b/src/main/java/xbot/common/controls/actuators/XCANVictorSPX.java deleted file mode 100644 index 9a727960..00000000 --- a/src/main/java/xbot/common/controls/actuators/XCANVictorSPX.java +++ /dev/null @@ -1,17 +0,0 @@ -package xbot.common.controls.actuators; - -import xbot.common.injection.DevicePolice; -import xbot.common.properties.PropertyFactory; - -public abstract class XCANVictorSPX extends XCANTalon { - - public interface XCANVictorSPXFactory { - XCANVictorSPX create(int deviceId); - } - - public XCANVictorSPX(int deviceId, PropertyFactory propMan, DevicePolice police) { - super(deviceId, propMan, police); - this.deviceId = deviceId; - this.propMan = propMan; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/actuators/XCompressor.java b/src/main/java/xbot/common/controls/actuators/XCompressor.java deleted file mode 100644 index d842289b..00000000 --- a/src/main/java/xbot/common/controls/actuators/XCompressor.java +++ /dev/null @@ -1,12 +0,0 @@ -package xbot.common.controls.actuators; - -public abstract class XCompressor { - - public interface XCompressorFactory { - XCompressor create(); - } - - public abstract void disable(); - public abstract void enable(); - public abstract boolean isEnabled(); -} diff --git a/src/main/java/xbot/common/controls/actuators/XDigitalOutput.java b/src/main/java/xbot/common/controls/actuators/XDigitalOutput.java deleted file mode 100644 index 19b33dac..00000000 --- a/src/main/java/xbot/common/controls/actuators/XDigitalOutput.java +++ /dev/null @@ -1,35 +0,0 @@ -package xbot.common.controls.actuators; - -import xbot.common.controls.XBaseIO; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; - -public abstract class XDigitalOutput implements XBaseIO { - - protected int channel; - - public interface XDigitalOutputFactory { - XDigitalOutput create(int channel); - } - - protected XDigitalOutput(int channel, DevicePolice police) { - this.channel = channel; - police.registerDevice(DeviceType.DigitalIO, channel, this); - } - - public int getChannel() { - return channel; - } - - public abstract void set(boolean value); - - /** - * Set the PWM frequency of ALL DIGITAL OUTPUT PWM CHANNELS - * @param frequency PWM frequency - */ - public abstract void setPWMRate(double frequency); - public abstract void enablePWM(double initialDutyCycle); - public abstract void updateDutyCycle(double dutyCycle); - public abstract void disablePWM(); - public abstract boolean get(); -} diff --git a/src/main/java/xbot/common/controls/actuators/XDoubleSolenoid.java b/src/main/java/xbot/common/controls/actuators/XDoubleSolenoid.java deleted file mode 100644 index 6182c3bf..00000000 --- a/src/main/java/xbot/common/controls/actuators/XDoubleSolenoid.java +++ /dev/null @@ -1,116 +0,0 @@ -package xbot.common.controls.actuators; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -public class XDoubleSolenoid { - - protected boolean isInverted = false; - public XSolenoid forwardSolenoid; - public XSolenoid reverseSolenoid; - - @AssistedFactory - public abstract static class XDoubleSolenoidFactory { - public abstract XDoubleSolenoid create( - @Assisted("forwardSolenoid") XSolenoid forwardSolenoid, - @Assisted("reverseSolenoid") XSolenoid reverseSolenoid); - } - - @AssistedInject - public XDoubleSolenoid(@Assisted("forwardSolenoid") XSolenoid forwardSolenoid, @Assisted("reverseSolenoid") XSolenoid reverseSolenoid) { - this.forwardSolenoid = forwardSolenoid; - this.reverseSolenoid = reverseSolenoid; - } - - public void setInverted(boolean isInverted) { - this.isInverted = isInverted; - } - - public enum DoubleSolenoidMode { - OFF, - FORWARD, - REVERSE - } - - public void setDoubleSolenoid(DoubleSolenoidMode mode) { - if (mode == DoubleSolenoidMode.FORWARD && isInverted) - { - mode = DoubleSolenoidMode.REVERSE; - } - else if (mode == DoubleSolenoidMode.REVERSE && isInverted) - { - mode = DoubleSolenoidMode.FORWARD; - } - - switch (mode) { - - case FORWARD: - setForwardInternal(); - break; - case REVERSE: - setReverseInternal(); - break; - default: - setOffInternal(); - break; - } - } - - public DoubleSolenoidMode getDoubleSolenoidMode() { - DoubleSolenoidMode modeCandidate = DoubleSolenoidMode.OFF; - - if(forwardSolenoid.getAdjusted()) { - modeCandidate = DoubleSolenoidMode.FORWARD; - } else if(reverseSolenoid.getAdjusted()) { - modeCandidate = DoubleSolenoidMode.REVERSE; - } - - if (isInverted && modeCandidate == DoubleSolenoidMode.FORWARD) { - modeCandidate = DoubleSolenoidMode.REVERSE; - } else if (isInverted && modeCandidate == DoubleSolenoidMode.REVERSE) { - modeCandidate = DoubleSolenoidMode.FORWARD; - } - - return modeCandidate; - } - - public boolean getIsForward() { - return getDoubleSolenoidMode() == DoubleSolenoidMode.FORWARD; - } - - public boolean getIsReverse() { - return getDoubleSolenoidMode() == DoubleSolenoidMode.REVERSE; - } - - public boolean getIsOff() { - return getDoubleSolenoidMode() == DoubleSolenoidMode.OFF; - } - - public void setOff() { - setDoubleSolenoid(DoubleSolenoidMode.OFF); - } - - public void setForward() { - setDoubleSolenoid(DoubleSolenoidMode.FORWARD); - } - - public void setReverse() { - setDoubleSolenoid(DoubleSolenoidMode.REVERSE); - } - - private void setOffInternal() { - forwardSolenoid.setOn(false); - reverseSolenoid.setOn(false); - } - - private void setForwardInternal() { - forwardSolenoid.setOn(true); - reverseSolenoid.setOn(false); - } - - private void setReverseInternal() { - forwardSolenoid.setOn(false); - reverseSolenoid.setOn(true); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/actuators/XPWM.java b/src/main/java/xbot/common/controls/actuators/XPWM.java deleted file mode 100644 index 9cf3eec9..00000000 --- a/src/main/java/xbot/common/controls/actuators/XPWM.java +++ /dev/null @@ -1,44 +0,0 @@ -package xbot.common.controls.actuators; - -import xbot.common.controls.XBaseIO; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; - -public abstract class XPWM implements XBaseIO -{ - protected int channel; - - public interface XPWMFactory { - XPWM create(int channel); - } - - protected XPWM(int channel, DevicePolice police) { - this.channel = channel; - police.registerDevice(DeviceType.PWM, channel, this); - } - - public int getChannel() { - return channel; - } - - /** - * Sets the PWM duty cycle - * @param value the value to set, in the range [0, 255] - */ - public abstract void setRaw(int value); - public abstract int getRaw(); - - /** - * Sets the PWM duty cycle - * @param value the value to set, in the range [-1, 1] - */ - public abstract void setSigned(double value); - public abstract double getSigned(); - - /** - * Sets the PWM duty cycle - * @param value the value to set, in the range [0, 1] - */ - public abstract void setUnsigned(double value); - public abstract double getUnsigned(); -} diff --git a/src/main/java/xbot/common/controls/actuators/XRelay.java b/src/main/java/xbot/common/controls/actuators/XRelay.java deleted file mode 100644 index 09144d3d..00000000 --- a/src/main/java/xbot/common/controls/actuators/XRelay.java +++ /dev/null @@ -1,48 +0,0 @@ -package xbot.common.controls.actuators; - -import edu.wpi.first.wpilibj.Relay.Value; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; - -public abstract class XRelay { - - protected int channel; - protected boolean inverted; - - public interface XRelayFactory { - XRelay create(int channel); - } - - protected XRelay(int channel, DevicePolice police) { - this.channel = channel; - police.registerDevice(DeviceType.PWM, channel, this); - } - - public void setForward() { - Value valueToSet = Value.kForward; - if (inverted) { - valueToSet = Value.kReverse; - } - - set(valueToSet); - } - - public void setReverse() { - Value valueToSet = Value.kReverse; - if (inverted) { - valueToSet = Value.kForward; - } - - set(valueToSet); - } - - public void stop() { - set(Value.kOff); - } - - public void setInverted(boolean inverted) { - this.inverted = inverted; - } - - public abstract void set(Value value); -} diff --git a/src/main/java/xbot/common/controls/actuators/XServo.java b/src/main/java/xbot/common/controls/actuators/XServo.java deleted file mode 100644 index 198d1c54..00000000 --- a/src/main/java/xbot/common/controls/actuators/XServo.java +++ /dev/null @@ -1,25 +0,0 @@ -package xbot.common.controls.actuators; - -import xbot.common.controls.XBaseIO; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; - -public abstract class XServo implements XBaseIO { - - protected int channel; - - public interface XServoFactory { - XServo create(int channel); - } - - protected XServo(int channel, DevicePolice police) { - this.channel = channel; - police.registerDevice(DeviceType.PWM, channel, this); - } - - public int getChannel() { - return channel; - } - - public abstract void set(double value); -} diff --git a/src/main/java/xbot/common/controls/actuators/XSolenoid.java b/src/main/java/xbot/common/controls/actuators/XSolenoid.java deleted file mode 100644 index aa0ef93b..00000000 --- a/src/main/java/xbot/common/controls/actuators/XSolenoid.java +++ /dev/null @@ -1,40 +0,0 @@ -package xbot.common.controls.actuators; - -import xbot.common.controls.XBaseIO; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; - -public abstract class XSolenoid implements XBaseIO { - - protected boolean isInverted = false; - protected final int channel; - - public interface XSolenoidFactory { - XSolenoid create(int channel); - } - - protected XSolenoid(int channel, DevicePolice police) { - this.channel = channel; - police.registerDevice(DeviceType.Solenoid, this.channel, 0, getMaxSupportedChannel()); - } - - public void setOn(boolean on) { - set(on ^ isInverted); - } - - public boolean getAdjusted() { - return get() ^ isInverted; - } - - public void setInverted(boolean isInverted) { - this.isInverted = isInverted; - } - - public int getChannel() { - return channel; - } - - protected abstract void set(boolean on); - protected abstract boolean get(); - protected abstract int getMaxSupportedChannel(); -} diff --git a/src/main/java/xbot/common/controls/actuators/XSpeedController.java b/src/main/java/xbot/common/controls/actuators/XSpeedController.java deleted file mode 100644 index 7c0fefe8..00000000 --- a/src/main/java/xbot/common/controls/actuators/XSpeedController.java +++ /dev/null @@ -1,42 +0,0 @@ -package xbot.common.controls.actuators; - -import xbot.common.controls.XBaseIO; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; - -public abstract class XSpeedController implements XBaseIO -{ - protected int channel; - protected boolean isInverted; - - public interface XSpeedControllerFactory { - XSpeedController create(int channel); - } - - public XSpeedController(int channel, DevicePolice police) { - this.channel = channel; - police.registerDevice(DeviceType.PWM, channel, this); - } - - public int getChannel() { - return channel; - } - - public boolean getInverted() { - return isInverted; - } - public void setInverted(boolean isInverted) { - this.isInverted = isInverted; - } - - public void setPower(double power) { - set(power * (isInverted ? -1 : 1)); - } - - public double getPower() { - return get() * (isInverted ? -1 : 1); - } - - protected abstract double get(); - protected abstract void set(double value); -} diff --git a/src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANSparkMax.java b/src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANSparkMax.java deleted file mode 100644 index 5d845a7f..00000000 --- a/src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANSparkMax.java +++ /dev/null @@ -1,674 +0,0 @@ -package xbot.common.controls.actuators.mock_adapters; - -import java.math.BigDecimal; - -import com.revrobotics.CANSparkMax; -import com.revrobotics.CANSparkMax.ControlType; -import com.revrobotics.CANSparkMax.ExternalFollower; -import com.revrobotics.CANSparkMax.FaultID; -import com.revrobotics.CANSparkMax.IdleMode; -import com.revrobotics.CANSparkMax.SoftLimitDirection; -import com.revrobotics.REVLibError; -import com.revrobotics.SparkMaxLimitSwitch.Type; -import com.revrobotics.SparkMaxPIDController.ArbFFUnits; - -import org.apache.log4j.Logger; -import org.json.JSONObject; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import xbot.common.controls.actuators.XCANSparkMax; -import xbot.common.controls.actuators.XCANSparkMaxPIDProperties; -import xbot.common.controls.sensors.XEncoder; -import xbot.common.controls.sensors.mock_adapters.MockEncoder; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.electrical_contract.DeviceInfo; -import xbot.common.properties.PropertyFactory; -import xbot.common.simulation.ISimulatableMotor; -import xbot.common.simulation.ISimulatableSensor; - -public class MockCANSparkMax extends XCANSparkMax implements ISimulatableMotor, ISimulatableSensor { - private static Logger log = Logger.getLogger(MockCANSparkMax.class); - private double power = 0; - private double velocity = 0; - private double simulationScalingValue; - boolean inverted = false; - public XEncoder internalEncoder = null; - double positionOffset = 0; - double simulationPosition = 0; - - // PID parameters - double kP = 0; - double kI = 0; - double kD = 0; - double kFF = 0; - double kMinOutput = -1.0; - double kMaxOutput = 1.0; - double referenceValue = 0; - ControlType controlType = null; - - @AssistedFactory - public abstract static class MockCANSparkMaxFactory extends XCANSparkMaxFactory { - public abstract MockCANSparkMax create( - @Assisted("deviceInfo") DeviceInfo deviceInfo, - @Assisted("owningSystemPrefix") String owningSystemPrefix, - @Assisted("name") String name, - @Assisted("defaultPIDProperties") XCANSparkMaxPIDProperties defaultPIDProperties); - } - - @AssistedInject - public MockCANSparkMax(@Assisted("deviceInfo") DeviceInfo deviceInfo, - @Assisted("owningSystemPrefix") String owningSystemPrefix, @Assisted("name") String name, - PropertyFactory propMan, DevicePolice police, - @Assisted("defaultPIDProperties") XCANSparkMaxPIDProperties defaultPIDProperties) { - super(deviceInfo, owningSystemPrefix, name, propMan, police, defaultPIDProperties); - log.info("Creating CAN talon with device ID: " + deviceId); - internalEncoder = new MockEncoder("Test", propMan); - setInverted(deviceInfo.inverted); - - this.simulationScalingValue = deviceInfo.simulationScalingValue; - double simulationScalingFloor = 0.00001; - if (Math.abs(simulationScalingValue) < simulationScalingFloor) { - log.error("Your scaling value was suspiciously low. Are you sure it should be smaller than " - + simulationScalingFloor + "?"); - } - } - - protected double inversionFactor() { - return this.getInverted() ? -1 : 1; - } - - @Override - public void set(double speed) { - clearPid(); - power = speed; - } - - @Override - public void setVoltage(double outputVolts) { - clearPid(); - power = outputVolts / 12; - } - - @Override - public double get() { - return power; - } - - @Override - public void setInverted(boolean isInverted) { - inverted = isInverted; - } - - @Override - public boolean getInverted() { - return inverted; - } - - @Override - public void disable() { - clearPid(); - power = 0; - } - - @Override - public void stopMotor() { - clearPid(); - power = 0; - } - - @Override - public REVLibError setSmartCurrentLimit(int limit) { - return REVLibError.kOk; - } - - @Override - public REVLibError setSmartCurrentLimit(int stallLimit, int freeLimit) { - return REVLibError.kOk; - } - - @Override - public REVLibError setSmartCurrentLimit(int stallLimit, int freeLimit, int limitRPM) { - return REVLibError.kOk; - } - - @Override - public REVLibError setSecondaryCurrentLimit(double limit) { - return REVLibError.kOk; - } - - @Override - public REVLibError setSecondaryCurrentLimit(double limit, int chopCycles) { - return REVLibError.kOk; - } - - @Override - public REVLibError setIdleMode(IdleMode mode) { - return REVLibError.kOk; - } - - @Override - public IdleMode getIdleMode() { - return null; - } - - @Override - public REVLibError enableVoltageCompensation(double nominalVoltage) { - return REVLibError.kOk; - } - - @Override - public REVLibError disableVoltageCompensation() { - return REVLibError.kOk; - } - - @Override - public double getVoltageCompensationNominalVoltage() { - return 0; - } - - @Override - public REVLibError setOpenLoopRampRate(double rate) { - return REVLibError.kOk; - } - - @Override - public REVLibError setClosedLoopRampRate(double rate) { - return REVLibError.kOk; - } - - @Override - public double getOpenLoopRampRate() { - return 0; - } - - @Override - public double getClosedLoopRampRate() { - return 0; - } - - @Override - public REVLibError follow(XCANSparkMax leader) { - return REVLibError.kOk; - } - - @Override - public REVLibError follow(XCANSparkMax leader, boolean invert) { - return REVLibError.kOk; - } - - @Override - public REVLibError follow(ExternalFollower leader, int deviceID) { - return REVLibError.kOk; - } - - @Override - public REVLibError follow(ExternalFollower leader, int deviceID, boolean invert) { - return REVLibError.kOk; - } - - @Override - public boolean isFollower() { - return false; - } - - @Override - public short getFaults() { - return 0; - } - - @Override - public short getStickyFaults() { - return 0; - } - - @Override - public boolean getFault(FaultID faultID) { - return false; - } - - @Override - public boolean getStickyFault(FaultID faultID) { - return false; - } - - @Override - public double getBusVoltage() { - return 0; - } - - @Override - public double getAppliedOutput() { - return 0; - } - - @Override - public double getOutputCurrent() { - return 0; - } - - @Override - public double getMotorTemperature() { - return 0; - } - - @Override - public REVLibError clearFaults() { - return REVLibError.kOk; - } - - @Override - public REVLibError burnFlash() { - return REVLibError.kOk; - } - - @Override - public REVLibError setCANTimeout(int milliseconds) { - return REVLibError.kOk; - } - - @Override - public REVLibError enableSoftLimit(SoftLimitDirection direction, boolean enable) { - return REVLibError.kOk; - } - - @Override - public REVLibError setSoftLimit(SoftLimitDirection direction, float limit) { - return REVLibError.kOk; - } - - @Override - public double getSoftLimit(SoftLimitDirection direction) { - return 0; - } - - @Override - public boolean isSoftLimitEnabled(SoftLimitDirection direction) { - return false; - } - - @Override - public REVLibError getLastError() { - return REVLibError.kOk; - } - - @Override - public double getPosition() { - return positionOffset + simulationPosition; - } - - @Override - public double getVelocity() { - return velocity; - } - - @Override - public REVLibError setPosition(double position) { - this.positionOffset = position - simulationPosition; - return REVLibError.kOk; - } - - @Override - public REVLibError setPositionConversionFactor(double factor) { - return REVLibError.kOk; - } - - @Override - public REVLibError setVelocityConversionFactor(double factor) { - return REVLibError.kOk; - } - - @Override - public double getPositionConversionFactor() { - return 0; - } - - @Override - public double getVelocityConversionFactor() { - return 0; - } - - @Override - public REVLibError setAverageDepth(int depth) { - return REVLibError.kOk; - } - - @Override - public int getAverageDepth() { - return 0; - } - - @Override - public REVLibError setMeasurementPeriod(int period_us) { - return REVLibError.kOk; - } - - @Override - public int getMeasurementPeriod() { - return 0; - } - - @Override - public int getCountsPerRevolution() { - return 0; - } - - @Override - public REVLibError setEncoderInverted(boolean inverted) { - return REVLibError.kOk; - } - - @Override - public REVLibError setP(double gain) { - kP = gain; - return REVLibError.kOk; - } - - @Override - public REVLibError setP(double gain, int slotID) { - kP = gain; - return REVLibError.kOk; - } - - @Override - public REVLibError setI(double gain) { - kI = gain; - return REVLibError.kOk; - } - - @Override - public REVLibError setI(double gain, int slotID) { - kI = gain; - return REVLibError.kOk; - } - - @Override - public REVLibError setD(double gain) { - kD = gain; - return REVLibError.kOk; - } - - @Override - public REVLibError setD(double gain, int slotID) { - kD = gain; - return REVLibError.kOk; - } - - @Override - public REVLibError setDFilter(double gain) { - return REVLibError.kOk; - } - - @Override - public REVLibError setDFilter(double gain, int slotID) { - return REVLibError.kOk; - } - - @Override - public REVLibError setFF(double gain) { - kFF = gain; - return REVLibError.kOk; - } - - @Override - public REVLibError setFF(double gain, int slotID) { - kFF = gain; - return REVLibError.kOk; - } - - //CHECKSTYLE:OFF - @Override - public REVLibError setIZone(double IZone) { - return REVLibError.kOk; - } - - @Override - public REVLibError setIZone(double IZone, int slotID) { - return REVLibError.kOk; - } - //CHECKSTYLE:ON - - @Override - public REVLibError setOutputRange(double min, double max) { - kMinOutput = min; - kMaxOutput = max; - return REVLibError.kOk; - } - - @Override - public REVLibError setOutputRange(double min, double max, int slotID) { - kMinOutput = min; - kMaxOutput = max; - return REVLibError.kOk; - } - - @Override - public double getP() { - return kP; - } - - @Override - public double getP(int slotID) { - return kP; - } - - @Override - public double getI() { - return kI; - } - - @Override - public double getI(int slotID) { - return kI; - } - - @Override - public double getD() { - return kD; - } - - @Override - public double getD(int slotID) { - return kD; - } - - @Override - public double getDFilter(int slotID) { - return 0; - } - - @Override - public double getFF() { - return kFF; - } - - @Override - public double getFF(int slotID) { - return kFF; - } - - @Override - public double getIZone() { - return 0; - } - - @Override - public double getIZone(int slotID) { - return 0; - } - - @Override - public double getOutputMin() { - return kMinOutput; - } - - @Override - public double getOutputMin(int slotID) { - return kMinOutput; - } - - @Override - public double getOutputMax() { - return kMaxOutput; - } - - @Override - public double getOutputMax(int slotID) { - return kMaxOutput; - } - - @Override - public REVLibError setSmartMotionMaxVelocity(double maxVel, int slotID) { - return REVLibError.kOk; - } - - @Override - public REVLibError setSmartMotionMaxAccel(double maxAccel, int slotID) { - return REVLibError.kOk; - } - - @Override - public REVLibError setSmartMotionMinOutputVelocity(double minVel, int slotID) { - return REVLibError.kOk; - } - - @Override - public REVLibError setSmartMotionAllowedClosedLoopError(double allowedErr, int slotID) { - return REVLibError.kOk; - } - - @Override - public double getSmartMotionMaxVelocity(int slotID) { - return 0; - } - - @Override - public double getSmartMotionMaxAccel(int slotID) { - return 0; - } - - @Override - public double getSmartMotionMinOutputVelocity(int slotID) { - return 0; - } - - @Override - public double getSmartMotionAllowedClosedLoopError(int slotID) { - return 0; - } - - @Override - public REVLibError setIMaxAccum(double iMaxAccum, int slotID) { - return REVLibError.kOk; - } - - @Override - public double getIMaxAccum(int slotID) { - return 0; - } - - @Override - public REVLibError setIAccum(double iAccum) { - return REVLibError.kOk; - } - - @Override - public double getIAccum() { - return 0; - } - - @Override - public REVLibError restoreFactoryDefaults() { - return REVLibError.kOk; - } - - @Override - public CANSparkMax getInternalSparkMax() { - return null; - } - - @Override - public REVLibError setReference(double value, ControlType ctrl) { - referenceValue = value - positionOffset; - controlType = ctrl; - return REVLibError.kOk; - } - - @Override - public REVLibError setReference(double value, ControlType ctrl, int pidSlot) { - referenceValue = value - positionOffset; - controlType = ctrl; - return REVLibError.kOk; - } - - @Override - public REVLibError setReference(double value, ControlType ctrl, int pidSlot, double arbFeedforward) { - referenceValue = value - positionOffset; - controlType = ctrl; - return REVLibError.kOk; - } - - @Override - public REVLibError setReference(double value, ControlType ctrl, int pidSlot, double arbFeedforward, - ArbFFUnits arbFFUnits) { - referenceValue = value - positionOffset; - controlType = ctrl; - return REVLibError.kOk; - } - - public double getReference() { - return referenceValue + positionOffset; - } - - public ControlType getControlType() { - return controlType; - } - - public void setVelocity(double velocity) { - this.velocity = velocity; - } - - private void clearPid() { - referenceValue = 0; - controlType = null; - } - - @Override - public JSONObject getSimulationData() { - JSONObject motorObject; - - if (controlType == ControlType.kPosition) { - motorObject = buildMotorObject(policeTicket, (float)(referenceValue / simulationScalingValue * inversionFactor())); - motorObject.put("mode", "POSITION"); - } else { - motorObject = buildMotorObject(policeTicket, (float)(get() * inversionFactor())); - } - - return motorObject; - } - - @Override - public void ingestSimulationData(JSONObject payload) { - BigDecimal intermediate = (BigDecimal) payload.get("EncoderTicks"); - simulationPosition = (intermediate.doubleValue() * simulationScalingValue * inversionFactor()); - } - - @Override - public void setForwardLimitSwitch(Type switchType, boolean enabled) { - } - - @Override - public void setReverseLimitSwitch(Type switchType, boolean enabled) { - } - - @Override - public boolean getForwardLimitSwitchPressed(Type switchType) { - return false; - } - - @Override - public boolean getReverseLimitSwitchPressed(Type switchType) { - return false; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANTalon.java b/src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANTalon.java deleted file mode 100644 index 3a70238f..00000000 --- a/src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANTalon.java +++ /dev/null @@ -1,891 +0,0 @@ -package xbot.common.controls.actuators.mock_adapters; - -import java.math.BigDecimal; - -import com.ctre.phoenix.ErrorCode; -import com.ctre.phoenix.ParamEnum; -import com.ctre.phoenix.motion.MotionProfileStatus; -import com.ctre.phoenix.motion.TrajectoryPoint; -import com.ctre.phoenix.motorcontrol.ControlFrame; -import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.DemandType; -import com.ctre.phoenix.motorcontrol.Faults; -import com.ctre.phoenix.motorcontrol.FeedbackDevice; -import com.ctre.phoenix.motorcontrol.IMotorController; -import com.ctre.phoenix.motorcontrol.InvertType; -import com.ctre.phoenix.motorcontrol.LimitSwitchNormal; -import com.ctre.phoenix.motorcontrol.LimitSwitchSource; -import com.ctre.phoenix.motorcontrol.NeutralMode; -import com.ctre.phoenix.motorcontrol.RemoteFeedbackDevice; -import com.ctre.phoenix.motorcontrol.RemoteLimitSwitchSource; -import com.ctre.phoenix.motorcontrol.RemoteSensorSource; -import com.ctre.phoenix.motorcontrol.SensorTerm; -import com.ctre.phoenix.motorcontrol.StatusFrame; -import com.ctre.phoenix.motorcontrol.StatusFrameEnhanced; -import com.ctre.phoenix.motorcontrol.StickyFaults; -import com.ctre.phoenix.motorcontrol.SupplyCurrentLimitConfiguration; -import com.ctre.phoenix.motorcontrol.can.BaseTalon; -import com.ctre.phoenix.sensors.CANCoder; -import com.ctre.phoenix.sensors.SensorVelocityMeasPeriod; - -import org.apache.log4j.Logger; -import org.json.JSONObject; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.controls.sensors.XEncoder; -import xbot.common.controls.sensors.mock_adapters.MockEncoder; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.electrical_contract.CANTalonInfo; -import xbot.common.logging.RobotAssertionManager; -import xbot.common.math.MathUtils; -import xbot.common.properties.PropertyFactory; -import xbot.common.simulation.ISimulatableMotor; -import xbot.common.simulation.ISimulatableSensor; - -public class MockCANTalon extends XCANTalon implements ISimulatableSensor, ISimulatableMotor { - - private static Logger log = Logger.getLogger(MockCANTalon.class); - - private int pulseWidthRiseToFallUs = 0; - - public final int deviceId; - private double setpoint = 0; - private double throttlePercent = 0; - public XEncoder internalEncoder = null; - double current = 0; - int continuousCurrentLimit = 1000; - double openLoopRamp = 0; - - private boolean forwardLimitSwitch; - private boolean reverseLimitSwitch; - - double kp; - double ki; - double kd; - double kf; - - private MockCANTalon master; - private RobotAssertionManager assertionManager; - - private double simulationScalingValue; - - private boolean inverted; - private boolean sensorPhaseInverted; - - @AssistedFactory - public abstract static class MockCANTalonFactory implements XCANTalonFactory { - public abstract MockCANTalon create(@Assisted("deviceInfo") CANTalonInfo deviceInfo); - } - - @AssistedInject - public MockCANTalon(@Assisted("deviceInfo") CANTalonInfo deviceInfo, PropertyFactory propMan, DevicePolice police, - RobotAssertionManager assertionManager) { - super(deviceInfo.channel, propMan, police); - log.info("Creating CAN talon with device ID: " + deviceInfo.channel); - - this.deviceId = deviceInfo.channel; - this.assertionManager = assertionManager; - this.simulationScalingValue = deviceInfo.simulationScalingValue; - double simulationScalingFloor = 0.00001; - if (Math.abs(simulationScalingValue) < simulationScalingFloor) { - log.error("Your scaling value was suspiciously low. Are you sure it should be smaller than " - + simulationScalingFloor + "?"); - } - - setInverted(deviceInfo.inverted); - if (deviceInfo.feedbackDevice != null) { - configSelectedFeedbackSensor(deviceInfo.feedbackDevice, 0, 0); - setSensorPhase(deviceInfo.feedbackDeviceInverted); - } - } - - @Override - public void set(ControlMode Mode, double demand) { - set(Mode, demand, 0); - } - - public double getSetpoint() { - return setpoint; - } - - @Override - public void set(ControlMode Mode, double demand0, double demand1) { - - this.setpoint = demand0 * (this.getInverted() ? -1 : 1); - - switch (Mode) { - case Disabled: - throttlePercent = 0; - break; - case PercentOutput: - throttlePercent = setpoint; - throttlePercent = MathUtils.constrainDoubleToRobotScale(throttlePercent); - break; - case Current: - // Guess voltage by assuming a linear relationship between current and voltage, - // bypassing PID - throttlePercent = setpoint / 40.0; - break; - case MotionProfile: - // This mode isn't supported in by the mock implementation (nor the real one) - throttlePercent = 0; - break; - case Velocity: - double rate = internalEncoder.getAdjustedRate(); - if (setpoint > rate) { - throttlePercent = 1; - } - if (setpoint < rate) { - throttlePercent = -1; - } - break; - case Position: - if (!Double.isFinite(this.kp)) { - throttlePercent = 0; - } else { - // Highly efficient P(IDF) implementation - throttlePercent = (this.setpoint - getPosition()) * this.kp; - } - break; - case Follower: - throttlePercent = master.getMotorOutputPercent(); - break; - default: - throttlePercent = 0; - } - } - - /** - * Returns the low-level throttle percentage that would typically be sent to a motor. - * For example, if a motor is configured as Inverted, and it was set to a value of 0.75: - * getThrottlePercent (this method) would return -0.75 - * getMotorOutputPercent would return 0.75 - * As such, this is the method you would want to hook into consumers like a simulator, so that - * changing inversion would affect them. - * @return Motor throttle percentage (potentially inverted) - */ - public double getThrottlePercent() { - if (master == null) { - return this.throttlePercent; - } else { - return this.master.getThrottlePercent(); - } - } - - @Override - public void neutralOutput() { - - } - - @Override - public void setNeutralMode(NeutralMode neutralMode) { - - } - - @Override - public void setSensorPhase(boolean PhaseSensor) { - this.sensorPhaseInverted = PhaseSensor; - } - - @Override - public void setInverted(boolean invert) { - this.inverted = invert; - } - - @Override - public boolean getInverted() { - return this.inverted; - } - - @Override - public ErrorCode configOpenloopRamp(double secondsFromNeutralToFull, int timeoutMs) { - openLoopRamp = secondsFromNeutralToFull; - return null; - } - - public double getOpenLoopRamp() { - return openLoopRamp; - } - - @Override - public ErrorCode configClosedloopRamp(double secondsFromNeutralToFull, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configPeakOutputForward(double percentOut, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configPeakOutputReverse(double percentOut, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configNominalOutputForward(double percentOut, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configNominalOutputReverse(double percentOut, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configNeutralDeadband(double percentDeadband, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configVoltageCompSaturation(double voltage, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configVoltageMeasurementFilter(int filterWindowSamples, int timeoutMs) { - - return null; - } - - @Override - public void enableVoltageCompensation(boolean enable) { - - } - - @Override - public double getBusVoltage() { - - return 12; - } - - @Override - public double getMotorOutputPercent() { - // if the Talon is set to invert, it will output negative voltages. This needs - // to be taken into account. - - double inversionFactor = this.getInverted() ? -1 : 1; - return this.getThrottlePercent() * inversionFactor; - } - - @Override - public double getMotorOutputVoltage() { - - return getMotorOutputPercent() * this.getBusVoltage(); - } - - @Override - public double getOutputCurrent() { - - return current; - } - - public void setOutputCurrent(double current) { - this.current = current; - } - - @Override - public double getTemperature() { - - return 0; - } - - @Override - public ErrorCode configSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configRemoteFeedbackFilter(int deviceID, RemoteSensorSource remoteSensorSource, int remoteOrdinal, - int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configSensorTerm(SensorTerm sensorTerm, FeedbackDevice feedbackDevice, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx, int timeoutMs) { - if (feedbackDevice == FeedbackDevice.QuadEncoder || feedbackDevice == FeedbackDevice.CTRE_MagEncoder_Relative - || feedbackDevice == FeedbackDevice.CTRE_MagEncoder_Absolute) { - this.internalEncoder = new MockEncoder("Test", propMan); - } else { - assertionManager.fail( - "Whatever you supplied is not supported by the test infrastructure! Update MockCANTalon to handle your scenario."); - } - - return ErrorCode.OK; - } - - @Override - public double getSelectedSensorPosition(int pidIdx) { - - return (int) getPosition() * (sensorPhaseInverted ? -1 : 1); - } - - @Override - public double getSelectedSensorVelocity(int pidIdx) { - - return 0; - } - - @Override - public ErrorCode setSelectedSensorPosition(int sensorPos, int pidIdx, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode setControlFramePeriod(ControlFrame frame, int periodMs) { - - return null; - } - - @Override - public ErrorCode setStatusFramePeriod(StatusFrame frame, int periodMs, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode setStatusFramePeriod(StatusFrameEnhanced frame, int periodMs, int timeoutMs) { - - return null; - } - - @Override - public int getStatusFramePeriod(StatusFrame frame, int timeoutMs) { - - return 0; - } - - @Override - public int getStatusFramePeriod(StatusFrameEnhanced frame, int timeoutMs) { - - return 0; - } - - @Override - public ErrorCode configVelocityMeasurementWindow(int windowSize, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configForwardLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configReverseLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID, int timeoutMs) { - - return null; - } - - @Override - public void overrideLimitSwitchesEnable(boolean enable) { - - } - - @Override - public ErrorCode configForwardLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configReverseLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configForwardSoftLimitThreshold(int forwardSensorLimit, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configReverseSoftLimitThreshold(int reverseSensorLimit, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configForwardSoftLimitEnable(boolean enable, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configReverseSoftLimitEnable(boolean enable, int timeoutMs) { - - return null; - } - - @Override - public void overrideSoftLimitsEnable(boolean enable) { - - } - - public boolean isFwdLimitSwitchClosed() { - return forwardLimitSwitch; - } - - public void setForwardLimitSwitch(boolean value) { - forwardLimitSwitch = value; - } - - public boolean isRevLimitSwitchClosed() { - return reverseLimitSwitch; - } - - public void setReverseLimitSwitch(boolean value) { - reverseLimitSwitch = value; - } - - @Override - public ErrorCode configPeakCurrentLimit(int amps, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configPeakCurrentDuration(int milliseconds, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configContinuousCurrentLimit(int amps, int timeoutMs) { - continuousCurrentLimit = amps; - return null; - } - - public int getContinuousCurrentLimit() { - return continuousCurrentLimit; - } - - @Override - public void enableCurrentLimit(boolean enable) { - - } - - @Override - public ErrorCode config_kP(int slotIdx, double value, int timeoutMs) { - this.kp = value; - return null; - } - - @Override - public ErrorCode config_kI(int slotIdx, double value, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode config_kD(int slotIdx, double value, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode config_kF(int slotIdx, double value, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode config_IntegralZone(int slotIdx, int izone, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configAllowableClosedloopError(int slotIdx, int allowableCloseLoopError, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configMaxIntegralAccumulator(int slotIdx, double iaccum, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode setIntegralAccumulator(double iaccum, int pidIdx, int timeoutMs) { - - return null; - } - - @Override - public double getClosedLoopError(int pidIdx) { - - return 0; - } - - @Override - public double getIntegralAccumulator(int pidIdx) { - - return 0; - } - - @Override - public double getErrorDerivative(int pidIdx) { - - return 0; - } - - @Override - public void selectProfileSlot(int slotIdx, int pidIdx) { - - } - - @Override - public double getActiveTrajectoryPosition() { - - return 0; - } - - @Override - public double getActiveTrajectoryVelocity() { - - return 0; - } - - @Override - public double getActiveTrajectoryHeading() { - - return 0; - } - - @Override - public ErrorCode configMotionCruiseVelocity(int sensorUnitsPer100ms, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configMotionAcceleration(int sensorUnitsPer100msPerSec, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode clearMotionProfileTrajectories() { - - return null; - } - - @Override - public int getMotionProfileTopLevelBufferCount() { - - return 0; - } - - @Override - public ErrorCode pushMotionProfileTrajectory(TrajectoryPoint trajPt) { - - return null; - } - - @Override - public boolean isMotionProfileTopLevelBufferFull() { - - return false; - } - - @Override - public void processMotionProfileBuffer() { - - } - - @Override - public ErrorCode getMotionProfileStatus(MotionProfileStatus statusToFill) { - - return null; - } - - @Override - public ErrorCode clearMotionProfileHasUnderrun(int timeoutMs) { - - return null; - } - - @Override - public ErrorCode changeMotionControlFramePeriod(int periodMs) { - - return null; - } - - @Override - public ErrorCode getLastError() { - - return null; - } - - @Override - public ErrorCode getFaults(Faults toFill) { - - return null; - } - - @Override - public ErrorCode getStickyFaults(StickyFaults toFill) { - - return null; - } - - @Override - public ErrorCode clearStickyFaults(int timeoutMs) { - - return null; - } - - @Override - public int getFirmwareVersion() { - - return 0; - } - - @Override - public boolean hasResetOccurred() { - - return false; - } - - @Override - public ErrorCode configSetCustomParam(int newValue, int paramIndex, int timeoutMs) { - - return null; - } - - @Override - public int configGetCustomParam(int paramIndex, int timoutMs) { - - return 0; - } - - @Override - public ErrorCode configSetParameter(ParamEnum param, double value, int subValue, int ordinal, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configSetParameter(int param, double value, int subValue, int ordinal, int timeoutMs) { - - return null; - } - - @Override - public double configGetParameter(ParamEnum paramEnum, int ordinal, int timeoutMs) { - - return 0; - } - - @Override - public double configGetParameter(int paramEnum, int ordinal, int timeoutMs) { - - return 0; - } - - @Override - public int getBaseID() { - - return 0; - } - - @Override - public int getDeviceID() { - - return 0; - } - - @Override - public void follow(IMotorController masterToFollow) { - master = (MockCANTalon) masterToFollow; - } - - @Override - public void valueUpdated() { - - } - - public double getPosition() { - if (internalEncoder == null) { - assertionManager.fail("Position requested before setting feedback device!"); - return 0; - } - - return internalEncoder.getAdjustedDistance(); - } - - public void setPosition(double pos) { - if (internalEncoder == null) { - assertionManager.fail("Position set before setting feedback device!"); - } else { - ((MockEncoder) internalEncoder).setDistance(pos); - } - } - - public void setRate(double rate) { - if (internalEncoder == null) { - assertionManager.fail("Rate set before setting feedback device!"); - } else { - ((MockEncoder) internalEncoder).setRate(rate); - } - } - - @Override - public void set(ControlMode Mode, double demand0, DemandType demand1Type, double demand1) { - - } - - @Override - public ErrorCode configSelectedFeedbackCoefficient(double coefficient, int pidIdx, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configClosedLoopPeakOutput(int slotIdx, double percentOut, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configClosedLoopPeriod(int slotIdx, int loopTimeMs, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configAuxPIDPolarity(boolean invert, int timeoutMs) { - return null; - } - - @Override - public double getClosedLoopTarget(int pidIdx) { - return 0; - } - - @Override - public ErrorCode configMotionProfileTrajectoryPeriod(int baseTrajDurationMs, int timeoutMs) { - return null; - } - - @Override - public ControlMode getControlMode() { - return null; - } - - @Override - public ErrorCode configMotionSCurveStrength(int curveStrength, int timeoutMs) { - return null; - } - - @Override - public int getPulseWidthRiseToFallUs() { - return pulseWidthRiseToFallUs; - } - - public void setPulseWidthRiseToFallUs(int value) { - pulseWidthRiseToFallUs = value; - } - - @Override - public void ingestSimulationData(JSONObject payload) { - BigDecimal intermediate = (BigDecimal) payload.get("EncoderTicks"); - setPosition((int) (intermediate.doubleValue() * simulationScalingValue)); - } - - @Override - public JSONObject getSimulationData() { - return buildMotorObject(policeTicket, (float)getThrottlePercent()); - } - - @Override - public ErrorCode configSupplyCurrentLimit(SupplyCurrentLimitConfiguration currLimitCfg, int timeoutMs) { - return null; - } - - @Override - public void setInverted(InvertType invertType) { - - } - - @Override - public ErrorCode configRemoteFeedbackFilter(CANCoder canCoderRef, int remoteOrdinal, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configRemoteFeedbackFilter(BaseTalon talonRef, int remoteOrdinal, int timeoutMs) { - return null; - } - - @Override - public ErrorCode setSelectedSensorPosition(double sensorPos, int pidIdx, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configForwardSoftLimitThreshold(double forwardSensorLimit, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configReverseSoftLimitThreshold(double reverseSensorLimit, int timeoutMs) { - return null; - } - - @Override - public ErrorCode config_IntegralZone(int slotIdx, double izone, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configAllowableClosedloopError(int slotIdx, double allowableCloseLoopError, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMotionCruiseVelocity(double sensorUnitsPer100ms, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMotionAcceleration(double sensorUnitsPer100msPerSec, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configVelocityMeasurementPeriod(SensorVelocityMeasPeriod period, int timeoutMs) { - return null; - } - - @Override - @SuppressWarnings( "deprecation" ) - public ErrorCode configVelocityMeasurementPeriod(com.ctre.phoenix.motorcontrol.VelocityMeasPeriod period, int timeoutMs) { - return null; - } -} diff --git a/src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANVictorSPX.java b/src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANVictorSPX.java deleted file mode 100644 index 079bb81e..00000000 --- a/src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANVictorSPX.java +++ /dev/null @@ -1,630 +0,0 @@ -package xbot.common.controls.actuators.mock_adapters; - -import com.ctre.phoenix.ErrorCode; -import com.ctre.phoenix.ParamEnum; -import com.ctre.phoenix.motion.MotionProfileStatus; -import com.ctre.phoenix.motion.TrajectoryPoint; -import com.ctre.phoenix.motorcontrol.ControlFrame; -import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.DemandType; -import com.ctre.phoenix.motorcontrol.Faults; -import com.ctre.phoenix.motorcontrol.FeedbackDevice; -import com.ctre.phoenix.motorcontrol.IMotorController; -import com.ctre.phoenix.motorcontrol.InvertType; -import com.ctre.phoenix.motorcontrol.LimitSwitchNormal; -import com.ctre.phoenix.motorcontrol.LimitSwitchSource; -import com.ctre.phoenix.motorcontrol.NeutralMode; -import com.ctre.phoenix.motorcontrol.RemoteFeedbackDevice; -import com.ctre.phoenix.motorcontrol.RemoteLimitSwitchSource; -import com.ctre.phoenix.motorcontrol.RemoteSensorSource; -import com.ctre.phoenix.motorcontrol.SensorTerm; -import com.ctre.phoenix.motorcontrol.StatusFrame; -import com.ctre.phoenix.motorcontrol.StatusFrameEnhanced; -import com.ctre.phoenix.motorcontrol.StickyFaults; -import com.ctre.phoenix.motorcontrol.SupplyCurrentLimitConfiguration; -import com.ctre.phoenix.motorcontrol.can.BaseTalon; -import com.ctre.phoenix.sensors.CANCoder; -import com.ctre.phoenix.sensors.SensorVelocityMeasPeriod; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.actuators.XCANVictorSPX; -import xbot.common.injection.DevicePolice; -import xbot.common.properties.PropertyFactory; - -public class MockCANVictorSPX extends XCANVictorSPX { - - double power; - - @AssistedFactory - public abstract static class MockCANVictorSPXFactory implements XCANVictorSPXFactory { - public abstract MockCANVictorSPX create(@Assisted("deviceId") int deviceId); - } - - @AssistedInject - public MockCANVictorSPX(@Assisted("deviceId") int deviceId, PropertyFactory propMan, DevicePolice police) { - super(deviceId, propMan, police); - } - - //CHECKSTYLE:OFF - - @Override - public void set(ControlMode Mode, double demand0, DemandType demand1Type, double demand1) { - power = demand0; - } - - @Override - public ErrorCode configSelectedFeedbackCoefficient(double coefficient, int pidIdx, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configClosedLoopPeakOutput(int slotIdx, double percentOut, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configClosedLoopPeriod(int slotIdx, int loopTimeMs, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configAuxPIDPolarity(boolean invert, int timeoutMs) { - return null; - } - - @Override - public double getClosedLoopTarget(int pidIdx) { - return 0; - } - - @Override - public ErrorCode configMotionSCurveStrength(int curveStrength, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMotionProfileTrajectoryPeriod(int baseTrajDurationMs, int timeoutMs) { - return null; - } - - @Override - public ControlMode getControlMode() { - return null; - } - - @Override - public void set(ControlMode Mode, double demand) { - - } - - @Override - public void neutralOutput() { - - } - - @Override - public void setNeutralMode(NeutralMode neutralMode) { - - } - - @Override - public void setSensorPhase(boolean PhaseSensor) { - - } - - @Override - public void setInverted(boolean invert) { - - } - - @Override - public boolean getInverted() { - return false; - } - - @Override - public ErrorCode configOpenloopRamp(double secondsFromNeutralToFull, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configClosedloopRamp(double secondsFromNeutralToFull, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configPeakOutputForward(double percentOut, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configPeakOutputReverse(double percentOut, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configNominalOutputForward(double percentOut, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configNominalOutputReverse(double percentOut, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configNeutralDeadband(double percentDeadband, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configVoltageCompSaturation(double voltage, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configVoltageMeasurementFilter(int filterWindowSamples, int timeoutMs) { - return null; - } - - @Override - public void enableVoltageCompensation(boolean enable) { - - } - - @Override - public double getBusVoltage() { - return 0; - } - - @Override - public double getMotorOutputPercent() { - return power; - } - - @Override - public double getMotorOutputVoltage() { - return 0; - } - - @Override - public double getOutputCurrent() { - return 0; - } - - @Override - public double getTemperature() { - return 0; - } - - @Override - public ErrorCode configSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configRemoteFeedbackFilter(int deviceID, RemoteSensorSource remoteSensorSource, int remoteOrdinal, - int timeoutMs) { - return null; - } - - @Override - public ErrorCode configSensorTerm(SensorTerm sensorTerm, FeedbackDevice feedbackDevice, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx, int timeoutMs) { - return null; - } - - @Override - public double getSelectedSensorPosition(int pidIdx) { - return 0; - } - - @Override - public double getSelectedSensorVelocity(int pidIdx) { - return 0; - } - - @Override - public ErrorCode setSelectedSensorPosition(int sensorPos, int pidIdx, int timeoutMs) { - return null; - } - - @Override - public ErrorCode setControlFramePeriod(ControlFrame frame, int periodMs) { - return null; - } - - @Override - public ErrorCode setStatusFramePeriod(StatusFrame frame, int periodMs, int timeoutMs) { - return null; - } - - @Override - public ErrorCode setStatusFramePeriod(StatusFrameEnhanced frame, int periodMs, int timeoutMs) { - return null; - } - - @Override - public int getStatusFramePeriod(StatusFrame frame, int timeoutMs) { - return 0; - } - - @Override - public int getStatusFramePeriod(StatusFrameEnhanced frame, int timeoutMs) { - return 0; - } - - @Override - @SuppressWarnings("deprecation") - public ErrorCode configVelocityMeasurementPeriod(com.ctre.phoenix.motorcontrol.VelocityMeasPeriod period, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configVelocityMeasurementWindow(int windowSize, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configForwardLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configReverseLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID, int timeoutMs) { - return null; - } - - @Override - public void overrideLimitSwitchesEnable(boolean enable) { - - } - - @Override - public ErrorCode configForwardLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int timeoutMs) { - return null; - } - - @Override - public ErrorCode configReverseLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int timeoutMs) { - return null; - } - - @Override - public boolean isFwdLimitSwitchClosed() { - return false; - } - - @Override - public boolean isRevLimitSwitchClosed() { - return false; - } - - @Override - public ErrorCode configForwardSoftLimitThreshold(int forwardSensorLimit, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configReverseSoftLimitThreshold(int reverseSensorLimit, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configForwardSoftLimitEnable(boolean enable, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configReverseSoftLimitEnable(boolean enable, int timeoutMs) { - return null; - } - - @Override - public void overrideSoftLimitsEnable(boolean enable) { - - } - - @Override - public ErrorCode configPeakCurrentLimit(int amps, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configPeakCurrentDuration(int milliseconds, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configContinuousCurrentLimit(int amps, int timeoutMs) { - return null; - } - - @Override - public void enableCurrentLimit(boolean enable) { - - } - - @Override - public ErrorCode config_kP(int slotIdx, double value, int timeoutMs) { - return null; - } - - @Override - public ErrorCode config_kI(int slotIdx, double value, int timeoutMs) { - return null; - } - - @Override - public ErrorCode config_kD(int slotIdx, double value, int timeoutMs) { - return null; - } - - @Override - public ErrorCode config_kF(int slotIdx, double value, int timeoutMs) { - return null; - } - - @Override - public ErrorCode config_IntegralZone(int slotIdx, int izone, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configAllowableClosedloopError(int slotIdx, int allowableCloseLoopError, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMaxIntegralAccumulator(int slotIdx, double iaccum, int timeoutMs) { - return null; - } - - @Override - public ErrorCode setIntegralAccumulator(double iaccum, int pidIdx, int timeoutMs) { - return null; - } - - @Override - public double getClosedLoopError(int pidIdx) { - return 0; - } - - @Override - public double getIntegralAccumulator(int pidIdx) { - return 0; - } - - @Override - public double getErrorDerivative(int pidIdx) { - return 0; - } - - @Override - public void selectProfileSlot(int slotIdx, int pidIdx) { - - } - - @Override - public double getActiveTrajectoryPosition() { - return 0; - } - - @Override - public double getActiveTrajectoryVelocity() { - return 0; - } - - @Override - public double getActiveTrajectoryHeading() { - return 0; - } - - @Override - public ErrorCode configMotionCruiseVelocity(int sensorUnitsPer100ms, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMotionAcceleration(int sensorUnitsPer100msPerSec, int timeoutMs) { - return null; - } - - @Override - public ErrorCode clearMotionProfileTrajectories() { - return null; - } - - @Override - public int getMotionProfileTopLevelBufferCount() { - return 0; - } - - @Override - public ErrorCode pushMotionProfileTrajectory(TrajectoryPoint trajPt) { - return null; - } - - @Override - public boolean isMotionProfileTopLevelBufferFull() { - return false; - } - - @Override - public void processMotionProfileBuffer() { - - } - - @Override - public ErrorCode getMotionProfileStatus(MotionProfileStatus statusToFill) { - return null; - } - - @Override - public ErrorCode clearMotionProfileHasUnderrun(int timeoutMs) { - return null; - } - - @Override - public ErrorCode changeMotionControlFramePeriod(int periodMs) { - return null; - } - - @Override - public ErrorCode getLastError() { - return null; - } - - @Override - public ErrorCode getFaults(Faults toFill) { - return null; - } - - @Override - public ErrorCode getStickyFaults(StickyFaults toFill) { - return null; - } - - @Override - public ErrorCode clearStickyFaults(int timeoutMs) { - return null; - } - - @Override - public int getFirmwareVersion() { - return 0; - } - - @Override - public boolean hasResetOccurred() { - return false; - } - - @Override - public ErrorCode configSetCustomParam(int newValue, int paramIndex, int timeoutMs) { - return null; - } - - @Override - public int configGetCustomParam(int paramIndex, int timoutMs) { - return 0; - } - - @Override - public ErrorCode configSetParameter(ParamEnum param, double value, int subValue, int ordinal, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configSetParameter(int param, double value, int subValue, int ordinal, int timeoutMs) { - return null; - } - - @Override - public double configGetParameter(ParamEnum paramEnum, int ordinal, int timeoutMs) { - return 0; - } - - @Override - public double configGetParameter(int paramEnum, int ordinal, int timeoutMs) { - return 0; - } - - @Override - public int getBaseID() { - return 0; - } - - @Override - public int getDeviceID() { - return 0; - } - - @Override - public void follow(IMotorController masterToFollow) { - - } - - @Override - public void valueUpdated() { - - } - - @Override - public int getPulseWidthRiseToFallUs() { - return 0; - } - - @Override - public ErrorCode configSupplyCurrentLimit(SupplyCurrentLimitConfiguration currLimitCfg, int timeoutMs) { - return null; - } - - @Override - public void setInverted(InvertType invertType) { - - } - - @Override - public ErrorCode configRemoteFeedbackFilter(CANCoder canCoderRef, int remoteOrdinal, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configRemoteFeedbackFilter(BaseTalon talonRef, int remoteOrdinal, int timeoutMs) { - return null; - } - - @Override - public ErrorCode setSelectedSensorPosition(double sensorPos, int pidIdx, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configForwardSoftLimitThreshold(double forwardSensorLimit, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configReverseSoftLimitThreshold(double reverseSensorLimit, int timeoutMs) { - return null; - } - - @Override - public ErrorCode config_IntegralZone(int slotIdx, double izone, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configAllowableClosedloopError(int slotIdx, double allowableCloseLoopError, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMotionCruiseVelocity(double sensorUnitsPer100ms, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMotionAcceleration(double sensorUnitsPer100msPerSec, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configVelocityMeasurementPeriod(SensorVelocityMeasPeriod period, int timeoutMs) { - return null; - } - - //CHECKSTYLE:ON -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/actuators/mock_adapters/MockLegacyCANTalon.java b/src/main/java/xbot/common/controls/actuators/mock_adapters/MockLegacyCANTalon.java deleted file mode 100644 index 8a8410de..00000000 --- a/src/main/java/xbot/common/controls/actuators/mock_adapters/MockLegacyCANTalon.java +++ /dev/null @@ -1,669 +0,0 @@ -/*package xbot.common.controls.actuators.mock_adapters; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.log4j.Logger; - -import com.ctre.CANTalon; -import com.ctre.CANTalon.FeedbackDevice; -import com.ctre.CANTalon.FeedbackDeviceStatus; -import com.ctre.CANTalon.StatusFrameRate; -import com.ctre.CANTalon.TalonControlMode; -import com.ctre.phoenix.motorcontrol.ControlMode; -import javax.inject.Inject; -import com.google.inject.assistedinject.Assisted; - -import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; -import xbot.common.controls.MockRobotIO; -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.controls.sensors.XEncoder; -import xbot.common.controls.sensors.mock_adapters.MockEncoder; -import xbot.common.math.MathUtils; -import xbot.common.properties.XPropertyManager; - -public class MockCANTalon extends XCANTalon { - public final int deviceId; - private ControlMode controlMode; - private ControlMode lastSetControlMode; - - private boolean outputInverted = false; - private boolean closedLoopOutputInverted = false; - - private double setpoint = 0; - private double throttlePercent = 0; - private double motorCurrent = 0; - - private int currentProfile = 0; - private Map profiles = new HashMap<>(); - - - @SuppressWarnings("unused") - private static class ProfileParams - { - public double p; - public double i; - public double d; - public double f; - public double iZone; - } - - private static final ProfileParams defaultParams = new ProfileParams(); - - MockRobotIO mockRobotIO; - public XEncoder internalEncoder = null; - - private static Logger log = Logger.getLogger(MockCANTalon.class); - - @Inject - public MockCANTalon(@Assisted("deviceId") int deviceId, MockRobotIO mockRobotIO, XPropertyManager propMan) { - super(deviceId, propMan); - log.info("Creating CAN talon with device ID: " + deviceId); - - this.deviceId = deviceId; - this.mockRobotIO = mockRobotIO; - mockRobotIO.setCANTalon(deviceId, this); - - this.setControlMode(TalonControlMode.Disabled); - } - - private void initCurrentProfileParams() { - if(!this.profiles.containsKey(currentProfile)) { - this.profiles.put(currentProfile, new ProfileParams()); - } - } - - public double getThrottlePercent() { - return this.throttlePercent; - } - - @Override - public LiveWindowSendable getLiveWindowSendable() { - return null; - } - - @Override - public boolean isEnabled() { - return controlMode != CANTalon.TalonControlMode.Disabled; - } - - @Override - public void enable() { - controlMode = lastSetControlMode; - } - - @Override - public void disable() { - controlMode = CANTalon.TalonControlMode.Disabled; - } - - @Override - public void setProfile(int profile) { - this.currentProfile = profile; - } - - @Override - public TalonControlMode getControlMode() { - return controlMode; - } - - @Override - public void setControlMode(TalonControlMode controlMode) { - this.controlMode = controlMode; - this.lastSetControlMode = controlMode; - } - - @Override - public boolean getBrakeEnableDuringNeutral() { - // Brake isn't supported in mock environment. - return false; - } - - @Override - public void setBrakeEnableDuringNeutral(boolean brake) { - // Intentionally left blank. Brake isn't supported in mock environment. - } - - @Override - public void setStatusFrameRateMs(StatusFrameRate stateFrame, int periodMs) { - // Intentionally left blank. There isn't an update rate in the mock environment. - } - - @Override - public void reset() { - this.clearIAccum(); - this.disable(); - } - - @Override - public int getDeviceID() { - return this.deviceId; - } - - @Override - public double getOutputCurrent() { - return motorCurrent; - } - - public void setOutputCurrent(double current){ - motorCurrent = current; - } - - @Override - public double getOutputVoltage() { - // if the Talon is set to invert, it will output negative voltages. This needs - // to be taken into account. - - - double inversionFactor = this.getInverted() ? -1 : 1; - return this.getThrottlePercent() * this.getBusVoltage() * inversionFactor; - } - - @Override - public double getTemperature() { - // No point in mocking this - return 0; - } - - @Override - public double getBusVoltage() { - return MockRobotIO.BUS_VOLTAGE; - } - - @Override - public long getFirmwareVersion() { - return 0; - } - - @Override - public void clearStickyFaults() { - // Intentionally left blank - } - - @Override - public int getFaultForwardLim() { - // Intentionally left blank - return 0; - } - - @Override - public int getFaultForwardSoftLim() { - // Intentionally left blank - return 0; - } - - @Override - public int getFaultHardwareFailure() { - // Intentionally left blank - return 0; - } - - @Override - public int getFaultOverTemp() { - // Intentionally left blank - return 0; - } - - @Override - public int getFaultReverseLim() { - // Intentionally left blank - return 0; - } - - @Override - public int getFaultReverseSoftLim() { - // Intentionally left blank - return 0; - } - - @Override - public int getFaultUnderVoltage() { - // Intentionally left blank - return 0; - } - - @Override - public int getStickyFaultForwardLim() { - // Intentionally left blank - return 0; - } - - @Override - public int getStickyFaultForwardSoftLim() { - // Intentionally left blank - return 0; - } - - @Override - public int getStickyFaultOverTemp() { - // Intentionally left blank - return 0; - } - - @Override - public int getStickyFaultReverseLim() { - // Intentionally left blank - return 0; - } - - @Override - public int getStickyFaultReverseSoftLim() { - // Intentionally left blank - return 0; - } - - @Override - public int getStickyFaultUnderVoltage() { - // Intentionally left blank - return 0; - } - - @Override - public double getP() { - return this.profiles.getOrDefault(currentProfile, defaultParams).p; - } - - @Override - public double getI() { - return this.profiles.getOrDefault(currentProfile, defaultParams).i; - } - - @Override - public double getD() { - return this.profiles.getOrDefault(currentProfile, defaultParams).d; - } - - @Override - public double getF() { - return this.profiles.getOrDefault(currentProfile, defaultParams).f; - } - - @Override - public void setP(double p) { - initCurrentProfileParams(); - this.profiles.get(currentProfile).p = p; - } - - @Override - public void setI(double i) { - initCurrentProfileParams(); - this.profiles.get(currentProfile).i = i; - } - - @Override - public void setD(double d) { - initCurrentProfileParams(); - this.profiles.get(currentProfile).d = d; - } - - @Override - public void setF(double f) { - initCurrentProfileParams(); - this.profiles.get(currentProfile).f = f; - - } - - @Override - public void setPID(double p, double i, double d) { - this.setP(p); - this.setI(i); - this.setD(d); - } - - @Override - public void clearIAccum() { - // Intentionally left blank. The mock implementation does not use full PID. - } - - @Override - public int getClosedLoopError() { - if(internalEncoder == null) { - return 0; - } - - double currentPos; - if(controlMode == TalonControlMode.Position) { - currentPos = internalEncoder.getAdjustedDistance(); - } - else if (controlMode == TalonControlMode.Speed) { - currentPos = internalEncoder.getAdjustedRate(); - } - else { - return 0; - } - - return (int)(setpoint - currentPos); - } - - @Override - public void setAllowableClosedLoopError(int allowableError) { - // Intentionally left blank. No point in doing the extra math in the mock impl. - } - - @Override - public double getIZone() { - // There isn't a full PID implementation here, so we don't need windup prevention - return Double.POSITIVE_INFINITY; - } - - @Override - public void setIZone(int iZone) { - // Intentionally left blank. - } - - @Override - public long getIAccum() { - // No full PID impl. in mock - return 0; - } - - @Override - public void setClosedLoopRampRate(double rampRate) { - // Intentionally left blank. The mock implementation does not handle ramping. - } -/* - @Override - public FeedbackDeviceStatus isSensorPresent(FeedbackDevice feedbackDevice) { - // The mock implementation only supports quadrature encoders - return feedbackDevice == FeedbackDevice.QuadEncoder ? FeedbackDeviceStatus.FeedbackStatusPresent : FeedbackDeviceStatus.FeedbackStatusNotPresent; - } - - @Override - public void setFeedbackDevice(FeedbackDevice device) { - if(device == FeedbackDevice.QuadEncoder) { - this.internalEncoder = new MockEncoder(propMan); - } - } - - @Override - public void configEncoderCodesPerRev(int codesPerRev) { - // This value isn't used and there is no getter that needs it, so we can ignore it. - } - - @Override - public void configPotentiometerTurns(int turns) { - // Intentionally left blank. The mock implementation only supports quadrature encoders. - } - - @Override - public double getPosition() { - if(internalEncoder == null) { - log.warn("Position requested before setting feedback device!"); - return 0; - } - - return internalEncoder.getAdjustedDistance(); - } - - @Override - public void setPosition(double pos) { - if(internalEncoder == null) { - log.warn("Position set before setting feedback device!"); - } - else { - ((MockEncoder)internalEncoder).setDistance(pos); - } - } - - @Override - public double getSpeed() { - if(internalEncoder == null) { - log.warn("Speed requested before setting feedback device!"); - return 0; - } - - return this.getEncoderSpeed(); - } - - @Override - public int getAnalogPosition() { - // Analog feedback sensors aren't supported by mock impl. - return 0; - } - - @Override - public void setAnalogPosition(int newPosition) { - // Intentionally left blank. Analog feedback sensors aren't supported by mock impl. - } - - @Override - public int getAnalogPositionRaw() { - // Analog feedback sensors aren't supported by mock impl. - return 0; - } - - @Override - public int getAnalogSpeed() { - // Analog feedback sensors aren't supported by mock impl. - return 0; - } - - @Override - public int getEncoderPosition() { - return internalEncoder == null ? 0 : (int) internalEncoder.getAdjustedDistance(); - } - - @Override - public void setEncoderPosition(int newPosition) { - if(internalEncoder == null) { - // Because the nullity of internalEncoder is used to determine whether a - // feedback device has been chosen, initializing it here will have the - // unintended side-effect of no longer warning about an unset sensor. - internalEncoder = new MockEncoder(propMan); - } - - ((MockEncoder)internalEncoder).setDistance(newPosition); - } - - @Override - public int getEncoderSpeed() { - return internalEncoder == null ? 0 : (int) internalEncoder.getAdjustedRate(); - } - - @Override - public void reverseSensor(boolean flip) { - if(internalEncoder != null) { - internalEncoder.setInverted(flip); - } - } - - @Override - public void enableZeroSensorPositionOnIndex(boolean enable, boolean risingEdge) { - // Intentionally left blank. Mock does not implement index pin. - } - - @Override - public int getNumberOfQuadIndexRises() { - // Mock does not implement index pin. - return 0; - } - - @Override - public boolean getInverted() { - return outputInverted; - } - - @Override - public void setInverted(boolean isInverted) { - this.outputInverted = isInverted; - } - - @Override - public void setVoltageCompensationRampRate(double rampRate) { - // Intentionally left blank. Mock impl. doesn't support ramping. - } - - @Override - public void configNominalOutputVoltage(double forwardVoltage, double reverseVoltage) { - // Intentionally left blank. Min output voltages aren't necessary in mock environment. - } - - @Override - public void configPeakOutputVoltage(double forwardVoltage, double reverseVoltage) { - // Intentionally left blank. Max output voltages aren't necessary in mock environment. - } - - @Override - public int getForwardSoftLimit() { - // Soft limits aren't implemented in mock environment. - return Integer.MAX_VALUE; - } - - @Override - public int getReverseSoftLimit() { - // Soft limits aren't implemented in mock environment. - return Integer.MIN_VALUE; - } - - @Override - public void setForwardSoftLimit(double forwardLimit) { - // Intentionally left blank. Soft limits aren't implemented in mock environment. - } - - @Override - public void setReverseSoftLimit(double reverseLimit) { - // Intentionally left blank. Soft limits aren't implemented in mock environment. - } - - @Override - public boolean isForwardSoftLimitEnabled() { - // Soft limits aren't implemented in mock environment. - return false; - } - - @Override - public boolean isReverseSoftLimitEnabled() { - // Soft limits aren't implemented in mock environment. - return false; - } - - @Override - public void enableForwardSoftLimit(boolean enable) { - // Intentionally left blank. Soft limits aren't implemented in mock environment. - } - - @Override - public void enableReverseSoftLimit(boolean enable) { - // Intentionally left blank. Soft limits aren't implemented in mock environment. - } - - @Override - public void enableLimitSwitches(boolean forwardEnabled, boolean reverseEnabled) { - // Intentionally left blank. Limit switches aren't implemented in mock environment. - } - - @Override - public boolean isForwardLimitSwitchClosed() { - // Limit switches aren't implemented in mock environment. - return false; - } - - @Override - public boolean isReverseLimitSwitchClosed() { - // Limit switches aren't implemented in mock environment. - return false; - } - - @Override - public void configForwardLimitSwitchNormallyOpen(boolean normallyOpen) { - // Intentionally left blank. Limit switches aren't implemented in mock environment. - } - - @Override - public void configReverseLimitSwitchNormallyOpen(boolean normallyOpen) { - // Intentionally left blank. Limit switches aren't implemented in mock environment. - } - - @Override - public double get() { - switch(controlMode) { - case Disabled: - return 0; - case Voltage: - return getOutputVoltage(); - case PercentVbus: - return setpoint; - case Current: - return this.getOutputCurrent(); - case MotionProfile: - // This mode isn't supported in by the mock implementation (nor the real one) - return 0; - case Speed: - return this.getSpeed(); - case Position: - return this.getPosition(); - case Follower: - MockCANTalon master = mockRobotIO.getCANTalon((int)setpoint); - return master.getOutputVoltage() / master.getBusVoltage() - * getClosedLoopOutputInversionFactor(); - default: - return 0; - } - } - - - public double getSetpoint() { - return setpoint; - } - - @Override - public void set(double outputValue) { - this.setpoint = outputValue; - - switch(controlMode) { - case Disabled: - throttlePercent = 0; - break; - case Voltage: - throttlePercent = setpoint / this.getBusVoltage(); - break; - case PercentVbus: - throttlePercent = MathUtils.constrainDouble(setpoint, -1, 1); - break; - case Current: - // Guess voltage by assuming a linear relationship between current and voltage, bypassing PID - throttlePercent = setpoint / MockRobotIO.NOMINAL_MOTOR_CURRENT; - break; - case MotionProfile: - // This mode isn't supported in by the mock implementation (nor the real one) - throttlePercent = 0; - break; - case Speed: - case Position: - if(!Double.isFinite(this.getP())) { - throttlePercent = 0; - } - else { - // Highly efficient P(IDF) implementation - throttlePercent = this.getClosedLoopError() * this.getP(); - } - break; - case Follower: - throttlePercent = mockRobotIO.getCANTalon((int)setpoint).getThrottlePercent(); - break; - default: - throttlePercent = 0; - } - - mockRobotIO.setPWM(-deviceId, this.getOutputVoltage() / this.getBusVoltage()); - } - - @Override - public void enableCurrentLimit(boolean enable) { - // no op - } - - @Override - public void setCurrentLimit(int amps) { - // no op - } - - public void reverseOutput(boolean isInverted) { - closedLoopOutputInverted = isInverted; - } - - private double getClosedLoopOutputInversionFactor() { - return closedLoopOutputInverted ? 1 : -1; - } -} -*/ \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/actuators/mock_adapters/MockRelay.java b/src/main/java/xbot/common/controls/actuators/mock_adapters/MockRelay.java deleted file mode 100644 index 88b760ea..00000000 --- a/src/main/java/xbot/common/controls/actuators/mock_adapters/MockRelay.java +++ /dev/null @@ -1,35 +0,0 @@ -package xbot.common.controls.actuators.mock_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.Relay.Value; -import xbot.common.controls.actuators.XRelay; -import xbot.common.injection.DevicePolice; - -public class MockRelay extends XRelay { - - private Value internalValue; - - @AssistedFactory - public abstract static class MockRelayFactory implements XRelayFactory { - public abstract MockRelay create(@Assisted("channel") int channel); - } - - @AssistedInject - public MockRelay(@Assisted("channel") int channel, DevicePolice police) { - super(channel, police); - - internalValue = Value.kOff; - } - @Override - public void set(Value value) { - internalValue = value; - } - - public Value get() { - return internalValue; - } - -} diff --git a/src/main/java/xbot/common/controls/actuators/wpi_adapters/CANSparkMaxWpiAdapter.java b/src/main/java/xbot/common/controls/actuators/wpi_adapters/CANSparkMaxWpiAdapter.java deleted file mode 100644 index 7524fa9c..00000000 --- a/src/main/java/xbot/common/controls/actuators/wpi_adapters/CANSparkMaxWpiAdapter.java +++ /dev/null @@ -1,599 +0,0 @@ -package xbot.common.controls.actuators.wpi_adapters; - -import com.revrobotics.CANSparkMax; -import com.revrobotics.CANSparkMax.ControlType; -import com.revrobotics.CANSparkMax.ExternalFollower; -import com.revrobotics.CANSparkMax.FaultID; -import com.revrobotics.CANSparkMax.IdleMode; -import com.revrobotics.CANSparkMax.SoftLimitDirection; -import com.revrobotics.CANSparkMaxLowLevel.MotorType; -import com.revrobotics.CANSparkMaxLowLevel.PeriodicFrame; -import com.revrobotics.MotorFeedbackSensor; -import com.revrobotics.REVLibError; -import com.revrobotics.RelativeEncoder; -import com.revrobotics.SparkMaxAnalogSensor; -import com.revrobotics.SparkMaxAnalogSensor.Mode; -import com.revrobotics.SparkMaxLimitSwitch; -import com.revrobotics.SparkMaxPIDController; -import com.revrobotics.SparkMaxPIDController.AccelStrategy; -import com.revrobotics.SparkMaxPIDController.ArbFFUnits; -import com.revrobotics.SparkMaxRelativeEncoder.Type; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import xbot.common.controls.actuators.XCANSparkMax; -import xbot.common.controls.actuators.XCANSparkMaxPIDProperties; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.electrical_contract.DeviceInfo; -import xbot.common.properties.PropertyFactory; - -public class CANSparkMaxWpiAdapter extends XCANSparkMax { - - private CANSparkMax internalSpark; - - @AssistedFactory - public abstract static class CANSparkMaxWpiAdapterFactory extends XCANSparkMaxFactory { - public abstract CANSparkMaxWpiAdapter create( - @Assisted("deviceInfo") DeviceInfo deviceInfo, - @Assisted("owningSystemPrefix") String owningSystemPrefix, - @Assisted("name") String name, - @Assisted("defaultPIDProperties") XCANSparkMaxPIDProperties defaultPIDProperties); - } - - @AssistedInject - public CANSparkMaxWpiAdapter(@Assisted("deviceInfo") DeviceInfo deviceInfo, - @Assisted("owningSystemPrefix") String owningSystemPrefix, @Assisted("name") String name, - PropertyFactory propMan, DevicePolice police, - @Assisted("defaultPIDProperties") XCANSparkMaxPIDProperties defaultPIDProperties) { - super(deviceInfo, owningSystemPrefix, name, propMan, police, defaultPIDProperties); - internalSpark = new CANSparkMax(deviceInfo.channel, MotorType.kBrushless); - setInverted(deviceInfo.inverted); - } - - @Override - public CANSparkMax getInternalSparkMax() { - return internalSpark; - } - - public void close() { - internalSpark.close(); - } - - @Override - public REVLibError follow(XCANSparkMax leader) { - return internalSpark.follow(leader.getInternalSparkMax()); - } - - @Override - public REVLibError follow(XCANSparkMax leader, boolean invert) { - return internalSpark.follow(leader.getInternalSparkMax(), invert); - } - - public REVLibError follow(CANSparkMax leader) { - return internalSpark.follow(leader); - } - - public REVLibError follow(CANSparkMax leader, boolean invert) { - return internalSpark.follow(leader, invert); - } - - public REVLibError follow(ExternalFollower leader, int deviceID) { - return internalSpark.follow(leader, deviceID); - } - - public REVLibError follow(ExternalFollower leader, int deviceID, boolean invert) { - return internalSpark.follow(leader, deviceID, invert); - } - - public int getFirmwareVersion() { - return internalSpark.getFirmwareVersion(); - } - - public void setControlFramePeriodMs(int periodMs) { - internalSpark.setControlFramePeriodMs(periodMs); - } - - public String getFirmwareString() { - return internalSpark.getFirmwareString(); - } - - public byte[] getSerialNumber() { - return internalSpark.getSerialNumber(); - } - - public int getDeviceId() { - return internalSpark.getDeviceId(); - } - - public void stopMotor() { - internalSpark.stopMotor(); - } - - public MotorType getMotorType() { - return internalSpark.getMotorType(); - } - - public REVLibError setPeriodicFramePeriod(PeriodicFrame frame, int periodMs) { - return internalSpark.setPeriodicFramePeriod(frame, periodMs); - } - - public float getSafeFloat(float f) { - return internalSpark.getSafeFloat(f); - } - - public int hashCode() { - return internalSpark.hashCode(); - } - - public void set(double speed) { - internalSpark.set(speed); - } - - public void setVoltage(double outputVolts) { - internalSpark.setVoltage(outputVolts); - } - - public double get() { - return internalSpark.get(); - } - - public void setInverted(boolean isInverted) { - internalSpark.setInverted(isInverted); - } - - public boolean getInverted() { - return internalSpark.getInverted(); - } - - public void disable() { - internalSpark.disable(); - } - - public RelativeEncoder getEncoder(Type encoderType, int countsPerRev) { - return internalSpark.getEncoder(encoderType, countsPerRev); - } - - public RelativeEncoder getAlternateEncoder(int countsPerRev) { - return internalSpark.getAlternateEncoder(countsPerRev); - } - - public RelativeEncoder getAlternateEncoder(com.revrobotics.SparkMaxAlternateEncoder.Type encoderType, - int countsPerRev) { - return internalSpark.getAlternateEncoder(encoderType, countsPerRev); - } - - public REVLibError restoreFactoryDefaults() { - return internalSpark.restoreFactoryDefaults(); - } - - public REVLibError restoreFactoryDefaults(boolean persist) { - return internalSpark.restoreFactoryDefaults(persist); - } - - public SparkMaxAnalogSensor getAnalog(Mode mode) { - return internalSpark.getAnalog(mode); - } - - public SparkMaxPIDController getPIDController() { - return internalSpark.getPIDController(); - } - - public SparkMaxLimitSwitch getForwardLimitSwitch(com.revrobotics.SparkMaxLimitSwitch.Type switchType) { - return internalSpark.getForwardLimitSwitch(switchType); - } - - public SparkMaxLimitSwitch getReverseLimitSwitch(com.revrobotics.SparkMaxLimitSwitch.Type switchType) { - return internalSpark.getReverseLimitSwitch(switchType); - } - - public REVLibError setSmartCurrentLimit(int limit) { - return internalSpark.setSmartCurrentLimit(limit); - } - - public REVLibError setSmartCurrentLimit(int stallLimit, int freeLimit) { - return internalSpark.setSmartCurrentLimit(stallLimit, freeLimit); - } - - public REVLibError setSmartCurrentLimit(int stallLimit, int freeLimit, int limitRPM) { - return internalSpark.setSmartCurrentLimit(stallLimit, freeLimit, limitRPM); - } - - public REVLibError setSecondaryCurrentLimit(double limit) { - return internalSpark.setSecondaryCurrentLimit(limit); - } - - public REVLibError setSecondaryCurrentLimit(double limit, int chopCycles) { - return internalSpark.setSecondaryCurrentLimit(limit, chopCycles); - } - - public REVLibError setIdleMode(IdleMode mode) { - return internalSpark.setIdleMode(mode); - } - - public IdleMode getIdleMode() { - return internalSpark.getIdleMode(); - } - - public REVLibError enableVoltageCompensation(double nominalVoltage) { - return internalSpark.enableVoltageCompensation(nominalVoltage); - } - - public REVLibError disableVoltageCompensation() { - return internalSpark.disableVoltageCompensation(); - } - - public double getVoltageCompensationNominalVoltage() { - return internalSpark.getVoltageCompensationNominalVoltage(); - } - - public REVLibError setOpenLoopRampRate(double rate) { - return internalSpark.setOpenLoopRampRate(rate); - } - - public REVLibError setClosedLoopRampRate(double rate) { - return internalSpark.setClosedLoopRampRate(rate); - } - - public double getOpenLoopRampRate() { - return internalSpark.getOpenLoopRampRate(); - } - - public double getClosedLoopRampRate() { - return internalSpark.getClosedLoopRampRate(); - } - - public boolean isFollower() { - return internalSpark.isFollower(); - } - - public short getFaults() { - return internalSpark.getFaults(); - } - - public short getStickyFaults() { - return internalSpark.getStickyFaults(); - } - - public boolean getFault(FaultID faultID) { - return internalSpark.getFault(faultID); - } - - public boolean getStickyFault(FaultID faultID) { - return internalSpark.getStickyFault(faultID); - } - - public double getBusVoltage() { - return internalSpark.getBusVoltage(); - } - - public double getAppliedOutput() { - return internalSpark.getAppliedOutput(); - } - - public double getOutputCurrent() { - return internalSpark.getOutputCurrent(); - } - - public double getMotorTemperature() { - return internalSpark.getMotorTemperature(); - } - - public REVLibError clearFaults() { - return internalSpark.clearFaults(); - } - - public REVLibError burnFlash() { - return internalSpark.burnFlash(); - } - - public REVLibError setCANTimeout(int milliseconds) { - return internalSpark.setCANTimeout(milliseconds); - } - - public REVLibError enableSoftLimit(SoftLimitDirection direction, boolean enable) { - return internalSpark.enableSoftLimit(direction, enable); - } - - public REVLibError setSoftLimit(SoftLimitDirection direction, float limit) { - return internalSpark.setSoftLimit(direction, limit); - } - - public double getSoftLimit(SoftLimitDirection direction) { - return internalSpark.getSoftLimit(direction); - } - - public boolean isSoftLimitEnabled(SoftLimitDirection direction) { - return internalSpark.isSoftLimitEnabled(direction); - } - - public REVLibError getLastError() { - return internalSpark.getLastError(); - } - - RelativeEncoder ce; - public double getPosition() { - return getEncoderInstance().getPosition(); - } - - public double getVelocity() { - return getEncoderInstance().getVelocity(); - } - - public REVLibError setPosition(double position) { - return getEncoderInstance().setPosition(position); - } - - public REVLibError setPositionConversionFactor(double factor) { - return getEncoderInstance().setPositionConversionFactor(factor); - } - - public REVLibError setVelocityConversionFactor(double factor) { - return getEncoderInstance().setVelocityConversionFactor(factor); - } - - public double getPositionConversionFactor() { - return getEncoderInstance().getPositionConversionFactor(); - } - - public double getVelocityConversionFactor() { - return getEncoderInstance().getVelocityConversionFactor(); - } - - public REVLibError setAverageDepth(int depth) { - return getEncoderInstance().setAverageDepth(depth); - } - - public int getAverageDepth() { - return getEncoderInstance().getAverageDepth(); - } - - public REVLibError setMeasurementPeriod(int period_ms) { - return getEncoderInstance().setMeasurementPeriod(period_ms); - } - - public int getMeasurementPeriod() { - return getEncoderInstance().getMeasurementPeriod(); - } - - public int getCountsPerRevolution() { - return getEncoderInstance().getCountsPerRevolution(); - } - - public REVLibError setEncoderInverted(boolean inverted) { - return getEncoderInstance().setInverted(inverted); - } - - private RelativeEncoder getEncoderInstance() { - if (ce == null) { - ce = internalSpark.getEncoder(); - } - return ce; - } - - SparkMaxPIDController pc; - - private SparkMaxPIDController getPIDControllerInstance() { - if (pc==null) { - pc = internalSpark.getPIDController(); - } - return pc; - } - - public REVLibError setP(double gain) { - return getPIDControllerInstance().setP(gain); - } - - public REVLibError setP(double gain, int slotID) { - return getPIDControllerInstance().setP(gain, slotID); - } - - public REVLibError setI(double gain) { - return getPIDControllerInstance().setI(gain); - } - - public REVLibError setI(double gain, int slotID) { - return getPIDControllerInstance().setI(gain, slotID); - } - - public REVLibError setD(double gain) { - return getPIDControllerInstance().setD(gain); - } - - public REVLibError setD(double gain, int slotID) { - return getPIDControllerInstance().setD(gain, slotID); - } - - public REVLibError setDFilter(double gain) { - return getPIDControllerInstance().setDFilter(gain); - } - - public REVLibError setDFilter(double gain, int slotID) { - return getPIDControllerInstance().setDFilter(gain, slotID); - } - - public REVLibError setFF(double gain) { - return getPIDControllerInstance().setFF(gain); - } - - public REVLibError setFF(double gain, int slotID) { - return getPIDControllerInstance().setFF(gain, slotID); - } - - public REVLibError setIZone(double iZone) { - return getPIDControllerInstance().setIZone(iZone); - } - - public REVLibError setIZone(double iZone, int slotID) { - return getPIDControllerInstance().setIZone(iZone, slotID); - } - - public REVLibError setOutputRange(double min, double max) { - return getPIDControllerInstance().setOutputRange(min, max); - } - - public REVLibError setOutputRange(double min, double max, int slotID) { - return getPIDControllerInstance().setOutputRange(min, max, slotID); - } - - public double getP() { - return getPIDControllerInstance().getP(); - } - - public double getP(int slotID) { - return getPIDControllerInstance().getP(slotID); - } - - public double getI() { - return getPIDControllerInstance().getI(); - } - - public double getI(int slotID) { - return getPIDControllerInstance().getI(slotID); - } - - public double getD() { - return getPIDControllerInstance().getD(); - } - - public double getD(int slotID) { - return getPIDControllerInstance().getD(slotID); - } - - public double getDFilter(int slotID) { - return getPIDControllerInstance().getDFilter(slotID); - } - - public double getFF() { - return getPIDControllerInstance().getFF(); - } - - public double getFF(int slotID) { - return getPIDControllerInstance().getFF(slotID); - } - - public double getIZone() { - return getPIDControllerInstance().getIZone(); - } - - public double getIZone(int slotID) { - return getPIDControllerInstance().getIZone(slotID); - } - - public double getOutputMin() { - return getPIDControllerInstance().getOutputMin(); - } - - public double getOutputMin(int slotID) { - return getPIDControllerInstance().getOutputMin(slotID); - } - - public double getOutputMax() { - return getPIDControllerInstance().getOutputMax(); - } - - public double getOutputMax(int slotID) { - return getPIDControllerInstance().getOutputMax(slotID); - } - - public REVLibError setSmartMotionMaxVelocity(double maxVel, int slotID) { - return getPIDControllerInstance().setSmartMotionMaxVelocity(maxVel, slotID); - } - - public REVLibError setSmartMotionMaxAccel(double maxAccel, int slotID) { - return getPIDControllerInstance().setSmartMotionMaxAccel(maxAccel, slotID); - } - - public REVLibError setSmartMotionMinOutputVelocity(double minVel, int slotID) { - return getPIDControllerInstance().setSmartMotionMinOutputVelocity(minVel, slotID); - } - - public REVLibError setSmartMotionAllowedClosedLoopError(double allowedErr, int slotID) { - return getPIDControllerInstance().setSmartMotionAllowedClosedLoopError(allowedErr, slotID); - } - - public REVLibError setSmartMotionAccelStrategy(AccelStrategy accelStrategy, int slotID) { - return getPIDControllerInstance().setSmartMotionAccelStrategy(accelStrategy, slotID); - } - - public double getSmartMotionMaxVelocity(int slotID) { - return getPIDControllerInstance().getSmartMotionMaxVelocity(slotID); - } - - public double getSmartMotionMaxAccel(int slotID) { - return getPIDControllerInstance().getSmartMotionMaxAccel(slotID); - } - - public double getSmartMotionMinOutputVelocity(int slotID) { - return getPIDControllerInstance().getSmartMotionMinOutputVelocity(slotID); - } - - public double getSmartMotionAllowedClosedLoopError(int slotID) { - return getPIDControllerInstance().getSmartMotionAllowedClosedLoopError(slotID); - } - - public AccelStrategy getSmartMotionAccelStrategy(int slotID) { - return getPIDControllerInstance().getSmartMotionAccelStrategy(slotID); - } - - public REVLibError setIMaxAccum(double iMaxAccum, int slotID) { - return getPIDControllerInstance().setIMaxAccum(iMaxAccum, slotID); - } - - public double getIMaxAccum(int slotID) { - return getPIDControllerInstance().getIMaxAccum(slotID); - } - - public REVLibError setIAccum(double iAccum) { - return getPIDControllerInstance().setIAccum(iAccum); - } - - public double getIAccum() { - return getPIDControllerInstance().getIAccum(); - } - - public REVLibError setFeedbackDevice(MotorFeedbackSensor sensor) { - return getPIDControllerInstance().setFeedbackDevice(sensor); - } - - public REVLibError setReference(double value, ControlType ctrl) { - return getPIDControllerInstance().setReference(value, ctrl); - } - - public REVLibError setReference(double value, ControlType ctrl, int pidSlot) { - return getPIDControllerInstance().setReference(value, ctrl, pidSlot); - } - - public REVLibError setReference(double value, ControlType ctrl, int pidSlot, double arbFeedforward) { - return getPIDControllerInstance().setReference(value, ctrl, pidSlot, arbFeedforward); - } - - public REVLibError setReference(double value, ControlType ctrl, int pidSlot, double arbFeedforward, - ArbFFUnits arbFFUnits) { - return getPIDControllerInstance().setReference(value, ctrl, pidSlot, arbFeedforward, arbFFUnits); - } - - public String toString() { - return getPIDControllerInstance().toString(); - } - - @Override - public void setForwardLimitSwitch(com.revrobotics.SparkMaxLimitSwitch.Type switchType, boolean enabled) { - internalSpark.getForwardLimitSwitch(switchType).enableLimitSwitch(enabled); - } - - @Override - public void setReverseLimitSwitch(com.revrobotics.SparkMaxLimitSwitch.Type switchType, boolean enabled) { - internalSpark.getReverseLimitSwitch(switchType).enableLimitSwitch(enabled); - } - - @Override - public boolean getForwardLimitSwitchPressed(com.revrobotics.SparkMaxLimitSwitch.Type switchType) { - return internalSpark.getForwardLimitSwitch(switchType).isPressed(); - } - - @Override - public boolean getReverseLimitSwitchPressed(com.revrobotics.SparkMaxLimitSwitch.Type switchType) { - return internalSpark.getReverseLimitSwitch(switchType).isPressed(); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/actuators/wpi_adapters/CANTalonWPIAdapter.java b/src/main/java/xbot/common/controls/actuators/wpi_adapters/CANTalonWPIAdapter.java deleted file mode 100644 index 28115b81..00000000 --- a/src/main/java/xbot/common/controls/actuators/wpi_adapters/CANTalonWPIAdapter.java +++ /dev/null @@ -1,580 +0,0 @@ -package xbot.common.controls.actuators.wpi_adapters; - -import com.ctre.phoenix.ErrorCode; -import com.ctre.phoenix.ParamEnum; -import com.ctre.phoenix.motion.MotionProfileStatus; -import com.ctre.phoenix.motion.TrajectoryPoint; -import com.ctre.phoenix.motorcontrol.ControlFrame; -import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.DemandType; -import com.ctre.phoenix.motorcontrol.Faults; -import com.ctre.phoenix.motorcontrol.FeedbackDevice; -import com.ctre.phoenix.motorcontrol.IMotorController; -import com.ctre.phoenix.motorcontrol.InvertType; -import com.ctre.phoenix.motorcontrol.LimitSwitchNormal; -import com.ctre.phoenix.motorcontrol.LimitSwitchSource; -import com.ctre.phoenix.motorcontrol.NeutralMode; -import com.ctre.phoenix.motorcontrol.RemoteFeedbackDevice; -import com.ctre.phoenix.motorcontrol.RemoteLimitSwitchSource; -import com.ctre.phoenix.motorcontrol.RemoteSensorSource; -import com.ctre.phoenix.motorcontrol.SensorCollection; -import com.ctre.phoenix.motorcontrol.SensorTerm; -import com.ctre.phoenix.motorcontrol.StatusFrame; -import com.ctre.phoenix.motorcontrol.StatusFrameEnhanced; -import com.ctre.phoenix.motorcontrol.StickyFaults; -import com.ctre.phoenix.motorcontrol.SupplyCurrentLimitConfiguration; -import com.ctre.phoenix.motorcontrol.can.BaseTalon; -import com.ctre.phoenix.motorcontrol.can.TalonSRX; -import com.ctre.phoenix.sensors.CANCoder; -import com.ctre.phoenix.sensors.SensorVelocityMeasPeriod; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.electrical_contract.CANTalonInfo; -import xbot.common.properties.PropertyFactory; - -public class CANTalonWPIAdapter extends XCANTalon { - - private TalonSRX internalTalon; - SensorCollection sensorCollection; - - @AssistedFactory - public abstract static class CANTalonWPIAdapterFactory implements XCANTalonFactory { - public abstract CANTalonWPIAdapter create(@Assisted("deviceInfo") CANTalonInfo deviceInfo); - } - - @AssistedInject - public CANTalonWPIAdapter(@Assisted("deviceInfo") CANTalonInfo deviceInfo, PropertyFactory propMan, DevicePolice police) { - super(deviceInfo.channel, propMan, police); - internalTalon = new TalonSRX(deviceInfo.channel); - setInverted(deviceInfo.inverted); - if (deviceInfo.feedbackDevice != null) { - configSelectedFeedbackSensor(deviceInfo.feedbackDevice, 0, 0); - setSensorPhase(deviceInfo.feedbackDeviceInverted); - } - } - - public ErrorCode setStatusFramePeriod(StatusFrameEnhanced frame, int periodMs, int timeoutMs) { - return internalTalon.setStatusFramePeriod(frame, periodMs, timeoutMs); - } - - public int getStatusFramePeriod(StatusFrameEnhanced frame, int timeoutMs) { - return internalTalon.getStatusFramePeriod(frame, timeoutMs); - } - - @SuppressWarnings("deprecation") - public ErrorCode configVelocityMeasurementPeriod(com.ctre.phoenix.motorcontrol.VelocityMeasPeriod period, int timeoutMs) { - return internalTalon.configVelocityMeasurementPeriod(period, timeoutMs); - } - - public ErrorCode configVelocityMeasurementWindow(int windowSize, int timeoutMs) { - return internalTalon.configVelocityMeasurementWindow(windowSize, timeoutMs); - } - - public ErrorCode configForwardLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int timeoutMs) { - return internalTalon.configForwardLimitSwitchSource(type, normalOpenOrClose, timeoutMs); - } - - public ErrorCode configReverseLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int timeoutMs) { - return internalTalon.configReverseLimitSwitchSource(type, normalOpenOrClose, timeoutMs); - } - - public ErrorCode configPeakCurrentLimit(int amps, int timeoutMs) { - return internalTalon.configPeakCurrentLimit(amps, timeoutMs); - } - - public long getHandle() { - return internalTalon.getHandle(); - } - - public int getDeviceID() { - return internalTalon.getDeviceID(); - } - - public void set(ControlMode mode, double outputValue) { - internalTalon.set(mode, outputValue); - } - - public ErrorCode configPeakCurrentDuration(int milliseconds, int timeoutMs) { - return internalTalon.configPeakCurrentDuration(milliseconds, timeoutMs); - } - - public ErrorCode configContinuousCurrentLimit(int amps, int timeoutMs) { - return internalTalon.configContinuousCurrentLimit(amps, timeoutMs); - } -/* - public boolean equals(Object obj) { - return internalTalon.equals(obj); - } -*/ - public void enableCurrentLimit(boolean enable) { - internalTalon.enableCurrentLimit(enable); - } - - public void neutralOutput() { - internalTalon.neutralOutput(); - } - - public void setNeutralMode(NeutralMode neutralMode) { - internalTalon.setNeutralMode(neutralMode); - } - - public void setSensorPhase(boolean PhaseSensor) { - internalTalon.setSensorPhase(PhaseSensor); - } - - public void setInverted(boolean invert) { - internalTalon.setInverted(invert); - } - - public boolean getInverted() { - return internalTalon.getInverted(); - } - - public ErrorCode configOpenloopRamp(double secondsFromNeutralToFull, int timeoutMs) { - return internalTalon.configOpenloopRamp(secondsFromNeutralToFull, timeoutMs); - } - - public ErrorCode configClosedloopRamp(double secondsFromNeutralToFull, int timeoutMs) { - return internalTalon.configClosedloopRamp(secondsFromNeutralToFull, timeoutMs); - } - - public ErrorCode configPeakOutputForward(double percentOut, int timeoutMs) { - return internalTalon.configPeakOutputForward(percentOut, timeoutMs); - } - - public ErrorCode configPeakOutputReverse(double percentOut, int timeoutMs) { - return internalTalon.configPeakOutputReverse(percentOut, timeoutMs); - } - - public ErrorCode configNominalOutputForward(double percentOut, int timeoutMs) { - return internalTalon.configNominalOutputForward(percentOut, timeoutMs); - } - - public ErrorCode configNominalOutputReverse(double percentOut, int timeoutMs) { - return internalTalon.configNominalOutputReverse(percentOut, timeoutMs); - } - - public String toString() { - return internalTalon.toString(); - } - - public ErrorCode configNeutralDeadband(double percentDeadband, int timeoutMs) { - return internalTalon.configNeutralDeadband(percentDeadband, timeoutMs); - } - - public ErrorCode configVoltageCompSaturation(double voltage, int timeoutMs) { - return internalTalon.configVoltageCompSaturation(voltage, timeoutMs); - } - - public ErrorCode configVoltageMeasurementFilter(int filterWindowSamples, int timeoutMs) { - return internalTalon.configVoltageMeasurementFilter(filterWindowSamples, timeoutMs); - } - - public void enableVoltageCompensation(boolean enable) { - internalTalon.enableVoltageCompensation(enable); - } - - public double getBusVoltage() { - return internalTalon.getBusVoltage(); - } - - public double getMotorOutputPercent() { - return internalTalon.getMotorOutputPercent(); - } - - public double getMotorOutputVoltage() { - return internalTalon.getMotorOutputVoltage(); - } - - public double getOutputCurrent() { - return internalTalon.getStatorCurrent(); - } - - public double getTemperature() { - return internalTalon.getTemperature(); - } - - public ErrorCode configSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx, int timeoutMs) { - return internalTalon.configSelectedFeedbackSensor(feedbackDevice, pidIdx, timeoutMs); - } - - public ErrorCode configSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx, int timeoutMs) { - return internalTalon.configSelectedFeedbackSensor(feedbackDevice, pidIdx, timeoutMs); - } - - public ErrorCode configRemoteFeedbackFilter(int deviceID, RemoteSensorSource remoteSensorSource, int remoteOrdinal, - int timeoutMs) { - return internalTalon.configRemoteFeedbackFilter(deviceID, remoteSensorSource, remoteOrdinal, timeoutMs); - } - - public ErrorCode configSensorTerm(SensorTerm sensorTerm, FeedbackDevice feedbackDevice, int timeoutMs) { - return internalTalon.configSensorTerm(sensorTerm, feedbackDevice, timeoutMs); - } - - public double getSelectedSensorPosition(int pidIdx) { - return internalTalon.getSelectedSensorPosition(pidIdx); - } - - public double getSelectedSensorVelocity(int pidIdx) { - return internalTalon.getSelectedSensorVelocity(pidIdx); - } - - public ErrorCode setSelectedSensorPosition(int sensorPos, int pidIdx, int timeoutMs) { - return internalTalon.setSelectedSensorPosition(sensorPos, pidIdx, timeoutMs); - } - - public ErrorCode setControlFramePeriod(ControlFrame frame, int periodMs) { - return internalTalon.setControlFramePeriod(frame, periodMs); - } - - public ErrorCode setControlFramePeriod(int frame, int periodMs) { - return internalTalon.setControlFramePeriod(frame, periodMs); - } - - public ErrorCode setStatusFramePeriod(int frameValue, int periodMs, int timeoutMs) { - return internalTalon.setStatusFramePeriod(frameValue, periodMs, timeoutMs); - } - - public ErrorCode setStatusFramePeriod(StatusFrame frame, int periodMs, int timeoutMs) { - return internalTalon.setStatusFramePeriod(frame, periodMs, timeoutMs); - } - - public int getStatusFramePeriod(int frame, int timeoutMs) { - return internalTalon.getStatusFramePeriod(frame, timeoutMs); - } - - public int getStatusFramePeriod(StatusFrame frame, int timeoutMs) { - return internalTalon.getStatusFramePeriod(frame, timeoutMs); - } - - public ErrorCode configForwardLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID, int timeoutMs) { - return internalTalon.configForwardLimitSwitchSource(type, normalOpenOrClose, deviceID, timeoutMs); - } - - public ErrorCode configReverseLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID, int timeoutMs) { - return internalTalon.configReverseLimitSwitchSource(type, normalOpenOrClose, deviceID, timeoutMs); - } - - public void overrideLimitSwitchesEnable(boolean enable) { - internalTalon.overrideLimitSwitchesEnable(enable); - } - - public ErrorCode configForwardSoftLimitThreshold(int forwardSensorLimit, int timeoutMs) { - return internalTalon.configForwardSoftLimitThreshold(forwardSensorLimit, timeoutMs); - } - - public ErrorCode configReverseSoftLimitThreshold(int reverseSensorLimit, int timeoutMs) { - return internalTalon.configReverseSoftLimitThreshold(reverseSensorLimit, timeoutMs); - } - - public ErrorCode configForwardSoftLimitEnable(boolean enable, int timeoutMs) { - return internalTalon.configForwardSoftLimitEnable(enable, timeoutMs); - } - - public ErrorCode configReverseSoftLimitEnable(boolean enable, int timeoutMs) { - return internalTalon.configReverseSoftLimitEnable(enable, timeoutMs); - } - - public void overrideSoftLimitsEnable(boolean enable) { - internalTalon.overrideSoftLimitsEnable(enable); - } - - public boolean isFwdLimitSwitchClosed() { - return internalTalon.getSensorCollection().isFwdLimitSwitchClosed(); - } - - public boolean isRevLimitSwitchClosed() { - return internalTalon.getSensorCollection().isRevLimitSwitchClosed(); - } - - public ErrorCode config_kP(int slotIdx, double value, int timeoutMs) { - return internalTalon.config_kP(slotIdx, value, timeoutMs); - } - - public ErrorCode config_kI(int slotIdx, double value, int timeoutMs) { - return internalTalon.config_kI(slotIdx, value, timeoutMs); - } - - public ErrorCode config_kD(int slotIdx, double value, int timeoutMs) { - return internalTalon.config_kD(slotIdx, value, timeoutMs); - } - - public ErrorCode config_kF(int slotIdx, double value, int timeoutMs) { - return internalTalon.config_kF(slotIdx, value, timeoutMs); - } - - public ErrorCode config_IntegralZone(int slotIdx, int izone, int timeoutMs) { - return internalTalon.config_IntegralZone(slotIdx, izone, timeoutMs); - } - - public ErrorCode configAllowableClosedloopError(int slotIdx, int allowableClosedLoopError, int timeoutMs) { - return internalTalon.configAllowableClosedloopError(slotIdx, allowableClosedLoopError, timeoutMs); - } - - public ErrorCode configMaxIntegralAccumulator(int slotIdx, double iaccum, int timeoutMs) { - return internalTalon.configMaxIntegralAccumulator(slotIdx, iaccum, timeoutMs); - } - - public ErrorCode setIntegralAccumulator(double iaccum, int pidIdx, int timeoutMs) { - return internalTalon.setIntegralAccumulator(iaccum, pidIdx, timeoutMs); - } - - public double getClosedLoopError(int pidIdx) { - return internalTalon.getClosedLoopError(pidIdx); - } - - public double getIntegralAccumulator(int pidIdx) { - return internalTalon.getIntegralAccumulator(pidIdx); - } - - public double getErrorDerivative(int pidIdx) { - return internalTalon.getErrorDerivative(pidIdx); - } - - public void selectProfileSlot(int slotIdx, int pidIdx) { - internalTalon.selectProfileSlot(slotIdx, pidIdx); - } - - public double getActiveTrajectoryPosition() { - return internalTalon.getActiveTrajectoryPosition(); - } - - public double getActiveTrajectoryVelocity() { - return internalTalon.getActiveTrajectoryVelocity(); - } - - public ErrorCode configMotionCruiseVelocity(int sensorUnitsPer100ms, int timeoutMs) { - return internalTalon.configMotionCruiseVelocity(sensorUnitsPer100ms, timeoutMs); - } - - public ErrorCode configMotionAcceleration(int sensorUnitsPer100msPerSec, int timeoutMs) { - return internalTalon.configMotionAcceleration(sensorUnitsPer100msPerSec, timeoutMs); - } - - public ErrorCode clearMotionProfileTrajectories() { - return internalTalon.clearMotionProfileTrajectories(); - } - - public int getMotionProfileTopLevelBufferCount() { - return internalTalon.getMotionProfileTopLevelBufferCount(); - } - - public ErrorCode pushMotionProfileTrajectory(TrajectoryPoint trajPt) { - return internalTalon.pushMotionProfileTrajectory(trajPt); - } - - public boolean isMotionProfileTopLevelBufferFull() { - return internalTalon.isMotionProfileTopLevelBufferFull(); - } - - public void processMotionProfileBuffer() { - internalTalon.processMotionProfileBuffer(); - } - - public ErrorCode getMotionProfileStatus(MotionProfileStatus statusToFill) { - return internalTalon.getMotionProfileStatus(statusToFill); - } - - public ErrorCode clearMotionProfileHasUnderrun(int timeoutMs) { - return internalTalon.clearMotionProfileHasUnderrun(timeoutMs); - } - - public ErrorCode changeMotionControlFramePeriod(int periodMs) { - return internalTalon.changeMotionControlFramePeriod(periodMs); - } - - public ErrorCode getLastError() { - return internalTalon.getLastError(); - } - - public ErrorCode getFaults(Faults toFill) { - return internalTalon.getFaults(toFill); - } - - public ErrorCode getStickyFaults(StickyFaults toFill) { - return internalTalon.getStickyFaults(toFill); - } - - public ErrorCode clearStickyFaults(int timeoutMs) { - return internalTalon.clearStickyFaults(timeoutMs); - } - - public int getFirmwareVersion() { - return internalTalon.getFirmwareVersion(); - } - - public boolean hasResetOccurred() { - return internalTalon.hasResetOccurred(); - } - - public ErrorCode configSetCustomParam(int newValue, int paramIndex, int timeoutMs) { - return internalTalon.configSetCustomParam(newValue, paramIndex, timeoutMs); - } - - public int configGetCustomParam(int paramIndex, int timoutMs) { - return internalTalon.configGetCustomParam(paramIndex, timoutMs); - } - - public ErrorCode configSetParameter(ParamEnum param, double value, int subValue, int ordinal, int timeoutMs) { - return internalTalon.configSetParameter(param, value, subValue, ordinal, timeoutMs); - } - - public ErrorCode configSetParameter(int param, double value, int subValue, int ordinal, int timeoutMs) { - return internalTalon.configSetParameter(param, value, subValue, ordinal, timeoutMs); - } - - public double configGetParameter(ParamEnum param, int ordinal, int timeoutMs) { - return internalTalon.configGetParameter(param, ordinal, timeoutMs); - } - - public double configGetParameter(int param, int ordinal, int timeoutMs) { - return internalTalon.configGetParameter(param, ordinal, timeoutMs); - } - - public int getBaseID() { - return internalTalon.getBaseID(); - } - - public void follow(IMotorController masterToFollow) { - internalTalon.follow(masterToFollow); - } - - public void valueUpdated() { - internalTalon.valueUpdated(); - } - - public SensorCollection getSensorCollection() { - return internalTalon.getSensorCollection(); - } - - public ControlMode getControlMode() { - return internalTalon.getControlMode(); - } - - @Override - public void set(ControlMode Mode, double demand0, DemandType demand1Type, double demand1) { - internalTalon.set(Mode, demand0, demand1Type, demand1); - } - - @Override - public ErrorCode configSelectedFeedbackCoefficient(double coefficient, int pidIdx, int timeoutMs) { - return internalTalon.configSelectedFeedbackCoefficient(coefficient, pidIdx, timeoutMs); - } - - @Override - public ErrorCode configClosedLoopPeakOutput(int slotIdx, double percentOut, int timeoutMs) { - return internalTalon.configClosedLoopPeakOutput(slotIdx, percentOut, timeoutMs); - } - - @Override - public ErrorCode configClosedLoopPeriod(int slotIdx, int loopTimeMs, int timeoutMs) { - return internalTalon.configClosedLoopPeriod(slotIdx, loopTimeMs, timeoutMs); - } - - @Override - public ErrorCode configAuxPIDPolarity(boolean invert, int timeoutMs) { - return internalTalon.configAuxPIDPolarity(invert, timeoutMs); - } - - @Override - public double getClosedLoopTarget(int pidIdx) { - return internalTalon.getClosedLoopTarget(pidIdx); - } - - @Override - public ErrorCode configMotionProfileTrajectoryPeriod(int baseTrajDurationMs, int timeoutMs) { - return internalTalon.configMotionProfileTrajectoryPeriod(baseTrajDurationMs, timeoutMs); - } - - @Override - public ErrorCode configMotionSCurveStrength(int curveStrength, int timeoutMs) { - return internalTalon.configMotionSCurveStrength(curveStrength, timeoutMs); - } - - private SensorCollection getSensorCollectionInstance() { - if (sensorCollection == null) { - sensorCollection = internalTalon.getSensorCollection(); - } - return sensorCollection; - } - - @Override - public int getPulseWidthRiseToFallUs() { - return getSensorCollectionInstance().getPulseWidthRiseToRiseUs(); - } - - @Override - public ErrorCode configSupplyCurrentLimit(SupplyCurrentLimitConfiguration currLimitCfg, int timeoutMs) { - return null; - } - - @Override - public void setInverted(InvertType invertType) { - - } - - @Override - public ErrorCode configRemoteFeedbackFilter(CANCoder canCoderRef, int remoteOrdinal, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configRemoteFeedbackFilter(BaseTalon talonRef, int remoteOrdinal, int timeoutMs) { - return null; - } - - @Override - public ErrorCode setSelectedSensorPosition(double sensorPos, int pidIdx, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configForwardSoftLimitThreshold(double forwardSensorLimit, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configReverseSoftLimitThreshold(double reverseSensorLimit, int timeoutMs) { - return null; - } - - @Override - public ErrorCode config_IntegralZone(int slotIdx, double izone, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configAllowableClosedloopError(int slotIdx, double allowableCloseLoopError, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMotionCruiseVelocity(double sensorUnitsPer100ms, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMotionAcceleration(double sensorUnitsPer100msPerSec, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configVelocityMeasurementPeriod(SensorVelocityMeasPeriod period, int timeoutMs) { - return null; - } - - @Override - public double getActiveTrajectoryHeading() { - return 0; - } - -} diff --git a/src/main/java/xbot/common/controls/actuators/wpi_adapters/CANVictorSPXWpiAdapter.java b/src/main/java/xbot/common/controls/actuators/wpi_adapters/CANVictorSPXWpiAdapter.java deleted file mode 100644 index f9919518..00000000 --- a/src/main/java/xbot/common/controls/actuators/wpi_adapters/CANVictorSPXWpiAdapter.java +++ /dev/null @@ -1,975 +0,0 @@ -package xbot.common.controls.actuators.wpi_adapters; - -import com.ctre.phoenix.ErrorCode; -import com.ctre.phoenix.ParamEnum; -import com.ctre.phoenix.motion.BufferedTrajectoryPointStream; -import com.ctre.phoenix.motion.MotionProfileStatus; -import com.ctre.phoenix.motion.TrajectoryPoint; -import com.ctre.phoenix.motorcontrol.ControlFrame; -import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.DemandType; -import com.ctre.phoenix.motorcontrol.Faults; -import com.ctre.phoenix.motorcontrol.FeedbackDevice; -import com.ctre.phoenix.motorcontrol.FollowerType; -import com.ctre.phoenix.motorcontrol.IMotorController; -import com.ctre.phoenix.motorcontrol.InvertType; -import com.ctre.phoenix.motorcontrol.LimitSwitchNormal; -import com.ctre.phoenix.motorcontrol.LimitSwitchSource; -import com.ctre.phoenix.motorcontrol.NeutralMode; -import com.ctre.phoenix.motorcontrol.RemoteFeedbackDevice; -import com.ctre.phoenix.motorcontrol.RemoteLimitSwitchSource; -import com.ctre.phoenix.motorcontrol.RemoteSensorSource; -import com.ctre.phoenix.motorcontrol.SensorTerm; -import com.ctre.phoenix.motorcontrol.StatusFrame; -import com.ctre.phoenix.motorcontrol.StatusFrameEnhanced; -import com.ctre.phoenix.motorcontrol.StickyFaults; -import com.ctre.phoenix.motorcontrol.SupplyCurrentLimitConfiguration; -import com.ctre.phoenix.motorcontrol.can.BaseTalon; -import com.ctre.phoenix.motorcontrol.can.FilterConfiguration; -import com.ctre.phoenix.motorcontrol.can.SlotConfiguration; -import com.ctre.phoenix.motorcontrol.can.VictorSPX; -import com.ctre.phoenix.motorcontrol.can.VictorSPXConfiguration; -import com.ctre.phoenix.motorcontrol.can.VictorSPXPIDSetConfiguration; -import com.ctre.phoenix.sensors.CANCoder; -import com.ctre.phoenix.sensors.SensorVelocityMeasPeriod; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.actuators.XCANVictorSPX; -import xbot.common.injection.DevicePolice; -import xbot.common.properties.PropertyFactory; - -public class CANVictorSPXWpiAdapter extends XCANVictorSPX { - - final VictorSPX internalVictor; - - @AssistedFactory - public abstract static class CANVictorSPXWpiAdapterFactory implements XCANVictorSPXFactory { - public abstract CANVictorSPXWpiAdapter create(@Assisted("deviceId") int deviceId); - } - - @AssistedInject - public CANVictorSPXWpiAdapter(@Assisted("deviceId") int deviceId, PropertyFactory propMan, DevicePolice police) { - super(deviceId, propMan, police); - internalVictor = new VictorSPX(deviceId); - } - - //CHECKSTYLE:OFF - - public ErrorCode DestroyObject() { - return internalVictor.DestroyObject(); - } - - public boolean equals(Object obj) { - return internalVictor.equals(obj); - } - - public long getHandle() { - return internalVictor.getHandle(); - } - - public int getDeviceID() { - return internalVictor.getDeviceID(); - } - - public void getPIDConfigs(VictorSPXPIDSetConfiguration pid, int pidIdx, int timeoutMs) { - internalVictor.getPIDConfigs(pid, pidIdx, timeoutMs); - } - - public int hashCode() { - return internalVictor.hashCode(); - } - - public void set(ControlMode mode, double outputValue) { - internalVictor.set(mode, outputValue); - } - - public void getPIDConfigs(VictorSPXPIDSetConfiguration pid) { - internalVictor.getPIDConfigs(pid); - } - - public ErrorCode configAllSettings(VictorSPXConfiguration allConfigs, int timeoutMs) { - return internalVictor.configAllSettings(allConfigs, timeoutMs); - } - - public void set(ControlMode mode, double demand0, DemandType demand1Type, double demand1) { - internalVictor.set(mode, demand0, demand1Type, demand1); - } - - public ErrorCode configAllSettings(VictorSPXConfiguration allConfigs) { - return internalVictor.configAllSettings(allConfigs); - } - - public void getAllConfigs(VictorSPXConfiguration allConfigs, int timeoutMs) { - internalVictor.getAllConfigs(allConfigs, timeoutMs); - } - - public void neutralOutput() { - internalVictor.neutralOutput(); - } - - public void setNeutralMode(NeutralMode neutralMode) { - internalVictor.setNeutralMode(neutralMode); - } - - public void getAllConfigs(VictorSPXConfiguration allConfigs) { - internalVictor.getAllConfigs(allConfigs); - } - - public void setSensorPhase(boolean PhaseSensor) { - internalVictor.setSensorPhase(PhaseSensor); - } - - public void setInverted(boolean invert) { - internalVictor.setInverted(invert); - } - - public void setInverted(InvertType invertType) { - internalVictor.setInverted(invertType); - } - - public boolean getInverted() { - return internalVictor.getInverted(); - } - - public ErrorCode configFactoryDefault(int timeoutMs) { - return internalVictor.configFactoryDefault(timeoutMs); - } - - public ErrorCode configFactoryDefault() { - return internalVictor.configFactoryDefault(); - } - - public ErrorCode configOpenloopRamp(double secondsFromNeutralToFull, int timeoutMs) { - return internalVictor.configOpenloopRamp(secondsFromNeutralToFull, timeoutMs); - } - - public ErrorCode configOpenloopRamp(double secondsFromNeutralToFull) { - return internalVictor.configOpenloopRamp(secondsFromNeutralToFull); - } - - public ErrorCode configClosedloopRamp(double secondsFromNeutralToFull, int timeoutMs) { - return internalVictor.configClosedloopRamp(secondsFromNeutralToFull, timeoutMs); - } - - public ErrorCode configClosedloopRamp(double secondsFromNeutralToFull) { - return internalVictor.configClosedloopRamp(secondsFromNeutralToFull); - } - - public ErrorCode configPeakOutputForward(double percentOut, int timeoutMs) { - return internalVictor.configPeakOutputForward(percentOut, timeoutMs); - } - - public ErrorCode configPeakOutputForward(double percentOut) { - return internalVictor.configPeakOutputForward(percentOut); - } - - public ErrorCode configPeakOutputReverse(double percentOut, int timeoutMs) { - return internalVictor.configPeakOutputReverse(percentOut, timeoutMs); - } - - public ErrorCode configPeakOutputReverse(double percentOut) { - return internalVictor.configPeakOutputReverse(percentOut); - } - - public ErrorCode configNominalOutputForward(double percentOut, int timeoutMs) { - return internalVictor.configNominalOutputForward(percentOut, timeoutMs); - } - - public ErrorCode configNominalOutputForward(double percentOut) { - return internalVictor.configNominalOutputForward(percentOut); - } - - public ErrorCode configNominalOutputReverse(double percentOut, int timeoutMs) { - return internalVictor.configNominalOutputReverse(percentOut, timeoutMs); - } - - public ErrorCode configNominalOutputReverse(double percentOut) { - return internalVictor.configNominalOutputReverse(percentOut); - } - - public ErrorCode configNeutralDeadband(double percentDeadband, int timeoutMs) { - return internalVictor.configNeutralDeadband(percentDeadband, timeoutMs); - } - - public ErrorCode configNeutralDeadband(double percentDeadband) { - return internalVictor.configNeutralDeadband(percentDeadband); - } - - public ErrorCode configVoltageCompSaturation(double voltage, int timeoutMs) { - return internalVictor.configVoltageCompSaturation(voltage, timeoutMs); - } - - public ErrorCode configVoltageCompSaturation(double voltage) { - return internalVictor.configVoltageCompSaturation(voltage); - } - - public ErrorCode configVoltageMeasurementFilter(int filterWindowSamples, int timeoutMs) { - return internalVictor.configVoltageMeasurementFilter(filterWindowSamples, timeoutMs); - } - - public ErrorCode configVoltageMeasurementFilter(int filterWindowSamples) { - return internalVictor.configVoltageMeasurementFilter(filterWindowSamples); - } - - public void enableVoltageCompensation(boolean enable) { - internalVictor.enableVoltageCompensation(enable); - } - - public double getBusVoltage() { - return internalVictor.getBusVoltage(); - } - - public double getMotorOutputPercent() { - return internalVictor.getMotorOutputPercent(); - } - - public double getMotorOutputVoltage() { - return internalVictor.getMotorOutputVoltage(); - } - - public double getTemperature() { - return internalVictor.getTemperature(); - } - - public ErrorCode configSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx, int timeoutMs) { - return internalVictor.configSelectedFeedbackSensor(feedbackDevice, pidIdx, timeoutMs); - } - - public ErrorCode configSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice) { - return internalVictor.configSelectedFeedbackSensor(feedbackDevice); - } - - public ErrorCode configSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx, int timeoutMs) { - return internalVictor.configSelectedFeedbackSensor(feedbackDevice, pidIdx, timeoutMs); - } - - public ErrorCode configSelectedFeedbackSensor(FeedbackDevice feedbackDevice) { - return internalVictor.configSelectedFeedbackSensor(feedbackDevice); - } - - public ErrorCode configSelectedFeedbackCoefficient(double coefficient, int pidIdx, int timeoutMs) { - return internalVictor.configSelectedFeedbackCoefficient(coefficient, pidIdx, timeoutMs); - } - - public ErrorCode configSelectedFeedbackCoefficient(double coefficient) { - return internalVictor.configSelectedFeedbackCoefficient(coefficient); - } - - public ErrorCode configRemoteFeedbackFilter(int deviceID, RemoteSensorSource remoteSensorSource, int remoteOrdinal, - int timeoutMs) { - return internalVictor.configRemoteFeedbackFilter(deviceID, remoteSensorSource, remoteOrdinal, timeoutMs); - } - - public ErrorCode configRemoteFeedbackFilter(int deviceID, RemoteSensorSource remoteSensorSource, - int remoteOrdinal) { - return internalVictor.configRemoteFeedbackFilter(deviceID, remoteSensorSource, remoteOrdinal); - } - - public ErrorCode configSensorTerm(SensorTerm sensorTerm, FeedbackDevice feedbackDevice, int timeoutMs) { - return internalVictor.configSensorTerm(sensorTerm, feedbackDevice, timeoutMs); - } - - public ErrorCode configSensorTerm(SensorTerm sensorTerm, FeedbackDevice feedbackDevice) { - return internalVictor.configSensorTerm(sensorTerm, feedbackDevice); - } - - public ErrorCode configSensorTerm(SensorTerm sensorTerm, RemoteFeedbackDevice feedbackDevice, int timeoutMs) { - return internalVictor.configSensorTerm(sensorTerm, feedbackDevice, timeoutMs); - } - - public ErrorCode configSensorTerm(SensorTerm sensorTerm, RemoteFeedbackDevice feedbackDevice) { - return internalVictor.configSensorTerm(sensorTerm, feedbackDevice); - } - - public double getSelectedSensorPosition(int pidIdx) { - return internalVictor.getSelectedSensorPosition(pidIdx); - } - - public double getSelectedSensorPosition() { - return internalVictor.getSelectedSensorPosition(); - } - - public double getSelectedSensorVelocity(int pidIdx) { - return internalVictor.getSelectedSensorVelocity(pidIdx); - } - - public double getSelectedSensorVelocity() { - return internalVictor.getSelectedSensorVelocity(); - } - - public ErrorCode setSelectedSensorPosition(int sensorPos, int pidIdx, int timeoutMs) { - return internalVictor.setSelectedSensorPosition(sensorPos, pidIdx, timeoutMs); - } - - public ErrorCode setSelectedSensorPosition(int sensorPos) { - return internalVictor.setSelectedSensorPosition(sensorPos); - } - - public ErrorCode setControlFramePeriod(ControlFrame frame, int periodMs) { - return internalVictor.setControlFramePeriod(frame, periodMs); - } - - public ErrorCode setControlFramePeriod(int frame, int periodMs) { - return internalVictor.setControlFramePeriod(frame, periodMs); - } - - public ErrorCode setStatusFramePeriod(int frameValue, int periodMs, int timeoutMs) { - return internalVictor.setStatusFramePeriod(frameValue, periodMs, timeoutMs); - } - - public ErrorCode setStatusFramePeriod(int frameValue, int periodMs) { - return internalVictor.setStatusFramePeriod(frameValue, periodMs); - } - - public ErrorCode setStatusFramePeriod(StatusFrame frame, int periodMs, int timeoutMs) { - return internalVictor.setStatusFramePeriod(frame, periodMs, timeoutMs); - } - - public ErrorCode setStatusFramePeriod(StatusFrame frame, int periodMs) { - return internalVictor.setStatusFramePeriod(frame, periodMs); - } - - public int getStatusFramePeriod(int frame, int timeoutMs) { - return internalVictor.getStatusFramePeriod(frame, timeoutMs); - } - - public int getStatusFramePeriod(int frame) { - return internalVictor.getStatusFramePeriod(frame); - } - - public int getStatusFramePeriod(StatusFrame frame, int timeoutMs) { - return internalVictor.getStatusFramePeriod(frame, timeoutMs); - } - - public int getStatusFramePeriod(StatusFrame frame) { - return internalVictor.getStatusFramePeriod(frame); - } - - public int getStatusFramePeriod(StatusFrameEnhanced frame, int timeoutMs) { - return internalVictor.getStatusFramePeriod(frame, timeoutMs); - } - - public int getStatusFramePeriod(StatusFrameEnhanced frame) { - return internalVictor.getStatusFramePeriod(frame); - } - - @SuppressWarnings("deprecation") - public ErrorCode configVelocityMeasurementPeriod(com.ctre.phoenix.motorcontrol.VelocityMeasPeriod period, int timeoutMs) { - return internalVictor.configVelocityMeasurementPeriod(period, timeoutMs); - } - - @SuppressWarnings("deprecation") - public ErrorCode configVelocityMeasurementPeriod(com.ctre.phoenix.motorcontrol.VelocityMeasPeriod period) { - return internalVictor.configVelocityMeasurementPeriod(period); - } - - public ErrorCode configVelocityMeasurementWindow(int windowSize, int timeoutMs) { - return internalVictor.configVelocityMeasurementWindow(windowSize, timeoutMs); - } - - public ErrorCode configVelocityMeasurementWindow(int windowSize) { - return internalVictor.configVelocityMeasurementWindow(windowSize); - } - - public ErrorCode configForwardLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID, int timeoutMs) { - return internalVictor.configForwardLimitSwitchSource(type, normalOpenOrClose, deviceID, timeoutMs); - } - - public ErrorCode configForwardLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID) { - return internalVictor.configForwardLimitSwitchSource(type, normalOpenOrClose, deviceID); - } - - public ErrorCode configReverseLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID, int timeoutMs) { - return internalVictor.configReverseLimitSwitchSource(type, normalOpenOrClose, deviceID, timeoutMs); - } - - public ErrorCode configReverseLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID) { - return internalVictor.configReverseLimitSwitchSource(type, normalOpenOrClose, deviceID); - } - - public ErrorCode configForwardLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int timeoutMs) { - return internalVictor.configForwardLimitSwitchSource(type, normalOpenOrClose, timeoutMs); - } - - public ErrorCode configForwardLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose) { - return internalVictor.configForwardLimitSwitchSource(type, normalOpenOrClose); - } - - public void overrideLimitSwitchesEnable(boolean enable) { - internalVictor.overrideLimitSwitchesEnable(enable); - } - - public ErrorCode configForwardSoftLimitThreshold(int forwardSensorLimit, int timeoutMs) { - return internalVictor.configForwardSoftLimitThreshold(forwardSensorLimit, timeoutMs); - } - - public ErrorCode configForwardSoftLimitThreshold(int forwardSensorLimit) { - return internalVictor.configForwardSoftLimitThreshold(forwardSensorLimit); - } - - public ErrorCode configReverseSoftLimitThreshold(int reverseSensorLimit, int timeoutMs) { - return internalVictor.configReverseSoftLimitThreshold(reverseSensorLimit, timeoutMs); - } - - public ErrorCode configReverseSoftLimitThreshold(int reverseSensorLimit) { - return internalVictor.configReverseSoftLimitThreshold(reverseSensorLimit); - } - - public ErrorCode configForwardSoftLimitEnable(boolean enable, int timeoutMs) { - return internalVictor.configForwardSoftLimitEnable(enable, timeoutMs); - } - - public ErrorCode configForwardSoftLimitEnable(boolean enable) { - return internalVictor.configForwardSoftLimitEnable(enable); - } - - public ErrorCode configReverseSoftLimitEnable(boolean enable, int timeoutMs) { - return internalVictor.configReverseSoftLimitEnable(enable, timeoutMs); - } - - public ErrorCode configReverseSoftLimitEnable(boolean enable) { - return internalVictor.configReverseSoftLimitEnable(enable); - } - - public void overrideSoftLimitsEnable(boolean enable) { - internalVictor.overrideSoftLimitsEnable(enable); - } - - public ErrorCode config_kP(int slotIdx, double value, int timeoutMs) { - return internalVictor.config_kP(slotIdx, value, timeoutMs); - } - - public ErrorCode config_kP(int slotIdx, double value) { - return internalVictor.config_kP(slotIdx, value); - } - - public ErrorCode config_kI(int slotIdx, double value, int timeoutMs) { - return internalVictor.config_kI(slotIdx, value, timeoutMs); - } - - public ErrorCode config_kI(int slotIdx, double value) { - return internalVictor.config_kI(slotIdx, value); - } - - public ErrorCode config_kD(int slotIdx, double value, int timeoutMs) { - return internalVictor.config_kD(slotIdx, value, timeoutMs); - } - - public ErrorCode config_kD(int slotIdx, double value) { - return internalVictor.config_kD(slotIdx, value); - } - - public ErrorCode config_kF(int slotIdx, double value, int timeoutMs) { - return internalVictor.config_kF(slotIdx, value, timeoutMs); - } - - public ErrorCode config_kF(int slotIdx, double value) { - return internalVictor.config_kF(slotIdx, value); - } - - public ErrorCode config_IntegralZone(int slotIdx, int izone, int timeoutMs) { - return internalVictor.config_IntegralZone(slotIdx, izone, timeoutMs); - } - - public ErrorCode config_IntegralZone(int slotIdx, int izone) { - return internalVictor.config_IntegralZone(slotIdx, izone); - } - - public ErrorCode configAllowableClosedloopError(int slotIdx, int allowableClosedLoopError, int timeoutMs) { - return internalVictor.configAllowableClosedloopError(slotIdx, allowableClosedLoopError, timeoutMs); - } - - public ErrorCode configAllowableClosedloopError(int slotIdx, int allowableClosedLoopError) { - return internalVictor.configAllowableClosedloopError(slotIdx, allowableClosedLoopError); - } - - public ErrorCode configMaxIntegralAccumulator(int slotIdx, double iaccum, int timeoutMs) { - return internalVictor.configMaxIntegralAccumulator(slotIdx, iaccum, timeoutMs); - } - - public ErrorCode configMaxIntegralAccumulator(int slotIdx, double iaccum) { - return internalVictor.configMaxIntegralAccumulator(slotIdx, iaccum); - } - - public ErrorCode configClosedLoopPeakOutput(int slotIdx, double percentOut, int timeoutMs) { - return internalVictor.configClosedLoopPeakOutput(slotIdx, percentOut, timeoutMs); - } - - public ErrorCode configClosedLoopPeakOutput(int slotIdx, double percentOut) { - return internalVictor.configClosedLoopPeakOutput(slotIdx, percentOut); - } - - public ErrorCode configClosedLoopPeriod(int slotIdx, int loopTimeMs, int timeoutMs) { - return internalVictor.configClosedLoopPeriod(slotIdx, loopTimeMs, timeoutMs); - } - - public ErrorCode configClosedLoopPeriod(int slotIdx, int loopTimeMs) { - return internalVictor.configClosedLoopPeriod(slotIdx, loopTimeMs); - } - - public ErrorCode configAuxPIDPolarity(boolean invert, int timeoutMs) { - return internalVictor.configAuxPIDPolarity(invert, timeoutMs); - } - - public ErrorCode configAuxPIDPolarity(boolean invert) { - return internalVictor.configAuxPIDPolarity(invert); - } - - public ErrorCode setIntegralAccumulator(double iaccum, int pidIdx, int timeoutMs) { - return internalVictor.setIntegralAccumulator(iaccum, pidIdx, timeoutMs); - } - - public ErrorCode setIntegralAccumulator(double iaccum) { - return internalVictor.setIntegralAccumulator(iaccum); - } - - public double getClosedLoopError(int pidIdx) { - return internalVictor.getClosedLoopError(pidIdx); - } - - public double getClosedLoopError() { - return internalVictor.getClosedLoopError(); - } - - public double getIntegralAccumulator(int pidIdx) { - return internalVictor.getIntegralAccumulator(pidIdx); - } - - public double getIntegralAccumulator() { - return internalVictor.getIntegralAccumulator(); - } - - public double getErrorDerivative(int pidIdx) { - return internalVictor.getErrorDerivative(pidIdx); - } - - public double getErrorDerivative() { - return internalVictor.getErrorDerivative(); - } - - public void selectProfileSlot(int slotIdx, int pidIdx) { - internalVictor.selectProfileSlot(slotIdx, pidIdx); - } - - public double getClosedLoopTarget(int pidIdx) { - return internalVictor.getClosedLoopTarget(pidIdx); - } - - public double getClosedLoopTarget() { - return internalVictor.getClosedLoopTarget(); - } - - public double getActiveTrajectoryPosition() { - return internalVictor.getActiveTrajectoryPosition(); - } - - public double getActiveTrajectoryPosition(int pidIdx) { - return internalVictor.getActiveTrajectoryPosition(pidIdx); - } - - public double getActiveTrajectoryVelocity() { - return internalVictor.getActiveTrajectoryVelocity(); - } - - public double getActiveTrajectoryVelocity(int pidIdx) { - return internalVictor.getActiveTrajectoryVelocity(pidIdx); - } - - public double getActiveTrajectoryArbFeedFwd() { - return internalVictor.getActiveTrajectoryArbFeedFwd(); - } - - public double getActiveTrajectoryArbFeedFwd(int pidIdx) { - return internalVictor.getActiveTrajectoryArbFeedFwd(pidIdx); - } - - public ErrorCode configMotionCruiseVelocity(int sensorUnitsPer100ms, int timeoutMs) { - return internalVictor.configMotionCruiseVelocity(sensorUnitsPer100ms, timeoutMs); - } - - public ErrorCode configMotionCruiseVelocity(int sensorUnitsPer100ms) { - return internalVictor.configMotionCruiseVelocity(sensorUnitsPer100ms); - } - - public ErrorCode configMotionAcceleration(int sensorUnitsPer100msPerSec, int timeoutMs) { - return internalVictor.configMotionAcceleration(sensorUnitsPer100msPerSec, timeoutMs); - } - - public ErrorCode configMotionAcceleration(int sensorUnitsPer100msPerSec) { - return internalVictor.configMotionAcceleration(sensorUnitsPer100msPerSec); - } - - public ErrorCode configMotionSCurveStrength(int curveStrength, int timeoutMs) { - return internalVictor.configMotionSCurveStrength(curveStrength, timeoutMs); - } - - public ErrorCode configMotionSCurveStrength(int curveStrength) { - return internalVictor.configMotionSCurveStrength(curveStrength); - } - - public ErrorCode clearMotionProfileTrajectories() { - return internalVictor.clearMotionProfileTrajectories(); - } - - public int getMotionProfileTopLevelBufferCount() { - return internalVictor.getMotionProfileTopLevelBufferCount(); - } - - public ErrorCode pushMotionProfileTrajectory(TrajectoryPoint trajPt) { - return internalVictor.pushMotionProfileTrajectory(trajPt); - } - - public ErrorCode startMotionProfile(BufferedTrajectoryPointStream stream, int minBufferedPts, - ControlMode motionProfControlMode) { - return internalVictor.startMotionProfile(stream, minBufferedPts, motionProfControlMode); - } - - public boolean isMotionProfileFinished() { - return internalVictor.isMotionProfileFinished(); - } - - public boolean isMotionProfileTopLevelBufferFull() { - return internalVictor.isMotionProfileTopLevelBufferFull(); - } - - public void processMotionProfileBuffer() { - internalVictor.processMotionProfileBuffer(); - } - - public ErrorCode getMotionProfileStatus(MotionProfileStatus statusToFill) { - return internalVictor.getMotionProfileStatus(statusToFill); - } - - public ErrorCode clearMotionProfileHasUnderrun(int timeoutMs) { - return internalVictor.clearMotionProfileHasUnderrun(timeoutMs); - } - - public ErrorCode clearMotionProfileHasUnderrun() { - return internalVictor.clearMotionProfileHasUnderrun(); - } - - public ErrorCode changeMotionControlFramePeriod(int periodMs) { - return internalVictor.changeMotionControlFramePeriod(periodMs); - } - - public ErrorCode configMotionProfileTrajectoryPeriod(int baseTrajDurationMs, int timeoutMs) { - return internalVictor.configMotionProfileTrajectoryPeriod(baseTrajDurationMs, timeoutMs); - } - - public ErrorCode configMotionProfileTrajectoryPeriod(int baseTrajDurationMs) { - return internalVictor.configMotionProfileTrajectoryPeriod(baseTrajDurationMs); - } - - public ErrorCode configMotionProfileTrajectoryInterpolationEnable(boolean enable, int timeoutMs) { - return internalVictor.configMotionProfileTrajectoryInterpolationEnable(enable, timeoutMs); - } - - public ErrorCode configMotionProfileTrajectoryInterpolationEnable(boolean enable) { - return internalVictor.configMotionProfileTrajectoryInterpolationEnable(enable); - } - - public ErrorCode configFeedbackNotContinuous(boolean feedbackNotContinuous, int timeoutMs) { - return internalVictor.configFeedbackNotContinuous(feedbackNotContinuous, timeoutMs); - } - - public ErrorCode configRemoteSensorClosedLoopDisableNeutralOnLOS(boolean remoteSensorClosedLoopDisableNeutralOnLOS, - int timeoutMs) { - return internalVictor.configRemoteSensorClosedLoopDisableNeutralOnLOS(remoteSensorClosedLoopDisableNeutralOnLOS, - timeoutMs); - } - - public ErrorCode configClearPositionOnLimitF(boolean clearPositionOnLimitF, int timeoutMs) { - return internalVictor.configClearPositionOnLimitF(clearPositionOnLimitF, timeoutMs); - } - - public ErrorCode configClearPositionOnLimitR(boolean clearPositionOnLimitR, int timeoutMs) { - return internalVictor.configClearPositionOnLimitR(clearPositionOnLimitR, timeoutMs); - } - - public ErrorCode configClearPositionOnQuadIdx(boolean clearPositionOnQuadIdx, int timeoutMs) { - return internalVictor.configClearPositionOnQuadIdx(clearPositionOnQuadIdx, timeoutMs); - } - - public ErrorCode configLimitSwitchDisableNeutralOnLOS(boolean limitSwitchDisableNeutralOnLOS, int timeoutMs) { - return internalVictor.configLimitSwitchDisableNeutralOnLOS(limitSwitchDisableNeutralOnLOS, timeoutMs); - } - - public ErrorCode configSoftLimitDisableNeutralOnLOS(boolean softLimitDisableNeutralOnLOS, int timeoutMs) { - return internalVictor.configSoftLimitDisableNeutralOnLOS(softLimitDisableNeutralOnLOS, timeoutMs); - } - - public ErrorCode configPulseWidthPeriod_EdgesPerRot(int pulseWidthPeriod_EdgesPerRot, int timeoutMs) { - return internalVictor.configPulseWidthPeriod_EdgesPerRot(pulseWidthPeriod_EdgesPerRot, timeoutMs); - } - - public ErrorCode configPulseWidthPeriod_FilterWindowSz(int pulseWidthPeriod_FilterWindowSz, int timeoutMs) { - return internalVictor.configPulseWidthPeriod_FilterWindowSz(pulseWidthPeriod_FilterWindowSz, timeoutMs); - } - - public ErrorCode getLastError() { - return internalVictor.getLastError(); - } - - public ErrorCode getFaults(Faults toFill) { - return internalVictor.getFaults(toFill); - } - - public ErrorCode getStickyFaults(StickyFaults toFill) { - return internalVictor.getStickyFaults(toFill); - } - - public ErrorCode clearStickyFaults(int timeoutMs) { - return internalVictor.clearStickyFaults(timeoutMs); - } - - public ErrorCode clearStickyFaults() { - return internalVictor.clearStickyFaults(); - } - - public int getFirmwareVersion() { - return internalVictor.getFirmwareVersion(); - } - - public boolean hasResetOccurred() { - return internalVictor.hasResetOccurred(); - } - - public ErrorCode configSetCustomParam(int newValue, int paramIndex, int timeoutMs) { - return internalVictor.configSetCustomParam(newValue, paramIndex, timeoutMs); - } - - public ErrorCode configSetCustomParam(int newValue, int paramIndex) { - return internalVictor.configSetCustomParam(newValue, paramIndex); - } - - public int configGetCustomParam(int paramIndex, int timeoutMs) { - return internalVictor.configGetCustomParam(paramIndex, timeoutMs); - } - - public int configGetCustomParam(int paramIndex) { - return internalVictor.configGetCustomParam(paramIndex); - } - - public ErrorCode configSetParameter(ParamEnum param, double value, int subValue, int ordinal, int timeoutMs) { - return internalVictor.configSetParameter(param, value, subValue, ordinal, timeoutMs); - } - - public ErrorCode configSetParameter(ParamEnum param, double value, int subValue, int ordinal) { - return internalVictor.configSetParameter(param, value, subValue, ordinal); - } - - public ErrorCode configSetParameter(int param, double value, int subValue, int ordinal, int timeoutMs) { - return internalVictor.configSetParameter(param, value, subValue, ordinal, timeoutMs); - } - - public ErrorCode configSetParameter(int param, double value, int subValue, int ordinal) { - return internalVictor.configSetParameter(param, value, subValue, ordinal); - } - - public double configGetParameter(ParamEnum param, int ordinal, int timeoutMs) { - return internalVictor.configGetParameter(param, ordinal, timeoutMs); - } - - public double configGetParameter(ParamEnum param, int ordinal) { - return internalVictor.configGetParameter(param, ordinal); - } - - public double configGetParameter(int param, int ordinal, int timeoutMs) { - return internalVictor.configGetParameter(param, ordinal, timeoutMs); - } - - public double configGetParameter(int param, int ordinal) { - return internalVictor.configGetParameter(param, ordinal); - } - - public int getBaseID() { - return internalVictor.getBaseID(); - } - - public ControlMode getControlMode() { - return internalVictor.getControlMode(); - } - - public void follow(IMotorController masterToFollow, FollowerType followerType) { - internalVictor.follow(masterToFollow, followerType); - } - - public void follow(IMotorController masterToFollow) { - internalVictor.follow(masterToFollow); - } - - public String toString() { - return internalVictor.toString(); - } - - public void valueUpdated() { - internalVictor.valueUpdated(); - } - - @Deprecated - public ErrorCode configureSlot(SlotConfiguration slot) { - return internalVictor.configureSlot(slot); - } - - @Deprecated - public ErrorCode configureSlot(SlotConfiguration slot, int slotIdx, int timeoutMs) { - return internalVictor.configureSlot(slot, slotIdx, timeoutMs); - } - - public void getSlotConfigs(SlotConfiguration slot, int slotIdx, int timeoutMs) { - internalVictor.getSlotConfigs(slot, slotIdx, timeoutMs); - } - - public void getSlotConfigs(SlotConfiguration slot) { - internalVictor.getSlotConfigs(slot); - } - - @Deprecated - public ErrorCode configureFilter(FilterConfiguration filter, int ordinal, int timeoutMs, - boolean enableOptimizations) { - return internalVictor.configureFilter(filter, ordinal, timeoutMs, enableOptimizations); - } - - @Deprecated - public ErrorCode configureFilter(FilterConfiguration filter, int ordinal, int timeoutMs) { - return internalVictor.configureFilter(filter, ordinal, timeoutMs); - } - - @Deprecated - public ErrorCode configureFilter(FilterConfiguration filter) { - return internalVictor.configureFilter(filter); - } - - public void getFilterConfigs(FilterConfiguration filter, int ordinal, int timeoutMs) { - internalVictor.getFilterConfigs(filter, ordinal, timeoutMs); - } - - - public void getFilterConfigs(FilterConfiguration filter) { - internalVictor.getFilterConfigs(filter); - } - - /// - // The Victor can't do anything below this line. - /// - - @Override - public double getOutputCurrent() { - return 0; - } - - @Override - public ErrorCode setStatusFramePeriod(StatusFrameEnhanced frame, int periodMs, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configReverseLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int timeoutMs) { - return null; - } - - @Override - public boolean isFwdLimitSwitchClosed() { - return false; - } - - @Override - public boolean isRevLimitSwitchClosed() { - return false; - } - - @Override - public ErrorCode configPeakCurrentLimit(int amps, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configPeakCurrentDuration(int milliseconds, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configContinuousCurrentLimit(int amps, int timeoutMs) { - return null; - } - - @Override - public void enableCurrentLimit(boolean enable) { - } - - @Override - public int getPulseWidthRiseToFallUs() { - return 0; - } - - @Override - public ErrorCode configSupplyCurrentLimit(SupplyCurrentLimitConfiguration currLimitCfg, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configRemoteFeedbackFilter(CANCoder canCoderRef, int remoteOrdinal, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configRemoteFeedbackFilter(BaseTalon talonRef, int remoteOrdinal, int timeoutMs) { - return null; - } - - @Override - public ErrorCode setSelectedSensorPosition(double sensorPos, int pidIdx, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configForwardSoftLimitThreshold(double forwardSensorLimit, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configReverseSoftLimitThreshold(double reverseSensorLimit, int timeoutMs) { - return null; - } - - @Override - public ErrorCode config_IntegralZone(int slotIdx, double izone, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configAllowableClosedloopError(int slotIdx, double allowableCloseLoopError, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMotionCruiseVelocity(double sensorUnitsPer100ms, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMotionAcceleration(double sensorUnitsPer100msPerSec, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configVelocityMeasurementPeriod(SensorVelocityMeasPeriod period, int timeoutMs) { - return null; - } - - @Override - public double getActiveTrajectoryHeading() { - return 0; - } - - //CHECKSTYLE:ON -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/actuators/wpi_adapters/CompressorWPIAdapter.java b/src/main/java/xbot/common/controls/actuators/wpi_adapters/CompressorWPIAdapter.java deleted file mode 100644 index 64a00bbe..00000000 --- a/src/main/java/xbot/common/controls/actuators/wpi_adapters/CompressorWPIAdapter.java +++ /dev/null @@ -1,37 +0,0 @@ -package xbot.common.controls.actuators.wpi_adapters; - -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.Compressor; -import edu.wpi.first.wpilibj.PneumaticsModuleType; -import xbot.common.controls.actuators.XCompressor; - -public class CompressorWPIAdapter extends XCompressor { - Compressor compressor; - - @AssistedFactory - public abstract static class CompressorWPIAdapterFactory implements XCompressorFactory { - public abstract CompressorWPIAdapter create(); - } - - @AssistedInject - public CompressorWPIAdapter() { - this.compressor = new Compressor(PneumaticsModuleType.REVPH); - } - - @Override - public void disable() { - compressor.disable(); - } - - @Override - public void enable() { - compressor.enableDigital(); - } - - @Override - public boolean isEnabled() { - return compressor.isEnabled(); - } -} diff --git a/src/main/java/xbot/common/controls/actuators/wpi_adapters/DigitalOutputWPIAdapter.java b/src/main/java/xbot/common/controls/actuators/wpi_adapters/DigitalOutputWPIAdapter.java deleted file mode 100644 index f48c377b..00000000 --- a/src/main/java/xbot/common/controls/actuators/wpi_adapters/DigitalOutputWPIAdapter.java +++ /dev/null @@ -1,58 +0,0 @@ -package xbot.common.controls.actuators.wpi_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.DigitalOutput; -import xbot.common.controls.actuators.XDigitalOutput; -import xbot.common.injection.DevicePolice; - -public class DigitalOutputWPIAdapter extends XDigitalOutput { - - DigitalOutput adapter; - - @AssistedFactory - public abstract static class DigitalOutputWPIAdapterFactory implements XDigitalOutputFactory { - public abstract DigitalOutputWPIAdapter create(@Assisted("channel") int channel); - } - - @AssistedInject - public DigitalOutputWPIAdapter(@Assisted("channel") int channel, DevicePolice police) { - super(channel, police); - adapter = new DigitalOutput(channel); - } - - public void set(boolean value) { - adapter.set(value); - } - - public DigitalOutput getWPIDigitalOutput() { - return adapter; - } - - @Override - public void setPWMRate(double frequency) { - adapter.setPWMRate(frequency); - } - - @Override - public void enablePWM(double initialDutyCycle) { - adapter.enablePWM(initialDutyCycle); - } - - @Override - public void updateDutyCycle(double dutyCycle) { - adapter.updateDutyCycle(dutyCycle); - } - - @Override - public void disablePWM() { - adapter.disablePWM(); - } - - @Override - public boolean get() { - return adapter.get(); - } -} diff --git a/src/main/java/xbot/common/controls/actuators/wpi_adapters/PWMWPIAdapter.java b/src/main/java/xbot/common/controls/actuators/wpi_adapters/PWMWPIAdapter.java deleted file mode 100644 index 74915ee4..00000000 --- a/src/main/java/xbot/common/controls/actuators/wpi_adapters/PWMWPIAdapter.java +++ /dev/null @@ -1,56 +0,0 @@ -package xbot.common.controls.actuators.wpi_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.PWM; -import xbot.common.controls.actuators.XPWM; -import xbot.common.injection.DevicePolice; - -public class PWMWPIAdapter extends XPWM -{ - private PWM pwm; - - @AssistedFactory - public abstract static class PWMWPIAdapterFactory implements XPWMFactory { - public abstract PWMWPIAdapter create(@Assisted("channel") int channel); - } - - @AssistedInject - public PWMWPIAdapter(@Assisted("channel") int channel, DevicePolice police) - { - super(channel, police); - pwm = new PWM(channel); - } - - @Override - public void setRaw(int value) { - pwm.setRaw(value); - } - - @Override - public int getRaw() { - return pwm.getRaw(); - } - - @Override - public void setSigned(double value) { - pwm.setSpeed(value); - } - - @Override - public double getSigned() { - return pwm.getSpeed(); - } - - @Override - public void setUnsigned(double value) { - pwm.setPosition(value); - } - - @Override - public double getUnsigned() { - return pwm.getPosition(); - } -} diff --git a/src/main/java/xbot/common/controls/actuators/wpi_adapters/RelayWPIAdapter.java b/src/main/java/xbot/common/controls/actuators/wpi_adapters/RelayWPIAdapter.java deleted file mode 100644 index dffaa1bf..00000000 --- a/src/main/java/xbot/common/controls/actuators/wpi_adapters/RelayWPIAdapter.java +++ /dev/null @@ -1,31 +0,0 @@ -package xbot.common.controls.actuators.wpi_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.Relay; -import edu.wpi.first.wpilibj.Relay.Value; -import xbot.common.controls.actuators.XRelay; -import xbot.common.injection.DevicePolice; - -public class RelayWPIAdapter extends XRelay { - - Relay internalRelay; - - @AssistedFactory - public abstract static class RelayWPIAdapterFactory implements XRelayFactory { - public abstract RelayWPIAdapter create(@Assisted("channel") int channel); - } - - @AssistedInject - public RelayWPIAdapter(@Assisted("channel") int channel, DevicePolice police) { - super(channel, police); - internalRelay = new Relay(channel); - } - - @Override - public void set(Value value) { - internalRelay.set(value); - } -} diff --git a/src/main/java/xbot/common/controls/actuators/wpi_adapters/ServoWPIAdapter.java b/src/main/java/xbot/common/controls/actuators/wpi_adapters/ServoWPIAdapter.java deleted file mode 100644 index a58d584e..00000000 --- a/src/main/java/xbot/common/controls/actuators/wpi_adapters/ServoWPIAdapter.java +++ /dev/null @@ -1,30 +0,0 @@ -package xbot.common.controls.actuators.wpi_adapters; - -import xbot.common.controls.actuators.XServo; -import xbot.common.injection.DevicePolice; -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.Servo; - -public class ServoWPIAdapter extends XServo{ - - Servo servo; - - @AssistedFactory - public abstract static class ServoWPIAdapterFactory implements XServoFactory { - public abstract ServoWPIAdapter create(@Assisted("channel") int channel); - } - - @AssistedInject - public ServoWPIAdapter(@Assisted("channel") int channel, DevicePolice police) { - super(channel, police); - this.servo = new Servo(channel); - } - - @Override - public void set(double value) { - this.servo.set(value); - } -} diff --git a/src/main/java/xbot/common/controls/actuators/wpi_adapters/SolenoidWPIAdapter.java b/src/main/java/xbot/common/controls/actuators/wpi_adapters/SolenoidWPIAdapter.java deleted file mode 100644 index afed150e..00000000 --- a/src/main/java/xbot/common/controls/actuators/wpi_adapters/SolenoidWPIAdapter.java +++ /dev/null @@ -1,43 +0,0 @@ -package xbot.common.controls.actuators.wpi_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.PneumaticsModuleType; -import edu.wpi.first.wpilibj.Solenoid; -import xbot.common.controls.actuators.XSolenoid; -import xbot.common.injection.DevicePolice; - -public class SolenoidWPIAdapter extends XSolenoid { - - private static final int SOLENOID_CHANNEL_COUNT = 16; - - Solenoid solenoid; - - @AssistedFactory - public abstract static class SolenoidWPIAdapterFactory implements XSolenoidFactory { - public abstract SolenoidWPIAdapter create(@Assisted("channel") int channel); - } - - @AssistedInject - public SolenoidWPIAdapter(@Assisted("channel") int channel, DevicePolice police) { - super(channel, police); - this.solenoid = new Solenoid(PneumaticsModuleType.REVPH, channel); - } - - @Override - public void set(boolean on) { - this.solenoid.set(on); - } - - @Override - public boolean get() { - return this.solenoid.get(); - } - - @Override - public int getMaxSupportedChannel() { - return SOLENOID_CHANNEL_COUNT - 1; - } -} diff --git a/src/main/java/xbot/common/controls/actuators/wpi_adapters/SpeedControllerWPIAdapter.java b/src/main/java/xbot/common/controls/actuators/wpi_adapters/SpeedControllerWPIAdapter.java deleted file mode 100644 index 4a2583b9..00000000 --- a/src/main/java/xbot/common/controls/actuators/wpi_adapters/SpeedControllerWPIAdapter.java +++ /dev/null @@ -1,37 +0,0 @@ -package xbot.common.controls.actuators.wpi_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.motorcontrol.PWMMotorController; -import edu.wpi.first.wpilibj.motorcontrol.Talon; -import xbot.common.controls.actuators.XSpeedController; -import xbot.common.injection.DevicePolice; - -public class SpeedControllerWPIAdapter extends XSpeedController -{ - private PWMMotorController controller; - - @AssistedFactory - public abstract static class SpeedControllerWPIAdapterFactory implements XSpeedControllerFactory { - public abstract SpeedControllerWPIAdapter create(@Assisted("channel") int channel); - } - - @AssistedInject - public SpeedControllerWPIAdapter(@Assisted("channel") int channel, DevicePolice police) - { - super(channel, police); - controller = new Talon(channel); - } - - public double get() - { - return controller.get(); - } - - public void set(double value) - { - controller.set(value); - } -} diff --git a/src/main/java/xbot/common/controls/actuators/wpi_adapters/VictorAppearingAsTalonWPIAdapter.java b/src/main/java/xbot/common/controls/actuators/wpi_adapters/VictorAppearingAsTalonWPIAdapter.java deleted file mode 100644 index 13112238..00000000 --- a/src/main/java/xbot/common/controls/actuators/wpi_adapters/VictorAppearingAsTalonWPIAdapter.java +++ /dev/null @@ -1,725 +0,0 @@ -package xbot.common.controls.actuators.wpi_adapters; - -import com.ctre.phoenix.ErrorCode; -import com.ctre.phoenix.ParamEnum; -import com.ctre.phoenix.motion.MotionProfileStatus; -import com.ctre.phoenix.motion.TrajectoryPoint; -import com.ctre.phoenix.motorcontrol.ControlFrame; -import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.DemandType; -import com.ctre.phoenix.motorcontrol.Faults; -import com.ctre.phoenix.motorcontrol.FeedbackDevice; -import com.ctre.phoenix.motorcontrol.IMotorController; -import com.ctre.phoenix.motorcontrol.InvertType; -import com.ctre.phoenix.motorcontrol.LimitSwitchNormal; -import com.ctre.phoenix.motorcontrol.LimitSwitchSource; -import com.ctre.phoenix.motorcontrol.NeutralMode; -import com.ctre.phoenix.motorcontrol.RemoteFeedbackDevice; -import com.ctre.phoenix.motorcontrol.RemoteLimitSwitchSource; -import com.ctre.phoenix.motorcontrol.RemoteSensorSource; -import com.ctre.phoenix.motorcontrol.SensorTerm; -import com.ctre.phoenix.motorcontrol.StatusFrame; -import com.ctre.phoenix.motorcontrol.StatusFrameEnhanced; -import com.ctre.phoenix.motorcontrol.StickyFaults; -import com.ctre.phoenix.motorcontrol.SupplyCurrentLimitConfiguration; -import com.ctre.phoenix.motorcontrol.can.BaseTalon; -import com.ctre.phoenix.sensors.CANCoder; -import com.ctre.phoenix.sensors.SensorVelocityMeasPeriod; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.motorcontrol.PWMMotorController; -import edu.wpi.first.wpilibj.motorcontrol.Victor; -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.injection.DevicePolice; -import xbot.common.logging.RobotAssertionManager; -import xbot.common.properties.PropertyFactory; - -public class VictorAppearingAsTalonWPIAdapter extends XCANTalon { - RobotAssertionManager assertionManager; - PWMMotorController internalSpeedController; - int deviceId; - - @AssistedInject - public VictorAppearingAsTalonWPIAdapter( - @Assisted("deviceId") int deviceId, - RobotAssertionManager assertionManager, - PropertyFactory propMan, - DevicePolice police) { - super(deviceId, propMan, police); - internalSpeedController = new Victor(deviceId); - this.deviceId = deviceId; - this.assertionManager = assertionManager; - } - - @Override - public void set(ControlMode mode, double demand) { - if (mode == ControlMode.PercentOutput) { - internalSpeedController.set(demand); - } - else { - internalSpeedController.set(0); - assertionManager.fail( - VictorAppearingAsTalonWPIAdapter.class.getSimpleName() - + " can only be used in PercentOutput mode;" - + " currently set to " + mode); - } - } - - @Override - public void set(ControlMode Mode, double demand0, DemandType demand1Type, double demand1) { - - } - - @Override - public void set(ControlMode mode, double demand0, double demand1) { - this.simpleSet(demand0); - - } - - @Override - public void neutralOutput() { - - this.simpleSet(0); - } - - @Override - public void setNeutralMode(NeutralMode neutralMode) { - - } - - @Override - public void setSensorPhase(boolean phaseSensor) { - - } - - @Override - public void setInverted(boolean invert) { - - internalSpeedController.setInverted(invert); - } - - @Override - public boolean getInverted() { - - return internalSpeedController.getInverted(); - } - - @Override - public ErrorCode configOpenloopRamp(double secondsFromNeutralToFull, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configClosedloopRamp(double secondsFromNeutralToFull, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configPeakOutputForward(double percentOut, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configPeakOutputReverse(double percentOut, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configNominalOutputForward(double percentOut, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configNominalOutputReverse(double percentOut, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configNeutralDeadband(double percentDeadband, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configVoltageCompSaturation(double voltage, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configVoltageMeasurementFilter(int filterWindowSamples, int timeoutMs) { - - return null; - } - - @Override - public void enableVoltageCompensation(boolean enable) { - - } - - @Override - public double getBusVoltage() { - - return 0; - } - - @Override - public double getMotorOutputPercent() { - - return internalSpeedController.get(); - } - - @Override - public double getMotorOutputVoltage() { - - return 0; - } - - @Override - public double getOutputCurrent() { - - return 0; - } - - @Override - public double getTemperature() { - - return 0; - } - - @Override - public ErrorCode configSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configRemoteFeedbackFilter(int deviceID, RemoteSensorSource remoteSensorSource, int remoteOrdinal, - int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configSensorTerm(SensorTerm sensorTerm, FeedbackDevice feedbackDevice, int timeoutMs) { - - return null; - } - - @Override - public double getSelectedSensorPosition(int pidIdx) { - - return 0; - } - - @Override - public double getSelectedSensorVelocity(int pidIdx) { - - return 0; - } - - @Override - public ErrorCode setSelectedSensorPosition(int sensorPos, int pidIdx, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode setControlFramePeriod(ControlFrame frame, int periodMs) { - - return null; - } - - @Override - public ErrorCode setStatusFramePeriod(StatusFrame frame, int periodMs, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode setStatusFramePeriod(StatusFrameEnhanced frame, int periodMs, int timeoutMs) { - - return null; - } - - @Override - public int getStatusFramePeriod(StatusFrame frame, int timeoutMs) { - - return 0; - } - - @Override - public int getStatusFramePeriod(StatusFrameEnhanced frame, int timeoutMs) { - - return 0; - } - - @Override - public ErrorCode configVelocityMeasurementWindow(int windowSize, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configForwardLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configForwardLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configReverseLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int deviceID, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configReverseLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, - int timeoutMs) { - - return null; - } - - @Override - public void overrideLimitSwitchesEnable(boolean enable) { - - } - - @Override - public ErrorCode configForwardSoftLimitThreshold(int forwardSensorLimit, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configReverseSoftLimitThreshold(int reverseSensorLimit, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configForwardSoftLimitEnable(boolean enable, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configReverseSoftLimitEnable(boolean enable, int timeoutMs) { - - return null; - } - - @Override - public void overrideSoftLimitsEnable(boolean enable) { - - } - - @Override - public ErrorCode configPeakCurrentLimit(int amps, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configPeakCurrentDuration(int milliseconds, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configContinuousCurrentLimit(int amps, int timeoutMs) { - - return null; - } - - @Override - public void enableCurrentLimit(boolean enable) { - - } - - @Override - public ErrorCode config_kP(int slotIdx, double value, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode config_kI(int slotIdx, double value, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode config_kD(int slotIdx, double value, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode config_kF(int slotIdx, double value, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode config_IntegralZone(int slotIdx, int izone, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configAllowableClosedloopError(int slotIdx, int allowableCloseLoopError, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configMaxIntegralAccumulator(int slotIdx, double iaccum, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode setIntegralAccumulator(double iaccum, int pidIdx, int timeoutMs) { - - return null; - } - - @Override - public double getClosedLoopError(int pidIdx) { - - return 0; - } - - @Override - public double getIntegralAccumulator(int pidIdx) { - - return 0; - } - - @Override - public double getErrorDerivative(int pidIdx) { - - return 0; - } - - @Override - public void selectProfileSlot(int slotIdx, int pidIdx) { - - } - - @Override - public double getActiveTrajectoryPosition() { - - return 0; - } - - @Override - public double getActiveTrajectoryVelocity() { - - return 0; - } - - @Override - public double getActiveTrajectoryHeading() { - - return 0; - } - - @Override - public ErrorCode configMotionCruiseVelocity(int sensorUnitsPer100ms, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configMotionAcceleration(int sensorUnitsPer100msPerSec, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode clearMotionProfileTrajectories() { - - return null; - } - - @Override - public int getMotionProfileTopLevelBufferCount() { - - return 0; - } - - @Override - public ErrorCode pushMotionProfileTrajectory(TrajectoryPoint trajPt) { - - return null; - } - - @Override - public boolean isMotionProfileTopLevelBufferFull() { - - return false; - } - - @Override - public void processMotionProfileBuffer() { - - } - - @Override - public ErrorCode getMotionProfileStatus(MotionProfileStatus statusToFill) { - - return null; - } - - @Override - public ErrorCode clearMotionProfileHasUnderrun(int timeoutMs) { - - return null; - } - - @Override - public ErrorCode changeMotionControlFramePeriod(int periodMs) { - - return null; - } - - @Override - public ErrorCode getLastError() { - - return null; - } - - @Override - public ErrorCode getFaults(Faults toFill) { - - return null; - } - - @Override - public ErrorCode getStickyFaults(StickyFaults toFill) { - - return null; - } - - @Override - public ErrorCode clearStickyFaults(int timeoutMs) { - - return null; - } - - @Override - public int getFirmwareVersion() { - - return 0; - } - - @Override - public boolean hasResetOccurred() { - - return false; - } - - @Override - public ErrorCode configSetCustomParam(int newValue, int paramIndex, int timeoutMs) { - - return null; - } - - @Override - public int configGetCustomParam(int paramIndex, int timoutMs) { - - return 0; - } - - @Override - public ErrorCode configSetParameter(ParamEnum param, double value, int subValue, int ordinal, int timeoutMs) { - - return null; - } - - @Override - public ErrorCode configSetParameter(int param, double value, int subValue, int ordinal, int timeoutMs) { - - return null; - } - - @Override - public double configGetParameter(ParamEnum paramEnum, int ordinal, int timeoutMs) { - - return 0; - } - - @Override - public double configGetParameter(int paramEnum, int ordinal, int timeoutMs) { - - return 0; - } - - @Override - public int getBaseID() { - return deviceId; - } - - @Override - public int getDeviceID() { - return deviceId; - } - - @Override - public void follow(IMotorController masterToFollow) { - - } - - @Override - public void valueUpdated() { - - } - - // This will never work - victors do not have this capability. - @Override - public boolean isFwdLimitSwitchClosed() { - return false; - } - - // This will never work - victors do not have this capability. - @Override - public boolean isRevLimitSwitchClosed() { - return false; - } - - @Override - public ErrorCode configSelectedFeedbackCoefficient(double coefficient, int pidIdx, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configClosedLoopPeakOutput(int slotIdx, double percentOut, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configClosedLoopPeriod(int slotIdx, int loopTimeMs, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configAuxPIDPolarity(boolean invert, int timeoutMs) { - return null; - } - - @Override - public double getClosedLoopTarget(int pidIdx) { - return 0; - } - - @Override - public ErrorCode configMotionProfileTrajectoryPeriod(int baseTrajDurationMs, int timeoutMs) { - return null; - } - - @Override - public ControlMode getControlMode() { - return null; - } - - @Override - public ErrorCode configMotionSCurveStrength(int curveStrength, int timeoutMs) { - return null; - } - - @Override - public int getPulseWidthRiseToFallUs() { - return 0; - } - - @Override - public ErrorCode configSupplyCurrentLimit(SupplyCurrentLimitConfiguration currLimitCfg, int timeoutMs) { - return null; - } - - @Override - public void setInverted(InvertType invertType) { - - } - - @Override - public ErrorCode configRemoteFeedbackFilter(CANCoder canCoderRef, int remoteOrdinal, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configRemoteFeedbackFilter(BaseTalon talonRef, int remoteOrdinal, int timeoutMs) { - return null; - } - - @Override - public ErrorCode setSelectedSensorPosition(double sensorPos, int pidIdx, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configForwardSoftLimitThreshold(double forwardSensorLimit, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configReverseSoftLimitThreshold(double reverseSensorLimit, int timeoutMs) { - return null; - } - - @Override - public ErrorCode config_IntegralZone(int slotIdx, double izone, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configAllowableClosedloopError(int slotIdx, double allowableCloseLoopError, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMotionCruiseVelocity(double sensorUnitsPer100ms, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configMotionAcceleration(double sensorUnitsPer100msPerSec, int timeoutMs) { - return null; - } - - @Override - public ErrorCode configVelocityMeasurementPeriod(SensorVelocityMeasPeriod period, int timeoutMs) { - return null; - } - - @Override - @SuppressWarnings("deprecation") - public ErrorCode configVelocityMeasurementPeriod(com.ctre.phoenix.motorcontrol.VelocityMeasPeriod period, int timeoutMs) { - return null; - } - -} diff --git a/src/main/java/xbot/common/controls/sensors/AnalogDistanceSensor.java b/src/main/java/xbot/common/controls/sensors/AnalogDistanceSensor.java deleted file mode 100644 index 216b3d19..00000000 --- a/src/main/java/xbot/common/controls/sensors/AnalogDistanceSensor.java +++ /dev/null @@ -1,76 +0,0 @@ -package xbot.common.controls.sensors; - -import org.apache.log4j.Logger; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.sensors.XAnalogInput.XAnalogInputFactory; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; - -import java.util.function.DoubleFunction; - -public class AnalogDistanceSensor extends XAnalogDistanceSensor { - - private static final int NUM_AVERAGE_BITS = 2; - - public XAnalogInput input; - - private DoubleProperty voltageOffset; - private DoubleProperty distanceOffset; - private DoubleProperty scalarMultiplier; - - private boolean isAveragingEnabled = false; - - private static final Logger log = Logger.getLogger(AnalogDistanceSensor.class); - - @AssistedFactory - public abstract static class AnalogDistanceSensorFactory implements XAnalogDistanceSensorFactory { - public abstract AnalogDistanceSensor create( - @Assisted("channel") int channel, - @Assisted("voltageMap") DoubleFunction voltageMap, - @Assisted("prefix") String prefix); - } - - @AssistedInject - public AnalogDistanceSensor( - XAnalogInputFactory analogInputFactory, - @Assisted("channel") int channel, - @Assisted("voltageMap") DoubleFunction voltageMap, - @Assisted("prefix") String prefix, - PropertyFactory propMan) { - super(channel, voltageMap); - - log.info("Initializing..."); - this.input = analogInputFactory.create(channel); - propMan.setPrefix(prefix); - voltageOffset = propMan.createPersistentProperty("Distance sensor " + input.getChannel() + " voltage offset", - 0d); - distanceOffset = propMan.createPersistentProperty("Distance sensor " + input.getChannel() + " distance offset", - 0d); - scalarMultiplier = propMan - .createPersistentProperty("Distance sensor " + input.getChannel() + "scalar multiplier", 1d); - } - - @Override - public double getDistance() { - double voltage = isAveragingEnabled ? input.getAverageVoltage() : input.getVoltage(); - return (voltageMap.apply(voltage + voltageOffset.get()) + distanceOffset.get()) * scalarMultiplier.get(); - } - - @Override - public void setAveraging(boolean shouldAverage) { - isAveragingEnabled = shouldAverage; - input.setAverageBits(shouldAverage ? NUM_AVERAGE_BITS : 0); - } - - public void setVoltageOffset(double offset) { - voltageOffset.set(offset); - } - - public void setDistanceOffset(double offset) { - distanceOffset.set(offset); - } -} diff --git a/src/main/java/xbot/common/controls/sensors/DistanceSensor.java b/src/main/java/xbot/common/controls/sensors/DistanceSensor.java deleted file mode 100644 index bffacc22..00000000 --- a/src/main/java/xbot/common/controls/sensors/DistanceSensor.java +++ /dev/null @@ -1,8 +0,0 @@ -package xbot.common.controls.sensors; - -public interface DistanceSensor { - - public double getDistance(); - - public void setAveraging(boolean shouldAverage); -} diff --git a/src/main/java/xbot/common/controls/sensors/DistanceSensorPair.java b/src/main/java/xbot/common/controls/sensors/DistanceSensorPair.java deleted file mode 100644 index 84f7eab4..00000000 --- a/src/main/java/xbot/common/controls/sensors/DistanceSensorPair.java +++ /dev/null @@ -1,8 +0,0 @@ -package xbot.common.controls.sensors; - -public interface DistanceSensorPair { - public DistanceSensor getSensorA(); - public DistanceSensor getSensorB(); - - public void update(); -} diff --git a/src/main/java/xbot/common/controls/sensors/IGamepad.java b/src/main/java/xbot/common/controls/sensors/IGamepad.java deleted file mode 100644 index ed5a28f0..00000000 --- a/src/main/java/xbot/common/controls/sensors/IGamepad.java +++ /dev/null @@ -1,15 +0,0 @@ -package xbot.common.controls.sensors; - -import xbot.common.math.XYPair; - -public interface IGamepad { - - public XYPair getLeftVector(); - public XYPair getRightVector(); - - public double getLeftTrigger(); - public double getRightTrigger(); - - public void setLeftInversion(boolean xInverted, boolean yInverted); - public void setRightInversion(boolean xInverted, boolean yInverted); -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/MultiplexedLidarPair.java b/src/main/java/xbot/common/controls/sensors/MultiplexedLidarPair.java deleted file mode 100644 index 15a62367..00000000 --- a/src/main/java/xbot/common/controls/sensors/MultiplexedLidarPair.java +++ /dev/null @@ -1,100 +0,0 @@ -package xbot.common.controls.sensors; - -import org.apache.log4j.Logger; - -import xbot.common.properties.PropertyFactory; -import edu.wpi.first.wpilibj.I2C; -import edu.wpi.first.wpilibj.I2C.Port; - -public class MultiplexedLidarPair implements DistanceSensorPair { - - private Logger log = Logger.getLogger(MultiplexedLidarPair.class); - - private byte lidarMuxIdA; - private byte lidarMuxIdB; - - private I2C i2c; - private byte[] distanceA; - private byte[] distanceB; - - private final int mux_address = 0x70; - private final int lidar_address = 0x62; - private final int lidar_config_register = 0x00; - private final int lidar_distance_register = 0x8f; - - private DistanceSensor sensorA; - private DistanceSensor sensorB; - - public MultiplexedLidarPair(Port port, byte lidarMuxIdA, byte lidarMuxIdB, PropertyFactory propMan) { - - log.info("Creating MultiplexedLidarPair on port: " + port.toString()); - - this.lidarMuxIdA = lidarMuxIdA; - this.lidarMuxIdB = lidarMuxIdB; - - i2c = new I2C(port, lidar_address); - - distanceA = new byte[2]; - distanceB = new byte[2]; - - sensorA = new DistanceSensor() { - - @Override - public void setAveraging(boolean shouldAverage) { - // Intentionally left blank - } - - @Override - public double getDistance() { - return (int) Integer.toUnsignedLong(distanceA[0] << 8) + Byte.toUnsignedInt(distanceA[1]); - } - }; - - sensorB = new DistanceSensor() { - - @Override - public void setAveraging(boolean shouldAverage) { - // Intentionally left blank - } - - @Override - public double getDistance() { - return (int) Integer.toUnsignedLong(distanceB[0] << 8) + Byte.toUnsignedInt(distanceB[1]); - } - }; - - initiateMeasurements(); - } - - @Override - public DistanceSensor getSensorA() { - return sensorA; - } - - @Override - public DistanceSensor getSensorB() { - return sensorB; - } - - private void initiateMeasurements() { - i2c.write(mux_address, 1 << lidarMuxIdA); - i2c.write(lidar_config_register, 0x04); - i2c.write(mux_address, 1 << lidarMuxIdB); - i2c.write(lidar_config_register, 0x04); - } - - @Override - public void update() { - // This sensor must be asked to take a distance measurement before - // updated data is available. Because there is a required delay - // between asking for a measurement and retrieving the value, we ask for - // a value at the end of the loop and wait for the next iteration. - - i2c.write(mux_address, 1 << lidarMuxIdA); - i2c.read(lidar_distance_register, 2, distanceA); - i2c.write(mux_address, 1 << lidarMuxIdB); - i2c.read(lidar_distance_register, 2, distanceB); - - initiateMeasurements(); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/SimulatedAnalogDistanceSensor.java b/src/main/java/xbot/common/controls/sensors/SimulatedAnalogDistanceSensor.java deleted file mode 100644 index a64ca441..00000000 --- a/src/main/java/xbot/common/controls/sensors/SimulatedAnalogDistanceSensor.java +++ /dev/null @@ -1,65 +0,0 @@ -package xbot.common.controls.sensors; - -import java.math.BigDecimal; -import java.util.function.DoubleFunction; - -import org.json.JSONObject; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; -import xbot.common.properties.PropertyFactory; -import xbot.common.simulation.ISimulatableSensor; - -public class SimulatedAnalogDistanceSensor extends XAnalogDistanceSensor implements ISimulatableSensor { - - private double distance; - - @AssistedFactory - public abstract static class SimulatedAnalogDistanceSensorFactory implements XAnalogDistanceSensorFactory { - public abstract SimulatedAnalogDistanceSensor create( - @Assisted("channel") int channel, - @Assisted("voltageMap") DoubleFunction voltageMap, - @Assisted("prefix") String prefix); - } - - @AssistedInject - public SimulatedAnalogDistanceSensor(@Assisted("channel") int channel, - @Assisted("voltageMap") DoubleFunction voltageMap, @Assisted("prefix") String prefix, - PropertyFactory propMan, DevicePolice police) { - super(channel, voltageMap); - - police.registerDevice(DeviceType.Analog, channel, this); - } - - @Override - public double getDistance() { - return distance; - } - - public void setDistance(double distance) { - this.distance = distance; - } - - @Override - public void setAveraging(boolean shouldAverage) { - } - - @Override - public void setVoltageOffset(double offset) { - } - - @Override - public void setDistanceOffset(double offset) { - } - - @Override - public void ingestSimulationData(JSONObject payload) { - // Some sort of BigDecimal issue - BigDecimal intermediate = (BigDecimal) payload.get("Distance"); - setDistance(intermediate.doubleValue()); - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/TalonCurrentMonitor.java b/src/main/java/xbot/common/controls/sensors/TalonCurrentMonitor.java deleted file mode 100644 index a7f89bfd..00000000 --- a/src/main/java/xbot/common/controls/sensors/TalonCurrentMonitor.java +++ /dev/null @@ -1,44 +0,0 @@ -package xbot.common.controls.sensors; - -import java.util.ArrayDeque; -import xbot.common.controls.actuators.XCANTalon; - -public class TalonCurrentMonitor { - - XCANTalon talon; - final int current_averaging_window=25; - ArrayDeque currentHistory; - - public TalonCurrentMonitor(XCANTalon talon) { - this.talon = talon; - currentHistory = new ArrayDeque(); - } - - public void updateCurrent() { - currentHistory.addFirst(talon.getOutputCurrent()); - if (currentHistory.size() > current_averaging_window) { - currentHistory.removeLast(); - } - } - - public double calculateAverageCurrent() { - double sum = 0; - for (Double current : currentHistory) { - sum += current; - } - return sum / currentHistory.size(); - } - - public double calculatePeakCurrent() { - double peakCurrent = 0; - currentHistory.addFirst(talon.getOutputCurrent()); - if (!currentHistory.isEmpty()) { - for (Double current : currentHistory) { - if (peakCurrent < current) { - peakCurrent = current; - } - } - } - return peakCurrent; - } -} diff --git a/src/main/java/xbot/common/controls/sensors/XAS5600.java b/src/main/java/xbot/common/controls/sensors/XAS5600.java deleted file mode 100644 index 3b4916ae..00000000 --- a/src/main/java/xbot/common/controls/sensors/XAS5600.java +++ /dev/null @@ -1,41 +0,0 @@ -package xbot.common.controls.sensors; - -import org.apache.log4j.Logger; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.actuators.XCANTalon; - -public class XAS5600 { - - XCANTalon talon; - int lastValue = Integer.MIN_VALUE; - protected Logger log = Logger.getLogger(XAS5600.class); - - @AssistedFactory - public abstract static class XAS5600Factory { - public abstract XAS5600 create(@Assisted("talon") XCANTalon talon); - } - - @AssistedInject - public XAS5600(@Assisted("talon") XCANTalon talon) { - this.talon = talon; - log.info("Creating XAS5600 using Talon with ID:" + talon.getDeviceID()); - } - - public int getPosition() { - int raw = talon.getPulseWidthRiseToFallUs(); - if (raw == 0) { - int lastValue = this.lastValue; - if (lastValue == Integer.MIN_VALUE) { - return 0; - } - return lastValue; - } - int actualValue = Math.min(4096, raw - 128); - lastValue = actualValue; - return actualValue; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/XAbsoluteEncoder.java b/src/main/java/xbot/common/controls/sensors/XAbsoluteEncoder.java deleted file mode 100644 index e7d75d91..00000000 --- a/src/main/java/xbot/common/controls/sensors/XAbsoluteEncoder.java +++ /dev/null @@ -1,23 +0,0 @@ -package xbot.common.controls.sensors; - -import xbot.common.injection.electrical_contract.DeviceInfo; -import xbot.common.resiliency.DeviceHealth; - -public abstract class XAbsoluteEncoder { - - public interface XAbsoluteEncoderFactory { - XAbsoluteEncoder create(DeviceInfo deviceInfo, String owningSystemPrefix); - } - - public abstract int getDeviceId(); - - public abstract double getPosition(); - - public abstract double getAbsolutePosition(); - - public abstract double getVelocity(); - - public abstract void setPosition(double newPostition); - - public abstract DeviceHealth getHealth(); -} diff --git a/src/main/java/xbot/common/controls/sensors/XAnalogDistanceSensor.java b/src/main/java/xbot/common/controls/sensors/XAnalogDistanceSensor.java deleted file mode 100644 index 96d38ce3..00000000 --- a/src/main/java/xbot/common/controls/sensors/XAnalogDistanceSensor.java +++ /dev/null @@ -1,42 +0,0 @@ -package xbot.common.controls.sensors; - -import java.util.function.DoubleFunction; - -public abstract class XAnalogDistanceSensor implements DistanceSensor { - - DoubleFunction voltageMap; - - public interface XAnalogDistanceSensorFactory { - XAnalogDistanceSensor create( - int channel, - DoubleFunction voltageMap, - String prefix); - } - - protected XAnalogDistanceSensor( - int channel, - DoubleFunction voltageMap) { - this.voltageMap = voltageMap; - } - - public abstract double getDistance(); - - public abstract void setAveraging(boolean shouldAverage); - - public abstract void setVoltageOffset(double offset); - - public abstract void setDistanceOffset(double offset); - - public static class VoltageMaps - { - public static final double sharp0A51SK(double voltage) - { - // 3.6601x4 - 20.375x3 + 41.593x2 - 38.528x + 15.848 - return (3.6601 * Math.pow(voltage, 4d)) - - (20.375 * Math.pow(voltage, 3d)) - + (41.593 * Math.pow(voltage, 2d)) - - (38.528 * voltage) - + 15.848; - } - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/XAnalogInput.java b/src/main/java/xbot/common/controls/sensors/XAnalogInput.java deleted file mode 100644 index 26760aed..00000000 --- a/src/main/java/xbot/common/controls/sensors/XAnalogInput.java +++ /dev/null @@ -1,27 +0,0 @@ -package xbot.common.controls.sensors; - -import xbot.common.controls.XBaseIO; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; - -public abstract class XAnalogInput implements XBaseIO { - - protected int channel; - - public interface XAnalogInputFactory { - XAnalogInput create(int channel); - } - - public XAnalogInput(int channel, DevicePolice police) { - this.channel = channel; - police.registerDevice(DeviceType.Analog, channel, this); - } - - public abstract double getVoltage(); - - public abstract double getAverageVoltage(); - - public abstract void setAverageBits(int bits); - - public abstract boolean getAsDigital(double threshold); -} diff --git a/src/main/java/xbot/common/controls/sensors/XCANCoder.java b/src/main/java/xbot/common/controls/sensors/XCANCoder.java deleted file mode 100644 index 542d85a4..00000000 --- a/src/main/java/xbot/common/controls/sensors/XCANCoder.java +++ /dev/null @@ -1,27 +0,0 @@ -package xbot.common.controls.sensors; - -import com.ctre.phoenix.ErrorCode; -import com.ctre.phoenix.sensors.CANCoderFaults; -import com.ctre.phoenix.sensors.CANCoderStatusFrame; -import com.ctre.phoenix.sensors.CANCoderStickyFaults; - -import xbot.common.injection.electrical_contract.DeviceInfo; - -public abstract class XCANCoder extends XAbsoluteEncoder { - - public interface XCANCoderFactory extends XAbsoluteEncoderFactory { - XCANCoder create(DeviceInfo deviceInfo, String owningSystemPrefix); - } - - public abstract ErrorCode setStatusFramePeriod(CANCoderStatusFrame frame, int periodMs); - - public abstract int getStatusFramePeriod(CANCoderStatusFrame frame); - - public abstract ErrorCode getFaults(CANCoderFaults toFill); - - public abstract ErrorCode getStickyFaults(CANCoderStickyFaults toFill); - - public abstract ErrorCode clearStickyFaults(); - - public abstract boolean hasResetOccurred(); -} diff --git a/src/main/java/xbot/common/controls/sensors/XDigitalInput.java b/src/main/java/xbot/common/controls/sensors/XDigitalInput.java deleted file mode 100644 index 28ae024f..00000000 --- a/src/main/java/xbot/common/controls/sensors/XDigitalInput.java +++ /dev/null @@ -1,32 +0,0 @@ -package xbot.common.controls.sensors; - -import xbot.common.controls.XBaseIO; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; - -public abstract class XDigitalInput implements XBaseIO { - - boolean inverted; - - public interface XDigitalInputFactory { - XDigitalInput create(int channel); - } - - public XDigitalInput(DevicePolice police, int channel) { - police.registerDevice(DeviceType.DigitalIO, channel, this); - } - - public boolean get() { - return getRaw() ^ inverted; - } - - public void setInverted(boolean inverted) { - this.inverted = inverted; - } - - public boolean getInverted() { - return inverted; - } - - protected abstract boolean getRaw(); -} diff --git a/src/main/java/xbot/common/controls/sensors/XDutyCycleEncoder.java b/src/main/java/xbot/common/controls/sensors/XDutyCycleEncoder.java deleted file mode 100644 index 3639e4f2..00000000 --- a/src/main/java/xbot/common/controls/sensors/XDutyCycleEncoder.java +++ /dev/null @@ -1,58 +0,0 @@ -package xbot.common.controls.sensors; - -import edu.wpi.first.math.geometry.Rotation2d; -import xbot.common.controls.XBaseIO; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.electrical_contract.DeviceInfo; -import xbot.common.math.ContiguousDouble; -import xbot.common.math.WrappedRotation2d; - -public abstract class XDutyCycleEncoder implements XBaseIO { - - protected int channel; - protected boolean inverted; - - public interface XDutyCycleEncoderFactory { - XDutyCycleEncoder create(DeviceInfo deviceInfo); - } - - public XDutyCycleEncoder(DeviceInfo info, DevicePolice police) { - this.channel = info.channel; - police.registerDevice(DevicePolice.DeviceType.DigitalIO, channel, this); - setInverted(info.inverted); - } - - protected abstract double getAbsoluteRawPosition(); - - /** - * Typically not recommended - use {@link #getWrappedPosition()} instead. - * @return the absolute position of the encoder in degrees from (0, 360) - */ - public Rotation2d getAbsolutePosition() { - return new Rotation2d(getAbsoluteRawPosition()*2*Math.PI * inversionFactor()); - } - - public double getAbsoluteDegrees() { - return getAbsoluteRawPosition() * 360 * inversionFactor(); - } - - /** - * @return the absolute position of the encoder in degrees from (-180, 180) - */ - public WrappedRotation2d getWrappedPosition() { - return WrappedRotation2d.fromRotation2d(getAbsolutePosition()); - } - - @Override - public int getChannel() { - return channel; - } - - public void setInverted(boolean inverted) { - this.inverted = inverted; - } - - protected double inversionFactor() { - return inverted ? -1 : 1; - } -} diff --git a/src/main/java/xbot/common/controls/sensors/XEncoder.java b/src/main/java/xbot/common/controls/sensors/XEncoder.java deleted file mode 100644 index 6fae282c..00000000 --- a/src/main/java/xbot/common/controls/sensors/XEncoder.java +++ /dev/null @@ -1,68 +0,0 @@ -package xbot.common.controls.sensors; - -import java.util.function.Supplier; - -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; - -public abstract class XEncoder { - - protected boolean isInverted; - protected DoubleProperty distancePerPulse; - protected Supplier distancePerPulseSupplier; - - public interface XEncoderFactory { - XEncoder create( - String name, - int aChannel, - int bChannel, - double defaultDistancePerPulse); - } - - public XEncoder( - String name, - int aChannel, - int bChannel, - double defaultDistancePerPulse, - PropertyFactory propMan, - DevicePolice police) { - propMan.setPrefix(name); - distancePerPulse = propMan.createPersistentProperty("DistancePerPulse", defaultDistancePerPulse); - setDistancePerPulseSupplier(() -> distancePerPulse.get()); - police.registerDevice(DeviceType.DigitalIO, aChannel, this); - police.registerDevice(DeviceType.DigitalIO, bChannel, this); - } - - public XEncoder(String prefix, PropertyFactory propMan) { - propMan.setPrefix(prefix); - var distancePerPulseProp = propMan.createPersistentProperty("Test" + "DistancePerPulse", 1); - setDistancePerPulseSupplier(() -> distancePerPulseProp.get()); - } - - public void setDistancePerPulseSupplier(Supplier supplier) { - distancePerPulseSupplier = supplier; - } - - public XEncoder(Supplier distancePerPulse) { - setDistancePerPulseSupplier(distancePerPulse); - } - - public double getAdjustedDistance() { - return getDistance() * (isInverted ? -1d : 1d) * distancePerPulseSupplier.get(); - } - - public double getAdjustedRate() { - return getRate() * (isInverted ? -1d : 1d) * distancePerPulseSupplier.get(); - } - - public void setInverted(boolean inverted) { - this.isInverted = inverted; - } - - protected abstract double getRate(); - protected abstract double getDistance(); - - public abstract void setSamplesToAverage(int samples); -} diff --git a/src/main/java/xbot/common/controls/sensors/XFTCGamepad.java b/src/main/java/xbot/common/controls/sensors/XFTCGamepad.java deleted file mode 100644 index 490c398f..00000000 --- a/src/main/java/xbot/common/controls/sensors/XFTCGamepad.java +++ /dev/null @@ -1,76 +0,0 @@ -package xbot.common.controls.sensors; - -import xbot.common.controls.sensors.buttons.AdvancedJoystickButtonTrigger.AdvancedJoystickButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AdvancedPovButtonTrigger.AdvancedPovButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger.AnalogHIDButtonTriggerFactory; -import xbot.common.injection.DevicePolice; -import xbot.common.logging.RobotAssertionManager; -import xbot.common.math.XYPair; - -public abstract class XFTCGamepad extends XJoystick implements IGamepad { - - public interface XFTCGamepadFactory { - XFTCGamepad create(int port, int numButtons); - } - - public XFTCGamepad(int port, AdvancedJoystickButtonTriggerFactory joystickButtonFactory, - AdvancedPovButtonTriggerFactory povButtonFactory, AnalogHIDButtonTriggerFactory analogHidButtonFactory, - RobotAssertionManager assertionManager, int numButtons, DevicePolice police) { - super(port, joystickButtonFactory, povButtonFactory, analogHidButtonFactory, assertionManager, numButtons, - police); - } - - protected int getLeftJoystickXAxis() { - return 0; - } - - protected int getLeftJoystickYAxis() { - return 1; - } - - protected int getRightJoystickXAxis() { - return 4; - } - - protected int getRightJoystickYAxis() { - return 5; - } - - protected int getLeftTriggerAxis() { - return 2; - } - - protected int getRightTriggerAxis() { - return 3; - } - - public XYPair getLeftVector() { - return this.getVectorForAxisPair( - getLeftJoystickXAxis(), - getLeftJoystickYAxis()); - } - - public XYPair getRightVector() { - return this.getVectorForAxisPair( - getRightJoystickXAxis(), - getRightJoystickYAxis()); - } - - public double getLeftTrigger() { - return getRawAxis(getLeftTriggerAxis()); - } - - public double getRightTrigger() { - return getRawAxis(getRightTriggerAxis()); - } - - public void setLeftInversion(boolean xInverted, boolean yInverted) { - setAxisInverted(getLeftJoystickXAxis(), xInverted); - setAxisInverted(getLeftJoystickYAxis(), yInverted); - } - - public void setRightInversion(boolean xInverted, boolean yInverted) { - setAxisInverted(getRightJoystickXAxis(), xInverted); - setAxisInverted(getRightJoystickYAxis(), yInverted); - } -} diff --git a/src/main/java/xbot/common/controls/sensors/XGyro.java b/src/main/java/xbot/common/controls/sensors/XGyro.java deleted file mode 100644 index cd2f2269..00000000 --- a/src/main/java/xbot/common/controls/sensors/XGyro.java +++ /dev/null @@ -1,120 +0,0 @@ -package xbot.common.controls.sensors; - -import edu.wpi.first.wpilibj.I2C; -import edu.wpi.first.wpilibj.SPI; -import edu.wpi.first.wpilibj.SerialPort; -import xbot.common.math.WrappedRotation2d; - -public abstract class XGyro -{ - public enum ImuType { - nav6, - navX, - mock - } - - protected ImuType imuType; - - public abstract static class XGyroFactory { - protected abstract XGyro create(SPI.Port spiPort, SerialPort.Port serialPort, I2C.Port i2cPort); - - public XGyro create() { - return create(SPI.Port.kMXP); - } - - public XGyro create(SPI.Port spiPort) { - return create(spiPort, null, null); - } - - public XGyro create(SerialPort.Port serialPort) { - return create(null, serialPort, null); - } - - public XGyro create(I2C.Port i2cPort) { - return create(null, null, i2cPort); - } - } - - protected XGyro(ImuType imuType) - { - this.imuType = imuType; - } - - public abstract boolean isBroken(); - - protected ImuType getImuType() { - return imuType; - } - - // Below are the "safe" methods that return gyro information. They pay attention - // to the state of the gyro, and as such will ideally not cause exceptions. - - /** - * In degrees - */ - public WrappedRotation2d getHeading() { - if (!isBroken()) { - return WrappedRotation2d.fromDegrees(getDeviceYaw()); - } - return WrappedRotation2d.fromDegrees(0); - } - - public double getRoll() { - if (!isBroken()) { - return getDeviceRoll(); - } - return 0; - } - - public double getPitch() { - if (!isBroken()) { - return getDevicePitch(); - } - return 0; - } - - public double getYawAngularVelocity() { - if (!isBroken()) { - return getDeviceYawAngularVelocity(); - } - return 0; - } - - // What follows are the primitive "gets" for the gyro. These aren't protected, - // and could cause exceptions if called while they gyro is not connected. - - public abstract boolean isConnected(); - - /** - * In degrees - */ - protected abstract double getDeviceRoll(); - - /** - * In degrees - */ - protected abstract double getDevicePitch(); - - /** - * In degrees - */ - protected abstract double getDeviceYaw(); - - /** - * In degrees per second - */ - protected abstract double getDeviceYawAngularVelocity(); - - - public abstract double getDeviceVelocityX(); - - public abstract double getDeviceVelocityY(); - - public abstract double getDeviceVelocityZ(); - - public abstract double getDeviceRawAccelX(); - - public abstract double getDeviceRawAccelY(); - - public abstract double getDeviceRawAccelZ(); -} diff --git a/src/main/java/xbot/common/controls/sensors/XJoystick.java b/src/main/java/xbot/common/controls/sensors/XJoystick.java deleted file mode 100644 index 34a49a8c..00000000 --- a/src/main/java/xbot/common/controls/sensors/XJoystick.java +++ /dev/null @@ -1,183 +0,0 @@ -package xbot.common.controls.sensors; - -import java.util.HashMap; - -import org.apache.log4j.Logger; - -import edu.wpi.first.wpilibj.GenericHID; -import xbot.common.controls.sensors.buttons.AdvancedJoystickButtonTrigger; -import xbot.common.controls.sensors.buttons.AdvancedPovButtonTrigger; -import xbot.common.controls.sensors.buttons.AdvancedTrigger; -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger; -import xbot.common.controls.sensors.buttons.AdvancedJoystickButtonTrigger.AdvancedJoystickButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AdvancedPovButtonTrigger.AdvancedPovButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger.AnalogHIDButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger.AnalogHIDDescription; -import xbot.common.controls.sensors.mock_adapters.MockJoystick; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; -import xbot.common.logging.RobotAssertionManager; -import xbot.common.math.XYPair; - -public abstract class XJoystick -{ - protected int port; - - private boolean[] axisInversion; - - private static final Logger log = Logger.getLogger(XJoystick.class); - - private HashMap buttonMap; - private HashMap analogButtonMap; - private HashMap povButtonMap; - private int maxButtons; - - private AdvancedJoystickButtonTriggerFactory joystickButtonFactory; - private AdvancedPovButtonTriggerFactory povButtonFactory; - private AnalogHIDButtonTriggerFactory analogHidButtonFactory; - - private RobotAssertionManager assertionManager; - private DevicePolice police; - - public interface XJoystickFactory { - XJoystick create(int port, int numButtons); - } - - public XJoystick( - int port, - AdvancedJoystickButtonTriggerFactory joystickButtonFactory, - AdvancedPovButtonTriggerFactory povButtonFactory, - AnalogHIDButtonTriggerFactory analogHidButtonFactory, - RobotAssertionManager assertionManager, - int numButtons, - DevicePolice police) { - this.port = port; - this.police = police; - this.joystickButtonFactory = joystickButtonFactory; - this.povButtonFactory = povButtonFactory; - this.analogHidButtonFactory = analogHidButtonFactory; - this.assertionManager = assertionManager; - maxButtons = numButtons; - - this.buttonMap = new HashMap(numButtons); - this.analogButtonMap = new HashMap<>(); - this.povButtonMap = new HashMap(); - this.axisInversion = new boolean[6]; - - for (int i = 1; i <= numButtons; i++) { - this.set(i, joystickButtonFactory.create(this, i)); - } - - for (int i = 0; i < 360; i+=45) { - povButtonMap.put(i, povButtonFactory.create(this, i)); - } - - police.registerDevice(DeviceType.USB, port, this); - } - - public int getPort() { - return port; - } - - public boolean getAxisInverted(int axisNumber) { - if (axisNumber >= 0 && axisNumber < axisInversion.length) - { - return axisInversion[axisNumber]; - } - return false; - } - - - public void setAxisInverted(int axisNumber, boolean inverted) { - if (axisNumber >= 0 && axisNumber < axisInversion.length) - { - axisInversion[axisNumber] = inverted; - } - } - - protected XYPair getVectorForAxisPair(int xAxis, int yAxis) { - double x = getRawAxis(xAxis) * (getAxisInverted(xAxis) ? -1 : 1); - double y = getRawAxis(xAxis) * (getAxisInverted(yAxis) ? -1 : 1); - return new XYPair(x, y); - } - - public abstract boolean getButton(int button); - - public abstract double getRawAxis(int axisNumber); - - public abstract GenericHID getGenericHID(); - - public abstract int getPOV(); - - public void addAnalogButton(int axisNumber, double minThreshold, double maxThreshold) { - addAnalogButton(new AnalogHIDDescription(axisNumber, minThreshold, maxThreshold)); - } - - public void addAnalogButton(AnalogHIDDescription desc) { - setAnalog(analogHidButtonFactory.create(this, desc)); - } - - public enum ButtonSource { - Standard, - POV - } - - public AdvancedTrigger getifAvailable(int buttonNumber) { - - if (buttonNumber < 1 || buttonNumber > maxButtons) { - return handleInvalidButton("button " + buttonNumber + " is out of range!"); - } - - if (buttonMap.containsKey(buttonNumber)) { - return buttonMap.remove(buttonNumber); - } else { - return handleInvalidButton("button " + buttonNumber + " is already used! Cannot be used twice!"); - } - } - - /** - * Uses the d-pad as a button source. - * @param povNumber 0 == Up, 90 == Right, 180 == down, 270 == left - * @return A trigger that represents the given POV direction. - */ - public AdvancedTrigger getPovIfAvailable(int povNumber) { - if (povNumber < -1 || povNumber > 315) { - return handleInvalidButton("button " + povNumber + " is out of range!"); - } - - if (povButtonMap.containsKey(povNumber)) { - return povButtonMap.remove(povNumber); - } else { - return handleInvalidButton("button " + povNumber + " is already used! Cannot be used twice!"); - } - } - - private AdvancedTrigger handleInvalidButton(String message) { - assertionManager.throwException(message, new Exception()); - - MockJoystick mj = new MockJoystick(0, joystickButtonFactory, povButtonFactory, analogHidButtonFactory, assertionManager, 12, police); - return new AdvancedJoystickButtonTrigger(mj, 1); - } - - public AnalogHIDButtonTrigger getAnalogIfAvailable(AnalogHIDDescription desc) { - if (analogButtonMap.containsKey(desc)) { - return analogButtonMap.remove(desc); - } else { - // Warn people that terrible things are happening, then return a null button. - log.error("analog button " + desc + " is already used! Cannot be used twice!"); - return null; - } - } - - // sets without checking - // intended only for initializing buttons from factory. - private void set(int buttonNumber, AdvancedJoystickButtonTrigger button) { - buttonMap.put(buttonNumber, button); - } - - // sets without checking - // intended only for initializing buttons from factory. - private void setAnalog(AnalogHIDButtonTrigger button) { - analogButtonMap.put(button.getDescription(), button); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/XLidarLite.java b/src/main/java/xbot/common/controls/sensors/XLidarLite.java deleted file mode 100644 index 339058a4..00000000 --- a/src/main/java/xbot/common/controls/sensors/XLidarLite.java +++ /dev/null @@ -1,93 +0,0 @@ -package xbot.common.controls.sensors; - -import java.util.TimerTask; - -import org.apache.log4j.Logger; - -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; -import edu.wpi.first.wpilibj.I2C.Port; - -public abstract class XLidarLite implements DistanceSensor { - - private Logger log = Logger.getLogger(XLidarLite.class); - - protected byte[] distance; - private java.util.Timer updater; - private LidarUpdater task; - - protected final int lidar_address = 0x62; - protected final int lidar_config_register = 0x00; - protected final int lidar_distance_register = 0x8f; - - private DoubleProperty lidarPollDuration; - - public interface XLidarLiteFactory { - public abstract XLidarLite create(Port port, String prefix); - } - - public XLidarLite(Port port, PropertyFactory propMan, DevicePolice police, String prefix) { - - log.info("Creating Lidar on port: " + port.toString()); - propMan.setPrefix(prefix); - lidarPollDuration = propMan.createPersistentProperty("LidarPollDurationMs", 100d); - - distance = new byte[2]; - - task = new LidarUpdater(); - updater = new java.util.Timer(); - - this.start(); - police.registerDevice(DeviceType.I2C, port.value, this); - } - - protected abstract void update(); - - // Distance in cm - public double getDistance() { - return (int) Integer.toUnsignedLong(distance[0] << 8) + Byte.toUnsignedInt(distance[1]); - } - - public double pidGet() { - return getDistance(); - } - - // Start 10Hz polling - public void start() { - log.info("Starting Lidar polling"); - updater.schedule(task, 0); - } - - public void stop() { - updater.cancel(); - } -/* - // Update distance variable - public void update() { - i2c.write(lidar_config_register, 0x04); // Initiate measurement - Timer.delay(0.04); // Delay for measurement to be taken - i2c.read(lidar_distance_register, 2, distance); // Read in measurement - Timer.delay(0.01); // Delay to prevent over polling - }*/ - - // Timer task to keep distance updated - private class LidarUpdater extends TimerTask { - public void run() { - while (true) { - update(); - try { - Thread.sleep((long) lidarPollDuration.get()); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - } - - @Override - public void setAveraging(boolean shouldAverage) { - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/XPowerDistributionPanel.java b/src/main/java/xbot/common/controls/sensors/XPowerDistributionPanel.java deleted file mode 100644 index e36d2e16..00000000 --- a/src/main/java/xbot/common/controls/sensors/XPowerDistributionPanel.java +++ /dev/null @@ -1,10 +0,0 @@ -package xbot.common.controls.sensors; - -public abstract class XPowerDistributionPanel -{ - public interface XPowerDistributionPanelFactory { - XPowerDistributionPanel create(); - } - - public abstract double getCurrent(int channel); -} diff --git a/src/main/java/xbot/common/controls/sensors/XSettableTimerImpl.java b/src/main/java/xbot/common/controls/sensors/XSettableTimerImpl.java deleted file mode 100644 index 8abd9e29..00000000 --- a/src/main/java/xbot/common/controls/sensors/XSettableTimerImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package xbot.common.controls.sensors; - -public interface XSettableTimerImpl extends XTimerImpl { - - /** - * Set the current time - * @param time The current time in seconds - */ - public void setTimeInSeconds(double time); - - /** - * Advance the timer - * @param time Duration in seconds to advance by - */ - public void advanceTimeInSecondsBy(double time); - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/XTimer.java b/src/main/java/xbot/common/controls/sensors/XTimer.java deleted file mode 100644 index 5340aeb3..00000000 --- a/src/main/java/xbot/common/controls/sensors/XTimer.java +++ /dev/null @@ -1,26 +0,0 @@ -package xbot.common.controls.sensors; - -public class XTimer -{ - private static XTimerImpl impl; - - public static void setImplementation(XTimerImpl implementation) { - impl = implementation; - } - - /** - * Returns the current time in seconds since the FPGA was powered on. - * @return Time in seconds - */ - public static double getFPGATimestamp() { - return impl.getFPGATimestamp(); - } - - public static double getMatchTime() { - return impl.getMatchTime(); - } - public static void delay(double seconds) { - impl.delay(seconds); - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/XTimerImpl.java b/src/main/java/xbot/common/controls/sensors/XTimerImpl.java deleted file mode 100644 index 16ac9601..00000000 --- a/src/main/java/xbot/common/controls/sensors/XTimerImpl.java +++ /dev/null @@ -1,7 +0,0 @@ -package xbot.common.controls.sensors; - -public interface XTimerImpl { - public double getFPGATimestamp(); - public double getMatchTime(); - public void delay(double seconds); -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/XXboxController.java b/src/main/java/xbot/common/controls/sensors/XXboxController.java deleted file mode 100644 index 453e703a..00000000 --- a/src/main/java/xbot/common/controls/sensors/XXboxController.java +++ /dev/null @@ -1,159 +0,0 @@ -package xbot.common.controls.sensors; - -import java.util.HashMap; - -import xbot.common.controls.sensors.buttons.AdvancedXboxAxisTrigger; -import xbot.common.controls.sensors.buttons.AdvancedXboxButtonTrigger; -import xbot.common.controls.sensors.buttons.AdvancedJoystickButtonTrigger.AdvancedJoystickButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AdvancedPovButtonTrigger.AdvancedPovButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger.AnalogHIDButtonTriggerFactory; -import xbot.common.injection.DevicePolice; -import xbot.common.logging.RobotAssertionManager; -import xbot.common.math.XYPair; -import xbot.common.subsystems.feedback.IRumbler; -import xbot.common.subsystems.feedback.XRumbleManager; -import xbot.common.subsystems.feedback.XRumbleManager.XRumbleManagerFactory; - -public abstract class XXboxController extends XJoystick implements IRumbler, IGamepad { - - protected final int port; - protected final RobotAssertionManager assertionManager; - - public final HashMap allocatedButtons; - - protected boolean leftXInversion = false; - protected boolean leftYInversion = false; - protected boolean rightXInversion = false; - protected boolean rightYInversion = false; - - protected final XRumbleManager rumbleManager; - - public interface XXboxControllerFactory { - XXboxController create(int port); - } - - protected XXboxController(int port, AdvancedJoystickButtonTriggerFactory joystickButtonFactory, - AdvancedPovButtonTriggerFactory advancedPovButtonFactory, AnalogHIDButtonTriggerFactory analogHidButtonFactory, - XRumbleManagerFactory rumbleManagerFactory, RobotAssertionManager assertionManager, - DevicePolice police) { - super(port, joystickButtonFactory, advancedPovButtonFactory, analogHidButtonFactory, assertionManager, 10, police); - this.port = port; - this.assertionManager = assertionManager; - allocatedButtons = new HashMap(); - rumbleManager = rumbleManagerFactory.create(this); - } - - @Override - public XRumbleManager getRumbleManager() { - return rumbleManager; - } - - public enum XboxButton { - A(1), B(2), X(3), Y(4), LeftBumper(5), RightBumper(6), Back(7), Start(8), LeftStick(9), RightStick(10), - LeftTrigger(-1), RightTrigger(-1), LeftJoystickYAxis(-1), RightJoystickYAxis(-1); - - private int value; - - private XboxButton(int value) { - this.value = value; - } - - public int getValue() { - return value; - } - } - - public AdvancedXboxButtonTrigger getifAvailable(XboxButton buttonName) { - if (!allocatedButtons.containsKey(buttonName)) { - // If we're trying to use the triggers as buttons, then we need to do some extra - // work. - if (buttonName.value == -1) { - AdvancedXboxAxisTrigger candidate = new AdvancedXboxAxisTrigger(this, buttonName, 0.75); - allocatedButtons.put(buttonName, candidate); - } else { - AdvancedXboxButtonTrigger candidate = new AdvancedXboxButtonTrigger(this, buttonName); - allocatedButtons.put(buttonName, candidate); - } - } else { - // button already used! - assertionManager.assertTrue(false, "Button " + buttonName + " has already been allocated!"); - } - - return allocatedButtons.get(buttonName); - } - - public AdvancedXboxButtonTrigger getXboxButton(XboxButton buttonName) { - - if (!allocatedButtons.containsKey(buttonName)) { - // key does not exist. Create button! - AdvancedXboxButtonTrigger candidate; - - // If it's a trigger button, create it in a different way - if (buttonName.value == -1) { - candidate = new AdvancedXboxAxisTrigger(this, buttonName, 0.75); - } else { - candidate = new AdvancedXboxButtonTrigger(this, buttonName); - } - - allocatedButtons.put(buttonName, candidate); - } - - return allocatedButtons.get(buttonName); - } - - // Joysticks--------------------------------------------------------------------------------------------- - public XYPair getLeftVector() { - return new XYPair(getLeftStickX(), getLeftStickY()); - } - - public XYPair getRightVector() { - return new XYPair(getRightStickX(), getRightStickY()); - } - - public void setLeftInversion(boolean xInverted, boolean yInverted) { - leftXInversion = xInverted; - leftYInversion = yInverted; - } - - public void setRightInversion(boolean xInverted, boolean yInverted) { - rightXInversion = xInverted; - rightYInversion = yInverted; - } - - public double getLeftStickX() { - return this.getLeftRawX() * (leftXInversion ? -1 : 1); - } - - public double getRightStickX() { - return this.getRightRawX() * (rightXInversion ? -1 : 1); - } - - public double getLeftStickY() { - return this.getLeftRawY() * (leftYInversion ? -1 : 1); - } - - public double getRightStickY() { - return this.getRightRawY() * (rightYInversion ? -1 : 1); - } - - // Triggers----------------------------------------------------------------------------------------------- - public double getLeftTrigger() { - return this.getLeftRawTriggerAxis(); - } - - public double getRightTrigger() { - return this.getRightRawTriggerAxis(); - } - - protected abstract double getLeftRawTriggerAxis(); - - protected abstract double getRightRawTriggerAxis(); - - protected abstract double getLeftRawX(); - - protected abstract double getLeftRawY(); - - protected abstract double getRightRawX(); - - protected abstract double getRightRawY(); -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/buttons/AdvancedJoystickButtonTrigger.java b/src/main/java/xbot/common/controls/sensors/buttons/AdvancedJoystickButtonTrigger.java deleted file mode 100644 index 7b857692..00000000 --- a/src/main/java/xbot/common/controls/sensors/buttons/AdvancedJoystickButtonTrigger.java +++ /dev/null @@ -1,35 +0,0 @@ -package xbot.common.controls.sensors.buttons; - -import java.util.function.BooleanSupplier; - -import org.apache.log4j.Logger; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import xbot.common.controls.sensors.XJoystick; - -public class AdvancedJoystickButtonTrigger extends AdvancedTrigger -{ - private static final Logger log = Logger.getLogger(AdvancedJoystickButtonTrigger.class); - - XJoystick joystick; - int buttonNumber; - - @AssistedFactory - public abstract static class AdvancedJoystickButtonTriggerFactory { - public abstract AdvancedJoystickButtonTrigger create( - @Assisted("joystick") XJoystick joystick, - @Assisted("buttonNumber") int buttonNumber); - } - - @AssistedInject - public AdvancedJoystickButtonTrigger( - @Assisted("joystick") XJoystick joystick, - @Assisted("buttonNumber")int buttonNumber) { - super((BooleanSupplier)(() -> joystick.getButton(buttonNumber))); - log.debug("Creating button " + buttonNumber + " on port " + joystick.getPort()); - this.joystick = joystick; - this.buttonNumber = buttonNumber; - } -} diff --git a/src/main/java/xbot/common/controls/sensors/buttons/AdvancedPovButtonTrigger.java b/src/main/java/xbot/common/controls/sensors/buttons/AdvancedPovButtonTrigger.java deleted file mode 100644 index 4b092c56..00000000 --- a/src/main/java/xbot/common/controls/sensors/buttons/AdvancedPovButtonTrigger.java +++ /dev/null @@ -1,34 +0,0 @@ -package xbot.common.controls.sensors.buttons; - -import org.apache.log4j.Logger; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import xbot.common.controls.sensors.XJoystick; - -public class AdvancedPovButtonTrigger extends AdvancedTrigger { - - private static final Logger log = Logger.getLogger(AdvancedPovButtonTrigger.class); - - XJoystick joystick; - int povNumber; - - @AssistedFactory - public abstract static class AdvancedPovButtonTriggerFactory { - public abstract AdvancedPovButtonTrigger create( - @Assisted("joystick") XJoystick joystick, - @Assisted("povNumber") int povNumber); - } - - @AssistedInject - public AdvancedPovButtonTrigger( - @Assisted("joystick") XJoystick joystick, - @Assisted("povNumber")int povNumber) { - super(() -> joystick.getPOV() == povNumber); - log.debug("Creating D-Pad button " + povNumber + " on port " + joystick.getPort()); - this.joystick = joystick; - this.povNumber = povNumber; - } - -} diff --git a/src/main/java/xbot/common/controls/sensors/buttons/AdvancedTrigger.java b/src/main/java/xbot/common/controls/sensors/buttons/AdvancedTrigger.java deleted file mode 100644 index 4b1ac8ab..00000000 --- a/src/main/java/xbot/common/controls/sensors/buttons/AdvancedTrigger.java +++ /dev/null @@ -1,26 +0,0 @@ -package xbot.common.controls.sensors.buttons; - -import java.util.function.BooleanSupplier; - -import edu.wpi.first.wpilibj2.command.button.Trigger; - -public abstract class AdvancedTrigger extends Trigger { - protected InvertingBooleanSupplier supplier; - - public AdvancedTrigger(BooleanSupplier supplier) { - this(new InvertingBooleanSupplier(supplier)); - } - - private AdvancedTrigger(InvertingBooleanSupplier supplier) { - super(supplier); - this.supplier = supplier; - } - - public void setInverted(boolean inverted) { - this.supplier.setInverted(inverted); - } - - public boolean getInverted() { - return this.supplier.getInverted(); - } -} diff --git a/src/main/java/xbot/common/controls/sensors/buttons/AdvancedXboxAxisTrigger.java b/src/main/java/xbot/common/controls/sensors/buttons/AdvancedXboxAxisTrigger.java deleted file mode 100644 index dd25b76b..00000000 --- a/src/main/java/xbot/common/controls/sensors/buttons/AdvancedXboxAxisTrigger.java +++ /dev/null @@ -1,36 +0,0 @@ -package xbot.common.controls.sensors.buttons; - -import java.util.function.BooleanSupplier; - -import xbot.common.controls.sensors.XXboxController; -import xbot.common.controls.sensors.XXboxController.XboxButton; - -public class AdvancedXboxAxisTrigger extends AdvancedXboxButtonTrigger { - - public AdvancedXboxAxisTrigger(XXboxController controller, XboxButton buttonName, double threshold) { - super(controller, buttonName, (BooleanSupplier)(() -> getValue(controller, buttonName, threshold))); - } - - private static boolean getValue(XXboxController controller, XboxButton buttonName, double threshold) { - double value = 0; - - switch(buttonName) { - case LeftTrigger: - value = controller.getLeftTrigger(); - break; - case RightTrigger: - value = controller.getRightTrigger(); - break; - case LeftJoystickYAxis: - value = controller.getLeftStickY(); - break; - case RightJoystickYAxis: - value = controller.getRightStickY(); - break; - default: - break; - } - - return Math.abs(value) > threshold; - } -} diff --git a/src/main/java/xbot/common/controls/sensors/buttons/AdvancedXboxButtonTrigger.java b/src/main/java/xbot/common/controls/sensors/buttons/AdvancedXboxButtonTrigger.java deleted file mode 100644 index 9fbde306..00000000 --- a/src/main/java/xbot/common/controls/sensors/buttons/AdvancedXboxButtonTrigger.java +++ /dev/null @@ -1,64 +0,0 @@ -package xbot.common.controls.sensors.buttons; - -import java.util.HashMap; -import java.util.function.BooleanSupplier; - -import org.apache.log4j.Logger; - -import edu.wpi.first.wpilibj2.command.Command; -import edu.wpi.first.wpilibj2.command.button.Trigger; -import xbot.common.controls.sensors.XXboxController; -import xbot.common.controls.sensors.XXboxController.XboxButton; - -public class AdvancedXboxButtonTrigger extends AdvancedTrigger { - - public enum ButtonTriggerType { - WhenPressed(0), WhileHeld(1), WhenReleased(2); - - private int value; - - private ButtonTriggerType(final int value) { - this.value = value; - } - - public int getValue() { - return value; - } - } - - private static final Logger log = Logger.getLogger(AdvancedTrigger.class); - - XXboxController controller; - public XboxButton buttonName; - - public final HashMap triggeredCommands = new HashMap(); - - public AdvancedXboxButtonTrigger(final XXboxController controller, final XboxButton buttonName) { - this(controller, buttonName, () -> controller.getButton(buttonName.getValue())); - } - - protected AdvancedXboxButtonTrigger(final XXboxController controller, final XboxButton buttonName, final BooleanSupplier supplier) { - super(supplier); - log.info("Creating XboxButton " + buttonName.toString());// + " on port " + controller.getInternalController().getPort()); - this.controller = controller; - this.buttonName = buttonName; - } - - @Override - public Trigger onTrue(final Command command) { - this.triggeredCommands.put(ButtonTriggerType.WhenPressed, command); - return super.onTrue(command); - } - - @Override - public Trigger onFalse(final Command command) { - this.triggeredCommands.put(ButtonTriggerType.WhenReleased, command); - return super.onFalse(command); - } - - @Override - public Trigger whileTrue(final Command command) { - this.triggeredCommands.put(ButtonTriggerType.WhileHeld, command); - return super.whileTrue(command); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/buttons/AnalogHIDButtonConfiguration.java b/src/main/java/xbot/common/controls/sensors/buttons/AnalogHIDButtonConfiguration.java deleted file mode 100644 index 12819a3c..00000000 --- a/src/main/java/xbot/common/controls/sensors/buttons/AnalogHIDButtonConfiguration.java +++ /dev/null @@ -1,33 +0,0 @@ -package xbot.common.controls.sensors.buttons; - -import java.util.function.BooleanSupplier; - -import xbot.common.controls.sensors.XJoystick; - -public class AnalogHIDButtonConfiguration { - - XJoystick m_joystick; - int m_axisNumber; - - double m_analogMinThreshold; - double m_analogMaxThreshold; - - public AnalogHIDButtonConfiguration(XJoystick joystick, int axisNumber, double analogMinThreshold, double analogMaxThreshold) { - m_joystick = joystick; - m_axisNumber = axisNumber; - m_analogMinThreshold = analogMinThreshold; - m_analogMaxThreshold = analogMaxThreshold; - } - - /** - * Supplier indicates whether the analog value is in the button's range - * - * @return A supplier for the value of the joystick button - */ - public BooleanSupplier getSupplier() { - return () -> { - double data = m_joystick.getRawAxis(m_axisNumber); - return data >= m_analogMinThreshold && data <= m_analogMaxThreshold; - }; - }; -} diff --git a/src/main/java/xbot/common/controls/sensors/buttons/AnalogHIDButtonTrigger.java b/src/main/java/xbot/common/controls/sensors/buttons/AnalogHIDButtonTrigger.java deleted file mode 100644 index 7135fdcd..00000000 --- a/src/main/java/xbot/common/controls/sensors/buttons/AnalogHIDButtonTrigger.java +++ /dev/null @@ -1,109 +0,0 @@ -package xbot.common.controls.sensors.buttons; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.sensors.XJoystick; - -public class AnalogHIDButtonTrigger extends AdvancedTrigger { - - @AssistedFactory - public abstract static class AnalogHIDButtonTriggerFactory { - public abstract AnalogHIDButtonTrigger create( - @Assisted("joystick") XJoystick joystick, - @Assisted("axisNumber") int axisNumber, - @Assisted("analogMinThreshold") double analogMinThreshold, - @Assisted("analogMaxThreshold") double analogMaxThreshold); - - public AnalogHIDButtonTrigger create(XJoystick joystick, AnalogHIDDescription desc) { - return create(joystick, desc.axisNumber, desc.analogMinThreshold, desc.analogMaxThreshold); - } - } - - private AnalogHIDButtonConfiguration m_configuration; - - /** - * Create a joystick button for triggering commands based off of an analog axis - * - * @param joystick - * The GenericHID object that has the analog axis to use - * @param axisNumber - * The axis number (appears to usually be [X=0,Y=1,Z=2]) - * @param analogThreshold - * Analog threshold to trigger binary button state - */ - @AssistedInject - public AnalogHIDButtonTrigger( - @Assisted("joystick") XJoystick joystick, - @Assisted("axisNumber") int axisNumber, - @Assisted("analogMinThreshold") double analogMinThreshold, - @Assisted("analogMaxThreshold") double analogMaxThreshold) { - this(new AnalogHIDButtonConfiguration(joystick, axisNumber, analogMinThreshold, analogMaxThreshold)); - } - - private AnalogHIDButtonTrigger(AnalogHIDButtonConfiguration configuration) { - super(configuration.getSupplier()); - m_configuration = configuration; - } - - public AnalogHIDDescription getDescription() { - return new AnalogHIDDescription( - m_configuration.m_axisNumber, - m_configuration.m_analogMinThreshold, - m_configuration.m_analogMaxThreshold); - } - - public static class AnalogHIDDescription { - public int axisNumber; - public double analogMinThreshold; - public double analogMaxThreshold; - - public AnalogHIDDescription(int axisNumber, double analogMinThreshold, - double analogMaxThreshold) { - this.axisNumber = axisNumber; - this.analogMinThreshold = analogMinThreshold; - this.analogMaxThreshold = analogMaxThreshold; - } - - @Override - public String toString() { - return axisNumber + "<" + analogMinThreshold + ", " - + analogMaxThreshold + ">"; - } - - // Auto-generated hash and equals methods (for HashMap) - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - temp = Double.doubleToLongBits(analogMaxThreshold); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(analogMinThreshold); - result = prime * result + (int) (temp ^ (temp >>> 32)); - result = prime * result + axisNumber; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj == null || getClass() != obj.getClass()) { - return false; - } - - AnalogHIDDescription other = (AnalogHIDDescription) obj; - if (Double.doubleToLongBits(analogMaxThreshold) != Double.doubleToLongBits(other.analogMaxThreshold) - || Double.doubleToLongBits(analogMinThreshold) != Double.doubleToLongBits(other.analogMinThreshold) - || axisNumber != other.axisNumber) { - return false; - } - - return true; - } - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/buttons/ChordTrigger.java b/src/main/java/xbot/common/controls/sensors/buttons/ChordTrigger.java deleted file mode 100644 index 09dab6da..00000000 --- a/src/main/java/xbot/common/controls/sensors/buttons/ChordTrigger.java +++ /dev/null @@ -1,25 +0,0 @@ -package xbot.common.controls.sensors.buttons; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import edu.wpi.first.wpilibj2.command.button.Trigger; - -public class ChordTrigger extends AdvancedTrigger { - - AdvancedTrigger a; - AdvancedTrigger b; - - @AssistedFactory - public abstract static class ChordTriggerFactory { - public abstract ChordTrigger create( - @Assisted("a") Trigger a, - @Assisted("b") Trigger b); - } - - @AssistedInject - public ChordTrigger(@Assisted("a") Trigger a, @Assisted("b") Trigger b) { - super(() -> a.getAsBoolean() && b.getAsBoolean()); - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/buttons/InvertingBooleanSupplier.java b/src/main/java/xbot/common/controls/sensors/buttons/InvertingBooleanSupplier.java deleted file mode 100644 index 1f98ea73..00000000 --- a/src/main/java/xbot/common/controls/sensors/buttons/InvertingBooleanSupplier.java +++ /dev/null @@ -1,29 +0,0 @@ -package xbot.common.controls.sensors.buttons; - -import java.util.function.BooleanSupplier; - -public class InvertingBooleanSupplier implements BooleanSupplier { - - private boolean isInverted = false; - private BooleanSupplier supplier; - - public InvertingBooleanSupplier(BooleanSupplier supplier) { - this.supplier = supplier; - } - - public void setInverted(boolean isInverted) { - this.isInverted = isInverted; - } - - public boolean getInverted() { - return this.isInverted; - } - - @Override - public boolean getAsBoolean() { - return this.supplier.getAsBoolean() ^ this.isInverted; - } - - - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/buttons/SettableBooleanSuppler.java b/src/main/java/xbot/common/controls/sensors/buttons/SettableBooleanSuppler.java deleted file mode 100644 index f3ec211c..00000000 --- a/src/main/java/xbot/common/controls/sensors/buttons/SettableBooleanSuppler.java +++ /dev/null @@ -1,26 +0,0 @@ -package xbot.common.controls.sensors.buttons; - -import java.util.function.BooleanSupplier; - -public class SettableBooleanSuppler implements BooleanSupplier { - - private boolean value; - - public SettableBooleanSuppler(boolean defaultValue) { - this.value = defaultValue; - } - - @Override - public boolean getAsBoolean() { - return value; - } - - public void set(boolean value) { - this.value = value; - } - - public void toggle() { - this.value = !this.value; - } - -} diff --git a/src/main/java/xbot/common/controls/sensors/buttons/VirtualTrigger.java b/src/main/java/xbot/common/controls/sensors/buttons/VirtualTrigger.java deleted file mode 100644 index 8e143773..00000000 --- a/src/main/java/xbot/common/controls/sensors/buttons/VirtualTrigger.java +++ /dev/null @@ -1,42 +0,0 @@ -package xbot.common.controls.sensors.buttons; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -/** - * A virtual button under program control that can be used for creating chords. - * This is useful to repurpose buttons in multiple "modes". - */ -public class VirtualTrigger extends AdvancedTrigger { - - private SettableBooleanSuppler supplier; - - @AssistedFactory - public abstract static class VirtualTriggerFactory { - public abstract VirtualTrigger create(@Assisted boolean defaultPressed); - - public VirtualTrigger create() { - return create(false); - } - } - - @AssistedInject - public VirtualTrigger(@Assisted boolean defaultPressed) { - this(new SettableBooleanSuppler(defaultPressed)); - } - - public VirtualTrigger(SettableBooleanSuppler supplier) { - super(supplier); - this.supplier = supplier; - } - - public void set(boolean value) { - this.supplier.set(value); - } - - public void toggle() { - this.supplier.toggle(); - } - -} diff --git a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockAbsoluteEncoder.java b/src/main/java/xbot/common/controls/sensors/mock_adapters/MockAbsoluteEncoder.java deleted file mode 100644 index a3a416cb..00000000 --- a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockAbsoluteEncoder.java +++ /dev/null @@ -1,98 +0,0 @@ -package xbot.common.controls.sensors.mock_adapters; - -import org.json.JSONObject; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.sensors.XAbsoluteEncoder; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; -import xbot.common.injection.electrical_contract.DeviceInfo; -import xbot.common.math.WrappedRotation2d; -import xbot.common.properties.BooleanProperty; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; -import xbot.common.resiliency.DeviceHealth; -import xbot.common.simulation.ISimulatableSensor; - -public class MockAbsoluteEncoder extends XAbsoluteEncoder implements ISimulatableSensor { - - private final int deviceId; - private final BooleanProperty inverted; - private final DoubleProperty simulationScale; - private final DoubleProperty positionOffset; - - private double velocity; - private WrappedRotation2d absolutePosition; - - @AssistedFactory - public abstract static class MockAbsoluteEncoderFactory implements XAbsoluteEncoderFactory { - public abstract MockAbsoluteEncoder create( - @Assisted("deviceInfo") DeviceInfo deviceInfo, - @Assisted("owningSystemPrefix") String owningSystemPrefix); - } - - @AssistedInject - public MockAbsoluteEncoder(@Assisted("deviceInfo") DeviceInfo deviceInfo, - @Assisted("owningSystemPrefix") String owningSystemPrefix, - DevicePolice police, PropertyFactory pf) { - pf.setPrefix(owningSystemPrefix); - - this.deviceId = deviceInfo.channel; - this.velocity = 0; - this.absolutePosition = new WrappedRotation2d(0); - this.positionOffset = pf.createEphemeralProperty("PositionOffset", 0); - this.inverted = pf.createEphemeralProperty("Inverted", deviceInfo.inverted); - this.simulationScale = pf.createEphemeralProperty("SimulationScale", deviceInfo.simulationScalingValue); - - police.registerDevice(DeviceType.CAN, deviceInfo.channel, this); - } - - @Override - public int getDeviceId() { - return this.deviceId; - } - - @Override - public double getPosition() { - return WrappedRotation2d.fromDegrees(this.absolutePosition.getDegrees() + this.positionOffset.get()).getDegrees() * (inverted.get() ? -1 : 1); - } - - @Override - public double getAbsolutePosition() { - return this.absolutePosition.getDegrees() * (inverted.get() ? -1 : 1); - } - - @Override - public double getVelocity() { - return this.velocity * (inverted.get() ? -1 : 1); - } - - @Override - public void setPosition(double newPosition) { - this.positionOffset.set(WrappedRotation2d.fromDegrees(newPosition).minus(this.absolutePosition).getDegrees()); - } - - - public double getPositionOffset() { - return this.positionOffset.get(); - } - - public void setAbsolutePosition(double position) { - this.absolutePosition = WrappedRotation2d.fromDegrees(position * (inverted.get() ? -1 : 1)); - } - - @Override - public void ingestSimulationData(JSONObject payload) { - setAbsolutePosition( - payload.getBigDecimal("EncoderTicks").doubleValue() * this.simulationScale.get() - ); - } - - @Override - public DeviceHealth getHealth() { - return DeviceHealth.Healthy; - } -} diff --git a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockCANCoder.java b/src/main/java/xbot/common/controls/sensors/mock_adapters/MockCANCoder.java deleted file mode 100644 index 7a55b152..00000000 --- a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockCANCoder.java +++ /dev/null @@ -1,133 +0,0 @@ -package xbot.common.controls.sensors.mock_adapters; - -import com.ctre.phoenix.ErrorCode; -import com.ctre.phoenix.sensors.CANCoderFaults; -import com.ctre.phoenix.sensors.CANCoderStatusFrame; -import com.ctre.phoenix.sensors.CANCoderStickyFaults; - -import org.json.JSONObject; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.sensors.XCANCoder; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; -import xbot.common.injection.electrical_contract.DeviceInfo; -import xbot.common.math.WrappedRotation2d; -import xbot.common.properties.BooleanProperty; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; -import xbot.common.resiliency.DeviceHealth; -import xbot.common.simulation.ISimulatableSensor; - -public class MockCANCoder extends XCANCoder implements ISimulatableSensor { - - private final int deviceId; - private final BooleanProperty inverted; - private final DoubleProperty simulationScale; - private final DoubleProperty positionOffset; - - private double velocity; - private WrappedRotation2d absolutePosition; - - @AssistedFactory - public abstract static class MockCANCoderFactory implements XCANCoderFactory { - public abstract MockCANCoder create( - @Assisted("deviceInfo") DeviceInfo deviceInfo, - @Assisted("owningSystemPrefix") String owningSystemPrefix); - } - - @AssistedInject - public MockCANCoder(@Assisted("deviceInfo") DeviceInfo deviceInfo, - @Assisted("owningSystemPrefix") String owningSystemPrefix, - DevicePolice police, PropertyFactory pf) { - pf.setPrefix(owningSystemPrefix); - - this.deviceId = deviceInfo.channel; - this.velocity = 0; - this.absolutePosition = new WrappedRotation2d(0); - this.positionOffset = pf.createEphemeralProperty("PositionOffset", 0); - this.inverted = pf.createEphemeralProperty("Inverted", deviceInfo.inverted); - this.simulationScale = pf.createEphemeralProperty("SimulationScale", deviceInfo.simulationScalingValue); - - police.registerDevice(DeviceType.CAN, deviceInfo.channel, this); - } - - @Override - public int getDeviceId() { - return this.deviceId; - } - - @Override - public double getPosition() { - return WrappedRotation2d.fromDegrees(this.absolutePosition.getDegrees() + this.positionOffset.get()).getDegrees() * (inverted.get() ? -1 : 1); - } - - @Override - public double getAbsolutePosition() { - return this.absolutePosition.getDegrees() * (inverted.get() ? -1 : 1); - } - - @Override - public double getVelocity() { - return this.velocity * (inverted.get() ? -1 : 1); - } - - @Override - public void setPosition(double newPosition) { - this.positionOffset.set(WrappedRotation2d.fromDegrees(newPosition).minus(this.absolutePosition).getDegrees()); - } - - - public double getPositionOffset() { - return this.positionOffset.get(); - } - - public void setAbsolutePosition(double position) { - this.absolutePosition = WrappedRotation2d.fromDegrees(position * (inverted.get() ? -1 : 1)); - } - - @Override - public void ingestSimulationData(JSONObject payload) { - setAbsolutePosition( - payload.getBigDecimal("EncoderTicks").doubleValue() * this.simulationScale.get() - ); - } - - @Override - public DeviceHealth getHealth() { - return DeviceHealth.Healthy; - } - - @Override - public ErrorCode setStatusFramePeriod(CANCoderStatusFrame frame, int periodMs) { - return ErrorCode.OK; - } - - @Override - public int getStatusFramePeriod(CANCoderStatusFrame frame) { - return 20; - } - - @Override - public ErrorCode getFaults(CANCoderFaults toFill) { - return ErrorCode.OK; - } - - @Override - public ErrorCode getStickyFaults(CANCoderStickyFaults toFill) { - return ErrorCode.OK; - } - - @Override - public ErrorCode clearStickyFaults() { - return ErrorCode.OK; - } - - @Override - public boolean hasResetOccurred() { - return false; - } -} diff --git a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockDutyCycleEncoder.java b/src/main/java/xbot/common/controls/sensors/mock_adapters/MockDutyCycleEncoder.java deleted file mode 100644 index c720d054..00000000 --- a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockDutyCycleEncoder.java +++ /dev/null @@ -1,39 +0,0 @@ -package xbot.common.controls.sensors.mock_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import edu.wpi.first.wpilibj.MockAnalogInput; -import xbot.common.controls.sensors.XAnalogInput; -import xbot.common.controls.sensors.XDutyCycleEncoder; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.electrical_contract.DeviceInfo; - -public class MockDutyCycleEncoder extends XDutyCycleEncoder { - - private double rawPosition; - - @AssistedFactory - public abstract static class MockDutyCycleEncoderFactory implements XDutyCycleEncoder.XDutyCycleEncoderFactory { - public abstract MockDutyCycleEncoder create(@Assisted("info") DeviceInfo info); - } - - @AssistedInject - public MockDutyCycleEncoder(@Assisted("info") DeviceInfo info, DevicePolice police) { - super(info, police); - } - - @Override - protected double getAbsoluteRawPosition() { - return rawPosition; - } - - public void setRawPosition(double rawPosition) { - this.rawPosition = rawPosition * inversionFactor(); - } - - @Override - public int getChannel() { - return channel; - } -} diff --git a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockEncoder.java b/src/main/java/xbot/common/controls/sensors/mock_adapters/MockEncoder.java deleted file mode 100644 index cf2b30c1..00000000 --- a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockEncoder.java +++ /dev/null @@ -1,62 +0,0 @@ -package xbot.common.controls.sensors.mock_adapters; - -import org.json.JSONObject; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.sensors.XEncoder; -import xbot.common.injection.DevicePolice; -import xbot.common.properties.PropertyFactory; -import xbot.common.simulation.ISimulatableSensor; - -public class MockEncoder extends XEncoder implements ISimulatableSensor { - - private double distance; - private double rate; - - @AssistedFactory - public abstract static class MockEncoderFactory implements XEncoderFactory { - public abstract MockEncoder create( - @Assisted("name") String name, - @Assisted("aChannel") int aChannel, - @Assisted("bChannel") int bChannel, - @Assisted("defaultDistancePerPulse") double defaultDistancePerPulse); - } - - @AssistedInject - public MockEncoder(@Assisted("name") String name, @Assisted("aChannel") int aChannel, - @Assisted("bChannel") int bChannel, @Assisted("defaultDistancePerPulse") double defaultDistancePerPulse, - PropertyFactory propMan, DevicePolice police) { - super(name, aChannel, bChannel, defaultDistancePerPulse, propMan, police); - } - - public MockEncoder(String prefix, PropertyFactory propMan) { - super(prefix, propMan); - } - - public void setDistance(double distance) { - this.distance = distance * (isInverted ? -1 : 1); - } - - protected double getRate() { - return rate; - } - - public void setRate(double newRate) { - this.rate = newRate; - } - - protected double getDistance() { - return distance; - } - - public void setSamplesToAverage(int samples) { - } - - @Override - public void ingestSimulationData(JSONObject payload) { - setDistance((double)payload.get("EncoderTicks")); - } -} diff --git a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockFTCGamepad.java b/src/main/java/xbot/common/controls/sensors/mock_adapters/MockFTCGamepad.java deleted file mode 100644 index d4b8072f..00000000 --- a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockFTCGamepad.java +++ /dev/null @@ -1,108 +0,0 @@ -package xbot.common.controls.sensors.mock_adapters; - -import java.util.HashMap; -import java.util.Map; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import edu.wpi.first.wpilibj.GenericHID; -import xbot.common.controls.sensors.XFTCGamepad; -import xbot.common.controls.sensors.buttons.AdvancedJoystickButtonTrigger.AdvancedJoystickButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AdvancedPovButtonTrigger.AdvancedPovButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger.AnalogHIDButtonTriggerFactory; -import xbot.common.injection.DevicePolice; -import xbot.common.logging.RobotAssertionManager; -import xbot.common.math.XYPair; - -public class MockFTCGamepad extends XFTCGamepad { - - Map buttons = new HashMap(); - Map rawAxis = new HashMap(); - - @AssistedFactory - public abstract static class MockFTCGamepadFactory implements XFTCGamepadFactory { - public abstract MockFTCGamepad create( - @Assisted("port") int port, - @Assisted("numButtons") int numButtons); - } - - @AssistedInject - public MockFTCGamepad( - @Assisted("port") int port, - AdvancedJoystickButtonTriggerFactory joystickButtonFactory, - AdvancedPovButtonTriggerFactory povButtonFactory, - AnalogHIDButtonTriggerFactory analogHidButtonFactory, - RobotAssertionManager assertionManager, - @Assisted("numButtons") int numButtons, - DevicePolice police) { - - super(port, joystickButtonFactory, povButtonFactory, analogHidButtonFactory, assertionManager, numButtons, police); - - for(int i = 0; i < 6; i++) - { - rawAxis.put(i, 0d); - } - - for(int i = 0; i < 12; i++) - { - releaseButton(i); - } - } - - public void setX(double x) { - setRawAxis(0, x); - } - - public void setY(double y) { - setRawAxis(1, y); - } - - public void setRawAxis(int which, double value) { - rawAxis.put(which, value); - } - - public void pressButton(int button) { - buttons.put(button, true); - } - - public void releaseButton(int button) { - buttons.put(button, false); - } - - public boolean getButton(int button) { - return buttons.getOrDefault(button, false); - } - - public double getRawAxis(int which) { - return rawAxis.get(which); - } - - private void setStick(XYPair vector, int xAxis, int yAxis) { - setRawAxis(xAxis, getAxisInverted(xAxis) ? -vector.x : vector.x); - setY(getAxisInverted(getLeftJoystickYAxis()) ? -vector.y : vector.y); - } - - public void setLeftStick(XYPair vector) { - int xAxis = getLeftJoystickXAxis(); - int yAxis = getLeftJoystickYAxis(); - setStick(vector, xAxis, yAxis); - } - - public void setRightStick(XYPair vector) { - int xAxis = getRightJoystickXAxis(); - int yAxis = getRightJoystickYAxis(); - setStick(vector, xAxis, yAxis); - } - - @Override - public int getPOV() { - return 0; - } - - @Override - public GenericHID getGenericHID() { - // We don't have a real HID - return null; - } -} diff --git a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockGyro.java b/src/main/java/xbot/common/controls/sensors/mock_adapters/MockGyro.java deleted file mode 100644 index f452592a..00000000 --- a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockGyro.java +++ /dev/null @@ -1,165 +0,0 @@ -package xbot.common.controls.sensors.mock_adapters; - -import java.math.BigDecimal; - -import org.json.JSONObject; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.I2C; -import edu.wpi.first.wpilibj.SPI; -import edu.wpi.first.wpilibj.SerialPort; -import xbot.common.controls.sensors.XGyro; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; -import xbot.common.simulation.ISimulatableSensor; - -public class MockGyro extends XGyro implements ISimulatableSensor { - private boolean isBroken; - - private double yaw; - private double pitch; - private double roll; - private double yawAngularVelocity; - private double velocityX; - private double velocityY; - private double velocityZ; - private double rawAccelX; - private double rawAccelY; - private double rawAccelZ; - - @AssistedFactory - public abstract static class MockGyroFactory extends XGyroFactory { - @Override - public abstract MockGyro create(@Assisted SPI.Port spiPort, @Assisted SerialPort.Port serialPort, @Assisted I2C.Port i2cPort); - } - - @AssistedInject - public MockGyro(DevicePolice police, @Assisted SPI.Port spiPort, @Assisted SerialPort.Port serialPort, @Assisted I2C.Port i2cPort) { - super(ImuType.mock); - if (spiPort != null) { - police.registerDevice(DeviceType.IMU, spiPort.value, this); - } else if (serialPort != null) { - police.registerDevice(DeviceType.IMU, serialPort.value, this); - } else if (i2cPort != null) { - police.registerDevice(DeviceType.IMU, i2cPort.value, this); - } - } - - public boolean isConnected() { - return true; - } - - public void setYaw(double yaw) { - this.yaw = yaw; - } - - public double getDeviceYaw() { - return yaw; - } - - public void setIsBroken(boolean broken) { - this.isBroken = broken; - } - - public boolean isBroken() { - return isBroken; - } - - public void setRoll(double roll) { - this.roll = roll; - } - - public double getDeviceRoll() { - return roll; - } - - public void setPitch(double pitch) { - this.pitch = pitch; - } - - public double getDevicePitch() { - return pitch; - } - - public void setYawAngularVelocity(double yawAngularVelocity) { - this.yawAngularVelocity = yawAngularVelocity; - } - - public double getDeviceYawAngularVelocity() { - return yawAngularVelocity; - } - - @Override - public double getDeviceVelocityX() { - return this.velocityX; - } - - public void setDeviceVelocityX(double velocity) { - this.velocityX = velocity; - } - - @Override - public double getDeviceVelocityY() { - return this.velocityY; - } - - public void setDeviceVelocityY(double velocity) { - this.velocityY = velocity; - } - - @Override - public double getDeviceVelocityZ() { - return this.velocityZ; - } - - public void setDeviceVelocityZ(double velocity) { - this.velocityZ = velocity; - } - - @Override - public double getDeviceRawAccelX() { - return this.rawAccelX; - } - - public void setDeviceRawAccelX(double accel) { - this.rawAccelX = accel; - } - - @Override - public double getDeviceRawAccelY() { - return this.rawAccelY; - } - - public void setDeviceRawAccelY(double accel) { - this.rawAccelY = accel; - } - - @Override - public double getDeviceRawAccelZ() { - return this.rawAccelZ; - } - - public void setDeviceRawAccelZ(double accel) { - this.rawAccelZ = accel; - } - - @Override - public void ingestSimulationData(JSONObject payload) { - BigDecimal intermediateYaw = (BigDecimal)payload.get("Roll"); - BigDecimal intermediateYawVelocity = (BigDecimal)payload.get("YawVelocity"); - - // The simulation returns values between -pi and pi, which is just like the NavX returning -180 to 180. We just need - // to do a quick conversion. - double yawInDegrees = intermediateYaw.doubleValue() * 180.0 / Math.PI; - double yawVelocityInDegrees = intermediateYawVelocity.doubleValue() * 180.0 / Math.PI; - - this.setYaw(yawInDegrees); - this.setYawAngularVelocity(yawVelocityInDegrees); - - // Eventually we will have more of these for more IMU elements - } - -} diff --git a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockJoystick.java b/src/main/java/xbot/common/controls/sensors/mock_adapters/MockJoystick.java deleted file mode 100644 index c66bf544..00000000 --- a/src/main/java/xbot/common/controls/sensors/mock_adapters/MockJoystick.java +++ /dev/null @@ -1,90 +0,0 @@ -package xbot.common.controls.sensors.mock_adapters; - -import java.util.HashMap; -import java.util.Map; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.GenericHID; -import xbot.common.controls.sensors.XJoystick; -import xbot.common.controls.sensors.buttons.AdvancedJoystickButtonTrigger.AdvancedJoystickButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AdvancedPovButtonTrigger.AdvancedPovButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger.AnalogHIDButtonTriggerFactory; -import xbot.common.injection.DevicePolice; -import xbot.common.logging.RobotAssertionManager; - -public class MockJoystick extends XJoystick { - - Map buttons = new HashMap(); - Map rawAxis = new HashMap(); - - @AssistedFactory - public abstract static class MockJoystickFactory implements XJoystickFactory { - @Override - public abstract MockJoystick create(@Assisted("port") int port, @Assisted("numButtons") int numButtons); - } - - @AssistedInject - public MockJoystick( - @Assisted("port") int port, - AdvancedJoystickButtonTriggerFactory joystickButtonFactory, - AdvancedPovButtonTriggerFactory povButtonFactory, - AnalogHIDButtonTriggerFactory analogHidButtonFactory, - RobotAssertionManager assertionManager, - @Assisted("numButtons") int numButtons, - DevicePolice police) { - - super(port, joystickButtonFactory, povButtonFactory, analogHidButtonFactory, assertionManager, numButtons, police); - - for(int i = 0; i < 6; i++) - { - rawAxis.put(i, 0d); - } - - for(int i = 0; i < 12; i++) - { - releaseButton(i); - } - } - - public void setX(double x) { - setRawAxis(0, x); - } - - public void setY(double y) { - setRawAxis(1, y); - } - - public void setRawAxis(int which, double value) { - rawAxis.put(which, value); - } - - public void pressButton(int button) { - buttons.put(button, true); - } - - public void releaseButton(int button) { - buttons.put(button, false); - } - - public boolean getButton(int button) { - return buttons.getOrDefault(button, false); - } - - public double getRawAxis(int which) { - return rawAxis.get(which); - } - - @Override - public int getPOV() { - return 0; - } - - @Override - public GenericHID getGenericHID() { - // We don't have a real HID - return null; - } -} diff --git a/src/main/java/xbot/common/controls/sensors/wpi_adapters/AnalogInputWPIAdapater.java b/src/main/java/xbot/common/controls/sensors/wpi_adapters/AnalogInputWPIAdapater.java deleted file mode 100644 index 504d3edf..00000000 --- a/src/main/java/xbot/common/controls/sensors/wpi_adapters/AnalogInputWPIAdapater.java +++ /dev/null @@ -1,53 +0,0 @@ -package xbot.common.controls.sensors.wpi_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import edu.wpi.first.wpilibj.AnalogInput; -import xbot.common.controls.sensors.XAnalogInput; -import xbot.common.injection.DevicePolice; - -public class AnalogInputWPIAdapater extends XAnalogInput { - AnalogInput input; - - @AssistedFactory - public abstract static class AnalogInputWPIAdapaterFactory implements XAnalogInputFactory { - public abstract AnalogInputWPIAdapater create(@Assisted("channel") int channel); - } - - @AssistedInject - public AnalogInputWPIAdapater(@Assisted("channel") int channel, DevicePolice police) { - super(channel, police); - input = new AnalogInput(channel); - } - - public int getValue() { - return input.getValue(); - } - - public double getVoltage() { - return input.getVoltage(); - } - - public double getAverageVoltage() { - return input.getAverageVoltage(); - } - - public void setAverageBits(int bits) { - input.setAverageBits(bits); - } - - public AnalogInput getInternalDevice() { - return input; - } - - @Override - public int getChannel() { - return input.getChannel(); - } - - @Override - public boolean getAsDigital(double threshold) { - return getVoltage() >= threshold; - } -} diff --git a/src/main/java/xbot/common/controls/sensors/wpi_adapters/CANCoderAdapter.java b/src/main/java/xbot/common/controls/sensors/wpi_adapters/CANCoderAdapter.java deleted file mode 100644 index eae787f3..00000000 --- a/src/main/java/xbot/common/controls/sensors/wpi_adapters/CANCoderAdapter.java +++ /dev/null @@ -1,146 +0,0 @@ -package xbot.common.controls.sensors.wpi_adapters; - -import com.ctre.phoenix.ErrorCode; -import com.ctre.phoenix.sensors.CANCoder; -import com.ctre.phoenix.sensors.CANCoderFaults; -import com.ctre.phoenix.sensors.CANCoderStatusFrame; -import com.ctre.phoenix.sensors.CANCoderStickyFaults; -import com.ctre.phoenix.sensors.WPI_CANCoder; - -import org.apache.log4j.Logger; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.sensors.XCANCoder; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; -import xbot.common.injection.electrical_contract.DeviceInfo; -import xbot.common.properties.BooleanProperty; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; -import xbot.common.resiliency.DeviceHealth; - -public class CANCoderAdapter extends XCANCoder { - - private static final Logger log = Logger.getLogger(CANCoderAdapter.class); - - private final int deviceId; - private final CANCoder cancoder; - - private final DoubleProperty magnetOffset; - private final BooleanProperty inverted; - - @AssistedFactory - public abstract static class CANCoderAdapterFactory implements XCANCoderFactory { - public abstract CANCoderAdapter create( - @Assisted("deviceInfo") DeviceInfo deviceInfo, - @Assisted("owningSystemPrefix") String owningSystemPrefix); - } - - @AssistedInject - public CANCoderAdapter(@Assisted("deviceInfo") DeviceInfo deviceInfo, - @Assisted("owningSystemPrefix") String owningSystemPrefix, - DevicePolice police, PropertyFactory pf) { - pf.setPrefix(owningSystemPrefix); - - this.inverted = pf.createEphemeralProperty("Inverted", deviceInfo.inverted); - this.magnetOffset = pf.createEphemeralProperty("Magnet offset", 0.0); - - this.cancoder = new WPI_CANCoder(deviceInfo.channel, "rio"); - this.cancoder.configSensorDirection(this.inverted.get()); - this.getMagnetOffset(); - - this.deviceId = deviceInfo.channel; - - police.registerDevice(DeviceType.CAN, deviceInfo.channel, this); - } - - @Override - public int getDeviceId() { - return this.deviceId; - } - - @Override - public double getPosition() { - return this.cancoder.getPosition(); - } - - @Override - public double getAbsolutePosition() { - return this.cancoder.getAbsolutePosition(); - } - - @Override - public double getVelocity() { - return this.cancoder.getVelocity(); - } - - public DeviceHealth getHealth() { - if (this.cancoder.getFirmwareVersion() == -1) { - return DeviceHealth.Unhealthy; - } - return DeviceHealth.Healthy; - } - - @Override - public void setPosition(double newPosition) { - this.cancoder.setPosition(newPosition); - } - - /** - * Gets the magnet offset configured on the encoder device. - * @return The magnet offset in degrees - */ - public double getMagnetOffset() { - this.magnetOffset.set(this.cancoder.configGetMagnetOffset()); - return this.magnetOffset.get(); - } - - /** - * Sets the magnet offset configured on the encoder device. - * @param offsetInDegrees The magnet offset in degrees - * @return True on success. - */ - public boolean setMagnetOffset(double offsetInDegrees) { - ErrorCode errorCode = this.cancoder.configMagnetOffset(offsetInDegrees); - if (errorCode.value != 0) { - log.error("Failed to set magnet offset for device " + this.getDeviceId() + ". Error code: " + errorCode.value); - return false; - } else { - this.magnetOffset.set(offsetInDegrees); - return true; - } - } - - @Override - public ErrorCode setStatusFramePeriod(CANCoderStatusFrame frame, int periodMs) { - return this.cancoder.setStatusFramePeriod(frame, periodMs); - } - - @Override - public int getStatusFramePeriod(CANCoderStatusFrame frame) { - return this.cancoder.getStatusFramePeriod(frame); - } - - @Override - public ErrorCode getFaults(CANCoderFaults toFill) { - return this.cancoder.getFaults(toFill); - } - - @Override - public ErrorCode getStickyFaults(CANCoderStickyFaults toFill) { - return this.cancoder.getStickyFaults(toFill); - } - - @Override - public ErrorCode clearStickyFaults() { - return this.cancoder.clearStickyFaults(); - } - - @Override - public boolean hasResetOccurred() { - return this.cancoder.hasResetOccurred(); - } -} diff --git a/src/main/java/xbot/common/controls/sensors/wpi_adapters/DigitalInputWPIAdapter.java b/src/main/java/xbot/common/controls/sensors/wpi_adapters/DigitalInputWPIAdapter.java deleted file mode 100644 index b42f1ca7..00000000 --- a/src/main/java/xbot/common/controls/sensors/wpi_adapters/DigitalInputWPIAdapter.java +++ /dev/null @@ -1,50 +0,0 @@ -package xbot.common.controls.sensors.wpi_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.DigitalInput; -import xbot.common.controls.sensors.XDigitalInput; -import xbot.common.injection.DevicePolice; - -public class DigitalInputWPIAdapter extends XDigitalInput { - - protected DigitalInput adapter; - - @AssistedFactory - public abstract static class DigitalInputWPIAdapterFactory implements XDigitalInputFactory - { - public abstract DigitalInputWPIAdapter create(@Assisted("channel") int channel); - } - - /** - * Create an instance of a Digital Input class. Creates a digital input given a channel. - * - * @param channel - * the DIO channel for the digital input 0-9 are on-board, 10-25 are on the MXP - */ - @AssistedInject - public DigitalInputWPIAdapter(@Assisted("channel") int channel, DevicePolice police) { - super(police, channel); - adapter = new DigitalInput(channel); - } - - /** - * Get the value from a digital input channel. Retrieve the value of a single digital input channel from the FPGA. - * - * @return the status of the digital input - */ - protected boolean getRaw() { - return adapter.get(); - } - - /** - * Get the channel of the digital input - * - * @return The GPIO channel number that this object represents. - */ - public int getChannel() { - return adapter.getChannel(); - } -} diff --git a/src/main/java/xbot/common/controls/sensors/wpi_adapters/DutyCycleEncoderWpiAdapter.java b/src/main/java/xbot/common/controls/sensors/wpi_adapters/DutyCycleEncoderWpiAdapter.java deleted file mode 100644 index afa208ea..00000000 --- a/src/main/java/xbot/common/controls/sensors/wpi_adapters/DutyCycleEncoderWpiAdapter.java +++ /dev/null @@ -1,31 +0,0 @@ -package xbot.common.controls.sensors.wpi_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import edu.wpi.first.wpilibj.DutyCycleEncoder; -import xbot.common.controls.sensors.XDutyCycleEncoder; -import xbot.common.controls.sensors.mock_adapters.MockDutyCycleEncoder; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.electrical_contract.DeviceInfo; - -public class DutyCycleEncoderWpiAdapter extends XDutyCycleEncoder { - - DutyCycleEncoder internalEncoder; - - @AssistedFactory - public abstract static class DutyCycleEncoderWpiAdapterFactory implements XDutyCycleEncoder.XDutyCycleEncoderFactory { - public abstract DutyCycleEncoderWpiAdapter create(@Assisted("info") DeviceInfo info); - } - - @AssistedInject - public DutyCycleEncoderWpiAdapter(@Assisted("info") DeviceInfo info, DevicePolice police) { - super(info, police); - internalEncoder = new DutyCycleEncoder(info.channel); - } - - @Override - protected double getAbsoluteRawPosition() { - return internalEncoder.get(); - } -} diff --git a/src/main/java/xbot/common/controls/sensors/wpi_adapters/EncoderWPIAdapter.java b/src/main/java/xbot/common/controls/sensors/wpi_adapters/EncoderWPIAdapter.java deleted file mode 100644 index a113ae46..00000000 --- a/src/main/java/xbot/common/controls/sensors/wpi_adapters/EncoderWPIAdapter.java +++ /dev/null @@ -1,47 +0,0 @@ -package xbot.common.controls.sensors.wpi_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import edu.wpi.first.wpilibj.Encoder; -import xbot.common.controls.sensors.XEncoder; -import xbot.common.injection.DevicePolice; -import xbot.common.properties.PropertyFactory; - -public class EncoderWPIAdapter extends XEncoder { - - Encoder internalEncoder; - - @AssistedFactory - public abstract static class EncoderWPIAdapterFactory implements XEncoderFactory { - public abstract EncoderWPIAdapter create( - @Assisted("name") String name, - @Assisted("aChannel") int aChannel, - @Assisted("bChannel") int bChannel, - @Assisted("defaultDistancePerPulse") double defaultDistancePerPulse); - } - - @AssistedInject - public EncoderWPIAdapter( - @Assisted("name")String name, - @Assisted("aChannel") int aChannel, - @Assisted("bChannel") int bChannel, - @Assisted("defaultDistancePerPulse") double defaultDistancePerPulse, - PropertyFactory propMan, - DevicePolice police) { - super(name, aChannel, bChannel, defaultDistancePerPulse, propMan, police); - internalEncoder = new Encoder(aChannel, bChannel); - } - - protected double getRate() { - return internalEncoder.getRate(); - } - - protected double getDistance() { - return internalEncoder.getDistance(); - } - - public void setSamplesToAverage(int samples) { - internalEncoder.setSamplesToAverage(samples); - } -} diff --git a/src/main/java/xbot/common/controls/sensors/wpi_adapters/FTCGamepadWpiAdapter.java b/src/main/java/xbot/common/controls/sensors/wpi_adapters/FTCGamepadWpiAdapter.java deleted file mode 100644 index 26c24ace..00000000 --- a/src/main/java/xbot/common/controls/sensors/wpi_adapters/FTCGamepadWpiAdapter.java +++ /dev/null @@ -1,66 +0,0 @@ -package xbot.common.controls.sensors.wpi_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.GenericHID; -import edu.wpi.first.wpilibj.Joystick; -import xbot.common.controls.sensors.XFTCGamepad; -import xbot.common.controls.sensors.buttons.AdvancedJoystickButtonTrigger.AdvancedJoystickButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AdvancedPovButtonTrigger.AdvancedPovButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger.AnalogHIDButtonTriggerFactory; -import xbot.common.injection.DevicePolice; -import xbot.common.logging.RobotAssertionManager; - -public class FTCGamepadWpiAdapter extends XFTCGamepad { - - private GenericHID internalHID; - - @AssistedFactory - public abstract static class FTCGamepadWpiAdapterFactory implements XFTCGamepadFactory { - public abstract FTCGamepadWpiAdapter create( - @Assisted("port") int port, - @Assisted("numButtons") int numButtons); - } - - @AssistedInject - public FTCGamepadWpiAdapter( - @Assisted("port") int port, - @Assisted("numButtons") int numButtons, - AdvancedJoystickButtonTriggerFactory joystickButtonFactory, - AdvancedPovButtonTriggerFactory povButtonFactory, - AnalogHIDButtonTriggerFactory analogHidButtonFactory, - RobotAssertionManager assertionManager, - DevicePolice police) { - super(port, joystickButtonFactory, povButtonFactory, analogHidButtonFactory, assertionManager, numButtons, police); - - internalHID = new Joystick(port); - } - - protected double getX() { - return internalHID.getRawAxis(0); - } - - protected double getY() { - return internalHID.getRawAxis(1); - } - - public double getRawAxis(int axisNumber) { - return this.internalHID.getRawAxis(axisNumber); - } - - public boolean getButton(int button) { - return this.internalHID.getRawButton(button); - } - - @Override - public int getPOV() { - return this.internalHID.getPOV(); - } - - @Override - public GenericHID getGenericHID() { - return internalHID; - } -} diff --git a/src/main/java/xbot/common/controls/sensors/wpi_adapters/InertialMeasurementUnitAdapter.java b/src/main/java/xbot/common/controls/sensors/wpi_adapters/InertialMeasurementUnitAdapter.java deleted file mode 100644 index 50b128ea..00000000 --- a/src/main/java/xbot/common/controls/sensors/wpi_adapters/InertialMeasurementUnitAdapter.java +++ /dev/null @@ -1,115 +0,0 @@ -package xbot.common.controls.sensors.wpi_adapters; - -import com.kauailabs.navx.frc.AHRS; - -import org.apache.log4j.Logger; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.I2C; -import edu.wpi.first.wpilibj.SPI; -import edu.wpi.first.wpilibj.SerialPort; -import xbot.common.controls.sensors.XGyro; -import xbot.common.injection.DevicePolice; -import xbot.common.injection.DevicePolice.DeviceType; - -public class InertialMeasurementUnitAdapter extends XGyro { - - AHRS ahrs; - boolean isBroken = false; - - static Logger log = Logger.getLogger(InertialMeasurementUnitAdapter.class); - - @AssistedFactory - public abstract static class InertialMeasurementUnitAdapterFactory extends XGyroFactory { - public abstract InertialMeasurementUnitAdapter create(@Assisted SPI.Port spiPort, @Assisted SerialPort.Port serialPort, @Assisted I2C.Port i2cPort); - } - - @AssistedInject - public InertialMeasurementUnitAdapter(DevicePolice police, @Assisted SPI.Port spiPort, @Assisted SerialPort.Port serialPort, @Assisted I2C.Port i2cPort) { - super(ImuType.navX); - /* Options: Port.kMXP, SPI.kMXP, I2C.kMXP or SerialPort.kUSB */ - try { - if (spiPort != null) { - this.ahrs = new AHRS(spiPort); - police.registerDevice(DeviceType.SPI, spiPort.value, this); - } else if (serialPort != null) { - this.ahrs = new AHRS(serialPort); - police.registerDevice(DeviceType.IMU, serialPort.value, this); - } else if (i2cPort != null) { - this.ahrs = new AHRS(i2cPort); - police.registerDevice(DeviceType.I2C, i2cPort.value, this); - } else { - throw new Exception("No port provided"); - } - log.info("AHRS successfully created"); - } - catch (Exception e){ - isBroken = true; - log.warn("AHRS could not be created - gyro is broken!"); - } - } - - @Override - public boolean isConnected() { - return this.ahrs.isConnected(); - } - - protected double getDeviceYaw() { - return -this.ahrs.getYaw(); - } - - @Override - public double getDeviceRoll() { - return -this.ahrs.getRoll(); - } - - @Override - public double getDevicePitch() { - return -this.ahrs.getPitch(); - } - - @Override - public boolean isBroken() { - return isBroken; - } - - /** - * Note: this is in degrees per second. - */ - public double getDeviceYawAngularVelocity(){ - return ahrs.getRate(); - } - - @Override - public double getDeviceVelocityX() { - return ahrs.getVelocityX(); - } - - @Override - public double getDeviceVelocityY() { - return ahrs.getVelocityY(); - } - - @Override - public double getDeviceVelocityZ() { - return ahrs.getVelocityZ(); - } - - @Override - public double getDeviceRawAccelX() { - return ahrs.getRawAccelX(); - } - - @Override - public double getDeviceRawAccelY() { - return ahrs.getRawAccelY(); - } - - @Override - public double getDeviceRawAccelZ() { - return ahrs.getRawAccelZ(); - } -} diff --git a/src/main/java/xbot/common/controls/sensors/wpi_adapters/JoystickWPIAdapter.java b/src/main/java/xbot/common/controls/sensors/wpi_adapters/JoystickWPIAdapter.java deleted file mode 100644 index 484b1e2a..00000000 --- a/src/main/java/xbot/common/controls/sensors/wpi_adapters/JoystickWPIAdapter.java +++ /dev/null @@ -1,66 +0,0 @@ -package xbot.common.controls.sensors.wpi_adapters; - -import xbot.common.controls.sensors.XJoystick; -import xbot.common.controls.sensors.buttons.AdvancedJoystickButtonTrigger.AdvancedJoystickButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AdvancedPovButtonTrigger.AdvancedPovButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger.AnalogHIDButtonTriggerFactory; -import xbot.common.injection.DevicePolice; -import xbot.common.logging.RobotAssertionManager; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.GenericHID; -import edu.wpi.first.wpilibj.Joystick; - -public class JoystickWPIAdapter extends XJoystick { - - private GenericHID internalHID; - - @AssistedFactory - public abstract static class JoystickWPIAdapterFactory implements XJoystickFactory { - @Override - public abstract JoystickWPIAdapter create(@Assisted("port") int port, @Assisted("numButtons") int numButtons); - } - - @AssistedInject - public JoystickWPIAdapter( - @Assisted("port") int port, - @Assisted("numButtons") int numButtons, - AdvancedJoystickButtonTriggerFactory joystickButtonFactory, - AdvancedPovButtonTriggerFactory povButtonFactory, - AnalogHIDButtonTriggerFactory analogHidButtonFactory, - RobotAssertionManager assertionManager, - DevicePolice police) { - super(port, joystickButtonFactory, povButtonFactory, analogHidButtonFactory, assertionManager, numButtons, police); - - internalHID = new Joystick(port); - } - - protected double getX() { - return internalHID.getRawAxis(0); - } - - protected double getY() { - return internalHID.getRawAxis(1); - } - - public double getRawAxis(int axisNumber) { - return this.internalHID.getRawAxis(axisNumber); - } - - public boolean getButton(int button) { - return this.internalHID.getRawButton(button); - } - - @Override - public int getPOV() { - return this.internalHID.getPOV(); - } - - @Override - public GenericHID getGenericHID() { - return internalHID; - } -} diff --git a/src/main/java/xbot/common/controls/sensors/wpi_adapters/LidarLiteWpiAdapter.java b/src/main/java/xbot/common/controls/sensors/wpi_adapters/LidarLiteWpiAdapter.java deleted file mode 100644 index 9d6890f6..00000000 --- a/src/main/java/xbot/common/controls/sensors/wpi_adapters/LidarLiteWpiAdapter.java +++ /dev/null @@ -1,38 +0,0 @@ -package xbot.common.controls.sensors.wpi_adapters; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import edu.wpi.first.wpilibj.I2C; -import edu.wpi.first.wpilibj.I2C.Port; -import xbot.common.controls.sensors.XLidarLite; -import xbot.common.controls.sensors.XTimer; -import xbot.common.injection.DevicePolice; -import xbot.common.properties.PropertyFactory; - -public class LidarLiteWpiAdapter extends XLidarLite{ - - private I2C i2c; - - @AssistedFactory - public abstract static class LidarLiteWpiAdapterFactory implements XLidarLiteFactory { - public abstract LidarLiteWpiAdapter create(@Assisted("port") Port port, @Assisted("prefix") String prefix); - } - - @AssistedInject - public LidarLiteWpiAdapter(@Assisted("port") Port port, PropertyFactory propMan, DevicePolice police, @Assisted("prefix") String prefix) { - super(port, propMan, police, prefix); - - i2c = new I2C(port, lidar_address); - } - - @Override - // Update distance variable - public void update() { - i2c.write(lidar_config_register, 0x04); // Initiate measurement - XTimer.delay(0.04); // Delay for measurement to be taken - i2c.read(lidar_distance_register, 2, distance); // Read in measurement - XTimer.delay(0.01); // Delay to prevent over polling - } - -} diff --git a/src/main/java/xbot/common/controls/sensors/wpi_adapters/PowerDistributionPanelWPIAdapter.java b/src/main/java/xbot/common/controls/sensors/wpi_adapters/PowerDistributionPanelWPIAdapter.java deleted file mode 100644 index 84935590..00000000 --- a/src/main/java/xbot/common/controls/sensors/wpi_adapters/PowerDistributionPanelWPIAdapter.java +++ /dev/null @@ -1,28 +0,0 @@ -package xbot.common.controls.sensors.wpi_adapters; - -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.PowerDistribution; -import xbot.common.controls.sensors.XPowerDistributionPanel; - -public class PowerDistributionPanelWPIAdapter extends XPowerDistributionPanel { - - private PowerDistribution pdp; - - @AssistedFactory - public abstract static class PowerDistributionPanelWPIAdapaterFactory implements XPowerDistributionPanelFactory { - @Override - public abstract PowerDistributionPanelWPIAdapter create(); - } - - @AssistedInject - public PowerDistributionPanelWPIAdapter() { - pdp = new PowerDistribution(); - } - - @Override - public double getCurrent(int channel) { - return pdp.getCurrent(channel); - } -} diff --git a/src/main/java/xbot/common/controls/sensors/wpi_adapters/TimerWpiAdapter.java b/src/main/java/xbot/common/controls/sensors/wpi_adapters/TimerWpiAdapter.java deleted file mode 100644 index 42ed3b5f..00000000 --- a/src/main/java/xbot/common/controls/sensors/wpi_adapters/TimerWpiAdapter.java +++ /dev/null @@ -1,39 +0,0 @@ -package xbot.common.controls.sensors.wpi_adapters; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import edu.wpi.first.wpilibj.Timer; -import xbot.common.controls.sensors.XSettableTimerImpl; - -@Singleton -public class TimerWpiAdapter implements XSettableTimerImpl { - - @Inject - public TimerWpiAdapter() {} - - @Override - public double getFPGATimestamp() { - return Timer.getFPGATimestamp(); - } - - @Override - public double getMatchTime() { - return Timer.getMatchTime(); - } - - @Override - public void delay(double seconds) { - Timer.delay(seconds); - } - - @Override - public void setTimeInSeconds(double time) { - // Deliberately do nothing. - } - - @Override - public void advanceTimeInSecondsBy(double time) { - // Deliberately do nothing. - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/controls/sensors/wpi_adapters/XboxControllerWpiAdapter.java b/src/main/java/xbot/common/controls/sensors/wpi_adapters/XboxControllerWpiAdapter.java deleted file mode 100644 index 23ebecb0..00000000 --- a/src/main/java/xbot/common/controls/sensors/wpi_adapters/XboxControllerWpiAdapter.java +++ /dev/null @@ -1,84 +0,0 @@ -package xbot.common.controls.sensors.wpi_adapters; - -import xbot.common.controls.sensors.XXboxController; -import xbot.common.controls.sensors.buttons.AdvancedJoystickButtonTrigger.AdvancedJoystickButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AdvancedPovButtonTrigger.AdvancedPovButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger.AnalogHIDButtonTriggerFactory; -import xbot.common.injection.DevicePolice; -import xbot.common.logging.RobotAssertionManager; -import xbot.common.subsystems.feedback.XRumbleManager.XRumbleManagerFactory; -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.GenericHID; -import edu.wpi.first.wpilibj.XboxController; - -public class XboxControllerWpiAdapter extends XXboxController { - - protected XboxController controller; - - @AssistedFactory - public abstract static class XboxControllerWpiAdapterFactory implements XXboxControllerFactory { - public abstract XboxControllerWpiAdapter create(@Assisted("port") int port); - } - - @AssistedInject - public XboxControllerWpiAdapter(@Assisted("port") int port, AdvancedJoystickButtonTriggerFactory joystickButtonFactory, - AdvancedPovButtonTriggerFactory povButtonFactory, AnalogHIDButtonTriggerFactory analogHidButtonFactory, - XRumbleManagerFactory rumbleManagerFactory, RobotAssertionManager manager, DevicePolice police) { - super(port, joystickButtonFactory, povButtonFactory, analogHidButtonFactory, rumbleManagerFactory, manager, - police); - controller = new XboxController(port); - } - - @Override - public double getRawAxis(int axis) { - return controller.getRawAxis(axis); - } - - @Override - public boolean getButton(int button) { - return controller.getRawButton(button); - } - - @Override - public GenericHID getGenericHID() { - return controller; - } - - @Override - public int getPOV() { - return controller.getPOV(); - } - - @Override - protected double getLeftRawTriggerAxis() { - return controller.getLeftTriggerAxis(); - } - - @Override - protected double getRightRawTriggerAxis() { - return controller.getRightTriggerAxis(); - } - - @Override - protected double getLeftRawX() { - return controller.getLeftX(); - } - - @Override - protected double getLeftRawY() { - return controller.getLeftY(); - } - - @Override - protected double getRightRawX() { - return controller.getRightX(); - } - - @Override - protected double getRightRawY() { - return controller.getRightY(); - } -} diff --git a/src/main/java/xbot/common/injection/BaseWPITest.java b/src/main/java/xbot/common/injection/BaseWPITest.java deleted file mode 100644 index 3c2a5b03..00000000 --- a/src/main/java/xbot/common/injection/BaseWPITest.java +++ /dev/null @@ -1,44 +0,0 @@ -package xbot.common.injection; - -import org.apache.log4j.xml.DOMConfigurator; -import org.junit.Before; -import org.junit.Ignore; - -import edu.wpi.first.wpilibj.MockTimer; -import xbot.common.controls.sensors.XTimer; -import xbot.common.injection.components.BaseComponent; -import xbot.common.math.PIDManager.PIDManagerFactory; -import xbot.common.properties.PropertyFactory; - -@Ignore -public abstract class BaseWPITest { - private BaseComponent injectorComponent; - - public PropertyFactory propertyFactory; - - protected PIDManagerFactory pf; - - protected MockTimer timer; - - /** - * Returns the {@link BaseComponent} instance used for dependency injection - */ - protected abstract BaseComponent createDaggerComponent(); - - protected BaseComponent getInjectorComponent() { - return injectorComponent; - } - - @Before - public void setUp() { - injectorComponent = createDaggerComponent(); - timer = (MockTimer)injectorComponent.timerImplementation(); - XTimer.setImplementation(timer); - - propertyFactory = injectorComponent.propertyFactory(); - - pf = injectorComponent.pidFactory(); - - DOMConfigurator.configure(getClass().getClassLoader().getResource("log4j4unitTesting.xml")); - } -} diff --git a/src/main/java/xbot/common/injection/DevicePolice.java b/src/main/java/xbot/common/injection/DevicePolice.java deleted file mode 100644 index 184ee02e..00000000 --- a/src/main/java/xbot/common/injection/DevicePolice.java +++ /dev/null @@ -1,120 +0,0 @@ -package xbot.common.injection; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import xbot.common.logging.RobotAssertionManager; - -/** - * Tracks how many devices are registered and prevents incorrectly re-using devices - */ -@Singleton -public class DevicePolice { - - RobotAssertionManager assertionManager; - /** - * A list of all the channels in use, and what device is using them. - */ - public Map registeredChannels; - /** - * A list of all the devices in use - */ - public List registeredDevices; - /** - * A mapping to get the device associated with a given ID - */ - //private Map deviceToId; - - /** - * Types of devices - */ - public enum DeviceType { - CAN, - PWM, - Solenoid, - DigitalIO, - Analog, - SPI, - I2C, - USB, - IMU - } - - /** - * Creates a new DevicePolice instance - */ - @Inject - public DevicePolice(RobotAssertionManager assertionManager) { - this.assertionManager = assertionManager; - registeredChannels = new HashMap(); - registeredDevices = new ArrayList<>(); - } - - - /** - * Register a device. Please use {@link #registerDevice(DeviceType, int, Object)} instead - * @param type Device type - * @param id Device id - */ - @Deprecated - public void registerDevice(DeviceType type, int id) { - this.registerDevice(type, id, null); - } - - /** - * Register a device - * @param type Device type - * @param id Device id - */ - public String registerDevice(DeviceType type, int id, Object device) { - // First, check to see if the overall device has already been registered once. We only - // want there to be one "main" entry for a given device, like an Encoder, which may use two channels. - // That way, when we ask the DevicePolice how many devices have been registered, it wouldn't return the - // same Encoder twice. - if (!registeredDevices.contains(device)) { - registeredDevices.add(device); - } - - String entry = type.toString() + id; - if (registeredChannels.keySet().contains(entry)) { - assertionManager.fail("A device has already been created that uses " + type.toString() + " port/id " + id); - } else { - registeredChannels.put(entry, device); - //deviceToId.put(device, entry); - } - - return entry; - } - - /** - * Register a device with an id falling into an allowable range - * @param type Device type - * @param id Device id - * @param minId Minimum allowable id - * @param maxId Maximum allowable id - */ - public void registerDevice(DeviceType type, int id, int minId, int maxId) { - this.registerDevice(type, id, minId, maxId, null); - } - - /** - * Register a device with an id falling into an allowable range - * @param type Device type - * @param id Device id - * @param minId Minimum allowable id - * @param maxId Maximum allowable id - */ - public void registerDevice(DeviceType type, int id, int minId, int maxId, Object device) { - if (id > maxId || id < minId) { - assertionManager.fail("A device has been added with an invalid id that uses " + type.toString() + " port/id " + id + ". " - + "Allowed range: [" + minId + ", " + maxId + "]"); - } - - registerDevice(type, id, device); - } -} diff --git a/src/main/java/xbot/common/injection/MockPermanentStorage.java b/src/main/java/xbot/common/injection/MockPermanentStorage.java deleted file mode 100644 index 45d91c42..00000000 --- a/src/main/java/xbot/common/injection/MockPermanentStorage.java +++ /dev/null @@ -1,52 +0,0 @@ -package xbot.common.injection; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import xbot.common.properties.TableProxy; - -@Singleton -public class MockPermanentStorage extends TableProxy { - - private StringBuffer buf; - - /** - * Permanent storage property storage delimiter - */ - protected String propertyDelimiter = ","; - /** - * Permanent storage line seperator - */ - protected String lineSeperator = "\n"; - - @Inject - public MockPermanentStorage() { - super(); - buf = new StringBuffer(); - } - - public void addTestDouble(String key, double value) { - buf.append("double").append(propertyDelimiter).append(key).append(propertyDelimiter).append(value) - .append(lineSeperator); - } - - public void addTestBoolean(String key, boolean value) { - buf.append("boolean").append(propertyDelimiter).append(key).append(propertyDelimiter).append(value) - .append(lineSeperator); - } - - public void addTestString(String key, String value) { - buf.append("string").append(propertyDelimiter).append(key).append(propertyDelimiter).append(value) - .append(lineSeperator); - } - - protected String readFromFile() { - return buf.toString(); - } - - protected void writeToFile(String data) { - StringBuffer sbdata = new StringBuffer(data); - buf = sbdata; - } - -} diff --git a/src/main/java/xbot/common/injection/components/BaseComponent.java b/src/main/java/xbot/common/injection/components/BaseComponent.java deleted file mode 100644 index b999260e..00000000 --- a/src/main/java/xbot/common/injection/components/BaseComponent.java +++ /dev/null @@ -1,184 +0,0 @@ -package xbot.common.injection.components; - -import javax.inject.Named; - -import xbot.common.command.SmartDashboardCommandPutter; -import xbot.common.command.XScheduler; -import xbot.common.controls.actuators.XCANSparkMax.XCANSparkMaxFactory; -import xbot.common.controls.actuators.XCANTalon.XCANTalonFactory; -import xbot.common.controls.actuators.XCANVictorSPX.XCANVictorSPXFactory; -import xbot.common.controls.actuators.XCompressor.XCompressorFactory; -import xbot.common.controls.actuators.XDigitalOutput.XDigitalOutputFactory; -import xbot.common.controls.actuators.XDoubleSolenoid.XDoubleSolenoidFactory; -import xbot.common.controls.actuators.XPWM.XPWMFactory; -import xbot.common.controls.actuators.XRelay.XRelayFactory; -import xbot.common.controls.actuators.XServo.XServoFactory; -import xbot.common.controls.actuators.XSolenoid.XSolenoidFactory; -import xbot.common.controls.actuators.XSpeedController.XSpeedControllerFactory; -import xbot.common.controls.sensors.XDutyCycleEncoder; -import xbot.common.controls.sensors.XSettableTimerImpl; -import xbot.common.controls.sensors.XTimerImpl; -import xbot.common.controls.sensors.XAS5600.XAS5600Factory; -import xbot.common.controls.sensors.XAbsoluteEncoder.XAbsoluteEncoderFactory; -import xbot.common.controls.sensors.XAnalogDistanceSensor.XAnalogDistanceSensorFactory; -import xbot.common.controls.sensors.XAnalogInput.XAnalogInputFactory; -import xbot.common.controls.sensors.XCANCoder.XCANCoderFactory; -import xbot.common.controls.sensors.XDigitalInput.XDigitalInputFactory; -import xbot.common.controls.sensors.XEncoder.XEncoderFactory; -import xbot.common.controls.sensors.XFTCGamepad.XFTCGamepadFactory; -import xbot.common.controls.sensors.XGyro.XGyroFactory; -import xbot.common.controls.sensors.XJoystick.XJoystickFactory; -import xbot.common.controls.sensors.XLidarLite.XLidarLiteFactory; -import xbot.common.controls.sensors.XPowerDistributionPanel.XPowerDistributionPanelFactory; -import xbot.common.controls.sensors.XXboxController.XXboxControllerFactory; -import xbot.common.controls.sensors.buttons.AdvancedJoystickButtonTrigger.AdvancedJoystickButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AdvancedPovButtonTrigger.AdvancedPovButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger.AnalogHIDButtonTriggerFactory; -import xbot.common.controls.sensors.buttons.ChordTrigger.ChordTriggerFactory; -import xbot.common.controls.sensors.buttons.VirtualTrigger.VirtualTriggerFactory; -import xbot.common.injection.DevicePolice; -import xbot.common.logging.RobotAssertionManager; -import xbot.common.logging.RobotSession; -import xbot.common.logic.CalibrationDecider.CalibrationDeciderFactory; -import xbot.common.logic.HumanVsMachineDecider.HumanVsMachineDeciderFactory; -import xbot.common.logic.StallDetector.StallDetectorFactory; -import xbot.common.logic.VelocityThrottleModule.VelocityThrottleModuleFactory; -import xbot.common.math.FieldPosePropertyManager.FieldPosePropertyManagerFactory; -import xbot.common.math.PIDManager.PIDManagerFactory; -import xbot.common.math.PIDPropertyManager.PIDPropertyManagerFactory; -import xbot.common.networking.XZeromqListener.XZeromqListenerFactory; -import xbot.common.properties.ITableProxy; -import xbot.common.properties.PermanentStorage; -import xbot.common.properties.PropertyFactory; -import xbot.common.properties.XPropertyManager; -import xbot.common.simulation.SimulationPayloadDistributor; -import xbot.common.simulation.WebotsClient; -import xbot.common.subsystems.autonomous.AutonomousCommandSelector; -import xbot.common.subsystems.drive.BaseDriveSubsystem; -import xbot.common.subsystems.drive.control_logic.HeadingAssistModule.HeadingAssistModuleFactory; -import xbot.common.subsystems.drive.control_logic.HeadingModule.HeadingModuleFactory; -import xbot.common.subsystems.feedback.XRumbleManager.XRumbleManagerFactory; -import xbot.common.subsystems.pose.BasePoseSubsystem; - -/** - * Base class for all Components that provides methods to get implementations from DI. - * Implementations of this abstract class map Modules to the Component. Dagger will automatically - * generate a class with the prefix "Dagger" in the same package. - */ -public abstract class BaseComponent { - public abstract XTimerImpl timerImplementation(); - - public abstract XSettableTimerImpl settableTimerImplementation(); - - public abstract ITableProxy tableProxy(); - - public abstract @Named(XPropertyManager.IN_MEMORY_STORE_NAME) ITableProxy inMemoryTableProxy(); - - public abstract PermanentStorage permanentStorage(); - - public abstract RobotAssertionManager robotAssertionManager(); - - public abstract DevicePolice devicePolice(); - - public abstract SmartDashboardCommandPutter smartDashboardCommandPutter(); - - public abstract XScheduler scheduler(); - - public abstract XPropertyManager propertyManager(); - - public abstract PropertyFactory propertyFactory(); - - public abstract FieldPosePropertyManagerFactory fieldPosePropertyManagerFactory(); - - public abstract AutonomousCommandSelector autonomousCommandSelector(); - - public abstract RobotSession robotSession(); - - public abstract WebotsClient webotsClient(); - - public abstract SimulationPayloadDistributor simulationPayloadDistributor(); - - public abstract PIDManagerFactory pidFactory(); - - public abstract PIDPropertyManagerFactory pidPropertyManagerFactory(); - - public abstract XPowerDistributionPanelFactory powerDistributionPanelFactory(); - - public abstract XJoystickFactory joystickFactory(); - - public abstract AdvancedJoystickButtonTriggerFactory joystickButtonFactory(); - - public abstract AdvancedPovButtonTriggerFactory povButtonFactory(); - - public abstract AnalogHIDButtonTriggerFactory analogHidButtonFactory(); - - public abstract XXboxControllerFactory xboxControllerFactory(); - - public abstract XFTCGamepadFactory ftcGamepadFactory(); - - public abstract XRumbleManagerFactory rumbleManagerFactory(); - - public abstract ChordTriggerFactory chordButtonFactory(); - - public abstract VirtualTriggerFactory virtualButtonFactory(); - - public abstract HumanVsMachineDeciderFactory humanVsMachineDeciderFactory(); - - public abstract CalibrationDeciderFactory calibrationDeciderFactory(); - - public abstract StallDetectorFactory stallDetectorFactory(); - - public abstract VelocityThrottleModuleFactory velocityThrottleModuleFactory(); - - public abstract XAnalogInputFactory analogInputFactory(); - - public abstract XDigitalInputFactory digitalInputFactory(); - - public abstract XDigitalOutputFactory digitalOutputFactory(); - - public abstract XPWMFactory pwmFactory(); - - public abstract XCompressorFactory compressorFactory(); - - public abstract XGyroFactory gyroFactory(); - - public abstract XServoFactory servoFactory(); - - public abstract HeadingModuleFactory headingModuleFactory(); - - public abstract HeadingAssistModuleFactory headingAssistModuleFactory(); - - public abstract XEncoderFactory encoderFactory(); - - public abstract XAbsoluteEncoderFactory absoluteEncoderFactory(); - - public abstract XCANCoderFactory canCoderFactory(); - - public abstract XSolenoidFactory solenoidFactory(); - - public abstract XRelayFactory relayFactory(); - - public abstract XDoubleSolenoidFactory doubleSolenoidFactory(); - - public abstract XAnalogDistanceSensorFactory analogDistanceSensorFactory(); - - public abstract XCANTalonFactory canTalonFactory(); - - public abstract XAS5600Factory as5600Factory(); - - public abstract XCANVictorSPXFactory canVictorSpxFactory(); - - public abstract XCANSparkMaxFactory canSparkMaxFactory(); - - public abstract XLidarLiteFactory lidarLiteFactory(); - - public abstract XSpeedControllerFactory speedControllerFactory(); - - public abstract XZeromqListenerFactory zeromqListenerFactory(); - - public abstract BaseDriveSubsystem driveSubsystem(); - - public abstract BasePoseSubsystem poseSubsystem(); - - public abstract XDutyCycleEncoder.XDutyCycleEncoderFactory dutyCycleEncoderFactory(); -} diff --git a/src/main/java/xbot/common/injection/components/PurePursuitTestComponent.java b/src/main/java/xbot/common/injection/components/PurePursuitTestComponent.java deleted file mode 100644 index ecdc960c..00000000 --- a/src/main/java/xbot/common/injection/components/PurePursuitTestComponent.java +++ /dev/null @@ -1,19 +0,0 @@ -package xbot.common.injection.components; - -import javax.inject.Singleton; - -import dagger.Component; -import xbot.common.injection.modules.MockControlsModule; -import xbot.common.injection.modules.MockDevicesModule; -import xbot.common.injection.modules.UnitTestModule; -import xbot.common.injection.modules.UnitTestRobotModule; -import xbot.common.subsystems.drive.ConfigurablePurePursuitCommand; - -/** - * Do not use this directly. Use auto-generated class DaggerUnitTestComponent. - */ -@Singleton -@Component(modules = { UnitTestModule.class, MockDevicesModule.class, MockControlsModule.class, UnitTestRobotModule.class }) -public abstract class PurePursuitTestComponent extends BaseComponent { - public abstract ConfigurablePurePursuitCommand configurablePurePursuitCommand(); -} diff --git a/src/main/java/xbot/common/injection/components/SimulationComponent.java b/src/main/java/xbot/common/injection/components/SimulationComponent.java deleted file mode 100644 index cc398c89..00000000 --- a/src/main/java/xbot/common/injection/components/SimulationComponent.java +++ /dev/null @@ -1,18 +0,0 @@ -package xbot.common.injection.components; - -import javax.inject.Singleton; - -import dagger.Component; -import xbot.common.injection.modules.MockDevicesModule; -import xbot.common.injection.modules.RealControlsModule; -import xbot.common.injection.modules.SimulationModule; -import xbot.common.injection.modules.UnitTestRobotModule; - -/** - * Do not use this directly. Use auto-generated class DaggerSimulationComponent. - */ -@Singleton -@Component(modules = { SimulationModule.class, MockDevicesModule.class, RealControlsModule.class, UnitTestRobotModule.class }) -public abstract class SimulationComponent extends BaseComponent { - -} diff --git a/src/main/java/xbot/common/injection/electrical_contract/CANTalonInfo.java b/src/main/java/xbot/common/injection/electrical_contract/CANTalonInfo.java deleted file mode 100644 index cc789bc9..00000000 --- a/src/main/java/xbot/common/injection/electrical_contract/CANTalonInfo.java +++ /dev/null @@ -1,33 +0,0 @@ -package xbot.common.injection.electrical_contract; - -import com.ctre.phoenix.motorcontrol.FeedbackDevice; - -public class CANTalonInfo { - - public int channel; - public boolean inverted; - public FeedbackDevice feedbackDevice; - public boolean feedbackDeviceInverted; - - public double simulationScalingValue; - - public CANTalonInfo(int channel){ - this.channel = channel; - } - - public CANTalonInfo(int channel, boolean inverted) { - this(channel); - this.inverted = inverted; - } - - public CANTalonInfo(int channel, boolean inverted, FeedbackDevice feedbackDevice, boolean feedbackDeviceInverted) { - this(channel, inverted); - this.feedbackDevice = feedbackDevice; - this.feedbackDeviceInverted = feedbackDeviceInverted; - } - - public CANTalonInfo(int channel, boolean inverted, FeedbackDevice feedbackDevice, boolean feedbackDeviceInverted, double simulationScalingValue) { - this(channel, inverted, feedbackDevice, feedbackDeviceInverted); - this.simulationScalingValue = simulationScalingValue; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/injection/electrical_contract/DeviceInfo.java b/src/main/java/xbot/common/injection/electrical_contract/DeviceInfo.java deleted file mode 100644 index c8368e82..00000000 --- a/src/main/java/xbot/common/injection/electrical_contract/DeviceInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package xbot.common.injection.electrical_contract; - -public class DeviceInfo { - public int channel; - public boolean inverted; - public double simulationScalingValue; - - public DeviceInfo(int channel){ - this.channel = channel; - } - - public DeviceInfo(int channel, boolean inverted) { - this(channel); - this.inverted = inverted; - } - - public DeviceInfo(int channel, boolean inverted, double simulationScalingValue) { - this(channel, inverted); - this.simulationScalingValue = simulationScalingValue; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/injection/modules/MockControlsModule.java b/src/main/java/xbot/common/injection/modules/MockControlsModule.java deleted file mode 100644 index 1ae8b729..00000000 --- a/src/main/java/xbot/common/injection/modules/MockControlsModule.java +++ /dev/null @@ -1,33 +0,0 @@ -package xbot.common.injection.modules; - -import javax.inject.Singleton; - -import dagger.Binds; -import dagger.Module; -import edu.wpi.first.wpilibj.MockXboxControllerAdapter.MockXboxControllerFactory; -import xbot.common.controls.sensors.XFTCGamepad.XFTCGamepadFactory; -import xbot.common.controls.sensors.XJoystick.XJoystickFactory; -import xbot.common.controls.sensors.XXboxController.XXboxControllerFactory; -import xbot.common.controls.sensors.mock_adapters.MockFTCGamepad.MockFTCGamepadFactory; -import xbot.common.controls.sensors.mock_adapters.MockJoystick.MockJoystickFactory; -import xbot.common.subsystems.feedback.RumbleManager.RumbleManagerFactory; -import xbot.common.subsystems.feedback.XRumbleManager.XRumbleManagerFactory; - -@Module -public abstract class MockControlsModule { - @Binds - @Singleton - public abstract XJoystickFactory getJoystickFactory(MockJoystickFactory impl); - - @Binds - @Singleton - public abstract XXboxControllerFactory getXboxControllerFactory(MockXboxControllerFactory impl); - - @Binds - @Singleton - public abstract XFTCGamepadFactory getFTCGamepadFactory(MockFTCGamepadFactory impl); - - @Binds - @Singleton - public abstract XRumbleManagerFactory getRumbleManagerFactory(RumbleManagerFactory impl); -} diff --git a/src/main/java/xbot/common/injection/modules/MockDevicesModule.java b/src/main/java/xbot/common/injection/modules/MockDevicesModule.java deleted file mode 100644 index 7d047142..00000000 --- a/src/main/java/xbot/common/injection/modules/MockDevicesModule.java +++ /dev/null @@ -1,135 +0,0 @@ -package xbot.common.injection.modules; - -import dagger.Binds; -import dagger.Module; -import edu.wpi.first.wpilibj.MockAnalogInput.MockAnalogInputFactory; -import edu.wpi.first.wpilibj.MockCompressor.MockCompressorFactory; -import edu.wpi.first.wpilibj.MockDigitalInput.MockDigitalInputFactory; -import edu.wpi.first.wpilibj.MockDigitalOutput.MockDigitalOutputFactory; -import edu.wpi.first.wpilibj.MockLidarLite.MockLidarLiteFactory; -import edu.wpi.first.wpilibj.MockPWM.MockPWMFactory; -import edu.wpi.first.wpilibj.MockPowerDistributionPanel.MockPowerDistributionPanelFactory; -import edu.wpi.first.wpilibj.MockServo.MockServoFactory; -import edu.wpi.first.wpilibj.MockSolenoid.MockSolenoidFactory; -import edu.wpi.first.wpilibj.MockSpeedController.MockSpeedControllerFactory; -import xbot.common.controls.actuators.XCANSparkMax.XCANSparkMaxFactory; -import xbot.common.controls.actuators.XCANTalon.XCANTalonFactory; -import xbot.common.controls.actuators.XCANVictorSPX.XCANVictorSPXFactory; -import xbot.common.controls.actuators.XCompressor.XCompressorFactory; -import xbot.common.controls.actuators.XDigitalOutput.XDigitalOutputFactory; -import xbot.common.controls.actuators.XPWM.XPWMFactory; -import xbot.common.controls.actuators.XRelay.XRelayFactory; -import xbot.common.controls.actuators.XServo.XServoFactory; -import xbot.common.controls.actuators.XSolenoid.XSolenoidFactory; -import xbot.common.controls.actuators.XSpeedController.XSpeedControllerFactory; -import xbot.common.controls.actuators.mock_adapters.MockCANSparkMax.MockCANSparkMaxFactory; -import xbot.common.controls.actuators.mock_adapters.MockCANTalon.MockCANTalonFactory; -import xbot.common.controls.actuators.mock_adapters.MockCANVictorSPX.MockCANVictorSPXFactory; -import xbot.common.controls.actuators.mock_adapters.MockRelay.MockRelayFactory; -import xbot.common.controls.sensors.SimulatedAnalogDistanceSensor.SimulatedAnalogDistanceSensorFactory; -import xbot.common.controls.sensors.XAbsoluteEncoder.XAbsoluteEncoderFactory; -import xbot.common.controls.sensors.XAnalogDistanceSensor.XAnalogDistanceSensorFactory; -import xbot.common.controls.sensors.XAnalogInput.XAnalogInputFactory; -import xbot.common.controls.sensors.XCANCoder.XCANCoderFactory; -import xbot.common.controls.sensors.XDigitalInput.XDigitalInputFactory; -import xbot.common.controls.sensors.XDutyCycleEncoder; -import xbot.common.controls.sensors.XEncoder.XEncoderFactory; -import xbot.common.controls.sensors.XGyro.XGyroFactory; -import xbot.common.controls.sensors.XLidarLite.XLidarLiteFactory; -import xbot.common.controls.sensors.XPowerDistributionPanel.XPowerDistributionPanelFactory; -import xbot.common.controls.sensors.mock_adapters.MockAbsoluteEncoder.MockAbsoluteEncoderFactory; -import xbot.common.controls.sensors.mock_adapters.MockCANCoder.MockCANCoderFactory; -import xbot.common.controls.sensors.mock_adapters.MockDutyCycleEncoder; -import xbot.common.controls.sensors.mock_adapters.MockEncoder.MockEncoderFactory; -import xbot.common.controls.sensors.mock_adapters.MockGyro.MockGyroFactory; -import xbot.common.networking.MockZeromqListener.MockZeromqListenerFactory; -import xbot.common.networking.XZeromqListener.XZeromqListenerFactory; - -import javax.inject.Singleton; - -@Module -public abstract class MockDevicesModule { - @Binds - @Singleton - public abstract XPowerDistributionPanelFactory getPowerDistributionPanelFactory(MockPowerDistributionPanelFactory impl); - - @Binds - @Singleton - public abstract XAnalogInputFactory getAnalogInputFactory(MockAnalogInputFactory impl); - - @Binds - @Singleton - public abstract XDigitalInputFactory getDigitalInputFactory(MockDigitalInputFactory impl); - - @Binds - @Singleton - public abstract XDigitalOutputFactory getDigitalOutputFactory(MockDigitalOutputFactory impl); - - @Binds - @Singleton - public abstract XPWMFactory getPwmFactory(MockPWMFactory impl); - - @Binds - @Singleton - public abstract XCompressorFactory getCompressorFactory(MockCompressorFactory impl); - - @Binds - @Singleton - public abstract XGyroFactory getGyroFactory(MockGyroFactory impl); - - @Binds - @Singleton - public abstract XServoFactory getServoFactory(MockServoFactory impl); - - @Binds - @Singleton - public abstract XAnalogDistanceSensorFactory getAnalogDistanceSensorFactory(SimulatedAnalogDistanceSensorFactory impl); - - @Binds - @Singleton - public abstract XCANTalonFactory getCANTalonFactory(MockCANTalonFactory impl); - - @Binds - @Singleton - public abstract XCANVictorSPXFactory getCANVictorSPXFactory(MockCANVictorSPXFactory impl); - - @Binds - @Singleton - public abstract XCANSparkMaxFactory getCANSparkMaxFactory(MockCANSparkMaxFactory impl); - - @Binds - @Singleton - public abstract XLidarLiteFactory getLidarLiteFactory(MockLidarLiteFactory impl); - - @Binds - @Singleton - public abstract XEncoderFactory getEncoderFactory(MockEncoderFactory impl); - - @Binds - @Singleton - public abstract XAbsoluteEncoderFactory getAbsoluteEncoderFactory(MockAbsoluteEncoderFactory impl); - - @Binds - @Singleton - public abstract XCANCoderFactory getCANCoderFactory(MockCANCoderFactory impl); - - @Binds - @Singleton - public abstract XSolenoidFactory getSolenoidFactory(MockSolenoidFactory impl); - - @Binds - @Singleton - public abstract XRelayFactory getRelayFactory(MockRelayFactory impl); - - @Binds - @Singleton - public abstract XSpeedControllerFactory getSpeedControllerFactory(MockSpeedControllerFactory impl); - - @Binds - @Singleton - public abstract XZeromqListenerFactory getZeromqListenerFactory(MockZeromqListenerFactory impl); - - @Binds - @Singleton - public abstract XDutyCycleEncoder.XDutyCycleEncoderFactory getDutyCycleEncoderFactory(MockDutyCycleEncoder.MockDutyCycleEncoderFactory impl); -} diff --git a/src/main/java/xbot/common/injection/modules/RealControlsModule.java b/src/main/java/xbot/common/injection/modules/RealControlsModule.java deleted file mode 100644 index ccb29e77..00000000 --- a/src/main/java/xbot/common/injection/modules/RealControlsModule.java +++ /dev/null @@ -1,33 +0,0 @@ -package xbot.common.injection.modules; - -import javax.inject.Singleton; - -import dagger.Binds; -import dagger.Module; -import xbot.common.controls.sensors.XFTCGamepad.XFTCGamepadFactory; -import xbot.common.controls.sensors.XJoystick.XJoystickFactory; -import xbot.common.controls.sensors.XXboxController.XXboxControllerFactory; -import xbot.common.controls.sensors.wpi_adapters.FTCGamepadWpiAdapter.FTCGamepadWpiAdapterFactory; -import xbot.common.controls.sensors.wpi_adapters.JoystickWPIAdapter.JoystickWPIAdapterFactory; -import xbot.common.controls.sensors.wpi_adapters.XboxControllerWpiAdapter.XboxControllerWpiAdapterFactory; -import xbot.common.subsystems.feedback.RumbleManager.RumbleManagerFactory; -import xbot.common.subsystems.feedback.XRumbleManager.XRumbleManagerFactory; - -@Module -public abstract class RealControlsModule { - @Binds - @Singleton - public abstract XJoystickFactory getJoystickFactory(JoystickWPIAdapterFactory impl); - - @Binds - @Singleton - public abstract XXboxControllerFactory getXboxControllerFactory(XboxControllerWpiAdapterFactory impl); - - @Binds - @Singleton - public abstract XFTCGamepadFactory getFTCGamepadFactory(FTCGamepadWpiAdapterFactory impl); - - @Binds - @Singleton - public abstract XRumbleManagerFactory getRumbleManagerFactory(RumbleManagerFactory impl); -} diff --git a/src/main/java/xbot/common/injection/modules/RealDevicesModule.java b/src/main/java/xbot/common/injection/modules/RealDevicesModule.java deleted file mode 100644 index 8f0548ae..00000000 --- a/src/main/java/xbot/common/injection/modules/RealDevicesModule.java +++ /dev/null @@ -1,134 +0,0 @@ -package xbot.common.injection.modules; - -import javax.inject.Singleton; - -import dagger.Binds; -import dagger.Module; -import xbot.common.controls.actuators.XCANSparkMax.XCANSparkMaxFactory; -import xbot.common.controls.actuators.XCANTalon.XCANTalonFactory; -import xbot.common.controls.actuators.XCANVictorSPX.XCANVictorSPXFactory; -import xbot.common.controls.actuators.XCompressor.XCompressorFactory; -import xbot.common.controls.actuators.XDigitalOutput.XDigitalOutputFactory; -import xbot.common.controls.actuators.XPWM.XPWMFactory; -import xbot.common.controls.actuators.XRelay.XRelayFactory; -import xbot.common.controls.actuators.XServo.XServoFactory; -import xbot.common.controls.actuators.XSolenoid.XSolenoidFactory; -import xbot.common.controls.actuators.XSpeedController.XSpeedControllerFactory; -import xbot.common.controls.actuators.wpi_adapters.CANSparkMaxWpiAdapter.CANSparkMaxWpiAdapterFactory; -import xbot.common.controls.actuators.wpi_adapters.CANTalonWPIAdapter.CANTalonWPIAdapterFactory; -import xbot.common.controls.actuators.wpi_adapters.CANVictorSPXWpiAdapter.CANVictorSPXWpiAdapterFactory; -import xbot.common.controls.actuators.wpi_adapters.CompressorWPIAdapter.CompressorWPIAdapterFactory; -import xbot.common.controls.actuators.wpi_adapters.DigitalOutputWPIAdapter.DigitalOutputWPIAdapterFactory; -import xbot.common.controls.actuators.wpi_adapters.PWMWPIAdapter.PWMWPIAdapterFactory; -import xbot.common.controls.actuators.wpi_adapters.RelayWPIAdapter.RelayWPIAdapterFactory; -import xbot.common.controls.actuators.wpi_adapters.ServoWPIAdapter.ServoWPIAdapterFactory; -import xbot.common.controls.actuators.wpi_adapters.SolenoidWPIAdapter.SolenoidWPIAdapterFactory; -import xbot.common.controls.actuators.wpi_adapters.SpeedControllerWPIAdapter.SpeedControllerWPIAdapterFactory; -import xbot.common.controls.sensors.AnalogDistanceSensor.AnalogDistanceSensorFactory; -import xbot.common.controls.sensors.XAbsoluteEncoder.XAbsoluteEncoderFactory; -import xbot.common.controls.sensors.XAnalogDistanceSensor.XAnalogDistanceSensorFactory; -import xbot.common.controls.sensors.XAnalogInput.XAnalogInputFactory; -import xbot.common.controls.sensors.XCANCoder.XCANCoderFactory; -import xbot.common.controls.sensors.XDigitalInput.XDigitalInputFactory; -import xbot.common.controls.sensors.XDutyCycleEncoder; -import xbot.common.controls.sensors.XEncoder.XEncoderFactory; -import xbot.common.controls.sensors.XGyro.XGyroFactory; -import xbot.common.controls.sensors.XLidarLite.XLidarLiteFactory; -import xbot.common.controls.sensors.XPowerDistributionPanel.XPowerDistributionPanelFactory; -import xbot.common.controls.sensors.wpi_adapters.AnalogInputWPIAdapater.AnalogInputWPIAdapaterFactory; -import xbot.common.controls.sensors.wpi_adapters.CANCoderAdapter.CANCoderAdapterFactory; -import xbot.common.controls.sensors.wpi_adapters.DigitalInputWPIAdapter.DigitalInputWPIAdapterFactory; -import xbot.common.controls.sensors.wpi_adapters.DutyCycleEncoderWpiAdapter; -import xbot.common.controls.sensors.wpi_adapters.EncoderWPIAdapter.EncoderWPIAdapterFactory; -import xbot.common.controls.sensors.wpi_adapters.InertialMeasurementUnitAdapter.InertialMeasurementUnitAdapterFactory; -import xbot.common.controls.sensors.wpi_adapters.LidarLiteWpiAdapter.LidarLiteWpiAdapterFactory; -import xbot.common.controls.sensors.wpi_adapters.PowerDistributionPanelWPIAdapter.PowerDistributionPanelWPIAdapaterFactory; -import xbot.common.networking.XZeromqListener.XZeromqListenerFactory; -import xbot.common.networking.ZeromqListener.ZeromqListenerFactory; - -@Module -public abstract class RealDevicesModule { - @Binds - @Singleton - public abstract XPowerDistributionPanelFactory getPowerDistributionPanelFactory(PowerDistributionPanelWPIAdapaterFactory impl); - - @Binds - @Singleton - public abstract XAnalogInputFactory getAnalogInputFactory(AnalogInputWPIAdapaterFactory impl); - - @Binds - @Singleton - public abstract XDigitalInputFactory getDigitalInputFactory(DigitalInputWPIAdapterFactory impl); - - @Binds - @Singleton - public abstract XDigitalOutputFactory getDigitalOutputFactory(DigitalOutputWPIAdapterFactory impl); - - @Binds - @Singleton - public abstract XPWMFactory getPwmFactory(PWMWPIAdapterFactory impl); - - @Binds - @Singleton - public abstract XCompressorFactory getCompressorFactory(CompressorWPIAdapterFactory impl); - - @Binds - @Singleton - public abstract XGyroFactory getGyroFactory(InertialMeasurementUnitAdapterFactory impl); - - @Binds - @Singleton - public abstract XServoFactory getServoFactory(ServoWPIAdapterFactory impl); - - @Binds - @Singleton - public abstract XAnalogDistanceSensorFactory getAnalogDistanceSensorFactory(AnalogDistanceSensorFactory impl); - - @Binds - @Singleton - public abstract XCANTalonFactory getCANTalonFactory(CANTalonWPIAdapterFactory impl); - - @Binds - @Singleton - public abstract XCANVictorSPXFactory getCANVictorSPXFactory(CANVictorSPXWpiAdapterFactory impl); - - @Binds - @Singleton - public abstract XCANSparkMaxFactory getCANSparkMaxFactory(CANSparkMaxWpiAdapterFactory impl); - - @Binds - @Singleton - public abstract XLidarLiteFactory getLidarLiteFactory(LidarLiteWpiAdapterFactory impl); - - @Binds - @Singleton - public abstract XEncoderFactory getEncoderFactory(EncoderWPIAdapterFactory impl); - - @Binds - @Singleton - public abstract XAbsoluteEncoderFactory getAbsoluteEncoderFactory(CANCoderAdapterFactory impl); - - @Binds - @Singleton - public abstract XCANCoderFactory getCANCoderFactory(CANCoderAdapterFactory impl); - - @Binds - @Singleton - public abstract XSolenoidFactory getSolenoidFactory(SolenoidWPIAdapterFactory impl); - - @Binds - @Singleton - public abstract XRelayFactory getRelayFactory(RelayWPIAdapterFactory impl); - - @Binds - @Singleton - public abstract XSpeedControllerFactory getSpeedControllerFactory(SpeedControllerWPIAdapterFactory impl); - - @Binds - @Singleton - public abstract XZeromqListenerFactory getZeromqListenerFactory(ZeromqListenerFactory impl); - - @Binds - @Singleton - public abstract XDutyCycleEncoder.XDutyCycleEncoderFactory getDutyCycleEncoderFactory(DutyCycleEncoderWpiAdapter.DutyCycleEncoderWpiAdapterFactory impl); -} diff --git a/src/main/java/xbot/common/injection/modules/RobotModule.java b/src/main/java/xbot/common/injection/modules/RobotModule.java deleted file mode 100644 index b5dbdf33..00000000 --- a/src/main/java/xbot/common/injection/modules/RobotModule.java +++ /dev/null @@ -1,56 +0,0 @@ -package xbot.common.injection.modules; - -import javax.inject.Named; -import javax.inject.Singleton; - -import dagger.Binds; -import dagger.Module; -import xbot.common.command.RealSmartDashboardCommandPutter; -import xbot.common.command.SmartDashboardCommandPutter; -import xbot.common.controls.sensors.XSettableTimerImpl; -import xbot.common.controls.sensors.XTimerImpl; -import xbot.common.controls.sensors.wpi_adapters.TimerWpiAdapter; -import xbot.common.logging.RobotAssertionManager; -import xbot.common.logging.SilentRobotAssertionManager; -import xbot.common.properties.ITableProxy; -import xbot.common.properties.PermanentStorage; -import xbot.common.properties.PreferenceStorage; -import xbot.common.properties.SmartDashboardTableWrapper; -import xbot.common.properties.TableProxy; -import xbot.common.properties.XPropertyManager; - -/** - * Module mapping interfaces to implementations for a real robot. - */ -@Module -public abstract class RobotModule { - @Binds - @Singleton - abstract XTimerImpl getTimer(TimerWpiAdapter impl); - - @Binds - @Singleton - abstract XSettableTimerImpl getSettableTimer(TimerWpiAdapter impl); - - @Binds - @Singleton - abstract ITableProxy getTableProxy(SmartDashboardTableWrapper impl); - - @Binds - @Named(XPropertyManager.IN_MEMORY_STORE_NAME) - @Singleton - // TODO: Figure out debug mode toggle - abstract ITableProxy getInMemoryTableProxy(TableProxy impl); - - @Binds - @Singleton - abstract PermanentStorage getPermanentStorage(PreferenceStorage impl); - - @Binds - @Singleton - abstract RobotAssertionManager getRobotAssertionManager(SilentRobotAssertionManager impl); - - @Binds - @Singleton - abstract SmartDashboardCommandPutter getSmartDashboardCommandPutter(RealSmartDashboardCommandPutter impl); -} diff --git a/src/main/java/xbot/common/injection/modules/SimulationModule.java b/src/main/java/xbot/common/injection/modules/SimulationModule.java deleted file mode 100644 index 22ac5426..00000000 --- a/src/main/java/xbot/common/injection/modules/SimulationModule.java +++ /dev/null @@ -1,54 +0,0 @@ -package xbot.common.injection.modules; - -import javax.inject.Named; -import javax.inject.Singleton; - -import dagger.Binds; -import dagger.Module; -import edu.wpi.first.wpilibj.MockTimer; -import xbot.common.command.RealSmartDashboardCommandPutter; -import xbot.common.command.SmartDashboardCommandPutter; -import xbot.common.controls.sensors.XSettableTimerImpl; -import xbot.common.controls.sensors.XTimerImpl; -import xbot.common.logging.LoudRobotAssertionManager; -import xbot.common.logging.RobotAssertionManager; -import xbot.common.properties.ITableProxy; -import xbot.common.properties.PermanentStorage; -import xbot.common.properties.PreferenceStorage; -import xbot.common.properties.SmartDashboardTableWrapper; -import xbot.common.properties.XPropertyManager; - -/** - * Module mapping interfaces to implementations for a simulated robot. - */ -@Module -public abstract class SimulationModule { - @Binds - @Singleton - abstract XTimerImpl getTimer(MockTimer impl); - - @Binds - @Singleton - abstract XSettableTimerImpl getSettableTimer(MockTimer impl); - - @Binds - @Singleton - abstract ITableProxy getTableProxy(SmartDashboardTableWrapper impl); - - @Binds - @Named(XPropertyManager.IN_MEMORY_STORE_NAME) - @Singleton - abstract ITableProxy getInMemoryTableProxy(SmartDashboardTableWrapper impl); - - @Binds - @Singleton - abstract PermanentStorage getPermanentStorage(PreferenceStorage impl); - - @Binds - @Singleton - abstract RobotAssertionManager getRobotAssertionManager(LoudRobotAssertionManager impl); - - @Binds - @Singleton - abstract SmartDashboardCommandPutter getSmartDashboardCommandPutter(RealSmartDashboardCommandPutter impl); -} diff --git a/src/main/java/xbot/common/injection/modules/UnitTestModule.java b/src/main/java/xbot/common/injection/modules/UnitTestModule.java deleted file mode 100644 index fc6b4664..00000000 --- a/src/main/java/xbot/common/injection/modules/UnitTestModule.java +++ /dev/null @@ -1,54 +0,0 @@ -package xbot.common.injection.modules; - -import javax.inject.Named; -import javax.inject.Singleton; - -import dagger.Binds; -import dagger.Module; -import edu.wpi.first.wpilibj.MockTimer; -import xbot.common.command.MockSmartDashboardCommandPutter; -import xbot.common.command.SmartDashboardCommandPutter; -import xbot.common.controls.sensors.XSettableTimerImpl; -import xbot.common.controls.sensors.XTimerImpl; -import xbot.common.logging.LoudRobotAssertionManager; -import xbot.common.logging.RobotAssertionManager; -import xbot.common.properties.ITableProxy; -import xbot.common.properties.MockPermamentStorage; -import xbot.common.properties.PermanentStorage; -import xbot.common.properties.TableProxy; -import xbot.common.properties.XPropertyManager; - -/** - * Module mapping interfaces to implementations for unit tests. - */ -@Module -public abstract class UnitTestModule { - @Binds - @Singleton - abstract XTimerImpl getTimer(MockTimer impl); - - @Binds - @Singleton - abstract XSettableTimerImpl getSettableTimer(MockTimer impl); - - @Binds - @Singleton - abstract ITableProxy getTableProxy(TableProxy impl); - - @Binds - @Named(XPropertyManager.IN_MEMORY_STORE_NAME) - @Singleton - abstract ITableProxy getInMemoryTableProxy(TableProxy impl); - - @Binds - @Singleton - abstract PermanentStorage getPermanentStorage(MockPermamentStorage impl); - - @Binds - @Singleton - abstract RobotAssertionManager getRobotAssertionManager(LoudRobotAssertionManager impl); - - @Binds - @Singleton - abstract SmartDashboardCommandPutter getSmartDashboardCommandPutter(MockSmartDashboardCommandPutter impl); -} diff --git a/src/main/java/xbot/common/injection/modules/UnitTestRobotModule.java b/src/main/java/xbot/common/injection/modules/UnitTestRobotModule.java deleted file mode 100644 index a74f694d..00000000 --- a/src/main/java/xbot/common/injection/modules/UnitTestRobotModule.java +++ /dev/null @@ -1,21 +0,0 @@ -package xbot.common.injection.modules; - -import javax.inject.Singleton; - -import dagger.Binds; -import dagger.Module; -import xbot.common.subsystems.drive.BaseDriveSubsystem; -import xbot.common.subsystems.drive.MockDriveSubsystem; -import xbot.common.subsystems.pose.BasePoseSubsystem; -import xbot.common.subsystems.pose.MockBasePoseSubsystem; - -@Module -public abstract class UnitTestRobotModule { - @Binds - @Singleton - abstract BasePoseSubsystem getBasePoseSubsystem(MockBasePoseSubsystem impl); - - @Binds - @Singleton - abstract BaseDriveSubsystem getBaseDriveSubsystem(MockDriveSubsystem impl); -} diff --git a/src/main/java/xbot/common/logging/DriverStationAppender.java b/src/main/java/xbot/common/logging/DriverStationAppender.java deleted file mode 100644 index d111fb1b..00000000 --- a/src/main/java/xbot/common/logging/DriverStationAppender.java +++ /dev/null @@ -1,38 +0,0 @@ -package xbot.common.logging; - -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.spi.LoggingEvent; - -import edu.wpi.first.wpilibj.DriverStation; - -public class DriverStationAppender extends AppenderSkeleton { - - boolean stationExists; - - public DriverStationAppender() { - try { - Class.forName("edu.wpi.first.wpilibj.DriverStation", false, this.getClass().getClassLoader()); - stationExists = true; - } catch (Exception e) { - // do nothing - } - } - - @Override - public void close() { - - } - - @Override - public boolean requiresLayout() { - return false; - } - - @Override - protected void append(LoggingEvent arg0) { - if (stationExists) { - DriverStation.reportError((String) arg0.getMessage(), true); - } - } - -} diff --git a/src/main/java/xbot/common/logging/IntermittentConsoleLogger.java b/src/main/java/xbot/common/logging/IntermittentConsoleLogger.java deleted file mode 100644 index 712b1887..00000000 --- a/src/main/java/xbot/common/logging/IntermittentConsoleLogger.java +++ /dev/null @@ -1,18 +0,0 @@ -package xbot.common.logging; - -public class IntermittentConsoleLogger { - - private int i = 0; - private int modulus = 500; - - public void logSometimes(String message) { - if (i % modulus == 0) { - System.out.println(message); - } - i++; - } - - public void setModulus(int modulus) { - this.modulus = modulus; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/logging/LoggingLatch.java b/src/main/java/xbot/common/logging/LoggingLatch.java deleted file mode 100644 index f179adbf..00000000 --- a/src/main/java/xbot/common/logging/LoggingLatch.java +++ /dev/null @@ -1,28 +0,0 @@ -package xbot.common.logging; - -import org.apache.log4j.Logger; - -import xbot.common.logic.Latch; -import xbot.common.logic.Latch.EdgeType; - -public class LoggingLatch { - - static Logger log = Logger.getLogger(LoggingLatch.class); - - private final Latch latch; - - public LoggingLatch(String callerName, String message, EdgeType edgeType) { - this.latch = new Latch(false, edgeType); - - latch.addObserver((e) -> { - EdgeType edge =e; - if(edge == edgeType) { - log.info(callerName + ": " + message); - } - }); - } - - public void checkValue(boolean value) { - latch.setValue(value); - } -} diff --git a/src/main/java/xbot/common/logging/LoudRobotAssertionManager.java b/src/main/java/xbot/common/logging/LoudRobotAssertionManager.java deleted file mode 100644 index 2724a79c..00000000 --- a/src/main/java/xbot/common/logging/LoudRobotAssertionManager.java +++ /dev/null @@ -1,25 +0,0 @@ -package xbot.common.logging; - -import javax.inject.Inject; - -/** - * Version of RobotAssertionManager that allows exceptions to be thrown. Should - * only be used off-robot or during controlled testing sessions; should never - * be used in competition. - */ -public class LoudRobotAssertionManager extends RobotAssertionManager { - - @Inject - public LoudRobotAssertionManager() {} - - @Override - protected void handlePlatformException(RuntimeException e) { - throw e; - } - - @Override - public boolean isExceptionsEnabled() { - return true; - } - -} diff --git a/src/main/java/xbot/common/logging/OneLogFilePerRunRollingFileAppender.java b/src/main/java/xbot/common/logging/OneLogFilePerRunRollingFileAppender.java deleted file mode 100644 index 91a307fe..00000000 --- a/src/main/java/xbot/common/logging/OneLogFilePerRunRollingFileAppender.java +++ /dev/null @@ -1,32 +0,0 @@ -package xbot.common.logging; - -import java.io.IOException; - -import org.apache.log4j.Layout; -import org.apache.log4j.RollingFileAppender; - -public class OneLogFilePerRunRollingFileAppender extends RollingFileAppender { - - public OneLogFilePerRunRollingFileAppender() { - super(); - } - - public OneLogFilePerRunRollingFileAppender(Layout layout, String filename, boolean append) throws IOException { - super(layout, filename, append); - } - - public OneLogFilePerRunRollingFileAppender(Layout layout, String filename) throws IOException { - super(layout, filename); - } - - @Override - public void activateOptions() { - super.activateOptions(); - this.rollOverManually(); - } - - public synchronized void rollOverManually() { - this.rollOver(); - } - -} diff --git a/src/main/java/xbot/common/logging/RobotAssertionException.java b/src/main/java/xbot/common/logging/RobotAssertionException.java deleted file mode 100644 index 3fa3da77..00000000 --- a/src/main/java/xbot/common/logging/RobotAssertionException.java +++ /dev/null @@ -1,8 +0,0 @@ -package xbot.common.logging; - -//@SuppressWarnings("serial") -public class RobotAssertionException extends RuntimeException { - public RobotAssertionException(String failureCauseCause) { - super("Assertion error: " + failureCauseCause); - } -} diff --git a/src/main/java/xbot/common/logging/RobotAssertionManager.java b/src/main/java/xbot/common/logging/RobotAssertionManager.java deleted file mode 100644 index ffdbdb99..00000000 --- a/src/main/java/xbot/common/logging/RobotAssertionManager.java +++ /dev/null @@ -1,44 +0,0 @@ -package xbot.common.logging; - -import java.util.Arrays; -import java.util.stream.Collectors; - -import org.apache.log4j.Logger; - -/** - * Base class for safe assertion manager. Allows context-based management of - * exceptions and assertion conditions. - * - */ -public abstract class RobotAssertionManager { - static Logger log = Logger.getLogger(RobotAssertionManager.class); - - public final void throwException(RuntimeException e) { - log.error("Safe exception encountered (exception throw " + (this.isExceptionsEnabled() ? "enabled" : "disabled") + "): " - + e.getMessage()); - log.error("Stack trace: \n " - + Arrays.stream(e.getStackTrace()) - .map(elem -> elem.toString()) - .collect(Collectors.joining("\n "))); - - handlePlatformException(e); - } - - public final void throwException(String message, Throwable cause) { - throwException(new RuntimeException(message, cause)); - } - - protected abstract void handlePlatformException(RuntimeException e); - - public abstract boolean isExceptionsEnabled(); - - public final void fail(String message) { - throwException(new RobotAssertionException(message)); - } - - public final void assertTrue(boolean value, String assertionFaliureCause) { - if(!value) { - fail(assertionFaliureCause); - } - } -} diff --git a/src/main/java/xbot/common/logging/RobotSession.java b/src/main/java/xbot/common/logging/RobotSession.java deleted file mode 100644 index b21cf542..00000000 --- a/src/main/java/xbot/common/logging/RobotSession.java +++ /dev/null @@ -1,59 +0,0 @@ -package xbot.common.logging; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import xbot.common.properties.PropertyFactory; -import xbot.common.properties.StringProperty; - -@Singleton -public class RobotSession { - - WordGenerator wg; - boolean hasStartedAuto; - boolean hasStartedTeleop; - String sessionId = ""; - StringProperty sessionProp; - String propertyName = "RobotSession"; - - @Inject - public RobotSession(WordGenerator wg, PropertyFactory propMan) { - this.wg = wg; - propMan.setTopLevelPrefix(); - sessionProp = propMan.createEphemeralProperty(propertyName, "NoSessionSetYet"); - reset(); - } - - public void autoInit() { - // Whenever autonomous mode starts, create a new ID, and reset. Then, mark that we have started autonomous. - reset(); - hasStartedAuto = true; - } - - public void teleopInit() { - if (hasStartedTeleop) { - // We've already been in teleop before. Reset. - reset(); - } - else if (hasStartedAuto && !hasStartedTeleop) { - // We were in auto, and this is the first teleop session. Continue using existing ID. - - } - else if (!hasStartedAuto && !hasStartedTeleop) { - // Starting fresh from teleop (typical for local testing). Continue using the existing ID. - } - - hasStartedTeleop = true; - } - - public void reset() { - hasStartedAuto = false; - hasStartedTeleop = false; - sessionId = wg.getRandomWordChain(2, "-"); - sessionProp.set(sessionId); - } - - public String getSessionId() { - return sessionId; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/logging/SilentRobotAssertionManager.java b/src/main/java/xbot/common/logging/SilentRobotAssertionManager.java deleted file mode 100644 index 0d98b6e8..00000000 --- a/src/main/java/xbot/common/logging/SilentRobotAssertionManager.java +++ /dev/null @@ -1,24 +0,0 @@ -package xbot.common.logging; - -import javax.inject.Inject; - -/** - * Version of RobotAssertionManager that prevents throwing of exceptions. Should - * be used on-robot in competitions. - */ -public class SilentRobotAssertionManager extends RobotAssertionManager { - - @Inject - public SilentRobotAssertionManager() {} - - @Override - protected void handlePlatformException(RuntimeException e) { - // Don't do anything: we don't need to throw - } - - @Override - public boolean isExceptionsEnabled() { - return false; - } - -} diff --git a/src/main/java/xbot/common/logging/TimeLogger.java b/src/main/java/xbot/common/logging/TimeLogger.java deleted file mode 100644 index 7bbb46c1..00000000 --- a/src/main/java/xbot/common/logging/TimeLogger.java +++ /dev/null @@ -1,54 +0,0 @@ -package xbot.common.logging; - -import org.apache.log4j.Logger; - -import xbot.common.controls.sensors.XTimer; - -public class TimeLogger { - - private static Logger log = Logger.getLogger(TimeLogger.class); - - boolean firstCall; - double lastReportTime; - double startTime; - String name; - double accumulatedTime; - int callCount; - int reportingIntervalInSeconds; - - public TimeLogger(String name, int reportingIntervalInSeconds) { - firstCall = true; - this.name = name; - this.reportingIntervalInSeconds = reportingIntervalInSeconds; - reset(); - } - - private void reset() { - accumulatedTime = 0; - callCount = 0; - lastReportTime = XTimer.getFPGATimestamp(); - } - - public void start() { - startTime = XTimer.getFPGATimestamp(); - - if (firstCall) { - firstCall = false; - reset(); - } - } - - public void stop() { - double duration = XTimer.getFPGATimestamp() - startTime; - - accumulatedTime += duration; - callCount++; - - if (XTimer.getFPGATimestamp() - lastReportTime > reportingIntervalInSeconds && callCount > 0) { - double averageLoopDuration = accumulatedTime / (double)callCount; - log.info("Average duration for " + name + " was: " + averageLoopDuration); - - reset(); - } - } -} diff --git a/src/main/java/xbot/common/logging/WordGenerator.java b/src/main/java/xbot/common/logging/WordGenerator.java deleted file mode 100644 index 7788aa80..00000000 --- a/src/main/java/xbot/common/logging/WordGenerator.java +++ /dev/null @@ -1,53 +0,0 @@ -package xbot.common.logging; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Random; -import java.util.stream.Collectors; - -import javax.inject.Inject; - -import org.apache.log4j.Logger; - - -public class WordGenerator { - - String[] wordArray; - private Logger log = Logger.getLogger("WordGenerator"); - Random rand = new Random(); - - @Inject - public WordGenerator() { - String words = getResourceFileAsString("10k.txt"); - if (words != null) { - wordArray = words.split(System.lineSeparator()); - log.info("Successfully loaded english dictionary."); - log.info("Dictionary contains " + wordArray.length + " words."); - } else { - log.warn("Could not load dictionary file"); - } - } - - public String getResourceFileAsString(String fileName) { - InputStream is = getClass().getClassLoader().getResourceAsStream(fileName); - if (is != null) { - BufferedReader reader = new BufferedReader(new InputStreamReader(is)); - return reader.lines().collect(Collectors.joining(System.lineSeparator())); - } - return null; - } - - public String getRandomWordChain(int length, String separator) { - StringBuilder b = new StringBuilder(); - - for (int i = 0; i < length; i++) { - int r = rand.nextInt(wordArray.length-1); - b.append(wordArray[r]).append(separator); - } - - String precandidate = b.toString(); - String candidate = precandidate.substring(0, precandidate.length()-1); - return candidate; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/logic/CalibrationDecider.java b/src/main/java/xbot/common/logic/CalibrationDecider.java deleted file mode 100644 index 70f0d4e9..00000000 --- a/src/main/java/xbot/common/logic/CalibrationDecider.java +++ /dev/null @@ -1,47 +0,0 @@ -package xbot.common.logic; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.sensors.XTimer; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; - -public class CalibrationDecider { - - public enum CalibrationMode { - Attempting, Calibrated, GaveUp - } - - final DoubleProperty calibrationTimeProp; - double startTime; - - @AssistedFactory - public abstract static class CalibrationDeciderFactory { - public abstract CalibrationDecider create(@Assisted("name") String name); - } - - @AssistedInject - public CalibrationDecider(@Assisted("name") String name, PropertyFactory propMan) { - propMan.setPrefix(name); - calibrationTimeProp = propMan.createPersistentProperty("CalibrationDecider/Attempt Time", 3); - reset(); - } - - public void reset() { - startTime = XTimer.getFPGATimestamp(); - } - - public CalibrationMode decideMode(boolean isCalibrated) { - if (isCalibrated) { - return CalibrationMode.Calibrated; - } - - if (XTimer.getFPGATimestamp() - startTime > calibrationTimeProp.get()) { - return CalibrationMode.GaveUp; - } - - return CalibrationMode.Attempting; - } -} diff --git a/src/main/java/xbot/common/logic/HumanVsMachineDecider.java b/src/main/java/xbot/common/logic/HumanVsMachineDecider.java deleted file mode 100644 index 071aac83..00000000 --- a/src/main/java/xbot/common/logic/HumanVsMachineDecider.java +++ /dev/null @@ -1,72 +0,0 @@ -package xbot.common.logic; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; -import xbot.common.controls.sensors.XTimer; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.Property; -import xbot.common.properties.PropertyFactory; - -public class HumanVsMachineDecider { - - public enum HumanVsMachineMode { - HumanControl, - Coast, - InitializeMachineControl, - MachineControl - } - - private double lastHumanTime; - private final DoubleProperty deadbandProp; - private final DoubleProperty coastTimeProp; - private boolean inAutomaticMode; - - @AssistedFactory - public abstract static class HumanVsMachineDeciderFactory { - public abstract HumanVsMachineDecider create(@Assisted("prefix") String prefix); - } - - @AssistedInject - public HumanVsMachineDecider(@Assisted("prefix") String prefix, PropertyFactory propMan) { - propMan.setPrefix(prefix); - propMan.appendPrefix("Decider"); - propMan.setDefaultLevel(Property.PropertyLevel.Debug); - deadbandProp = propMan.createPersistentProperty("Deadband", 0.1); - coastTimeProp = propMan.createPersistentProperty("Coast Time", 0.3); - reset(); - } - - public void reset() { - reset(true); - } - - public void reset(boolean startInAutomaticMode) { - lastHumanTime = XTimer.getFPGATimestamp()-100; - inAutomaticMode = startInAutomaticMode; - } - - public HumanVsMachineMode getRecommendedMode(double humanInput) { - - if (Math.abs(humanInput) > deadbandProp.get()) { - lastHumanTime = XTimer.getFPGATimestamp(); - inAutomaticMode = false; - return HumanVsMachineMode.HumanControl; - } - - if (XTimer.getFPGATimestamp() - lastHumanTime < coastTimeProp.get()) { - return HumanVsMachineMode.Coast; - } - - if (!inAutomaticMode) { - inAutomaticMode = true; - return HumanVsMachineMode.InitializeMachineControl; - } - - return HumanVsMachineMode.MachineControl; - } - - public double getDeadband() { - return deadbandProp.get(); - } -} diff --git a/src/main/java/xbot/common/logic/Latch.java b/src/main/java/xbot/common/logic/Latch.java deleted file mode 100644 index 8fa8f5f7..00000000 --- a/src/main/java/xbot/common/logic/Latch.java +++ /dev/null @@ -1,43 +0,0 @@ -package xbot.common.logic; -import java.util.function.Consumer; - -/** - * Logical switch which consumes booleans and signals when the given value - * changes. - */ -public class Latch { - - private final EdgeType latchType; - private boolean value; - private Consumer callback; - - public enum EdgeType { - RisingEdge, FallingEdge, Both - } - - public Latch(boolean initialValue, EdgeType latchType) { - value = initialValue; - this.latchType = latchType; - } - - public Latch(boolean initialValue, EdgeType latchType, Consumer callback) { - this(initialValue, latchType); - addObserver(callback); - } - - public void addObserver(Consumer callback) { - this.callback = callback; - } - - public void setValue(boolean newValue) { - if (this.value == newValue) { - return; /* Do nothing if value stays the same */ - } - - EdgeType edgeType = newValue ? EdgeType.RisingEdge : EdgeType.FallingEdge; - if (latchType == edgeType || latchType == EdgeType.Both) { - callback.accept(edgeType); - } - this.value = newValue; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/logic/StallDetector.java b/src/main/java/xbot/common/logic/StallDetector.java deleted file mode 100644 index 723957eb..00000000 --- a/src/main/java/xbot/common/logic/StallDetector.java +++ /dev/null @@ -1,116 +0,0 @@ -package xbot.common.logic; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.sensors.XTimer; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; - -public class StallDetector { - - // Very generally, we have a few ways of detecting stall: - // 1. We are commanding a motor to use a large voltage, but we are getting very - // little motion - // 2. The motor is using a critical amount of current - // 3. The motor itself believes we are in some kind of stall condition - - // In each case, we need to check if this condition been true for more than an - // instant (to avoid false positives) - - // Finally, once we detect the condition, we need to suppress behavior for a few - // moments before allowing motion again. - // This will have the effect of "pulsing" the motor. - - public enum StallState { - NOT_STALLED, - STALLED, - WAS_STALLED_RECENTLY - } - - final TimeStableValidator currentLimitValidator; - final DoubleProperty currentTimeWindow; - final DoubleProperty currentLimit; - - final TimeStableValidator noMotionValidator; - final DoubleProperty noMotionTimeWindow; - final DoubleProperty tryingHardVoltagePercentThreshold; - final DoubleProperty littleMotionThreshold; - - final DoubleProperty stallCoolDown; - - double timeOfLastDetectedStall; - - @AssistedFactory - public abstract static class StallDetectorFactory { - public abstract StallDetector create(@Assisted("owningSystemPrefix") String owningSystemPrefix); - } - - @AssistedInject - public StallDetector(PropertyFactory pf, @Assisted("owningSystemPrefix") String owningSystemPrefix) { - pf.setPrefix(owningSystemPrefix + "StallDetector/"); - currentTimeWindow = pf.createPersistentProperty("CurrentTimeWindow", 0.1); - currentLimit = pf.createPersistentProperty("CurrentLimit", 1000); - - noMotionTimeWindow = pf.createPersistentProperty("NoMotionTimeWindow", 0.1); - tryingHardVoltagePercentThreshold = pf.createPersistentProperty("TryingHardVoltagePercentThreshold", 10); - littleMotionThreshold = pf.createPersistentProperty("LittleMotionThreshold", 1000.0); - - stallCoolDown = pf.createPersistentProperty("StallCoolDown", 0.); - - currentLimitValidator = new TimeStableValidator(() -> currentTimeWindow.get()); - noMotionValidator = new TimeStableValidator(() -> noMotionTimeWindow.get()); - - timeOfLastDetectedStall = -9999; - } - - public void setAllParameters(double currentTimeWindow, double currentLimit, - double noMotionTimeWindow, double tryingHardVoltagePercentThreshold, double littleMotionThreshold, - double stallCoolDown) { - this.currentTimeWindow.set(currentTimeWindow); - this.currentLimit.set(currentLimit); - this.noMotionTimeWindow.set(noMotionTimeWindow); - this.tryingHardVoltagePercentThreshold.set(tryingHardVoltagePercentThreshold); - this.littleMotionThreshold.set(littleMotionThreshold); - this.stallCoolDown.set(stallCoolDown); - } - - public StallState getIsStalled(double current, double voltagePercent, double velocity) { - // Feed current and motion data into the validators. If either of these - // triggers, we need to - // set the time of the last detected stall to the current time. - - boolean currentOverLimit = currentLimitValidator.checkStable(Math.abs(current) > currentLimit.get()); - boolean voltageCondition = false; - - // Check for stalls in either direction - if (voltagePercent > 0) { - // check for velocity below critical point - voltageCondition = voltagePercent > tryingHardVoltagePercentThreshold.get(); - } else if (voltagePercent < 0) { - // check for velocity above v - voltageCondition = voltagePercent < -tryingHardVoltagePercentThreshold.get(); - } - - boolean noMotion = noMotionValidator.checkStable( - Math.abs(velocity) < littleMotionThreshold.get() && voltageCondition); - - if (currentOverLimit || noMotion) { - timeOfLastDetectedStall = XTimer.getFPGATimestamp(); - return StallState.STALLED; - } - - // Check to see if we have been stalled for longer than the stall cool down - // time. - if (wasStalledRecently()) { - return StallState.WAS_STALLED_RECENTLY; - } else { - return StallState.NOT_STALLED; - } - } - - public boolean wasStalledRecently() { - return XTimer.getFPGATimestamp() - timeOfLastDetectedStall < stallCoolDown.get(); - } -} diff --git a/src/main/java/xbot/common/logic/TimeStableValidator.java b/src/main/java/xbot/common/logic/TimeStableValidator.java deleted file mode 100644 index edeca7e8..00000000 --- a/src/main/java/xbot/common/logic/TimeStableValidator.java +++ /dev/null @@ -1,61 +0,0 @@ -package xbot.common.logic; - -import java.util.function.Supplier; - -import xbot.common.controls.sensors.XTimer; -import xbot.common.logic.Latch.EdgeType; - -public class TimeStableValidator { - - Latch latch; - double risingEdgeTime; - double stableWindow; - Supplier stableWindowProvider; - - public TimeStableValidator(double stableWindow) { - this.stableWindow = stableWindow; - initialize(); - } - - public TimeStableValidator(Supplier stableWindowProvider) { - setStableWindowProvider(stableWindowProvider); - initialize(); - } - - private void initialize() { - latch = new Latch(false, EdgeType.RisingEdge); - latch.addObserver((e) -> risingEdgeTime = XTimer.getFPGATimestamp()); - } - - public void setStableWindowProvider(Supplier stableWindowProvider) { - this.stableWindowProvider = stableWindowProvider; - } - - public void setStableWindow(double stableWindow) { - this.stableWindow = stableWindow; - } - - private double getStableWindow() { - if (stableWindowProvider == null) { - return stableWindow; - } - return stableWindowProvider.get(); - } - - public boolean checkStable(boolean value) { - latch.setValue(value); - double duration = XTimer.getFPGATimestamp() - risingEdgeTime; - // if the value is true now, and has been for a while, it is stable. - return (duration > getStableWindow()) && value; - } - - /** - * Used if you want the validator to start in a stable state - */ - public void setStable() { - latch.setValue(true); - risingEdgeTime = -10000; - } - - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/logic/VelocityThrottleModule.java b/src/main/java/xbot/common/logic/VelocityThrottleModule.java deleted file mode 100644 index 10f22c00..00000000 --- a/src/main/java/xbot/common/logic/VelocityThrottleModule.java +++ /dev/null @@ -1,50 +0,0 @@ -package xbot.common.logic; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.math.MathUtils; -import xbot.common.math.PIDManager; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; - -public class VelocityThrottleModule { - - final PIDManager velocityPid; - final DoubleProperty throttleUpperLimitProp; - final DoubleProperty throttleLowerLimitProp; - private double throttle; - - @AssistedFactory - public abstract static class VelocityThrottleModuleFactory { - public abstract VelocityThrottleModule create( - @Assisted("name") String name, - @Assisted("velocityPid") PIDManager velocityPid); - } - - @AssistedInject - public VelocityThrottleModule(@Assisted("name") String name, @Assisted("velocityPid") PIDManager velocityPid, PropertyFactory propMan) { - this.velocityPid = velocityPid; - propMan.setPrefix(name + "/ThrottleModule"); - throttleUpperLimitProp = propMan.createPersistentProperty("ThrottleUpperLimit", 1); - throttleLowerLimitProp = propMan.createPersistentProperty("ThrottleLowerLimit", -1); - } - - public void setThrottleLimits(double lowerLimit, double upperLimit) { - throttleUpperLimitProp.set(upperLimit); - throttleLowerLimitProp.set(lowerLimit); - } - - public void reset() { - throttle = 0; - velocityPid.reset(); - } - - public double calculateThrottle(double goalSpeed, double currentSpeed) { - double throttleDelta = velocityPid.calculate(goalSpeed, currentSpeed); - throttle += throttleDelta; - throttle = MathUtils.constrainDouble(throttle, throttleLowerLimitProp.get(), throttleUpperLimitProp.get()); - return throttle; - } -} diff --git a/src/main/java/xbot/common/logic/WatchdogTimer.java b/src/main/java/xbot/common/logic/WatchdogTimer.java deleted file mode 100644 index 1f3d2371..00000000 --- a/src/main/java/xbot/common/logic/WatchdogTimer.java +++ /dev/null @@ -1,68 +0,0 @@ -package xbot.common.logic; - -import xbot.common.controls.sensors.XTimer; -import xbot.common.logic.Latch.EdgeType; -import xbot.common.properties.BooleanProperty; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; - -public class WatchdogTimer { - private double lastKick = Double.NEGATIVE_INFINITY; - private Latch latch; - - private BooleanProperty isUpProp; - private DoubleProperty timeSinceKickProp; - - private final double timeout; - private Runnable onUp = null; - private Runnable onDown = null; - - private WatchdogTimer(double timeout) { - this.timeout = timeout; - latch = new Latch(false, EdgeType.Both, this::handleLatchUpdate); - } - - public WatchdogTimer(double timeout, String name, PropertyFactory propMan) { - this(timeout); - propMan.setPrefix(name); - this.isUpProp = propMan.createEphemeralProperty("Is up?", false); - this.timeSinceKickProp = propMan.createEphemeralProperty("Time since kick", Double.POSITIVE_INFINITY); - } - - public WatchdogTimer(double timeout, Runnable onUp, Runnable onDown) { - this(timeout); - this.onUp = onUp; - this.onDown = onDown; - } - - public WatchdogTimer(double timeout, Runnable onUp, Runnable onDown, String name, PropertyFactory propMan) { - this(timeout, name, propMan); - this.onUp = onUp; - this.onDown = onDown; - } - - private void handleLatchUpdate(EdgeType edge) { - if (edge == EdgeType.RisingEdge && onUp != null) { - onUp.run(); - } - else if (edge == EdgeType.FallingEdge && onDown != null) { - onDown.run(); - } - } - - public void kick() { - lastKick = XTimer.getFPGATimestamp(); - } - - public void check() { - double now = XTimer.getFPGATimestamp(); - double timeSinceKick = now - lastKick; - boolean isUp = Double.isFinite(timeSinceKick) && timeSinceKick <= timeout; - - latch.setValue(isUp); - if (this.isUpProp != null && this.timeSinceKickProp != null) { - isUpProp.set(isUp); - timeSinceKickProp.set(timeSinceKick); - } - } -} diff --git a/src/main/java/xbot/common/math/ContiguousDouble.java b/src/main/java/xbot/common/math/ContiguousDouble.java deleted file mode 100644 index ebf2a452..00000000 --- a/src/main/java/xbot/common/math/ContiguousDouble.java +++ /dev/null @@ -1,228 +0,0 @@ -package xbot.common.math; - -import org.apache.log4j.Logger; - -/** - * Wraps a double to allow easy comparison and manipulation of sensor readings - * that wrap (e.g. -180 to 180). - * - * For bounds 0 - 10, logically: - * - 10 + 1 == 1 - * - 0 - 1 == 9 - * - 0 == 10 - */ -public class ContiguousDouble { - - private static Logger log = Logger.getLogger(ContiguousDouble.class); - - private double value; - - private double lowerBound; - private double upperBound; - - public ContiguousDouble(double value, double lowerBound, double upperBound) { - this.value = value; - - this.lowerBound = lowerBound; - this.upperBound = upperBound; - - this.validateBounds(); - this.reboundValue(); - } - - public ContiguousDouble(double lowerBound, double upperBound) { - this.lowerBound = lowerBound; - this.upperBound = upperBound; - this.validateBounds(); - this.value = 0; - } - - public ContiguousDouble() { - this.value = 0; - this.lowerBound = 0; - this.upperBound = 0; - } - - /** - * Shifts the value so that it still represents the same position but is - * within the current bounds. - * - * @return the new value for chaining functions - */ - public double reboundValue() { - value = reboundValue(this.value, this.lowerBound, this.upperBound); - return value; - } - - public static double reboundValue(double value, double lowerBound, double upperBound) { - if (value < lowerBound) { - value = upperBound - + ((value - lowerBound) % (upperBound - lowerBound)); - } else if (value > upperBound) { - value = lowerBound - + ((value - upperBound) % (upperBound - lowerBound)); - } - - return value; - } - - /** - * Flips the lower and upper bounds if the lower bound is larger than the - * upper bound. - */ - private void validateBounds() { - if (lowerBound > upperBound) { - log.warn(String - .format("Given bounds are out of order (Low: %.4f, High: %.4f). Flipping them to continue.", - this.lowerBound, this.upperBound)); - double tmp = this.lowerBound; - this.lowerBound = this.upperBound; - this.upperBound = tmp; - } - } - - /** - * Calculates a number representing the current value that is lower than (or - * equal to) the lower bound. Used to make normal numerical comparisons - * without needing to handle wrap cases. - * - * @return the computed value - */ - public double unwrapBelow() { - return lowerBound - (upperBound - value); - } - - /** - * Calculates a number representing the current value that is higher than - * (or equal to) the upper bound. Used to make normal numerical comparisons - * without needing to handle wrap cases. - * - * @return the computed value - */ - public double unwrapAbove() { - return upperBound + (value - lowerBound); - } - - /** - * Computes the difference between two values (other - this), accounting for - * wrapping. Treats the given 'other' value as a number within the same bounds - * as the current instance. - * - * @param otherValue - * the other value to compare against - * @return the computed difference - */ - public double difference(double otherValue) { - return difference(new ContiguousDouble(otherValue, lowerBound, - upperBound)); - } - - /** - * Computes the difference between two values (other - this), accounting for - * wrapping - * - * @param otherValue - * the other value to compare against (must have the same bounds - * as the current instance) - * @return the computed difference - */ - public double difference(ContiguousDouble otherValue) { - if (otherValue.getLowerBound() != lowerBound - || otherValue.getUpperBound() != upperBound) { - log.warn("The given ContiguousDouble does not have the same upper and lower bounds. " - + "This may lead to unexpected behavior."); - } - - // Find the shortest path to the target (smallest difference) - double aboveDiff = otherValue.getValue() - this.unwrapAbove(); - double belowDiff = otherValue.getValue() - this.unwrapBelow(); - double stdDiff = otherValue.getValue() - this.getValue(); - - double finalDiff = stdDiff; - - if (Math.abs(aboveDiff) < Math.abs(belowDiff) - && Math.abs(aboveDiff) < Math.abs(stdDiff)) { - finalDiff = aboveDiff; - } else if (Math.abs(belowDiff) < Math.abs(aboveDiff) - && Math.abs(belowDiff) < Math.abs(stdDiff)) { - finalDiff = belowDiff; - } - - return finalDiff; - } - - /** - * Shifts both bounds by the specified amount - * - * @param shiftMagnitude - * the amount to add to each bound - */ - public ContiguousDouble shiftBounds(double shiftMagnitude) { - upperBound += shiftMagnitude; - lowerBound += shiftMagnitude; - reboundValue(); - return this; - } - - /** - * Shifts value by the specified amount (addition) - * - * @param shiftMagnitude - * the amount to add to the current value - * - * @return A reference to the current ContiguousDouble, for daisy chaining. - */ - public ContiguousDouble shiftValue(double shiftMagnitude) { - value += shiftMagnitude; - reboundValue(); - - return this; - } - - // Getters/Setters ---------------- - // Value - public double getValue() { - return value; - } - - public void setValue(double newValue) { - value = newValue; - this.reboundValue(); - } - - // Upper bound - public double getUpperBound() { - return upperBound; - } - - public void setUpperBound(double newValue) { - upperBound = newValue; - - this.validateBounds(); - this.reboundValue(); - } - - // Lower bound - public double getLowerBound() { - return lowerBound; - } - - public void setLowerBound(double newValue) { - lowerBound = newValue; - - this.validateBounds(); - this.reboundValue(); - } - - @Override - public ContiguousDouble clone() { - return new ContiguousDouble(value, lowerBound, upperBound); - } - - @Override - public String toString() { - return "ContiguousDouble" - + "[" + this.getLowerBound() +", " + this.getUpperBound() + "]" - + " " + this.getValue(); - } -} diff --git a/src/main/java/xbot/common/math/FieldPose.java b/src/main/java/xbot/common/math/FieldPose.java deleted file mode 100644 index bf7ca6e5..00000000 --- a/src/main/java/xbot/common/math/FieldPose.java +++ /dev/null @@ -1,156 +0,0 @@ -package xbot.common.math; - -import edu.wpi.first.math.geometry.Rotation2d; - -/** - * The FieldPose class represents a point on the field as well as a heading. - * - * It also keeps track of some linear equation parameters such as slope and y-intercept. - * These are used to calculate intersection points between multiple FieldPose instances, - * which can then be used as part of path-following logic. - * - * @author John - * - */ -public class FieldPose { - - private WrappedRotation2d heading; - private final XYPair fieldPosition; - - public FieldPose() { - this.fieldPosition = new XYPair(); - this.heading = WrappedRotation2d.fromDegrees(0); - } - - public FieldPose(XYPair point, Rotation2d heading) { - this.fieldPosition = point.clone(); - this.heading = new WrappedRotation2d(heading.getRadians()); - } - - public FieldPose(double x, double y, double heading) { - this.fieldPosition = new XYPair(x, y); - this.heading = WrappedRotation2d.fromDegrees(heading); - } - - public FieldPose clone() { - return new FieldPose(fieldPosition.clone(), heading); - } - - public WrappedRotation2d getHeading() { - return heading; - } - - public XYPair getPoint() { - return fieldPosition; - } - - public WrappedRotation2d getPerpendicularHeadingTowardsPoint(FieldPose other) { - boolean direction = getPoseRelativeDisplacement(other).y > 0; - return WrappedRotation2d.fromRotation2d(heading.rotateBy(Rotation2d.fromDegrees(direction ? -90 : 90))); - } - - public XYPair getPointAlongPoseClosestToPoint(XYPair other) { - - XYPair relativeVector = new XYPair(other.x - fieldPosition.x, other.y - fieldPosition.y); - - - // Found by taking the derivative of the distance between any point along the - // projected pose, denoted by a distance P along the line, and the "other" point: - // d/dP(D(P)=sqrt((sin(a)*P-y)^2+(cos(a)*P-x)^2)) - // Then finding the zero of the resultant function, denoting the position along - // the projected line which is closest to the target: - // solve (-x cos(a) - y sin(a) + P)/sqrt(-2 P x cos(a) - 2 P y sin(a) + P^2 + x^2 + y^2) for P - // ...and finally using that distance formula to construct the final point: - // (cos(a)*P, sin(a)*P), for P=xcos(a)+ysin(a) - double headingCosine = getHeadingCosine(); - double headingSine = getHeadingSine(); - double distanceAlongPoseLine = headingCosine * relativeVector.x + headingSine * relativeVector.y; - - return new XYPair( - fieldPosition.x + headingCosine * distanceAlongPoseLine, - fieldPosition.y + headingSine * distanceAlongPoseLine); - } - - public double getDistanceAlongPoseLine(XYPair other) { - XYPair relativeVector = new XYPair(other.x - fieldPosition.x, other.y - fieldPosition.y); - double headingCosine = getHeadingCosine(); - double headingSine = getHeadingSine(); - return headingCosine * relativeVector.x + headingSine * relativeVector.y; - } - - private double getHeadingCosine() { - return heading.getCos(); - } - - private double getHeadingSine() { - return heading.getSin(); - } - - public FieldPose getRabbitPose(XYPair other, double lookaheadDistance) { - XYPair closestPoint = getPointAlongPoseClosestToPoint(other); - XYPair rabbitLocation = closestPoint.add(new XYPair(lookaheadDistance * getHeadingCosine(), lookaheadDistance * getHeadingSine())); - return new FieldPose(rabbitLocation, getHeading()); - } - - public double getDeltaAngleToRabbit(FieldPose other, double lookaheadDistance) { - return WrappedRotation2d.fromDegrees(getVectorToRabbit(other, lookaheadDistance).getAngle()).minus(other.getHeading()).getDegrees(); - } - - public XYPair getVectorToRabbit(FieldPose other, double lookaheadDistance) { - FieldPose rabbitPose = getRabbitPose(other.getPoint(), lookaheadDistance); - return rabbitPose.getPoint().add(other.getPoint().clone().scale(-1)); - } - - public double getAngleToPoint(XYPair point) { - return point.clone().add(this.getPoint().clone().scale(-1)).getAngle(); - } - - public double getDistanceToLineFromPoint(XYPair currentPoint) { - return getPointAlongPoseClosestToPoint(currentPoint).getDistanceToPoint(currentPoint); - } - - public XYPair getPoseRelativeDisplacement(FieldPose other) { - XYPair clonedPoint = this.getPoint().clone(); - XYPair normalizedPoint = clonedPoint.add(other.getPoint().scale(-1)); - - // then rotate that point to 90 degrees - return normalizedPoint.rotate(90 - other.getHeading().getDegrees()); - } - - /** - * Projects along the line created by the X,Y pair and the Heading. - * Positive distances are in front, negative are behind. Keeps the - * original heading. - * @param distance Positive distances are in front, negative are behind. - * @return FieldPose projected along the line - */ - public FieldPose getPointAlongPoseLine(double distance) { - double deltaX = this.heading.getCos() * distance; - double deltaY = this.heading.getSin() * distance; - double updatedX = this.getPoint().x + deltaX; - double updatedY = this.getPoint().y + deltaY; - - return new FieldPose(new XYPair(updatedX, updatedY), new Rotation2d(deltaX, deltaY)); - } - - /** - * Returns a FieldPose that's "subtracted" by the offset FieldPose. Useful for setting your current position - * as 0,0 and measuring relative to that as you move around the field. - * @param offset The offset location - * @return The FieldPose shifted by the given offset - */ - public FieldPose getFieldPoseOffsetBy(FieldPose offset) { - XYPair changedPoint = this.getPoint().clone().add(offset.getPoint().clone().scale(-1)); - // Currently only handling point offsets, not heading offsets - WrappedRotation2d changedHeading = this.getHeading(); - - return new FieldPose(changedPoint, changedHeading); - } - - @Override - public String toString() { - String xyString = fieldPosition == null ? "null, null" : fieldPosition.x + ", " + fieldPosition.y; - String headingString = heading == null ? "null" : Double.toString(heading.getDegrees()); - return "FieldPose(" + xyString + ", "+ headingString + ")"; - } -} diff --git a/src/main/java/xbot/common/math/FieldPosePropertyManager.java b/src/main/java/xbot/common/math/FieldPosePropertyManager.java deleted file mode 100644 index 4e965e73..00000000 --- a/src/main/java/xbot/common/math/FieldPosePropertyManager.java +++ /dev/null @@ -1,48 +0,0 @@ -package xbot.common.math; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.math.geometry.Rotation2d; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; - -public class FieldPosePropertyManager { - - private final DoubleProperty xProp; - private final DoubleProperty yProp; - private final DoubleProperty headingProp; - - @AssistedFactory - public abstract static class FieldPosePropertyManagerFactory { - public abstract FieldPosePropertyManager create( - @Assisted("poseName") String poseName, - @Assisted("x") double x, - @Assisted("y") double y, - @Assisted("heading") double heading); - - public FieldPosePropertyManager create( - String poseName, - FieldPose fieldPose) { - return create(poseName, fieldPose.getPoint().x, fieldPose.getPoint().y, fieldPose.getHeading().getDegrees()); - } - } - - @AssistedInject - public FieldPosePropertyManager( - @Assisted("poseName") String poseName, - @Assisted("x") double x, - @Assisted("y") double y, - @Assisted("heading") double heading, - PropertyFactory propMan) { - propMan.setPrefix(poseName); - xProp = propMan.createPersistentProperty("X", x); - yProp = propMan.createPersistentProperty("Y", y); - headingProp = propMan.createPersistentProperty("Heading", heading); - } - - public FieldPose getPose() { - return new FieldPose(new XYPair(xProp.get(), yProp.get()), Rotation2d.fromDegrees(headingProp.get())); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/math/InterpolatingFieldPoseBuffer.java b/src/main/java/xbot/common/math/InterpolatingFieldPoseBuffer.java deleted file mode 100644 index 382148ae..00000000 --- a/src/main/java/xbot/common/math/InterpolatingFieldPoseBuffer.java +++ /dev/null @@ -1,37 +0,0 @@ -package xbot.common.math; - -import edu.wpi.first.math.geometry.Rotation2d; -import xbot.common.controls.sensors.XTimer; - -public class InterpolatingFieldPoseBuffer { - - private InterpolatingHistoryBuffer xBuffer; - private InterpolatingHistoryBuffer yBuffer; - private InterpolatingHistoryBuffer headingBuffer; - - private double unwrappedHeading; - - public InterpolatingFieldPoseBuffer(FieldPose pose) { - xBuffer = new InterpolatingHistoryBuffer(50, pose.getPoint().x); - yBuffer = new InterpolatingHistoryBuffer(50, pose.getPoint().y); - unwrappedHeading = pose.getHeading().getDegrees(); - headingBuffer = new InterpolatingHistoryBuffer(50, unwrappedHeading); - } - - public void insert(FieldPose pose) { - xBuffer.insert(XTimer.getFPGATimestamp(), pose.getPoint().x); - yBuffer.insert(XTimer.getFPGATimestamp(), pose.getPoint().y); - - double headingDelta = pose.getHeading().minus(Rotation2d.fromDegrees(unwrappedHeading)).getDegrees(); - unwrappedHeading += headingDelta; - headingBuffer.insert(XTimer.getFPGATimestamp(), unwrappedHeading); - } - - public FieldPose getPoseAtTime(double timeInSeconds) { - return new FieldPose(new XYPair( - xBuffer.getValAtTime(timeInSeconds), - yBuffer.getValAtTime(timeInSeconds)), - Rotation2d.fromDegrees(headingBuffer.getValAtTime(timeInSeconds))); - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/math/InterpolatingHistoryBuffer.java b/src/main/java/xbot/common/math/InterpolatingHistoryBuffer.java deleted file mode 100644 index e0bcc594..00000000 --- a/src/main/java/xbot/common/math/InterpolatingHistoryBuffer.java +++ /dev/null @@ -1,110 +0,0 @@ -package xbot.common.math; - -/* - ******************************************************************************************* - * Copyright (C) 2017 FRC Team 1736 Robot Casserole - www.robotcasserole.org - ******************************************************************************************* -*/ - -import java.util.Arrays; - -import xbot.common.controls.sensors.XTimer; - -public class InterpolatingHistoryBuffer { - - // I manually implemented a circular buffer cuz I enjoy difficult things like - // that. - private int bufferSize; // size of buffers - private double[] value_buffer; // circular buffer to hold all values - private double[] time_buffer; // circular buffer to hold all values - private int index; // "pointer" to the starting index in the buffers - - /** - * This class implements a set of circular buffers that can be used to store - * values of signals in the past, and retrieve values at arbitrary previous time - * indexes. - * - * The value is assumed to saturate at the end of the maintained history. - * - * @param length Number of samples to keep - * @param init_val Value to fill the inital samples with (probably zero is fine) - */ - public InterpolatingHistoryBuffer(int length, double init_val) { - double init_time = XTimer.getFPGATimestamp(); - value_buffer = new double[length]; - time_buffer = new double[length]; - Arrays.fill(value_buffer, init_val); - Arrays.fill(time_buffer, init_time); - index = 0; - bufferSize = length; - } - - /** - * Insert a new value into the buffer. Discards the oldest value. - * - * @param time Time at which the value was sampled. elements must be inserted - * in a monotomically increasing fashion - * @param value Value of the signal right now - * @return true if the value was inserted, false otherwise - */ - public boolean insert(double time, double value) { - - // Sanity check the inserted value - if (time_buffer[index] > time) { - System.out.println("ERROR: InterpValueHistoryBuffer got non-increasing time vector. Tell software team!"); - return false; - } - - // Update index - index = getNextIdx(index); - - // Insert values - value_buffer[index] = value; - time_buffer[index] = time; - - return true; - } - - /** - * Returns the value at a given time, linearlly interpolated. - * - * @param time time at which to retrieve value - * @return value at inputted time. - */ - public double getValAtTime(double time) { - int lower_idx = index; - int upper_idx = getNextIdx(index); - boolean firstPass = true; - - while (true) { - if ((time_buffer[lower_idx] <= time) & (time_buffer[upper_idx] >= time)) { - // Case, we've found the desired block. Calculate the value at the given time - // with linear interpolation - double segment_delta_t = time_buffer[upper_idx] - time_buffer[lower_idx]; - double segment_delta_v = value_buffer[upper_idx] - value_buffer[lower_idx]; - double time_ratio = (time - time_buffer[lower_idx]) / segment_delta_t; - return value_buffer[lower_idx] + (segment_delta_v * time_ratio); - } - - // Update iteration indicies for next loop - lower_idx = getNextIdx(lower_idx); - upper_idx = getNextIdx(upper_idx); - - if (lower_idx == index && !firstPass) { - // Terminal case, we're off the end. Return the oldest value. - return value_buffer[lower_idx]; - } else { - firstPass = false; - } - } - } - - private int getNextIdx(int idx) { - if (idx + 1 >= bufferSize) { - return 0; - } else { - return idx + 1; - } - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/math/MathUtils.java b/src/main/java/xbot/common/math/MathUtils.java deleted file mode 100644 index c0a607ef..00000000 --- a/src/main/java/xbot/common/math/MathUtils.java +++ /dev/null @@ -1,68 +0,0 @@ -package xbot.common.math; - -import java.util.function.Function; - -public class MathUtils -{ - public static double constrainDouble(double value, double lowerBound, double upperBound) - { - return Math.max(lowerBound, Math.min(value, upperBound)); - } - - public static int constrainInt(int value, int lowerBound, int upperBound) - { - return Math.max(lowerBound, Math.min(value, upperBound)); - } - - public static double scaleDouble(double value, double oldMin, double oldMax, double newMin, double newMax) - { - value -= oldMin; - value /= oldMax - oldMin; - value *= newMax - newMin; - value += newMin; - return value; - } - - public static double constrainDoubleToRobotScale(double value) { - return constrainDouble(value, -1, 1); - } - - public static double squareAndRetainSign(double value) { - double squared = Math.pow(value, 2); - return value < 0 ? -squared : squared; - } - - public static double exponentAndRetainSign(double value, int exponent) { - double raised = Math.pow(value, exponent); - return (value < 0 && raised > 0) ? -raised : raised; - } - - public static double deadband(double input, double deadband) { - if (Math.abs(input) < deadband) { - return 0; - } - return input; - } - - public static double deadband(double input, double deadband, Function function) { - if (Math.abs(input) < deadband) { - return 0; - } - - // Subtract the input from the deadband to get a new "zero" - double reducedInput = 0; - if (input > 0) { - reducedInput = input - deadband; - } else { - reducedInput = input + deadband; - } - - // Divide the input by the remaining range to scale it back to a (0, 1) range. - double scaledInput = reducedInput / (1-deadband); - - // Apply whatever further function is appropriate - return function.apply(scaledInput); - } - - public static double Tau = Math.PI * 2; -} diff --git a/src/main/java/xbot/common/math/PID.java b/src/main/java/xbot/common/math/PID.java deleted file mode 100644 index 825657c0..00000000 --- a/src/main/java/xbot/common/math/PID.java +++ /dev/null @@ -1,270 +0,0 @@ -package xbot.common.math; - -import xbot.common.controls.sensors.XTimer; - -/** - * This PID was extracted from WPILib. It has all the same functionality, but - * does not run on its own separate thread. - */ -public class PID -{ - public enum OffTargetReason { - Unknown, - OffTargetNotConfigured, - ErrorTooLarge, - DerivativeTooLarge, - NotTimeStable, - OnTarget - } - - private double m_error = 0.0; - private double m_maximumOutput = 1.0; // |maximum output| - private double m_minimumOutput = -1.0; // |minimum output| - private double m_result; - private double m_prevError; - private double m_totalError; - private double m_targetInputValue; - private double m_currentInputValue; - - private double m_derivativeValue; - private boolean errorIsSmall = false; - private boolean derivativeIsSmall = false; - double errorTolerance = 0; - double derivativeTolerance = 0; - - private boolean checkErrorThreshold = false; - private boolean checkDerivativeThreshold = false; - private boolean checkTimeThreshold = false; - private boolean waitingToStabilize = false; - private double timeToleranceInSeconds = 0; - - private double startTime = 0; - - private boolean onTarget = false; - private OffTargetReason offTargetReason = OffTargetReason.Unknown; - - - /** - * Resets the PID controller. - */ - public void reset() - { - m_prevError = 0; - m_totalError = 0; - errorIsSmall = false; - derivativeIsSmall = false; - } - - /** - * Set tolerances for the PID system. - * @param errorTolerance - * How close the error can be before it is considered - * "on-target." - * - * Negative values will cause that constraint to skipped when checking - * isOnTarget(). - * - * This is in the same units as your current and goal values. - * @param derivativeTolerance - * Set how small the derivative of the error can be before it is considered - * "on-target." - * - * This is roughly in the same units as your current and goal values, - * but per 1/20th of a second. - * - * e.g. if you wanted a minimum rotation speed of 5 degrees per second, - * this tolerance would need to be 0.25. - */ - public void setTolerances(double errorTolerance, double derivativeTolerance, double timeToleranceInSeconds) { - this.errorTolerance = errorTolerance; - this.derivativeTolerance = derivativeTolerance; - this.timeToleranceInSeconds = timeToleranceInSeconds; - } - - /** - * Controls whether or not the tolerances are checked as part of isOnTarget(). - */ - public void setShouldCheckTolerances(boolean checkError, boolean checkDerivative, boolean checkTime) { - checkErrorThreshold = checkError; - checkDerivativeThreshold = checkDerivative; - checkTimeThreshold = checkTime; - } - - /** - * Calculates the output value given P,I,D, a process variable and a goal - * - * @param goal - * What value you are trying to achieve - * @param current - * What the value under observation currently is - * @param p - * Proportionate response - * @param i - * Integral response. - * @param d - * Derivative response. - * @param f - * Feed-forward response - * @return The output value to achieve goal - */ - public double calculate(double goal, double current, - double p, double i, double d, double f, double iZone) - { - m_targetInputValue = goal; - m_currentInputValue = current; - double result; - m_error = m_targetInputValue - m_currentInputValue; - - if (i != 0) - { - double potentialIGain = (m_totalError + m_error) * i; - if (potentialIGain < m_maximumOutput) - { - if (potentialIGain > m_minimumOutput) - { - m_totalError += m_error; - } else - { - m_totalError = m_minimumOutput / i; - } - } else - { - m_totalError = m_maximumOutput / i; - } - } - - m_derivativeValue = m_error - m_prevError; - m_result = p * m_error + d * (m_derivativeValue) + f * goal; - if(iZone <= 0 || Math.abs(m_error) < iZone) { - m_result += i * m_totalError; - } - m_prevError = m_error; - - if (m_result > m_maximumOutput) - { - m_result = m_maximumOutput; - } else if (m_result < m_minimumOutput) - { - m_result = m_minimumOutput; - } - result = m_result; - - errorIsSmall = checkErrorThreshold && Math.abs(m_targetInputValue - m_currentInputValue) < errorTolerance; - derivativeIsSmall = checkDerivativeThreshold && Math.abs(m_derivativeValue) < derivativeTolerance; - - checkIsOnTarget(); - - return result; - } - - /** - * Calculates the output value given P,I,D, a process variable and a goal - * - * @param goal - * What value you are trying to achieve - * @param current - * What the value under observation currently is - * @param p - * Proportionate response - * @param i - * Integral response. - * @param d - * Derivative response. - * @param f - * Feed-forward response. - * @return The output value to achieve goal - */ - public double calculate(double goal, double current, - double p, double i, double d, double f) { - return calculate(goal, current, p, i, d, f, 0); - } - - /** - * Calculates the output value given P,I,D, a process variable and a goal - * - * @param goal - * What value you are trying to achieve - * @param current - * What the value under observation currently is - * @param p - * Proportionate response - * @param i - * Integral response. - * @param d - * Derivative response. - * @return The output value to achieve goal - */ - public double calculate(double goal, double current, - double p, double i, double d) { - return calculate(goal, current, p, i, d, 0); - } - - /** - * With the addition of a time threshold, "onTarget" needs to be updated every tick, since - * isOnTarget() should return true if all conditions are met EVEN IF it's the first time - * being called. - * - * While that's unlikely due to our command infrastructure, it's still possible, and the PID - * class should be able to handle that scenario. - * - * As a result, this checkIsOnTarget method was added, which does all the onTarget calculations - * during every calculate() call. the isOnTarget() method just returns a stored class-level variable. - */ - private void checkIsOnTarget() { - if (!checkErrorThreshold && !checkDerivativeThreshold && !checkTimeThreshold) { - // No tolerances are enabled, but isOnTarget is being called anyway. We still need to return something. - // In this case, we return FALSE, as it promotes robot action (the command using this will complete - // its activity, even if it doesn't signal that it is done to allow other actions to proceed). - onTarget = false; - offTargetReason = OffTargetReason.OffTargetNotConfigured; - return; - } - - // Assume we are on target, and then look for reasons we may not be. - offTargetReason = OffTargetReason.OnTarget; - onTarget = true; - - if (checkDerivativeThreshold) { - onTarget &= derivativeIsSmall; - offTargetReason = derivativeIsSmall ? offTargetReason : OffTargetReason.DerivativeTooLarge; - } - if (checkErrorThreshold) { - onTarget &= errorIsSmall; - offTargetReason = errorIsSmall ? offTargetReason : OffTargetReason.ErrorTooLarge; - } - - if (checkTimeThreshold) { - if(onTarget){ - if(waitingToStabilize == false){ - waitingToStabilize = true; - startTime = XTimer.getFPGATimestamp(); - onTarget = false; - offTargetReason = OffTargetReason.NotTimeStable; - } else { - onTarget = (XTimer.getFPGATimestamp() - startTime) > timeToleranceInSeconds; - offTargetReason = onTarget ? OffTargetReason.OnTarget : OffTargetReason.NotTimeStable; - } - } else { - waitingToStabilize = false; - onTarget = false; - } - } - } - - public boolean isOnTarget() { - return onTarget; - } - - /** - * Returns an enum explaining the reason the PID is not on target. - * It has the following priority list if there are multiple reasons (higher ones overrule lower ones): - * - Too much error - * - Too much derivative - * - Waiting for time stability - * - On Target - * @return The reason the PID is not on target. - */ - public OffTargetReason getOffTargetReason() { - return offTargetReason; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/math/PIDManager.java b/src/main/java/xbot/common/math/PIDManager.java deleted file mode 100644 index 020b958d..00000000 --- a/src/main/java/xbot/common/math/PIDManager.java +++ /dev/null @@ -1,196 +0,0 @@ -package xbot.common.math; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.logging.RobotAssertionManager; -import xbot.common.math.PID.OffTargetReason; -import xbot.common.properties.BooleanProperty; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.Property; -import xbot.common.properties.StringProperty; -import xbot.common.properties.PropertyFactory; - -/** - * Wrapper for PID class which automatically puts the P, I and D values on - * the SmartDashboard. - */ -public class PIDManager extends PIDPropertyManager { - private PID pid; - - private DoubleProperty maxOutput; - private DoubleProperty minOutput; - private BooleanProperty isEnabled; - private boolean isIMasked = false; - private StringProperty offTargetReasonProp; - - @AssistedFactory - public abstract static class PIDManagerFactory { - public abstract PIDManager create( - String functionName, - @Assisted("defaultP") double defaultP, - @Assisted("defaultI") double defaultI, - @Assisted("defaultD") double defaultD, - @Assisted("defaultF") double defaultF, - @Assisted("defaultMaxOutput") double defaultMaxOutput, - @Assisted("defaultMinOutput") double defaultMinOutput, - @Assisted("errorThreshold") double errorThreshold, - @Assisted("derivativeThreshold") double derivativeThreshold, - @Assisted("timeThreshold") double timeThreshold, - @Assisted("iZone") double iZone); - - public PIDManager create( - String functionName, - double defaultP, - double defaultI, - double defaultD, - double defaultF, - double defaultMaxOutput, - double defaultMinOutput, - double errorThreshold, - double derivativeThreshold, - double timeThreshold) { - return create(functionName, defaultP, defaultI, defaultD, defaultF, defaultMaxOutput, - defaultMinOutput, errorThreshold, derivativeThreshold, timeThreshold, -1); - } - - public PIDManager create( - String functionName, - double defaultP, - double defaultI, - double defaultD, - double defaultF, - double defaultMaxOutput, - double defaultMinOutput) { - return create(functionName, defaultP, defaultI, defaultD, defaultF, defaultMaxOutput, - defaultMinOutput, -1, -1, -1); - } - - public PIDManager create( - String functionName, - double defaultP, - double defaultI, - double defaultD, - double defaultMaxOutput, - double defaultMinOutput) { - return create(functionName, defaultP, defaultI, defaultD, 0, defaultMaxOutput, - defaultMinOutput); - } - - public PIDManager create( - String functionName, - double defaultP, - double defaultI, - double defaultD) { - return create(functionName, defaultP, defaultI, defaultD, 1.0, -1.0); - } - - public PIDManager create(String functionName) { - return create(functionName, 0, 0, 0); - } - } - - @AssistedInject - public PIDManager( - @Assisted String functionName, - PropertyFactory propMan, - RobotAssertionManager assertionManager, - @Assisted("defaultP") double defaultP, - @Assisted("defaultI") double defaultI, - @Assisted("defaultD") double defaultD, - @Assisted("defaultF") double defaultF, - @Assisted("defaultMaxOutput") double defaultMaxOutput, - @Assisted("defaultMinOutput") double defaultMinOutput, - @Assisted("errorThreshold") double errorThreshold, - @Assisted("derivativeThreshold") double derivativeThreshold, - @Assisted("timeThreshold") double timeThreshold, - @Assisted("iZone") double iZone) { - super(functionName, propMan, assertionManager, defaultP, defaultI, defaultD, defaultF, errorThreshold, - derivativeThreshold, timeThreshold, iZone); - - propMan.setDefaultLevel(Property.PropertyLevel.Debug); - maxOutput = propMan.createPersistentProperty("Max Output", defaultMaxOutput); - minOutput = propMan.createPersistentProperty("Min Output", defaultMinOutput); - isEnabled = propMan.createPersistentProperty("Is Enabled", true); - offTargetReasonProp = propMan.createEphemeralProperty("OffTargetReason", ""); - propMan.setDefaultLevel(Property.PropertyLevel.Important); - - pid = new PID(); - sendTolerancesToInternalPID(); - } - - private void sendTolerancesToInternalPID() { - pid.setTolerances(getErrorThreshold(), getDerivativeThreshold(), getTimeThreshold()); - pid.setShouldCheckTolerances(getEnableErrorThreshold(), getEnableDerivativeThreshold(), - getEnableTimeThreshold()); - } - - public double calculate(double goal, double current) { - // update tolerances via properties - sendTolerancesToInternalPID(); - - if (isEnabled.get()) { - double pidResult = pid.calculate(goal, current, getP(), isIMasked ? 0 : getI(), getD(), getF(), getIZone()); - offTargetReasonProp.set(pid.getOffTargetReason().toString()); - return MathUtils.constrainDouble(pidResult, minOutput.get(), maxOutput.get()); - } else { - return 0; - } - } - - public void reset() { - pid.reset(); - } - - @Deprecated - /** - * Legacy method to support old callers. - */ - public boolean isOnTarget(double errorTolerance) { - setErrorThreshold(errorTolerance); - setEnableErrorThreshold(true); - sendTolerancesToInternalPID(); - return pid.isOnTarget(); - } - - /** - * Determines if you are on target. - * Only works if: you have called setErrorThreshold() and/or - * setDerivativeThreshold(), as well as - * setEnableErrorThreshold() and/or setDerivativeErrorThreshold(), or if you - * have set - * these values in the SmartDashboard at runtime. - */ - public boolean isOnTarget() { - return pid.isOnTarget(); - } - - public OffTargetReason getOffTargetReason() { - return pid.getOffTargetReason(); - } - - public void setIMask(boolean isMasked) { - isIMasked = isMasked; - } - - public boolean getIMask() { - return isIMasked; - } - - public void setMinOutput(double value) { - minOutput.set(value); - } - - public double getMinOutput() { - return minOutput.get(); - } - - public void setMaxOutput(double value) { - maxOutput.set(value); - } - - public double getMaxOutput() { - return maxOutput.get(); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/math/PIDPropertyManager.java b/src/main/java/xbot/common/math/PIDPropertyManager.java deleted file mode 100644 index 90565211..00000000 --- a/src/main/java/xbot/common/math/PIDPropertyManager.java +++ /dev/null @@ -1,199 +0,0 @@ -package xbot.common.math; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.logging.RobotAssertionManager; -import xbot.common.properties.BooleanProperty; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.Property; -import xbot.common.properties.PropertyFactory; - -public class PIDPropertyManager { - - private final DoubleProperty propP; - private final DoubleProperty propI; - private final DoubleProperty propD; - private final DoubleProperty propF; - private final DoubleProperty propIZone; - - private final DoubleProperty propErrorThreshold; - private final DoubleProperty propDerivativeThreshold; - private final DoubleProperty propTimeThreshold; - - private final BooleanProperty propEnableErrorThreshold; - private final BooleanProperty propEnableDerivativeThreshold; - private final BooleanProperty propEnableTimeThreshold; - - private final RobotAssertionManager assertionManager; - - @AssistedFactory - public abstract static class PIDPropertyManagerFactory { - - public abstract PIDPropertyManager create( - String functionName, - @Assisted("defaultP") double defaultP, - @Assisted("defaultI") double defaultI, - @Assisted("defaultD") double defaultD, - @Assisted("defaultF") double defaultF, - @Assisted("errorThreshold") double errorThreshold, - @Assisted("derivativeThreshold") double derivativeThreshold, - @Assisted("timeThreshold") double timeThreshold, - @Assisted("iZone") double defaultIZone); - - public PIDPropertyManager create( - String functionName, - double defaultP, - double defaultI, - double defaultD, - double defaultF, - double errorThreshold, - double derivativeThreshold, - double timeThreshold) { - return create(functionName, defaultP, defaultI, defaultD, defaultF, errorThreshold, derivativeThreshold, - timeThreshold, -1); - } - - public PIDPropertyManager create( - String functionName, - double defaultP, - double defaultI, - double defaultD, - double defaultF) { - return create(functionName, defaultP, defaultI, defaultD, defaultF, -1, -1, -1); - } - } - - @AssistedInject - public PIDPropertyManager( - @Assisted String functionName, - PropertyFactory propMan, - RobotAssertionManager assertionManager, - @Assisted("defaultP") double defaultP, - @Assisted("defaultI") double defaultI, - @Assisted("defaultD") double defaultD, - @Assisted("defaultF") double defaultF, - @Assisted("errorThreshold") double errorThreshold, - @Assisted("derivativeThreshold") double derivativeThreshold, - @Assisted("timeThreshold") double timeThreshold, - @Assisted("iZone") double defaultIZone) { - propMan.setPrefix(functionName); - - propP = propMan.createPersistentProperty("P", defaultP); - propI = propMan.createPersistentProperty("I", defaultI); - propD = propMan.createPersistentProperty("D", defaultD); - - propMan.setDefaultLevel(Property.PropertyLevel.Debug); - propF = propMan.createPersistentProperty("F", defaultF); - propIZone = propMan.createPersistentProperty("IZone", defaultIZone); - - propErrorThreshold = - propMan.createPersistentProperty("Error threshold", errorThreshold); - propDerivativeThreshold = - propMan.createPersistentProperty("Derivative threshold", derivativeThreshold); - propTimeThreshold = - propMan.createPersistentProperty("Time threshold", timeThreshold); - - - propEnableErrorThreshold = - propMan.createPersistentProperty("Enable error threshold", errorThreshold > 0); - propEnableDerivativeThreshold = - propMan.createPersistentProperty("Enable derivative threshold", derivativeThreshold > 0); - propEnableTimeThreshold = - propMan.createPersistentProperty("Enable time threshold", timeThreshold > 0); - - this.assertionManager = assertionManager; - } - - public double getP() { - return propP.get(); - } - - public void setP(double p) { - propP.set(p); - } - - public double getI() { - return propI.get(); - } - - public void setI(double i) { - propI.set(i); - } - - public double getD() { - return propD.get(); - } - - public void setD(double d) { - propD.set(d); - } - - public double getF() { - return propF.get(); - } - - public void setF(double f) { - propF.set(f); - } - - public double getIZone() { - return propIZone.get(); - } - - public void setIZone(double iZone) { - propIZone.set(iZone); - } - - public double getErrorThreshold() { - return propErrorThreshold.get(); - } - - public void setErrorThreshold(double errorThreshold) { - assertionManager.assertTrue(errorThreshold >= 0, "Thresholds won't work if they are negative!"); - propErrorThreshold.set(Math.abs(errorThreshold)); - } - - public double getDerivativeThreshold() { - return propDerivativeThreshold.get(); - } - - public void setDerivativeThreshold(double derivativeThreshold) { - assertionManager.assertTrue(derivativeThreshold >= 0, "Thresholds won't work if they are negative!"); - propDerivativeThreshold.set(Math.abs(derivativeThreshold)); - } - - public double getTimeThreshold() { - return propTimeThreshold.get(); - } - - public void setTimeThreshold(double timeThreshold) { - assertionManager.assertTrue(timeThreshold >= 0, "Thresholds won't work if they are negative!"); - propDerivativeThreshold.set(Math.abs(timeThreshold)); - } - - public boolean getEnableErrorThreshold() { - return propEnableErrorThreshold.get(); - } - - public void setEnableErrorThreshold(boolean isEnabled) { - propEnableErrorThreshold.set(isEnabled); - } - - public boolean getEnableDerivativeThreshold() { - return propEnableDerivativeThreshold.get(); - } - - public void setEnableDerivativeThreshold(boolean isEnabled) { - propEnableDerivativeThreshold.set(isEnabled); - } - - public boolean getEnableTimeThreshold() { - return propEnableTimeThreshold.get(); - } - - public void setEnableTimeThreshold(boolean isEnabled) { - propEnableTimeThreshold.set(isEnabled); - } -} diff --git a/src/main/java/xbot/common/math/PlanarEngine.java b/src/main/java/xbot/common/math/PlanarEngine.java deleted file mode 100644 index 624c3cbd..00000000 --- a/src/main/java/xbot/common/math/PlanarEngine.java +++ /dev/null @@ -1,60 +0,0 @@ -package xbot.common.math; - -import edu.wpi.first.math.geometry.Rotation2d; - -public class PlanarEngine { - - double friction = 0.005; - double power_factor = 0.1; - double heading_factor = 0.1; - double rotate_factor = 3; - int loops; - - XYPair robotPosition; - double velocity; - Rotation2d heading; - XYPair goalPoint; - XYPair goalVector; - - public PlanarEngine() { - robotPosition = new XYPair(); - heading = Rotation2d.fromDegrees(90); - - goalPoint = new XYPair(10, 0); - goalVector = new XYPair(1, 0); - } - - public XYPair getGoalPoint() { - return goalPoint; - } - - public XYPair step(double forwardPower, double rotatePower) { - double left = MathUtils.constrainDoubleToRobotScale(forwardPower-rotatePower); - double right = MathUtils.constrainDoubleToRobotScale(forwardPower+rotatePower); - velocity += ((left+right)/2*power_factor); - heading = heading.plus(Rotation2d.fromDegrees(rotatePower*rotate_factor)); - - // apply friction model to velocity - velocity *= 0.9; - - // sharp turns also murder velocity - velocity -= (Math.abs(rotatePower))*velocity*.05; - - robotPosition.x += heading.getCos()*velocity; - robotPosition.y += heading.getSin()*velocity; - loops++; - return robotPosition; - } - - public double getVelocity() { - return velocity; - } - - public FieldPose getRobotPose() { - return new FieldPose(robotPosition, heading); - } - - public int getLoops() { - return loops; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/math/PlanarTestVisualizer.java b/src/main/java/xbot/common/math/PlanarTestVisualizer.java deleted file mode 100644 index 6445896b..00000000 --- a/src/main/java/xbot/common/math/PlanarTestVisualizer.java +++ /dev/null @@ -1,80 +0,0 @@ -package xbot.common.math; - -import java.awt.EventQueue; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.swing.BoxLayout; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JSlider; -import javax.swing.JSplitPane; - -import edu.wpi.first.math.geometry.Rotation2d; -import xbot.common.subsystems.drive.RabbitPoint; - - -public class PlanarTestVisualizer { - - public JFrame frmLinearTestVisualizer; - public PlanarVisualizationPanel vizPanel; - public JPanel controlPanel; - public JSlider speedSlider; - - public static void main(String[] args) { - EventQueue.invokeLater(new Runnable() { - public void run() { - try { - RabbitPoint p = new RabbitPoint(new FieldPose(new XYPair(100, 100), Rotation2d.fromDegrees(135))); - PlanarTestVisualizer window = new PlanarTestVisualizer(new ArrayList(Arrays.asList(p))); - window.frmLinearTestVisualizer.setVisible(true); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - } - - public PlanarTestVisualizer(List points) { - initialize(points); - } - - private void initialize(List points) { - frmLinearTestVisualizer = new JFrame(); - - frmLinearTestVisualizer.setTitle("Linear test visualizer"); - frmLinearTestVisualizer.setBounds(100, 100, 1600, 1000); - frmLinearTestVisualizer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frmLinearTestVisualizer.getContentPane().setLayout(new BoxLayout(frmLinearTestVisualizer.getContentPane(), BoxLayout.Y_AXIS)); - - JSplitPane splitPane = new JSplitPane(); - frmLinearTestVisualizer.getContentPane().add(splitPane); - - vizPanel = new PlanarVisualizationPanel(1200, 1200); - splitPane.setLeftComponent(vizPanel); - - controlPanel = new JPanel(); - splitPane.setRightComponent(controlPanel); - - speedSlider = new JSlider(); - speedSlider.setMinimum(1); - speedSlider.setValue(10); - controlPanel.add(speedSlider); - - startTest(points); - } - - private void startTest(List points) { - PurePursuitTest test = new PurePursuitTest(points); - test.setAsAsync((envState) -> { - vizPanel.updateViz(envState); - vizPanel.repaint(); - - - test.setAsyncPeriodMultiplier(10d / speedSlider.getValue()); - }); - - test.vizRun(); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/math/PlanarVisualizationPanel.java b/src/main/java/xbot/common/math/PlanarVisualizationPanel.java deleted file mode 100644 index d20ae045..00000000 --- a/src/main/java/xbot/common/math/PlanarVisualizationPanel.java +++ /dev/null @@ -1,119 +0,0 @@ -package xbot.common.math; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; - -import javax.swing.JPanel; - -import edu.wpi.first.math.geometry.Rotation2d; - -//@SuppressWarnings("serial") -public class PlanarVisualizationPanel extends JPanel { - private int centerX; - private int centerY; - - private String loops = "0"; - private String robotStats = "0, 0"; - private FieldPose robotCurrentPosition = new FieldPose(new XYPair(0,0), new Rotation2d()); - private XYPair goalPosition = new XYPair(0,0); - private FieldPose rabbitPosition = new FieldPose(new XYPair(0,0), new Rotation2d()); - private String rabbitStats = "..."; - - private int preferredWidth = 300; - private int minimumWidth = 300; - - public PlanarVisualizationPanel() { - - } - - public PlanarVisualizationPanel(int preferredWidth, int minimumWidth) { - this.preferredWidth = preferredWidth; - this.minimumWidth = minimumWidth; - } - /* - public void setRobotDistance(XYPair position) { - robotCurrentPosition = position; - }*/ - - public void updateViz(PurePursuitTest.PursuitEnvironmentState state) { - robotCurrentPosition = state.robot; - loops = Integer.toString(state.loops); - goalPosition = state.goal.getPoint(); - rabbitPosition = state.rabbit; - - robotStats = String.format("%.2f, %.2f, Angle: %.2f", - robotCurrentPosition.getPoint().x, - robotCurrentPosition.getPoint().y, - robotCurrentPosition.getHeading().getDegrees()); - rabbitStats = String.format("Angle to Rabbit: %.2f, TurnPower: %.2f, Translate: %.2f", - state.rabbitAngle, state.turnPower, state.translatePower); - } - - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - Graphics2D graphics = (Graphics2D) g; - - centerX = this.getWidth() / 4; - centerY = this.getHeight() / 2; - - int linearFactor = 1; - - // draw start - graphics.setColor(Color.GREEN); - graphics.setStroke(new BasicStroke(5)); - graphics.drawOval(centerX, centerY, 5, 5); - - // draw finish - graphics.setColor(Color.RED); - graphics.setStroke(new BasicStroke(5)); - graphics.drawOval( - (int)(centerX+goalPosition.x*linearFactor), - (int)(centerY-goalPosition.y*linearFactor), - 5, 5); - - // draw rabbit - graphics.setColor(Color.GREEN); - graphics.setStroke(new BasicStroke(5)); - graphics.drawOval( - (int)(centerX+rabbitPosition.getPoint().x*linearFactor), - (int)(centerY-rabbitPosition.getPoint().y*linearFactor), - 5, 5); - - // draw robot - graphics.setColor(Color.BLUE); - graphics.setStroke(new BasicStroke(5)); - graphics.drawOval( - (int)(centerX+robotCurrentPosition.getPoint().x * linearFactor), - (int)(centerY-robotCurrentPosition.getPoint().y * linearFactor), - 5, 5); - - graphics.setColor(Color.BLACK); - graphics.setStroke(new BasicStroke(5)); - graphics.drawString(robotStats, centerX, centerY+150); - - graphics.setColor(Color.BLACK); - graphics.setStroke(new BasicStroke(5)); - graphics.drawString(rabbitStats, centerX, centerY+100); - - //draw loops - graphics.setColor(Color.BLACK); - graphics.setStroke(new BasicStroke(5)); - graphics.drawString(loops, centerX, centerY+50); - - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(preferredWidth, 0); - } - - @Override - public Dimension getMinimumSize() { - return new Dimension(minimumWidth, 0); - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/math/PurePursuitTest.java b/src/main/java/xbot/common/math/PurePursuitTest.java deleted file mode 100644 index adfa5bbd..00000000 --- a/src/main/java/xbot/common/math/PurePursuitTest.java +++ /dev/null @@ -1,136 +0,0 @@ -package xbot.common.math; - -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; - -import xbot.common.injection.BaseWPITest; -import xbot.common.injection.components.BaseComponent; -import xbot.common.injection.components.DaggerPurePursuitTestComponent; -import xbot.common.injection.components.PurePursuitTestComponent; -import xbot.common.math.PIDManager.PIDManagerFactory; -import xbot.common.subsystems.drive.ConfigurablePurePursuitCommand; -import xbot.common.subsystems.drive.MockDriveSubsystem; -import xbot.common.subsystems.drive.PurePursuitCommand.RabbitChaseInfo; -import xbot.common.subsystems.drive.RabbitPoint; -import xbot.common.subsystems.pose.MockBasePoseSubsystem; - -public class PurePursuitTest extends BaseWPITest { - - double target_distance = 5; - protected Timer asyncTimer; - protected AsyncLinearIntervalJob asyncJob; - protected double periodMultiplier = 1; - PlanarEngine engine; - FieldPose goalOne; - FieldPose goalTwo; - boolean pastOne; - List points; - - public PurePursuitTest(List points) - { - this.points = points; - } - - @Override - protected BaseComponent createDaggerComponent() { - return DaggerPurePursuitTestComponent.create(); - } - - protected PurePursuitTestComponent getInjectorComponent() { - return (PurePursuitTestComponent)super.getInjectorComponent(); - } - - public static class PursuitEnvironmentState { - public FieldPose robot; - public FieldPose goal; - public FieldPose rabbit; - public int loops; - public double rabbitAngle; - public double turnPower; - public double translatePower; - - public PursuitEnvironmentState(FieldPose robot, FieldPose goal, FieldPose rabbit, - int loops, double rabbitAngle, double turnPower, double translatePower) { - this.robot = robot; - this.goal = goal; - this.loops = loops; - this.rabbit = rabbit; - this.rabbitAngle = rabbitAngle; - this.turnPower = turnPower; - this.translatePower = translatePower; - } - } - - public static interface AsyncLinearIntervalJob { - void onNewStep(PursuitEnvironmentState envState); - } - - public void setAsAsync(AsyncLinearIntervalJob asyncIntervalJob) { - this.asyncJob = asyncIntervalJob; - } - - public void setAsyncPeriodMultiplier(double newMultiplier) { - if(Math.abs(this.periodMultiplier - newMultiplier) > 0.01) { - this.periodMultiplier = newMultiplier; - - asyncTimer.cancel(); - startAsyncTimer(); - } - } - - protected ConfigurablePurePursuitCommand command; - MockBasePoseSubsystem poseSystem; - - public void vizRun() { - super.setUp(); - engine = new PlanarEngine(); - PIDManagerFactory pf = getInjectorComponent().pidFactory(); - MockDriveSubsystem b = (MockDriveSubsystem)getInjectorComponent().driveSubsystem(); - this.poseSystem = (MockBasePoseSubsystem)getInjectorComponent().poseSubsystem(); - b.changeRotationalPid(pf.create("testRot", 0.05, 0, 0)); - b.changePositionalPid(pf.create("testPos", 0.1, 0, 0.1)); - command = getInjectorComponent().configurablePurePursuitCommand(); - command.setDotProductDrivingEnabled(true); - setPoints(); - command.initialize(); - startAsyncTimer(); - } - - public void setPoints() { - command.setPoints(points); - } - - public void startAsyncTimer() { - asyncTimer = new Timer(); - asyncTimer.schedule( - new TimerTask() { - @Override - public void run() { - FieldPose robot = engine.getRobotPose(); - poseSystem.setCurrentHeading(robot.getHeading().getDegrees()); - poseSystem.setCurrentPosition(robot.getPoint().x, robot.getPoint().y); - RabbitChaseInfo info = command.evaluateCurrentPoint(robot); - FieldPose target = info.target; - double angleToRabbit = target.getDeltaAngleToRabbit(robot, 5); - - engine.step(info.translation, info.rotation); - - PursuitEnvironmentState state = new PursuitEnvironmentState( - engine.getRobotPose(), - target, - info.rabbit, - engine.loops, - angleToRabbit, - info.rotation, - info.translation); - - asyncJob.onNewStep(state); - } - }, 0, (int)(100*this.periodMultiplier)); - } - - public void stopTestEnv() { - asyncTimer.cancel(); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/math/WrappedRotation2d.java b/src/main/java/xbot/common/math/WrappedRotation2d.java deleted file mode 100644 index eab84940..00000000 --- a/src/main/java/xbot/common/math/WrappedRotation2d.java +++ /dev/null @@ -1,52 +0,0 @@ -package xbot.common.math; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import edu.wpi.first.math.MathUtil; -import edu.wpi.first.math.geometry.Rotation2d; - -/** - * A rotation in a 2d coordinate frame, with its rotation wrapped from -pi to pi radians (-180 to 180 degrees). - * Prefer this class over Rotation2d when representing robot pose. - */ -public class WrappedRotation2d extends Rotation2d { - /** - * Constructs a WrappedRotation2d with the given radian value. - * - * @param value The value of the angle in radians. - */ - @JsonCreator - public WrappedRotation2d(@JsonProperty(required = true, value = "radians") double value) { - super(MathUtil.angleModulus(value)); - } - - /** - * Constructs a WrappedRotation2d with the given x and y (cosine and sine) components. The x and y don't have to be normalized. - * - * @param x The x component or cosine of the rotation. - * @param y The y component or sine of the rotation. - */ - public WrappedRotation2d(double x, double y) { - super(x, y); - } - - /** - * Converts a Rotation2d to the wrapped equivalent. - * @param rotation The rotation. - * @return The rotation with its angle wrapped from -pi to pi radians. - */ - public static WrappedRotation2d fromRotation2d(Rotation2d rotation) { - return new WrappedRotation2d(rotation.getCos(), rotation.getSin()); - } - - /** - * Constructs and returns a Rotation2d with the given degree value. - * - * @param degrees The value of the angle in degrees. - * @return The rotation object with the desired angle value. - */ - public static WrappedRotation2d fromDegrees(double degrees) { - return new WrappedRotation2d(Math.toRadians(degrees)); - } -} diff --git a/src/main/java/xbot/common/math/XYPair.java b/src/main/java/xbot/common/math/XYPair.java deleted file mode 100644 index 05e0727f..00000000 --- a/src/main/java/xbot/common/math/XYPair.java +++ /dev/null @@ -1,184 +0,0 @@ -package xbot.common.math; - -import edu.wpi.first.math.geometry.Rotation2d; -import edu.wpi.first.math.geometry.Translation2d; - -/** - * Pair of X and Y coordinates. Can be used for points, vectors, or anything - * else that requires a coordinate pair. - */ -public class XYPair { - public static final XYPair ZERO = new XYPair(0, 0); - - public double x; - public double y; - - /** - * Create a coordinate with the specified x and y value. - * @param x the x value to use - * @param y the y value to use - */ - public XYPair(double x, double y) { - this.x = x; - this.y = y; - } - - /** - * Creates a coordinate representing the unit vector for a rotation. - * @param rotation The rotation value. - */ - public XYPair(Rotation2d rotation) { - this.x = rotation.getCos(); - this.y = rotation.getSin(); - } - - /** - * Create a coordinate at the origin. - */ - public XYPair() { - this.x = 0; - this.y = 0; - } - - /** - * Clone the object - */ - public XYPair clone() { - return new XYPair(x, y); - } - - /** - * Create a coordinate from an angle and magnitude - * @param angle angle in degrees - * @param magnitude magnitude - * @return coordinate - */ - public static XYPair fromPolar(double angle, double magnitude) { - XYPair newValue = new XYPair(magnitude, 0); - return newValue.rotate(angle); - } - - /** - * Create a coordinate of magnitude 1 with an angle - * @param angle angle in degrees - * @return coordinate - */ - public static XYPair fromUnitPolar(double angle) { - XYPair newValue = new XYPair(1, 0); - return newValue.rotate(angle); - } - - /** - * Scales the current coordinate by a magnitude equally in both dimensions. - * @param scalarMagnitude the magnitude to scale the coordinate by - * @return the scaled object - */ - public XYPair scale(double scalarMagnitude) { - this.x *= scalarMagnitude; - this.y *= scalarMagnitude; - return this; - } - - /** - * Scales the coordinate by an x- and y- magnitude. - * @param xMagnitude the magnitude to scale the x-coordinate by - * @param yMagnitude the magnitude to scale the y-coordinate by - * @return the scaled object - */ - public XYPair scale(double xMagnitude, double yMagnitude) { - this.x *= xMagnitude; - this.y *= yMagnitude; - return this; - } - - /** - * Add the magnitude to the vector represented by the coordinate. - * @param magnitudeToAdd magnitude to add - * @return the modified coordinate - */ - public XYPair addMagnitude(double magnitudeToAdd) { - double currentMagnitude = this.getMagnitude(); - - if (currentMagnitude == 0) { - this.y = magnitudeToAdd; - return this; - } - - double totalMagnitude = currentMagnitude + magnitudeToAdd; - return this.scale(totalMagnitude / currentMagnitude); - } - - /** - * Rotates the vector by a given angle. - * @param angle the angle in degrees to rotate the pair by - * @return the rotated object - */ - public XYPair rotate(double angle) { - double cosA = Math.cos(Math.toRadians(angle)); - double sinA = Math.sin(Math.toRadians(angle)); - double tempX = x * cosA - y * sinA; - double tempY = x * sinA + y * cosA; - - this.x = tempX; - this.y = tempY; - - return this; - } - - /** - * Get the angle of the vector in degrees - * @return angle in degrees - */ - public double getAngle() { - return Math.toDegrees(Math.atan2(y, x)); - } - - /** - * Get the magnitude of the vector (i.e. distance from origin to the coordinate). - * @return magnitude - */ - public double getMagnitude() { - return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); - } - - /** - * Adds the value of a second coordinate to the current coordinate. - * @param pair coordinate to add - * @return the combined object - */ - public XYPair add(XYPair pair) { - this.x += pair.x; - this.y += pair.y; - return this; - } - - /** - * Get the distance between the current point and a second point. - * @param otherPoint the point to calculate the distance from - * @return the distance - */ - public double getDistanceToPoint(XYPair otherPoint) { - // Subtract the points from each other - XYPair normalizedPoint = this.clone().add(otherPoint.clone().scale(-1)); - // Get the magnitude of the resultant vector - return normalizedPoint.getMagnitude(); - } - - /** - * Calculate the dot-product between this and another point. - * @param otherPoint the second point to use for calculating dot product - * @return the dot product value - */ - public double dotProduct(XYPair otherPoint) { - return (this.x * otherPoint.x) + (this.y * otherPoint.y); - } - - @Override - public String toString() { - return "(X:" + x + ", Y:" + y + ")"; - } - - public Translation2d toTranslation2d() { - return new Translation2d(x, y); - } -} diff --git a/src/main/java/xbot/common/networking/MockZeromqListener.java b/src/main/java/xbot/common/networking/MockZeromqListener.java deleted file mode 100644 index cbd80af6..00000000 --- a/src/main/java/xbot/common/networking/MockZeromqListener.java +++ /dev/null @@ -1,38 +0,0 @@ -package xbot.common.networking; - -import java.util.function.Consumer; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -public class MockZeromqListener implements XZeromqListener { - - @AssistedFactory - public abstract static class MockZeromqListenerFactory implements XZeromqListenerFactory { - public abstract MockZeromqListener create( - @Assisted("connectionString") String connectionString, - @Assisted("topic") String topic); - } - - @AssistedInject - public MockZeromqListener(@Assisted("connectionString") String connectionString, @Assisted("topic") String topic) { - } - - Consumer handler; - - @Override - public void start() { - - } - - @Override - public void setNewPacketHandler(Consumer handler) { - this.handler = handler; - } - - public void sendPacket(String packet) { - handler.accept(packet); - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/networking/XZeromqListener.java b/src/main/java/xbot/common/networking/XZeromqListener.java deleted file mode 100644 index 49ba33fc..00000000 --- a/src/main/java/xbot/common/networking/XZeromqListener.java +++ /dev/null @@ -1,13 +0,0 @@ -package xbot.common.networking; - -import java.util.function.Consumer; - -public interface XZeromqListener { - - public interface XZeromqListenerFactory { - XZeromqListener create(String connectionString, String topic); - } - - public void start(); - public void setNewPacketHandler(Consumer handler); -} \ No newline at end of file diff --git a/src/main/java/xbot/common/networking/ZeromqListener.java b/src/main/java/xbot/common/networking/ZeromqListener.java deleted file mode 100644 index cf8e7a04..00000000 --- a/src/main/java/xbot/common/networking/ZeromqListener.java +++ /dev/null @@ -1,138 +0,0 @@ -package xbot.common.networking; - -import java.util.function.Consumer; - -import org.apache.log4j.Logger; -import org.zeromq.SocketType; -import org.zeromq.ZMQ; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -public class ZeromqListener implements XZeromqListener { - - private static Logger log = Logger.getLogger(ZeromqListener.class); - private Consumer packetHandler; - private ZeromqClient client; - private final String connectionString; - private final String topic; - - @AssistedFactory - public abstract static class ZeromqListenerFactory implements XZeromqListenerFactory { - public abstract ZeromqListener create( - @Assisted("connectionString") String connectionString, - @Assisted("topic") String topic); - } - - /** - * This is the wrapper class for the actual ZeroMQ subscriber, based on - * http://zguide.zeromq.org/java:wuclient and our 2017 ethernet implementation. - * It represents the Subscriber half of the Publisher/Subscriber 0MQ model, - * reading packets as strings. - * - * @param connectionString Typically something like "tcp://localhost:5556"; read - * the ZeroMQ documentation. - * @param topic Will filter to messages beginning with this topic. - * Empty string will read all messages posted ot the - * given connectionString. - */ - @AssistedInject - public ZeromqListener(@Assisted("connectionString") String connectionString, @Assisted("topic") String topic) { - this.connectionString = connectionString; - this.topic = topic; - } - - @Override - public void start() { - if (client != null) { - log.warn("Server already running; cannot start again."); - return; - } - - client = new ZeromqClient(connectionString, topic); - client.setNewPacketHandler(this.packetHandler); - client.startClient(); - } - - public void stop() { - if (client != null) { - client.stopClient(); - } else { - log.warn("Tried to stop the client before starting it!"); - } - } - - @Override - public void setNewPacketHandler(Consumer handler) { - this.packetHandler = handler; - } - - private static class ZeromqClient extends Thread { - private static Logger log = Logger.getLogger(ZeromqClient.class); - private volatile boolean isRunning = false; - private volatile Consumer packetHandler; - private String connectionString; - private String topic; - private ZMQ.Context context; - private ZMQ.Socket socket; - - public ZeromqClient(String connectionString, String topic) { - this.connectionString = connectionString; - this.topic = topic; - } - - public void setNewPacketHandler(Consumer packetHandler) { - this.packetHandler = packetHandler; - } - - public void startClient() { - if (this.isRunning) { - log.warn("Client already started, will not start it again."); - return; - } - - if (packetHandler == null) { - log.warn("No packet handler registered - you will not get any network messages!"); - } - - log.info("Creating ZMQ Context"); - context = ZMQ.context(1); - log.info("Creating ZMQ Subscriber Socket"); - socket = context.socket(SocketType.SUB); - // SetConflate to True means we only get the most recent value. It will also be - // need to set server-side, I think. - socket.setConflate(true); - log.info("Connecting Socket with connection string: " + connectionString); - boolean result = socket.connect(connectionString); - if (result) { - log.info("Connection succeeded."); - } else { - log.warn("Connection failed!"); - } - log.info("Setting subscription filter to: " + topic); - socket.subscribe(topic.getBytes()); - isRunning = true; - this.start(); - } - - public void stopClient() { - log.info("client stopping"); - isRunning = false; - - socket.close(); - context.term(); - } - - @Override - public void run() { - while (isRunning) { - String packet = socket.recvStr(0).trim(); - if (packetHandler != null) { - packetHandler.accept(packet); - } - } - } - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/properties/BooleanProperty.java b/src/main/java/xbot/common/properties/BooleanProperty.java deleted file mode 100644 index c8f153f8..00000000 --- a/src/main/java/xbot/common/properties/BooleanProperty.java +++ /dev/null @@ -1,92 +0,0 @@ -package xbot.common.properties; - -/** - * A property holding a boolean value. - * - * @author Sterling - */ -public class BooleanProperty extends Property { - private boolean defaultValue; - - /** - * - * @param name key of the property - * @param defaultValue initial value if none there from the permanent store - */ - public BooleanProperty(String name, boolean defaultValue, - XPropertyManager manager) { - super(name, manager); - this.defaultValue = defaultValue; - load(); - } - - public BooleanProperty(String name, boolean defaultValue, PropertyPersistenceType persistenceType, - XPropertyManager manager) { - super(name, manager, persistenceType); - this.defaultValue = defaultValue; - load(); - } - - public BooleanProperty(String name, boolean defaultValue, PropertyPersistenceType persistenceType, - XPropertyManager manager, PropertyLevel level) { - super(name, manager, persistenceType, level); - this.defaultValue = defaultValue; - load(); - } - - /** - * - * @return the current boolean value - */ - public boolean get() { - Boolean nullableTableValue = randomAccessStore.getBoolean(key); - - if(nullableTableValue == null) { - log.error("Property key \"" + key + "\" not present in the underlying store!" - + " IF THIS IS AN IMPORTANT ROBOT PROPERTY, MAKE SURE IT HAS A SANE VALUE BEFORE ENABLING THE ROBOT!"); - return defaultValue; - } - - return nullableTableValue.booleanValue(); - } - - /** - * - * @param value - * the value to set - */ - public void set(boolean value) { - randomAccessStore.setBoolean(key, value); - } - - /** - * Saves the value permanently (presumably to the Robot). - */ - public void save() { - if(persistenceType == PropertyPersistenceType.Persistent) { - if (!isSetToDefault()) { - permanentStore.setBoolean(key, get()); - } else { - permanentStore.remove(key); - } - } - } - - /** - * Load the boolean value from the permanent store. - */ - public void load() { - Boolean value = permanentStore.getBoolean(key); - if (value != null) { - set(value.booleanValue()); - log.info("Property " + key + " has the non-default value " + value.booleanValue()); - } else { - set(defaultValue); - } - } - - @Override - public boolean isSetToDefault() { - return get() == defaultValue; - } -} diff --git a/src/main/java/xbot/common/properties/ConfigurePropertiesCommand.java b/src/main/java/xbot/common/properties/ConfigurePropertiesCommand.java deleted file mode 100644 index df4f057d..00000000 --- a/src/main/java/xbot/common/properties/ConfigurePropertiesCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -package xbot.common.properties; - -import javax.inject.Inject; - -import xbot.common.command.BaseCommand; - -public class ConfigurePropertiesCommand extends BaseCommand { - - ITableProxy table; - boolean fastMode; - - @Inject - public ConfigurePropertiesCommand(ITableProxy table) { - this.table = table; - } - - @Override - public boolean runsWhenDisabled() { - return true; - } - - public void setFastMode(boolean on) { - fastMode = on; - } - - @Override - public void initialize() { - log.info("Initializing with fastMode: " + fastMode); - table.setFastMode(fastMode); - } - - @Override - public void execute() { - } - - @Override - public boolean isFinished() { - return true; - } -} diff --git a/src/main/java/xbot/common/properties/DatabaseStorageBase.java b/src/main/java/xbot/common/properties/DatabaseStorageBase.java deleted file mode 100644 index a3ea1d45..00000000 --- a/src/main/java/xbot/common/properties/DatabaseStorageBase.java +++ /dev/null @@ -1,225 +0,0 @@ -package xbot.common.properties; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -import org.apache.log4j.Logger; - -/** - * - * @author John - */ -public abstract class DatabaseStorageBase implements PermanentStorage { - - private static Logger log = Logger.getLogger(DatabaseStorageBase.class); - - private String dbUrlPreFormat = "jdbc:derby:%1s;create=true"; - private final String dbUrl; - private Connection conn; - - public DatabaseStorageBase(String databaseDirectory) { - - dbUrl = String.format(dbUrlPreFormat, databaseDirectory); - - try { - conn = DriverManager.getConnection(dbUrl); - } catch (SQLException e) { - log.error("Ran into a SQL problem - could not open a connection to the database! No properties will be loaded or persisted!!"); - log.error(e.toString()); - e.printStackTrace(); - } catch (Exception e) { - log.error("Ran into a general exception, so could not open a connection to the database! No properties will be loaded or persisted!!"); - log.error(e.toString()); - e.printStackTrace(); - } - - // create properties if not exists - if (propertiesTableExists() == false) - { - createPropertiesTable(); - } - } - - public void setDouble(String key, double value){ - saveProperty("double", key, Double.toString(value)); - } - - public void setBoolean(String key, boolean value){ - saveProperty("boolean", key, Boolean.toString(value)); - } - - public void setString(String key, String value){ - saveProperty("string", key, value); - } - - public Double getDouble(String key){ - String value = loadProperty(key); - try { - return Double.parseDouble(value); - } - catch (NumberFormatException e) - { - return null; - } - } - - public Boolean getBoolean (String key){ - String value = loadProperty(key); - // See the comments on parseBoolean() as to why we have to do this. - return parseBoolean(value); - } - - // The default Java boolean parser is good, but makes too many assumptions. Any variation of "true" - // comes back as true, and LITERALLY ANYTHING ELSE (including null) is considered false. Since we want - // to keep null as "I didn't find this property", we need to more explicitly parse true and false. - private Boolean parseBoolean(String value) - { - if (value.toLowerCase().equals("true")) - { - return true; - } - - if (value.toLowerCase().equals("false")) - { - return false; - } - - return null; - } - - public String getString (String key){ - String value = loadProperty(key); - if (value.length() == 0) - { - return null; - } - return value; - } - - public void clear(){ - obliterateStorage(); - } - - private void saveProperty(String type, String name, String value) { - - try { - PreparedStatement sta = conn.prepareStatement("UPDATE PROPERTIES SET TYPE= ?, VALUE= ? WHERE NAME = ?"); - sta.setString(1, type); - sta.setString(2, value); - sta.setString(3, name); - - int count = sta.executeUpdate(); - - if (count == 0) { - // Looks like this isn't currently in the database. We need to add it instead. - PreparedStatement insert = conn.prepareStatement("INSERT INTO PROPERTIES VALUES (?, ?, ?)"); - insert.setString(1, name); - insert.setString(2, value); - insert.setString(3, value); - - count = insert.executeUpdate(); - } - } catch (SQLException e) { - log.warn("Unable to save property " + name + "!"); - log.warn(e.toString()); - e.printStackTrace(); - } - } - - private String loadProperty(String name) - { - try { - PreparedStatement sta = conn.prepareStatement("SELECT * FROM PROPERTIES WHERE NAME = ?"); - sta.setString(1, name); - ResultSet rs = sta.executeQuery(); - - if (rs.next()) - { - String value = rs.getString("Value"); - rs.close(); - return value; - } - rs.close(); - } catch (SQLException e) { - log.warn("Unable to load property " + name + "!"); - log.warn(e.toString()); - e.printStackTrace(); - } - return ""; - } - - /** - * @return True if the PROPERTIES table is present in the Database; False otherwise - */ - private boolean propertiesTableExists() { - try { - DatabaseMetaData md = conn.getMetaData(); - // The following method returns tables that match a given pattern. Since we don't care about - // Catalog, Schema, or Types (we only care about the TableNamePattern), we leave those - // fields null. - ResultSet tables = md.getTables(null, null, "PROPERTIES", null); - - if (tables.next()) { - tables.close(); - return true; - } - tables.close(); - return false; - - } catch (SQLException e) { - log.warn("Ran into problems when checking to see if the PROPERTIES table existed."); - log.warn(e.toString()); - e.printStackTrace(); - } - return false; - } - - private boolean createPropertiesTable() { - - Statement sta; - try { - sta = conn.createStatement(); - String payload = "CREATE TABLE PROPERTIES (Name VARCHAR(100), Type VARCHAR(100), Value VARCHAR(100), UNIQUE (Name))"; - sta.executeUpdate(payload); - return true; - } catch (SQLException e) { - log.warn("Could not create the properties table! Properties will not be saved!!"); - log.warn(e.toString()); - e.printStackTrace(); - } - - return false; - } - - public boolean obliterateStorage() { - try { - - if (propertiesTableExists()) { - Statement sta = conn.createStatement(); - String payload = "DROP TABLE PROPERTIES"; - - int response = sta.executeUpdate(payload); - - if (response == 0) { - return true; - } - // something went wrong - return false; - } else { - // table does not exist, nothing to obliterate - return true; - } - } catch (SQLException e) { - log.warn("Something went wrong when attempting to drop the PROPERTIES table!"); - log.warn(e.toString()); - e.printStackTrace(); - return false; - } - - } -} diff --git a/src/main/java/xbot/common/properties/DebugFlag.java b/src/main/java/xbot/common/properties/DebugFlag.java deleted file mode 100644 index bf0eec94..00000000 --- a/src/main/java/xbot/common/properties/DebugFlag.java +++ /dev/null @@ -1,16 +0,0 @@ -package xbot.common.properties; - -import javax.inject.Singleton; - -@Singleton -public class DebugFlag { - boolean isDebug = false; - - public void setDebug(boolean debug) { - isDebug = debug; - } - - public boolean isDebug() { - return isDebug; - } -} diff --git a/src/main/java/xbot/common/properties/DoubleProperty.java b/src/main/java/xbot/common/properties/DoubleProperty.java deleted file mode 100644 index 78920d1e..00000000 --- a/src/main/java/xbot/common/properties/DoubleProperty.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package xbot.common.properties; - -import java.util.function.Consumer; - -/** - * This manages a double in the property system. - * - * @author Alex - */ -public class DoubleProperty extends Property { - double defaultValue; - double lastValue; - - public DoubleProperty(String name, double defaultValue, XPropertyManager manager) { - super(name, manager); - this.defaultValue = defaultValue; - load(); - lastValue = get(); - } - - public DoubleProperty(String name, double defaultValue, PropertyPersistenceType persistenceType, XPropertyManager manager) { - super(name, manager, persistenceType); - this.defaultValue = defaultValue; - load(); - lastValue = get(); - } - - public DoubleProperty(String name, double defaultValue, PropertyPersistenceType persistenceType, XPropertyManager manager, PropertyLevel level) { - super(name, manager, persistenceType, level); - this.defaultValue = defaultValue; - load(); - lastValue = get(); - } - - - public double get() { - Double nullableTableValue = randomAccessStore.getDouble(key); - - if(nullableTableValue == null) { - log.error("Property key \"" + key + "\" not present in the underlying store!" - + " IF THIS IS AN IMPORTANT ROBOT PROPERTY, MAKE SURE IT HAS A SANE VALUE BEFORE ENABLING THE ROBOT!"); - return defaultValue; - } - - return nullableTableValue.doubleValue(); - } - - public void set(double value) { - randomAccessStore.setDouble(key, value); - } - - /** - * We only save the property if it's from a persistent type - */ - public void save() { - if(persistenceType == PropertyPersistenceType.Persistent) { - if (!isSetToDefault()) { - permanentStore.setDouble(key, get()); - } else { - permanentStore.remove(key); - } - } - } - - /** - * - */ - public void load() { - Double value = permanentStore.getDouble(key); - if(value != null) { - log.info("Property " + key + " has the non-default value " + value.doubleValue()); - randomAccessStore.setDouble(key, value.doubleValue()); - } else { - set(defaultValue); - } - } - - public void hasChangedSinceLastCheck(Consumer callback) { - double currentValue = get(); - // TODO: Check if we can just use direct equality here, since we are in fact comparing a value to itself. - if (Math.abs(currentValue - lastValue) > 0.00000000001) { - callback.accept(currentValue); - } - lastValue = currentValue; - } - - public boolean isSetToDefault() { - return get() == defaultValue; - } -} diff --git a/src/main/java/xbot/common/properties/IPropertySupport.java b/src/main/java/xbot/common/properties/IPropertySupport.java deleted file mode 100644 index cdabbcf7..00000000 --- a/src/main/java/xbot/common/properties/IPropertySupport.java +++ /dev/null @@ -1,5 +0,0 @@ -package xbot.common.properties; - -public interface IPropertySupport { - public String getPrefix(); -} \ No newline at end of file diff --git a/src/main/java/xbot/common/properties/ITableProxy.java b/src/main/java/xbot/common/properties/ITableProxy.java deleted file mode 100644 index cdf809d7..00000000 --- a/src/main/java/xbot/common/properties/ITableProxy.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package xbot.common.properties; - -/** - * This interface defines a simple table interface, where you can set and retrieve - * values. All methods are strongly typed (so we have SetDouble instead of Set(object)) - * @author Alex - */ -public interface ITableProxy { - - public void setDouble(String key, double value); - - public void setBoolean(String key, boolean value); - - public void setString(String key, String value); - - public Double getDouble(String key); - - public Boolean getBoolean (String key); - - public String getString (String key); - - public void clear(); - - public void setFastMode(boolean on); - - public void remove(String key); -} \ No newline at end of file diff --git a/src/main/java/xbot/common/properties/MockPermamentStorage.java b/src/main/java/xbot/common/properties/MockPermamentStorage.java deleted file mode 100644 index ce4bfd2a..00000000 --- a/src/main/java/xbot/common/properties/MockPermamentStorage.java +++ /dev/null @@ -1,12 +0,0 @@ -package xbot.common.properties; - -import javax.inject.Inject; -import javax.inject.Singleton; - -@Singleton -public class MockPermamentStorage extends TableProxy implements PermanentStorage { - - @Inject - public MockPermamentStorage() {} - -} diff --git a/src/main/java/xbot/common/properties/PermanentStorage.java b/src/main/java/xbot/common/properties/PermanentStorage.java deleted file mode 100644 index 0df9ffbf..00000000 --- a/src/main/java/xbot/common/properties/PermanentStorage.java +++ /dev/null @@ -1,5 +0,0 @@ -package xbot.common.properties; - -public interface PermanentStorage extends ITableProxy { - -} diff --git a/src/main/java/xbot/common/properties/PreferenceStorage.java b/src/main/java/xbot/common/properties/PreferenceStorage.java deleted file mode 100644 index 8cf91775..00000000 --- a/src/main/java/xbot/common/properties/PreferenceStorage.java +++ /dev/null @@ -1,87 +0,0 @@ -package xbot.common.properties; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.apache.log4j.Logger; - -import edu.wpi.first.wpilibj.Preferences; - -/** - * @author John - * - * This saves properties to the robot using WPI's built-in Preferences library: - * http://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/wpilibj/Preferences.html - * - * This stores them in a simple key-value pair on the robot, in a file called - * /home/lvuser/networktables.ini - * - */ -@Singleton -public class PreferenceStorage implements PermanentStorage { - - protected static Logger log = Logger.getLogger(PreferenceStorage.class); - boolean fastMode = false; - - @Inject - public PreferenceStorage() {} - - @Override - public void setDouble(String key, double value) { - Preferences.setDouble(key, value); - } - - @Override - public void setBoolean(String key, boolean value) { - Preferences.setBoolean(key, value); - } - - @Override - public void setString(String key, String value) { - Preferences.setString(key, value); - } - - @Override - public Double getDouble(String key) { - if (Preferences.containsKey(key)) - { - return Preferences.getDouble(key, 0); - } - return null; - } - - @Override - public Boolean getBoolean(String key) { - if (Preferences.containsKey(key)) - { - return Preferences.getBoolean(key, false); - } - return null; - } - - @Override - public String getString(String key) { - if (Preferences.containsKey(key)) - { - return Preferences.getString(key, null); - } - return null; - } - - @Override - public void clear() { - Preferences.getKeys().clear(); - } - - @Override - public void setFastMode(boolean on) { - } - - @Override - public void remove(String key) { - if (Preferences.containsKey(key)) - { - Preferences.remove(key); - } - } -} diff --git a/src/main/java/xbot/common/properties/Property.java b/src/main/java/xbot/common/properties/Property.java deleted file mode 100644 index 4a1f8374..00000000 --- a/src/main/java/xbot/common/properties/Property.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package xbot.common.properties; - -import org.apache.log4j.Logger; - -/** - * There are many values on the robot that we want to configure on the fly as - * well as persist once we're happy with the result. We call these Properties. - * They can be read/written to rapidly using a RandomAccessStore, and know how - * to save themselves to PermanentStorage when a save is necessary. - * - * @author Alex - */ -public abstract class Property { - /** - * - */ - public String key; - - PermanentStorage permanentStore; - ITableProxy randomAccessStore; - - /** - * New enum to determine property persistence - * Ephemeral properties will not be saved or load from a persistent storage - * Persistent properties will be saved and load from a persistent storage - */ - public enum PropertyPersistenceType{ - Ephemeral, - Persistent - } - - public enum PropertyLevel { - Important, - Debug - } - - public PropertyPersistenceType persistenceType; - public PropertyLevel level; - protected static Logger log; - - /** - * The name of the property. This should be unique unless you really know - * what you're doing. - * New builder with persistence type. Old builder will be deprecated. - * @author Marc - */ - public Property(String key, XPropertyManager manager, PropertyPersistenceType persistenceType, PropertyLevel level) { - this.key = sanitizeKey(key); - log = Logger.getLogger(this.getClass().getSimpleName() + " (\"" + this.key + "\")"); - - this.permanentStore = manager.permanentStore; - - if(level == PropertyLevel.Debug){ - this.randomAccessStore = manager.inMemoryRandomAccessStore; - } else { - this.randomAccessStore = manager.randomAccessStore; - } - - this.persistenceType = persistenceType; - manager.registerProperty(this); - } - - /** - * The name of the property. This should be unique unless you really know - * what you're doing. - * New builder with persistence type. Old builder will be deprecated. - * @author Marc - */ - public Property(String key, XPropertyManager manager, PropertyPersistenceType persistenceType) { - this(key, manager, persistenceType, PropertyLevel.Important); - } - - /** - * The name of the property. This should be unique unless you really know - * what you're doing. - * - */ - public Property(String key, XPropertyManager manager) { - this(key, manager, PropertyPersistenceType.Persistent); - } - - private String sanitizeKey(String key) { - String sanitizedKey = key; - sanitizedKey = sanitizedKey.replace(",", ""); - sanitizedKey = sanitizedKey.replace("\n", ""); - if (sanitizedKey != key) { - log.warn(String - .format("Property '%s' contained illegal characters, has been sanitzed to '%s'", - key, sanitizedKey)); - } - return sanitizedKey; - } - - /** - * Save the property permanently. This shouldn't happen very often (I/O is - * expensive). - */ - public abstract void save(); - - /** - * Load the property from storage. This shouldn't happen very often (I/O is - * expensive). - */ - public abstract void load(); - - /** - * Checks if the property's current value matches the default. - * @return True if the current value is the default. - */ - public abstract boolean isSetToDefault(); -} diff --git a/src/main/java/xbot/common/properties/PropertyFactory.java b/src/main/java/xbot/common/properties/PropertyFactory.java deleted file mode 100644 index 18358eea..00000000 --- a/src/main/java/xbot/common/properties/PropertyFactory.java +++ /dev/null @@ -1,205 +0,0 @@ -package xbot.common.properties; - -import javax.inject.Inject; - -import org.apache.log4j.Logger; - -import xbot.common.logging.RobotAssertionManager; -import xbot.common.properties.Property.PropertyLevel; -import xbot.common.properties.Property.PropertyPersistenceType; - -public class PropertyFactory { - - protected Logger log; - private final XPropertyManager propertyManager; - private String prefix = ""; - private RobotAssertionManager assertionManager; - private boolean prefixSet; - private PropertyLevel defaultLevel = PropertyLevel.Important; - - @Inject - PropertyFactory(XPropertyManager propertyManager, RobotAssertionManager assertionManager) { - this.propertyManager = propertyManager; - this.assertionManager = assertionManager; - log = Logger.getLogger(PropertyFactory.class); - } - - public void setPrefix(String prefix) { - this.prefix = prefix; - prefixSet = true; - } - - public void setPrefix(IPropertySupport prefixSource) { - this.prefix = prefixSource.getPrefix(); - prefixSet = true; - } - - public void appendPrefix(String toAppend) { - prefix = prefix + "/" + toAppend; - prefixSet = true; - } - - public void setTopLevelPrefix() { - prefix = ""; - prefixSet = true; - } - - public String getPrefix() { - return this.prefix; - } - - public String createFullKey(String key) { - String fullKey = null; - if(this.prefix == null || this.prefix.isEmpty()) { - fullKey = key; - } - else if (prefix.charAt(prefix.length() -1) == '/') - { - // If somebody already put a slash as a trailing character, then we don't have much to do. - fullKey = this.getPrefix() + key; - } else { - fullKey = this.getPrefix() + "/" + key; - } - // We've seen issues with badly assembled keys where slashes are getting doubled up - String cleanedKey = fullKey.replaceAll("/+", "/"); - if (fullKey != cleanedKey) { - //log.warn("Property key '" + fullKey + "' had double slashes that were stripped out. Please fix the key logic to not create double slashes."); - } - return cleanedKey; - } - - private void checkPrefixSet() { - if (!prefixSet) { - assertionManager.fail("You should always call setPrefix() on PropertyFactory before creating new properties; " - + "otherwise, all properties will be at the root level." - + "If you meant to have the property at the root level, call setTopLevelPrefix() first." - ); - } - } - - public void setDefaultLevel(PropertyLevel level) { - this.defaultLevel = level; - } - - /** - * Method for creating a boolean ephemeral property - * - * @author Marc - */ - public BooleanProperty createEphemeralProperty(String key, boolean defaultValue) { - checkPrefixSet(); - return new BooleanProperty(this.createFullKey(key), defaultValue, PropertyPersistenceType.Ephemeral, this.propertyManager, defaultLevel); - } - - /** - * Method for creating a boolean ephemeral property - * - * @author Marc - */ - public BooleanProperty createEphemeralProperty(String key, boolean defaultValue, PropertyLevel level) { - checkPrefixSet(); - return new BooleanProperty(this.createFullKey(key), defaultValue, PropertyPersistenceType.Ephemeral, this.propertyManager, level); - } - - /** - * Method for creating a string ephemeral property - * - * @author Marc - */ - public StringProperty createEphemeralProperty(String key, String defaultValue, PropertyLevel level) { - checkPrefixSet(); - return new StringProperty(this.createFullKey(key), defaultValue, PropertyPersistenceType.Ephemeral, this.propertyManager); - } - - /** - * Method for creating a string ephemeral property - * - * @author Marc - */ - public StringProperty createEphemeralProperty(String key, String defaultValue) { - checkPrefixSet(); - return new StringProperty(this.createFullKey(key), defaultValue, PropertyPersistenceType.Ephemeral, this.propertyManager, defaultLevel); - } - - /** - * Method for creating a double ephemeral property - * - * @author Marc - */ - public DoubleProperty createEphemeralProperty(String key, double defaultValue) { - checkPrefixSet(); - return new DoubleProperty(this.createFullKey(key), defaultValue, PropertyPersistenceType.Ephemeral, this.propertyManager, defaultLevel); - } - - /** - * Method for creating a double ephemeral property - * - * @author Marc - */ - public DoubleProperty createEphemeralProperty(String key, double defaultValue, PropertyLevel level) { - checkPrefixSet(); - return new DoubleProperty(this.createFullKey(key), defaultValue, PropertyPersistenceType.Ephemeral, this.propertyManager, level); - } - - /** - * Method for creating a double persistent property - * - * @author Marc - */ - public BooleanProperty createPersistentProperty(String key, boolean defaultValue) { - checkPrefixSet(); - return new BooleanProperty(this.createFullKey(key), defaultValue, PropertyPersistenceType.Persistent, this.propertyManager, defaultLevel); - } - - /** - * Method for creating a double persistent property - * - * @author Marc - */ - public BooleanProperty createPersistentProperty(String key, boolean defaultValue, PropertyLevel level) { - checkPrefixSet(); - return new BooleanProperty(this.createFullKey(key), defaultValue, PropertyPersistenceType.Persistent, this.propertyManager, level); - } - - /** - * Method for creating a double persistent property - * - * @author Marc - */ - public StringProperty createPersistentProperty(String key, String defaultValue) { - checkPrefixSet(); - return new StringProperty(this.createFullKey(key), defaultValue, PropertyPersistenceType.Persistent, this.propertyManager, defaultLevel); - } - - /** - * Method for creating a double persistent property - * - * @author Marc - */ - public StringProperty createPersistentProperty(String key, String defaultValue, PropertyLevel level) { - checkPrefixSet(); - return new StringProperty(this.createFullKey(key), defaultValue, PropertyPersistenceType.Persistent, this.propertyManager, level); - } - - /** - * Method for creating a double persistent property - * - * @author Marc - */ - public DoubleProperty createPersistentProperty(String key, double defaultValue) { - checkPrefixSet(); - return new DoubleProperty(this.createFullKey(key), defaultValue, PropertyPersistenceType.Persistent, this.propertyManager, defaultLevel); - } - - /** - * Method for creating a double persistent property - * - * @author Marc - */ - public DoubleProperty createPersistentProperty(String key, double defaultValue, PropertyLevel level) { - checkPrefixSet(); - return new DoubleProperty(this.createFullKey(key), defaultValue, PropertyPersistenceType.Persistent, this.propertyManager, level); - } - - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/properties/SmartDashboardTableWrapper.java b/src/main/java/xbot/common/properties/SmartDashboardTableWrapper.java deleted file mode 100644 index d42d09c2..00000000 --- a/src/main/java/xbot/common/properties/SmartDashboardTableWrapper.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package xbot.common.properties; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.apache.log4j.Logger; - -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; - -/** - * - * @author Alex - */ -@Singleton -public class SmartDashboardTableWrapper implements ITableProxy { - - private static final Logger log = Logger.getLogger(SmartDashboardTableWrapper.class); - boolean fastMode = false; - private TableProxy fastTable; - - @Inject - public SmartDashboardTableWrapper() { - fastTable = new TableProxy(); - } - - public void setDouble(String key, double value) { - fastTable.setDouble(key, value); - if (!fastMode) { - SmartDashboard.putNumber(key, value); - } - } - - public void clear() { - // Do not clear the smart dashboard - the SmartDashboard doesn't really have a mechanism - // to clear it, so instead we'll just put an angry warning message! - log.warn("Somebody attempted to clear the SmartDashboard. This will never work - why are you doing this?!"); - } - - public Double getDouble(String key) { - if (!fastMode) { - if (SmartDashboard.containsKey(key)) { - return Double.valueOf(SmartDashboard.getNumber(key, 0)); - } else { - return null; - } - } - return fastTable.getDouble(key); - } - - public void setBoolean(String key, boolean value) { - fastTable.setBoolean(key, value); - if (!fastMode) { - SmartDashboard.putBoolean(key, value); - } - } - - public Boolean getBoolean(String key) { - if (!fastMode) { - if (SmartDashboard.containsKey(key)) { - return Boolean.valueOf(SmartDashboard.getBoolean(key, false)); - } else { - return null; - } - } - return fastTable.getBoolean(key); - } - - public void setString(String key, String value) { - fastTable.setString(key, value); - if (!fastMode) { - SmartDashboard.putString(key, value); - } - } - - public String getString(String key) { - if (!fastMode) { - if (SmartDashboard.containsKey(key)) { - return SmartDashboard.getString(key, ""); - } else { - return null; - } - } - return fastTable.getString(key); - } - - @Override - public void setFastMode(boolean on) { - fastMode = on; - } - - public void remove(String key) { - if (SmartDashboard.containsKey(key)) { - SmartDashboard.getEntry(key).unpublish(); - } - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/properties/StringProperty.java b/src/main/java/xbot/common/properties/StringProperty.java deleted file mode 100644 index 8cdcc731..00000000 --- a/src/main/java/xbot/common/properties/StringProperty.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package xbot.common.properties; - -/** - * A type of Property that manages a String value. - * @author Sterling - */ -public class StringProperty extends Property { - private String defaultValue; - - public StringProperty(String name, String defaultValue, XPropertyManager manager) { - super(name, manager); - this.defaultValue = defaultValue; - load(); - } - - public StringProperty(String name, String defaultValue, PropertyPersistenceType persistenceType, XPropertyManager manager) { - super(name, manager, persistenceType); - this.defaultValue = defaultValue; - load(); - } - - public StringProperty(String name, String defaultValue, PropertyPersistenceType persistenceType, XPropertyManager manager, PropertyLevel level) { - super(name, manager, persistenceType, level); - this.defaultValue = defaultValue; - load(); - } - - public String get() { - String nullableTableValue = randomAccessStore.getString(key); - - if(nullableTableValue == null) { - log.error("Property key \"" + key + "\" not present in the underlying store!" - + " IF THIS IS AN IMPORTANT ROBOT PROPERTY, MAKE SURE IT HAS A SANE VALUE BEFORE ENABLING THE ROBOT!"); - return defaultValue; - } - - return nullableTableValue; - } - - public void set(String value) { - randomAccessStore.setString(key, value); - } - - /** - * We only save the property if it's from a persistent type - */ - public void save() { - if(persistenceType == PropertyPersistenceType.Persistent) { - if (!isSetToDefault()) { - permanentStore.setString(key, get()); - } else { - permanentStore.remove(key); - } - } - } - - public void load() { - String value = permanentStore.getString(key); - if(value != null) { - set(value); - log.info("Property " + key + " has the non-default value " + value); - } else { - set(defaultValue); - } - } - - public boolean isSetToDefault() { - return get().equals(defaultValue); - } -} diff --git a/src/main/java/xbot/common/properties/TableProxy.java b/src/main/java/xbot/common/properties/TableProxy.java deleted file mode 100644 index d5496a8e..00000000 --- a/src/main/java/xbot/common/properties/TableProxy.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package xbot.common.properties; - -import java.util.Hashtable; - -import javax.inject.Inject; - -/** - * A simple implementation of ITableProxy. Uses a HashTable as the table to store and save properties. - * - * @author Alex - */ -public class TableProxy implements ITableProxy { - - public Hashtable table; - - @Inject - public TableProxy() { - clear(); - } - - public void clear() { - this.table = new Hashtable(); - } - - public void setDouble(String key, double value) { - table.put(key, Double.toString(value)); - } - - public Double getDouble(String key) { - if (table.get(key) == null) { - return null; - } else { - return Double.valueOf(table.get(key).toString()); - } - } - - public void setBoolean(String key, boolean value) { - table.put(key, Boolean.toString(value)); - } - - public Boolean getBoolean(String key) { - if (table.get(key) == null) { - return null; - } else { - return parseBoolean((String) table.get(key)); - } - } - - public void setString(String key, String value) { - table.put(key, value); - } - - public String getString(String key) { - return (String) table.get(key); - } - - private static boolean parseBoolean(String string) { - if (string.equals("true")) { - return true; - } else { - return false; - } - } - - @Override - public void setFastMode(boolean on) { - } - - public void remove(String key) { - table.remove(key); - } -} diff --git a/src/main/java/xbot/common/properties/XPropertyManager.java b/src/main/java/xbot/common/properties/XPropertyManager.java deleted file mode 100644 index 58f6a828..00000000 --- a/src/main/java/xbot/common/properties/XPropertyManager.java +++ /dev/null @@ -1,90 +0,0 @@ -package xbot.common.properties; - -import java.util.ArrayList; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.apache.log4j.Logger; - -/** - * The PropertyManager keeps track of all properties in CoreCode. All properties are implicitly added into its storage. - * It is capable of loading or saving all properties via permanentStorage, and getting updates to these properties via - * the RandomAccessStore. - * - * @author Alex - */ -@Singleton -public class XPropertyManager { - public static final String IN_MEMORY_STORE_NAME = "InMemoryStore"; - private static final Logger log = Logger.getLogger(XPropertyManager.class); - - public final ArrayList properties; - public final PermanentStorage permanentStore; - public final ITableProxy randomAccessStore; - public final ITableProxy inMemoryRandomAccessStore; - - @Inject - public XPropertyManager( - PermanentStorage permanentStore, - ITableProxy randomAccessStore, - @Named(IN_MEMORY_STORE_NAME) ITableProxy inMemoryRandomAccessStore - ) { - this.properties = new ArrayList(); - this.permanentStore = permanentStore; - this.randomAccessStore = randomAccessStore; - this.inMemoryRandomAccessStore = new TableProxy(); - } - - /** - * Adds the property to the local collection. - */ - public void registerProperty(Property property) { - properties.add(property); - } - - /** - * Loads all properties from storage into the PermanentStore's table. - */ - public void loadPropertiesFromStorage() { - // We need to somehow get the random store and force load everything in that. - int escape = 0; - for (int i = 0; i < properties.size(); i++) { - Property prop = (Property) properties.get(i); - prop.load(); - - escape++; - if (escape > 2000) { - break; - } - } - } - - /** - * Save all properties into permanent storage. - */ - public void saveOutAllProperties() { - - // We should clear the permanent storage before we save, otherwise we can have - // "orphaned" values that are loaded/saved indefinitely, even if there's nothing in the - // code that uses them. - - if (properties.size() == 0) { - log.error("No properties to save! Skipping save phase."); - return; - } - - int escape = 0; - - for (int i = 0; i < properties.size(); i++) { - Property prop = (Property) properties.get(i); - prop.save(); - - escape++; - if (escape > 2000) { - break; - } - } - } -} diff --git a/src/main/java/xbot/common/resiliency/DeviceHealth.java b/src/main/java/xbot/common/resiliency/DeviceHealth.java deleted file mode 100644 index 8d36cbf6..00000000 --- a/src/main/java/xbot/common/resiliency/DeviceHealth.java +++ /dev/null @@ -1,6 +0,0 @@ -package xbot.common.resiliency; - -public enum DeviceHealth { - Healthy, - Unhealthy -} diff --git a/src/main/java/xbot/common/simulation/BaseSimulationTest.java b/src/main/java/xbot/common/simulation/BaseSimulationTest.java deleted file mode 100644 index 842b853f..00000000 --- a/src/main/java/xbot/common/simulation/BaseSimulationTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package xbot.common.simulation; - -import java.math.BigDecimal; - -import org.apache.log4j.xml.DOMConfigurator; -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.Before; -import org.junit.Ignore; - -import edu.wpi.first.wpilibj.MockTimer; -import xbot.common.controls.sensors.XTimer; -import xbot.common.injection.components.DaggerSimulationComponent; -import xbot.common.math.PIDManager.PIDManagerFactory; -import xbot.common.injection.components.BaseComponent; -import xbot.common.properties.PropertyFactory; - -@Ignore -public class BaseSimulationTest { - public BaseComponent injectorComponent; - - public PropertyFactory propertyFactory; - - protected PIDManagerFactory pf; - - protected MockTimer timer; - - SimulationPayloadDistributor distributor; - - @Before - public void setUp() { - injectorComponent = DaggerSimulationComponent.create(); - timer = (MockTimer)injectorComponent.timerImplementation(); - XTimer.setImplementation(timer); - - propertyFactory = injectorComponent.propertyFactory(); - - pf = injectorComponent.pidFactory(); - - DOMConfigurator.configure(getClass().getClassLoader().getResource("log4j4unitTesting.xml")); - - distributor = injectorComponent.simulationPayloadDistributor(); - } - - protected JSONObject createSimpleSensorPayload(String id, JSONObject keysAndValues) { - JSONObject overallPayload = new JSONObject(); - JSONObject singleSensor = new JSONObject(); - singleSensor.put("ID", id); - singleSensor.put("Payload", keysAndValues); - JSONArray sensorList = new JSONArray(); - sensorList.put(singleSensor); - overallPayload.put("Sensors", sensorList); - JSONObject worldPose = new JSONObject(); - worldPose.put("Time", new BigDecimal(1.23)); - overallPayload.put("WorldPose", worldPose); - - return overallPayload; - } - - protected JSONObject createSimpleWorldPosePayload(JSONObject keysAndValues) { - JSONObject overallPayload = new JSONObject(); - overallPayload.put("Sensors", new JSONArray()); - JSONObject worldPose = keysAndValues; - overallPayload.put("WorldPose", worldPose); - - return overallPayload; - } -} diff --git a/src/main/java/xbot/common/simulation/ExampleSensorData.json b/src/main/java/xbot/common/simulation/ExampleSensorData.json deleted file mode 100644 index f88e51ee..00000000 --- a/src/main/java/xbot/common/simulation/ExampleSensorData.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Sensors": [ - { - "ID": "DigitalIO3", - "Payload": { - "EncoderTicks": 123 - } - }, - { - "ID": "Analog5", - "Payload": { - "Voltage": 2.45784 - } - }, - { - "ID": "Analog6", - "Payload": { - "Distance": 129.323 - } - }, - { - "ID": "CAN12", - "Payload": { - "EncoderTicks": 224 - } - } - ] -} \ No newline at end of file diff --git a/src/main/java/xbot/common/simulation/ISimulatableMotor.java b/src/main/java/xbot/common/simulation/ISimulatableMotor.java deleted file mode 100644 index adf90544..00000000 --- a/src/main/java/xbot/common/simulation/ISimulatableMotor.java +++ /dev/null @@ -1,16 +0,0 @@ -package xbot.common.simulation; - -import org.json.JSONObject; - -public interface ISimulatableMotor { - public JSONObject getSimulationData(); - - default JSONObject buildMotorObject(String name, float value) { - JSONObject result = new JSONObject(); - // For now the simulation robot expects "Motor1, Motor2" etc but at some point - // we'll change this so it's better linked to DevicePolice or some other name mapping - result.put("id", name.replace("CAN", "Motor")); - result.put("val", value); - return result; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/simulation/ISimulatableSensor.java b/src/main/java/xbot/common/simulation/ISimulatableSensor.java deleted file mode 100644 index 68f07b5a..00000000 --- a/src/main/java/xbot/common/simulation/ISimulatableSensor.java +++ /dev/null @@ -1,7 +0,0 @@ -package xbot.common.simulation; - -import org.json.JSONObject; - -public interface ISimulatableSensor { - public void ingestSimulationData(JSONObject payload); -} \ No newline at end of file diff --git a/src/main/java/xbot/common/simulation/ISimulatableSolenoid.java b/src/main/java/xbot/common/simulation/ISimulatableSolenoid.java deleted file mode 100644 index 050f5864..00000000 --- a/src/main/java/xbot/common/simulation/ISimulatableSolenoid.java +++ /dev/null @@ -1,22 +0,0 @@ -package xbot.common.simulation; - -import org.json.JSONObject; - -public interface ISimulatableSolenoid { - public JSONObject getSimulationData(); - public final String SOLENOID_POWER_MODE = "VIRTUAL_SOLENOID"; - - default JSONObject buildMotorObject(int channel, boolean isOn) { - JSONObject result = new JSONObject(); - - result.put("id", "Solenoid" + channel); - result.put("mode", SOLENOID_POWER_MODE); - if(isOn) { - result.put("val", "ON"); - } else { - result.put("val", "OFF"); - } - - return result; - } -} diff --git a/src/main/java/xbot/common/simulation/ResetSimulatorPositionCommand.java b/src/main/java/xbot/common/simulation/ResetSimulatorPositionCommand.java deleted file mode 100644 index 63dbf6e8..00000000 --- a/src/main/java/xbot/common/simulation/ResetSimulatorPositionCommand.java +++ /dev/null @@ -1,62 +0,0 @@ -package xbot.common.simulation; - -import java.util.ArrayList; - -import javax.inject.Inject; - -import org.json.JSONObject; - -import edu.wpi.first.math.geometry.Rotation2d; -import xbot.common.command.BaseCommand; -import xbot.common.math.FieldPose; -import xbot.common.math.XYPair; -import xbot.common.subsystems.pose.BasePoseSubsystem; - -public class ResetSimulatorPositionCommand extends BaseCommand { - - final WebotsClient webots; - final BasePoseSubsystem pose; - - private FieldPose targetPose; - SimulationPayloadDistributor distributor; - - @Inject - public ResetSimulatorPositionCommand(WebotsClient webots, BasePoseSubsystem pose, - SimulationPayloadDistributor distributor) { - this.webots = webots; - this.pose = pose; - this.distributor = distributor; - targetPose = new FieldPose(new XYPair(0, 0), new Rotation2d()); - } - - public void setTargetPose(FieldPose p) { - this.targetPose = p; - } - - @Override - public void initialize() { - log.info("Initializing"); - webots.resetPosition(targetPose.getPoint().x, targetPose.getPoint().y, targetPose.getHeading().getDegrees()); - // Need to add a tiny sleep to let Webots update itself, since there are async elements on that end. If that gets ironed out, we can remove this delay. - try { - Thread.sleep(50); - } catch (InterruptedException e) { - e.printStackTrace(); - } - JSONObject response = webots.sendMotors(new ArrayList()); - distributor.distributeSimulationPayload(response); - pose.periodic(); - - pose.setCurrentPosition(targetPose.getPoint().x, targetPose.getPoint().y); - pose.setCurrentHeading(targetPose.getHeading().getDegrees()); - } - - @Override - public boolean isFinished() { - return true; - } - - @Override - public void execute() { - } -} diff --git a/src/main/java/xbot/common/simulation/SimulationPayloadDistributor.java b/src/main/java/xbot/common/simulation/SimulationPayloadDistributor.java deleted file mode 100644 index 7fa96156..00000000 --- a/src/main/java/xbot/common/simulation/SimulationPayloadDistributor.java +++ /dev/null @@ -1,71 +0,0 @@ -package xbot.common.simulation; - -import java.math.BigDecimal; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.json.JSONArray; -import org.json.JSONObject; - -import org.apache.log4j.Logger; - -import xbot.common.controls.sensors.XSettableTimerImpl; -import xbot.common.injection.DevicePolice; - -@Singleton -public class SimulationPayloadDistributor { - - private DevicePolice police; - private XSettableTimerImpl timer; - private static Logger log = Logger.getLogger(SimulationPayloadDistributor.class); - - @Inject - public SimulationPayloadDistributor(DevicePolice police, XSettableTimerImpl timer) { - this.police = police; - this.timer = timer; - } - - /** - * Fans out data from a simulation (like Webots) to all the simulatable devices registered on the robot. - * @param allSensorsPayload The JSON sensor payload, containing all sensor data from the simulation environment - */ - public void distributeSimulationPayload(JSONObject allSensorsPayload) { - - if (allSensorsPayload != null) { - // This assumes that the element containing the array of sensor data is called "Sensors". - JSONArray allSensorsArray = allSensorsPayload.getJSONArray("Sensors"); - allSensorsArray.forEach(item -> { - JSONObject sensorJson = (JSONObject)item; - String id = sensorJson.getString("ID"); - JSONObject payload = sensorJson.getJSONObject("Payload"); - - Object device = police.registeredChannels.get(id); - if (device == null) { - // skip for now - //log.error("Unable to find device with ID" + id + " in the DevicePolice. Make sure it's being properly created somewhere."); - } else { - ISimulatableSensor robotSensor = null; - try { - robotSensor = (ISimulatableSensor)device; - } - catch (Exception e) { - log.error("Unable to cast device with ID " + id + " to an ISimulatableSensor. Make sure that sensor implements ISimulatableSensor."); - throw e; - } - robotSensor.ingestSimulationData(payload); - } - }); - - // This assumes that the element containing the world pose is called "WorldPose". - JSONObject worldPose = allSensorsPayload.optJSONObject("WorldPose"); - if (worldPose != null) { - // Only update the simulation time is present and valid - BigDecimal timeInSeconds = worldPose.optBigDecimal("Time", BigDecimal.valueOf(-1)); - if (timeInSeconds.compareTo(BigDecimal.ZERO) >= 0) { - this.timer.setTimeInSeconds(timeInSeconds.doubleValue()); - } - } - } - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/simulation/WebotsClient.java b/src/main/java/xbot/common/simulation/WebotsClient.java deleted file mode 100644 index 2d9c3902..00000000 --- a/src/main/java/xbot/common/simulation/WebotsClient.java +++ /dev/null @@ -1,240 +0,0 @@ -package xbot.common.simulation; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.ProxySelector; -import java.net.URI; -import java.net.http.HttpClient; -import java.net.http.HttpClient.Builder; -import java.net.http.HttpClient.Version; -import java.net.http.HttpRequest; -import java.net.http.HttpRequest.BodyPublishers; -import java.net.http.HttpResponse; -import java.net.http.HttpResponse.BodyHandlers; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.json.JSONArray; -import org.json.JSONObject; - -import edu.wpi.first.wpilibj.util.Color; -import xbot.common.math.FieldPose; -import xbot.common.math.XYPair; -import xbot.common.properties.BooleanProperty; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; -import xbot.common.properties.StringProperty; -import xbot.common.subsystems.pose.BasePoseSubsystem; - -@Singleton -public class WebotsClient { - final DoubleProperty simulatorPoseX; - final DoubleProperty simulatorPoseY; - final DoubleProperty simulatorPoseYaw; - final StringProperty simulatorRobotTemplate; - final BooleanProperty enableProxy; - final DoubleProperty proxyPort; - final String hostname = "127.0.0.1"; - final int supervisorPort = 10001; - final HttpClient client; - - int robotPort = -1; - - private FieldPose fieldOffset; - - @Inject - public WebotsClient(PropertyFactory propertyFactory) { - propertyFactory.setPrefix("Webots"); - simulatorPoseX = propertyFactory.createEphemeralProperty("Simulator Pose X", 0); - simulatorPoseY = propertyFactory.createEphemeralProperty("Simulator Pose Y", 0); - simulatorPoseYaw = propertyFactory.createEphemeralProperty("Simulator Pose Yaw", 0); - simulatorRobotTemplate = propertyFactory.createPersistentProperty("Robot Template", "HttpRobotTemplate"); - enableProxy = propertyFactory.createPersistentProperty("Enable Proxy", false); - proxyPort = propertyFactory.createPersistentProperty("Proxy Port", 8888); - - fieldOffset = new FieldPose(); - client = buildHttpClient(enableProxy.get(), (int)proxyPort.get()); - } - - /** - * In the case where the origin of the field doesn't match our traditional convention (with 0,0 - * on the bottom-left vertex of the rectangular FRC field if viewed from above with your alliance - * driver station at the bottom), then we need to shift X,Y coordinates to get everything to line up. - * @param offset A FieldPose that represents the bottom-left part of the field in Webots (in absolute inches) - */ - public void setFieldPoseOffset(FieldPose offset) { - this.fieldOffset = offset; - } - - public void initialize() { - // Spawn a robot in the sim - JSONObject data = new JSONObject(); - data.put("template", simulatorRobotTemplate.get()); - - HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://" + hostname + ":" + supervisorPort + "/robot")) - .header("Content-Type", "application/json").POST(BodyPublishers.ofString(data.toString())).build(); - HttpResponse response; - try { - response = client.send(request, BodyHandlers.ofString()); - robotPort = Integer.parseInt(response.body()); - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - public JSONObject sendMotors(List motorValues) { - JSONObject data = new JSONObject(); - data.put("motors", motorValues); - - HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://" + hostname + ":" + robotPort + "/motors")) - .header("Content-Type", "application/json").PUT(BodyPublishers.ofString(data.toString())).build(); - HttpResponse response; - try { - response = client.send(request, BodyHandlers.ofString()); - if (response.statusCode() == 200) { - // parse response for sensor values - JSONObject responseData = new JSONObject(response.body()); - handleSimulatorPose(responseData.getJSONObject("WorldPose")); - return responseData; - } - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return null; - } - - public void handleSimulatorPose(JSONObject worldPose) { - JSONArray positionArray = worldPose.getJSONArray("Position"); - FieldPose truePose = new FieldPose( - positionArray.getDouble(0)*BasePoseSubsystem.INCHES_IN_A_METER, - positionArray.getDouble(1)*BasePoseSubsystem.INCHES_IN_A_METER, - worldPose.getDouble("Yaw")); - FieldPose calibratedPose = truePose.getFieldPoseOffsetBy(fieldOffset); - simulatorPoseX.set(calibratedPose.getPoint().x); - simulatorPoseY.set(calibratedPose.getPoint().y); - simulatorPoseYaw.set(calibratedPose.getHeading().getDegrees()); - } - - public void resetPosition() { - resetPosition(0, 0, 0); - } - - public void resetPosition(double x, double y, double rotationInDegrees) { - - x += fieldOffset.getPoint().x; - y += fieldOffset.getPoint().y; - rotationInDegrees += fieldOffset.getHeading().getDegrees(); - - x /= BasePoseSubsystem.INCHES_IN_A_METER; - y /= BasePoseSubsystem.INCHES_IN_A_METER; - - JSONArray positionArray = new JSONArray(new double[] {x, y, 0.1}); - JSONArray rotationArray = new JSONArray(new double[] {0, 0, 1, Math.toRadians(rotationInDegrees)}); - - JSONObject data = new JSONObject(); - data.put("position", positionArray); - data.put("rotation", rotationArray); - // TODO: Support passing in position and or rotation here - HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://" + hostname + ":" + robotPort + "/position")) - .header("Content-Type", "application/json").PUT(BodyPublishers.ofString(data.toString())).build(); - HttpResponse response; - try { - response = client.send(request, BodyHandlers.ofString()); - if (response.statusCode() == 200) { - // ok - } - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - public void drawLine(String name, XYPair point1, XYPair point2, Color color, float zIndex) { - JSONObject data = new JSONObject(); - data.put("name", name); - XYPair point1Meters = point1.clone().add(this.fieldOffset.getPoint()).scale(1 / BasePoseSubsystem.INCHES_IN_A_METER); - XYPair point2Meters = point2.clone().add(this.fieldOffset.getPoint()).scale(1 / BasePoseSubsystem.INCHES_IN_A_METER); - data.put("point_1", new JSONArray(new double[] {point1Meters.x, point1Meters.y, zIndex / BasePoseSubsystem.INCHES_IN_A_METER})); - data.put("point_2", new JSONArray(new double[] {point2Meters.x, point2Meters.y, zIndex / BasePoseSubsystem.INCHES_IN_A_METER})); - data.put("color", new JSONArray(new double[] {color.red, color.green, color.blue})); - - HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://" + hostname + ":" + robotPort + "/overlay/line")) - .header("Content-Type", "application/json").PUT(BodyPublishers.ofString(data.toString())).build(); - HttpResponse response; - try { - response = client.send(request, BodyHandlers.ofString()); - if (response.statusCode() == 200) { - // ok - } - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - public void drawArrow(String name, XYPair point1, XYPair point2, Color color, float zIndex) { - JSONObject data = new JSONObject(); - data.put("name", name); - XYPair point1Meters = point1.clone().add(this.fieldOffset.getPoint()).scale(1 / BasePoseSubsystem.INCHES_IN_A_METER); - XYPair point2Meters = point2.clone().add(this.fieldOffset.getPoint()).scale(1 / BasePoseSubsystem.INCHES_IN_A_METER); - data.put("point_1", new JSONArray(new double[] {point1Meters.x, point1Meters.y, zIndex / BasePoseSubsystem.INCHES_IN_A_METER})); - data.put("point_2", new JSONArray(new double[] {point2Meters.x, point2Meters.y, zIndex / BasePoseSubsystem.INCHES_IN_A_METER})); - data.put("color", new JSONArray(new double[] {color.red, color.green, color.blue})); - - HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://" + hostname + ":" + robotPort + "/overlay/arrow")) - .header("Content-Type", "application/json").PUT(BodyPublishers.ofString(data.toString())).build(); - HttpResponse response; - try { - response = client.send(request, BodyHandlers.ofString()); - if (response.statusCode() == 200) { - // ok - } - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - public void drawCircle(String name, XYPair center, float radius, Color color, float zIndex) { - JSONObject data = new JSONObject(); - data.put("name", name); - XYPair centerMeters = center.clone().add(this.fieldOffset.getPoint()).scale(1 / BasePoseSubsystem.INCHES_IN_A_METER); - data.put("center", new JSONArray(new double[] {centerMeters.x, centerMeters.y, zIndex / BasePoseSubsystem.INCHES_IN_A_METER})); - data.put("color", new JSONArray(new double[] {color.red, color.green, color.blue})); - data.put("radius", radius); - - HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://" + hostname + ":" + robotPort + "/overlay/circle")) - .header("Content-Type", "application/json").PUT(BodyPublishers.ofString(data.toString())).build(); - HttpResponse response; - try { - response = client.send(request, BodyHandlers.ofString()); - if (response.statusCode() == 200) { - // ok - } - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - private static HttpClient buildHttpClient(boolean enableProxy, int proxyPort) { - Builder clientBuilder = HttpClient.newBuilder().version(Version.HTTP_1_1); - - if (enableProxy) { - clientBuilder.proxy(ProxySelector.of(InetSocketAddress.createUnresolved("localhost", proxyPort))); - } - - return clientBuilder.build(); - } - -} diff --git a/src/main/java/xbot/common/subsystems/BaseXCANTalonPairSpeedControlledSubsystem.java b/src/main/java/xbot/common/subsystems/BaseXCANTalonPairSpeedControlledSubsystem.java deleted file mode 100644 index 6a29920b..00000000 --- a/src/main/java/xbot/common/subsystems/BaseXCANTalonPairSpeedControlledSubsystem.java +++ /dev/null @@ -1,42 +0,0 @@ -package xbot.common.subsystems; - -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.controls.actuators.XCANTalon.XCANTalonFactory; -import xbot.common.injection.electrical_contract.CANTalonInfo; -import xbot.common.math.PIDPropertyManager; -import xbot.common.properties.PropertyFactory; - -public class BaseXCANTalonPairSpeedControlledSubsystem extends BaseXCANTalonSpeedControlledSubsystem { - - protected XCANTalon followerMotor; - - /** - * @param systemName What the system is called. This will apply to various Properties. - * @param masterChannel The CAN index of the master motor (or the only motor, for a simple system) - * @param followChannel The CAN index of the follow motor (-1 if no follow motor) - * @param factory The WPIFactory - * @param pidPropertyManager The default PIDF values the system should use - * @param propManager The PropertyFactory - */ - public BaseXCANTalonPairSpeedControlledSubsystem( - String name, - int masterChannel, - int followChannel, - boolean invertMaster, - boolean invertMasterSensor, - boolean invertFollower, - XCANTalonFactory factory, - PIDPropertyManager pidPropertyManager, - PropertyFactory propManager) { - super(name, masterChannel, invertMaster, invertMasterSensor, factory, pidPropertyManager, propManager); - - followerMotor = factory.create(new CANTalonInfo(followChannel, false)); - initializeFollowerMotorConfiguration(invertFollower); - } - - protected void initializeFollowerMotorConfiguration(boolean motorInverted) { - followerMotor.follow(masterMotor); - followerMotor.setInverted(motorInverted); - } - -} \ No newline at end of file diff --git a/src/main/java/xbot/common/subsystems/BaseXCANTalonSpeedControlledSubsystem.java b/src/main/java/xbot/common/subsystems/BaseXCANTalonSpeedControlledSubsystem.java deleted file mode 100644 index d5de006e..00000000 --- a/src/main/java/xbot/common/subsystems/BaseXCANTalonSpeedControlledSubsystem.java +++ /dev/null @@ -1,160 +0,0 @@ -package xbot.common.subsystems; - -import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.FeedbackDevice; - -import xbot.common.command.BaseSubsystem; -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.controls.actuators.XCANTalon.XCANTalonFactory; -import xbot.common.controls.sensors.XTimer; -import xbot.common.injection.electrical_contract.CANTalonInfo; -import xbot.common.math.PIDPropertyManager; -import xbot.common.properties.BooleanProperty; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; - -/** - * We have a few Subsystems that have one primary goal: - * -Get a motor to rotate at a specific controlled speed. - * -Occasionally set the motor to use a specific power. - * This requires a decent amount of overhead in terms of Properties and - * other configuration, and is something that could be mostly delegated to this class, - * as the only significant point of difference is how many motors are controlled - * by the Subsystem. - * - * If the system has more than one motor it is typically - * configured into follower mode, so almost no extra configuration is needed. - * @author John - * - */ -public abstract class BaseXCANTalonSpeedControlledSubsystem extends BaseSubsystem { - - protected final XCANTalon masterMotor; - protected XCANTalon followerMotor; - - // output telemetry properties - protected final DoubleProperty systemCurrentSpeed; - protected final DoubleProperty systemTargetSpeed; - protected final DoubleProperty systemOutputPower; - protected final DoubleProperty systemTalonError; - protected final BooleanProperty atSpeedProp; - protected final BooleanProperty enablesystemLogging; - - private final DoubleProperty systemSpeedThresh; - protected final PIDPropertyManager pidPropertyManager; - protected final int masterChannel; - - /** - * - * @param name What the system is called. This will apply to various Properties. - * @param masterChannel The CAN index of the master motor (or the only motor, for a simple system) - * @param factory The WPIFactory - * @param pidPropertyManager The default PIDF values the system should use - * @param propManager The PropertyFactory - */ - public BaseXCANTalonSpeedControlledSubsystem( - String name, - int masterChannel, - boolean invertMaster, - boolean invertMasterSensor, - XCANTalonFactory factory, - PIDPropertyManager pidPropertyManager, - PropertyFactory propManager){ - super(); - log.info("Creating"); - - this.pidPropertyManager = pidPropertyManager; - this.masterChannel = masterChannel; - - // Reading through the manual, it looks like only a few things - // support human units. It might be easier to just keep everything in native units per 100ms, - // which is what the Talon uses for all its calculations. - // I call this Ticks per Deciseconds, or TPD - systemSpeedThresh = propManager.createPersistentProperty(name + " nominal speed thresh (TPD)", 1); - systemCurrentSpeed = propManager.createEphemeralProperty(name + " current speed (TPD)", 0); - systemTargetSpeed = propManager.createEphemeralProperty(name + " goal speed (TPD)", 0); - systemOutputPower = propManager.createEphemeralProperty(name + " voltage", 0); - atSpeedProp = propManager.createEphemeralProperty("Is" + name + " at speed?", false); - systemTalonError = propManager.createEphemeralProperty(name + " speed error", 0); - enablesystemLogging = propManager.createEphemeralProperty("Is " + name + " logging enabled?", false); - - masterMotor = factory.create(new CANTalonInfo(masterChannel, false)); - initializeMasterMotorConfiguration(invertMaster, invertMasterSensor); - masterMotor.createTelemetryProperties(name + "/", name + " master"); - } - - protected void initializeMasterMotorConfiguration(boolean motorInverted, boolean motorSensorInverted) { - masterMotor.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder, 0, 0); - - masterMotor.setInverted(motorInverted); - masterMotor.setSensorPhase(motorSensorInverted); - } - - private void updateMotorPidValues() { - masterMotor.config_kP(0, pidPropertyManager.getP(), 0); - masterMotor.config_kI(0, pidPropertyManager.getI(), 0); - masterMotor.config_kD(0, pidPropertyManager.getD(), 0); - masterMotor.config_kF(0, pidPropertyManager.getF(), 0); - } - - /** - * Sets the output power of the system directly - no PID of any kind - * @param Power is set to system - */ - public void setPower(double power) { - masterMotor.set(ControlMode.PercentOutput, power); - } - - /** - * Returns the current "robot power" (e.g. -1 == full reverse, 1 == full forward) - * @return Last Motor power - */ - public double getPower() { - double robotPower = masterMotor.getMotorOutputVoltage() / masterMotor.getBusVoltage(); - double inversionFactor = masterMotor.getInverted() ? -1 : 1; - return robotPower * inversionFactor; - } - - /** - * Gives the system a new speed goal. - * @param systemTargetSpeed in Rotations per Second (RPS) - */ - public void setTargetSpeed(double speed) { - // Update property for dashboard - systemTargetSpeed.set(speed); - // If there have been any changes to encoder settings or PID setings, apply them. - updateMotorPidValues(); - // Instruct motor about new speed goal - masterMotor.set(ControlMode.Velocity, speed); - } - - public double getSpeed() { - return masterMotor.getSelectedSensorVelocity(0); - } - - public boolean isAtSpeed() { - return Math.abs(getSpeed() - systemTargetSpeed.get()) <= systemSpeedThresh.get(); - } - - public double getTargetSpeed() { - return systemTargetSpeed.get(); - } - - @Override - public void periodic() { - masterMotor.updateTelemetryProperties(); - atSpeedProp.set(isAtSpeed()); - systemCurrentSpeed.set(getSpeed()); - systemOutputPower.set(masterMotor.getMotorOutputVoltage() / masterMotor.getBusVoltage()); - systemTalonError.set(masterMotor.getClosedLoopError(0)); - - if(enablesystemLogging.get()){ - double currentTime = XTimer.getFPGATimestamp(); - // Format: time, voltage, error, speed - log.info(currentTime + "," - + systemOutputPower.get() + "," - + systemTalonError.get() + "," - + systemCurrentSpeed.get()); - } - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/subsystems/autonomous/AutonomousCommandSelector.java b/src/main/java/xbot/common/subsystems/autonomous/AutonomousCommandSelector.java deleted file mode 100644 index 64a6fa13..00000000 --- a/src/main/java/xbot/common/subsystems/autonomous/AutonomousCommandSelector.java +++ /dev/null @@ -1,59 +0,0 @@ -package xbot.common.subsystems.autonomous; - -import java.util.function.Supplier; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.apache.log4j.Logger; - -import edu.wpi.first.wpilibj2.command.Command; - -import xbot.common.command.BaseSubsystem; -import xbot.common.properties.PropertyFactory; -import xbot.common.properties.StringProperty; - -@Singleton -public class AutonomousCommandSelector extends BaseSubsystem { - private static Logger log = Logger.getLogger(AutonomousCommandSelector.class); - - public final StringProperty currentAutonomousCommandName; - public final StringProperty currentAutonomousState; - Supplier commandSupplier; - - Command currentAutonomousCommand; - - @Inject - public AutonomousCommandSelector(PropertyFactory propFactory) { - propFactory.setTopLevelPrefix(); - currentAutonomousCommandName = propFactory.createEphemeralProperty("Current autonomous command name", - "No command set"); - currentAutonomousState = propFactory.createEphemeralProperty("Auto Program State", "Not set"); - } - - public Command getCurrentAutonomousCommand() { - if (commandSupplier != null) { - return commandSupplier.get(); - } - return currentAutonomousCommand; - } - - public void setCurrentAutonomousCommand(Command currentAutonomousCommand) { - log.info("Setting CurrentAutonomousCommand to " + currentAutonomousCommand); - this.currentAutonomousCommandName - .set(currentAutonomousCommand == null ? "No command set" : currentAutonomousCommand.getName()); - - this.currentAutonomousCommand = currentAutonomousCommand; - commandSupplier = null; - } - - public void setCurrentAutonomousCommandSupplier(Supplier supplier) { - commandSupplier = supplier; - this.currentAutonomousCommand = null; - } - - public void setAutonomousState(String state) { - currentAutonomousState.set(state); - } - -} diff --git a/src/main/java/xbot/common/subsystems/autonomous/SetAutonomousCommand.java b/src/main/java/xbot/common/subsystems/autonomous/SetAutonomousCommand.java deleted file mode 100644 index aec1f981..00000000 --- a/src/main/java/xbot/common/subsystems/autonomous/SetAutonomousCommand.java +++ /dev/null @@ -1,45 +0,0 @@ -package xbot.common.subsystems.autonomous; - -import javax.inject.Inject; - -import edu.wpi.first.wpilibj2.command.Command; -import xbot.common.command.BaseCommand; - -public class SetAutonomousCommand extends BaseCommand { - - private final AutonomousCommandSelector selector; - private Command autonomousCommand; - - @Inject - public SetAutonomousCommand(AutonomousCommandSelector selector) { - this.selector = selector; - } - - @Override - public boolean runsWhenDisabled() { - return true; - } - - public void setAutoCommand(Command autonomousCommand) { - this.autonomousCommand = autonomousCommand; - } - - @Override - public void initialize() { - if (autonomousCommand != null) { - log.info("Setting Auto to: " + autonomousCommand.getName()); - selector.setCurrentAutonomousCommand(autonomousCommand); - } else { - log.warn("No autonomous command configured. Not changing the current autonomous command."); - } - } - - @Override - public void execute() { - } - - @Override - public boolean isFinished() { - return true; - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/subsystems/compressor/CompressorSubsystem.java b/src/main/java/xbot/common/subsystems/compressor/CompressorSubsystem.java deleted file mode 100644 index fa75c017..00000000 --- a/src/main/java/xbot/common/subsystems/compressor/CompressorSubsystem.java +++ /dev/null @@ -1,48 +0,0 @@ -package xbot.common.subsystems.compressor; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import edu.wpi.first.wpilibj2.command.Command; -import xbot.common.command.BaseSubsystem; -import xbot.common.command.NamedRunCommand; -import xbot.common.controls.actuators.XCompressor; -import xbot.common.controls.actuators.XCompressor.XCompressorFactory; -import xbot.common.properties.BooleanProperty; -import xbot.common.properties.PropertyFactory; - -@Singleton -public class CompressorSubsystem extends BaseSubsystem { - final XCompressor compressor; - final BooleanProperty isEnabledProperty; - - @Inject - public CompressorSubsystem(XCompressorFactory compressorFactory, PropertyFactory pf) { - pf.setPrefix("CompressorSubsystem"); - this.compressor = compressorFactory.create(); - this.isEnabledProperty = pf.createEphemeralProperty("Compressor Enabled", compressor.isEnabled()); - this.register(); - } - - public void enable() { - this.compressor.enable(); - } - - public void disable() { - this.compressor.disable(); - } - - public Command getEnableCommand() { - return new NamedRunCommand(getName() + "-Enable", ()->compressor.enable(), this); - } - - public Command getDisableCommand() { - return new NamedRunCommand(getName() + "-Disable", ()->compressor.disable(), this); - } - - @Override - public void periodic() { - super.periodic(); - isEnabledProperty.set(compressor.isEnabled()); - } -} diff --git a/src/main/java/xbot/common/subsystems/drive/BaseDriveSubsystem.java b/src/main/java/xbot/common/subsystems/drive/BaseDriveSubsystem.java deleted file mode 100644 index 72caa412..00000000 --- a/src/main/java/xbot/common/subsystems/drive/BaseDriveSubsystem.java +++ /dev/null @@ -1,187 +0,0 @@ -package xbot.common.subsystems.drive; - -import xbot.common.command.BaseSubsystem; -import xbot.common.math.PIDManager; -import xbot.common.math.XYPair; - -public abstract class BaseDriveSubsystem extends BaseSubsystem { - - public abstract PIDManager getPositionalPid(); - public abstract PIDManager getRotateToHeadingPid(); - public abstract PIDManager getRotateDecayPid(); - boolean isQuickTurn; - - public abstract void move(XYPair translate, double rotate); - - /** - * Returns the total distance tracked by the encoder - * - On the LEFT side of the robot - * - Pointing in the direction of +Y travel - */ - public abstract double getLeftTotalDistance(); - - /** - * Returns the total distance tracked by the encoder - * - On the RIGHT side of the robot - * - Pointing in the direction of +Y travel - */ - public abstract double getRightTotalDistance(); - - /** - * Returns the total distance tracked by the encoder - * - In the center of the robot - * - Pointing in the direction of +X travel - */ - public abstract double getTransverseDistance(); - - /** - * Commands each of the XCANTalons to respond to translation/rotation input. - * Each "wheel" is independently responsible, and as such there isn't any actual - * drive logic in this method. - * @param translation +Y is towards the front of the robot, +X is towards the right of the robot. Range between -1 and 1. - * @param rotation +Rotation is left turn, -Rotation is right turn. Range between -1 and 1. - * @param normalize If the largest output is greater than 1, should all outputs be - * normalized so that 1 is the maximum? - */ - public void drive(XYPair translation, double rotation, boolean normalize) { - - double normalizationFactor = 1; - if (normalize) { - normalizationFactor = Math.max(1, getMaxOutput(translation, rotation)); - } - - XYPair translationIntent = translation.clone().scale(1/normalizationFactor); - double rotationIntent = rotation / normalizationFactor; - - move(translationIntent, rotationIntent); - } - - /** - * Commands each of the XCANTalons to respond to translation/rotation input. - * Each "wheel" is independently responsible, and as such there isn't any actual - * drive logic in this method. - * @param translation +Y is towards the front of the robot, +X is towards the right of the robot. Range between -1 and 1 - * @param rotation +Rotation is left turn, -Rotation is right turn. Range between -1 and 1. - */ - public void drive(XYPair translation, double rotation) { - drive(translation, rotation, false); - } - - /** - * Classic tank drive. - * @param left Power to the left drive motor. Range between -1 and 1. - * @param right Power to the right drive motor. Range between -1 and 1. - */ - public void drive(double left, double right) { - // the amount of "forward" we want to go is the average of the two joysticks - double yTranslation = (left + right) / 2; - - // the amount of rotation we want is the difference between the two joysticks, normalized - // to (-1, 1). - double rotation = (right - left) / 2; - - drive(new XYPair(0, yTranslation), rotation); - } - - public void fieldOrientedDrive( - XYPair translation, - double rotation, - double currentHeading, - boolean normalize) { - // rotate the translation vector into the robot coordinate frame - XYPair fieldRelativeVector = translation.clone(); - - // 90 degrees is the defined "forward" direction for a driver - fieldRelativeVector.rotate(-currentHeading); - - // send the rotated vector to be driven - drive(fieldRelativeVector, rotation, normalize); - } - - public void setQuickTurn(boolean value) { - isQuickTurn = value; - } - - double mQuickStopAccumulator; - public static final double kThrottleDeadband = 0.02; - private static final double kTurnSensitivity = 1.0; - /** - * Slightly adapted from 254's 2016 CheesyDriveHelper.java. - */ - public void cheesyDrive(double translation, double rotation) { - - double overPower; - double angularPower; - - if (isQuickTurn) { - overPower = 1.0; - // Rotation is directly proportional to rotation input - more like classic tank/arcade drive. - angularPower = rotation; - } else { - // If the robot isn't in QuickTurn, then we want smooth, controlled motion. The core concept is that - // rotational force is scaled proportionately to translation force. - // overPower is disabled - this means that if the robot hits any sort of saturation point, - // it just ignores it an continues. - overPower = 0.0; - // This is the core bit of logic - our rotation power is proportional to our translation power. - // The downside is that you cannot turn if you aren't moving - but if you wanted to do that, you would - // engage quick turn mode. - angularPower = Math.abs(translation) * rotation * kTurnSensitivity; - // Since we are no longer commanding quickTurn, this causes the quickStopAccumulator to decay much faster. - // In quick turn mode, it decays by 10% each tick - here, it's rapidly set to 0. - } - - double rightPwm = translation + angularPower; - double leftPwm = translation - angularPower; - - if (overPower >= 0) { - if (leftPwm > 1.0) { - rightPwm -= overPower * (leftPwm - 1.0); - leftPwm = 1.0; - } else if (rightPwm > 1.0) { - leftPwm -= overPower * (rightPwm - 1.0); - rightPwm = 1.0; - } else if (leftPwm < -1.0) { - rightPwm += overPower * (-1.0 - leftPwm); - leftPwm = -1.0; - } else if (rightPwm < -1.0) { - leftPwm += overPower * (-1.0 - rightPwm); - rightPwm = -1.0; - } - } - - drive(leftPwm, rightPwm); - } - - public void stop() { - drive(new XYPair(0, 0), 0); - } - - /** - * Classic arcade drive - * @param yTranslation Translation power. Range between -1 and 1. - * @param rotation Rotation power. Range between -1 and 1. - */ - public void arcadeDrive(double yTranslation, double rotation) { - drive(new XYPair(0, yTranslation), rotation); - } - - /** - * Classic tank drive. - * @param left Power to the left drive motor. Range between -1 and 1. - * @param right Power to the right drive motor. Range between -1 and 1. - */ - public void tankDrive(double left, double right) { - drive(left, right); - } - - /** - * Determine the largest commanded output for a given wheel for a given - * translation/rotation input. For example, you would see a maximum output of - * two in a Tank Drive system that's commanded to go forward at full speed AND - * rotate at full speed. - */ - protected double getMaxOutput(XYPair translation, double rotation) { - return Math.abs(translation.x) + Math.abs(translation.y) + Math.abs(rotation); - } -} diff --git a/src/main/java/xbot/common/subsystems/drive/ConfigurablePurePursuitCommand.java b/src/main/java/xbot/common/subsystems/drive/ConfigurablePurePursuitCommand.java deleted file mode 100644 index c311291e..00000000 --- a/src/main/java/xbot/common/subsystems/drive/ConfigurablePurePursuitCommand.java +++ /dev/null @@ -1,59 +0,0 @@ -package xbot.common.subsystems.drive; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; - -import javax.inject.Inject; - -import xbot.common.math.FieldPose; -import xbot.common.properties.PropertyFactory; -import xbot.common.subsystems.drive.control_logic.HeadingModule.HeadingModuleFactory; -import xbot.common.subsystems.pose.BasePoseSubsystem; - -public class ConfigurablePurePursuitCommand extends PurePursuitCommand { - private List originalPoints; - private PointLoadingMode mode; - private Supplier> externalPointSource; - - @Inject - public ConfigurablePurePursuitCommand(HeadingModuleFactory headingModuleFactory, BasePoseSubsystem pose, BaseDriveSubsystem drive, - PropertyFactory propMan) { - super(headingModuleFactory, pose, drive, propMan); - mode = PointLoadingMode.Absolute; - originalPoints = new ArrayList<>(); - externalPointSource = null; - } - - public void addPoint(RabbitPoint point) { - originalPoints.add(point); - } - - public void addPoint(FieldPose point) { - originalPoints.add(new RabbitPoint(point)); - } - - public void setMode(PointLoadingMode mode) { - this.mode = mode; - } - - public void setPoints(List points) { - this.originalPoints = points; - } - - public void setPointSupplier(Supplier> externalPointSource) { - this.externalPointSource = externalPointSource; - } - - protected List getOriginalPoints() { - if (externalPointSource != null) { - originalPoints = externalPointSource.get(); - } - return originalPoints; - } - - protected PointLoadingMode getPursuitMode() { - return this.mode; - } - -} diff --git a/src/main/java/xbot/common/subsystems/drive/MockDriveSubsystem.java b/src/main/java/xbot/common/subsystems/drive/MockDriveSubsystem.java deleted file mode 100644 index 0e52d5a2..00000000 --- a/src/main/java/xbot/common/subsystems/drive/MockDriveSubsystem.java +++ /dev/null @@ -1,118 +0,0 @@ -package xbot.common.subsystems.drive; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.controls.actuators.XCANTalon.XCANTalonFactory; -import xbot.common.injection.electrical_contract.CANTalonInfo; -import xbot.common.math.PIDManager; -import xbot.common.math.XYPair; -import xbot.common.math.PIDManager.PIDManagerFactory; - -@Singleton -public class MockDriveSubsystem extends BaseDriveSubsystem { - - final XCANTalonFactory canTalonFactory; - - public double leftTotalDistance; - public double rightTotalDistance; - public double transverseTotalDistance; - - public XCANTalon leftTank; - public XCANTalon rightTank; - - public XCANTalon fl; - public XCANTalon fr; - public XCANTalon rl; - public XCANTalon rr; - - private PIDManager positionalPid; - private PIDManager rotateToHeadingPid; - private PIDManager rotateDecayPid; - - @Inject - public MockDriveSubsystem(XCANTalonFactory canTalonFactory, PIDManagerFactory pf) { - this.canTalonFactory = canTalonFactory; - changeIntoTankDrive(); - - positionalPid = pf.create("Drive to position", 100, 0, 0, 0, 0.5, -0.5, 3, 1, 0.5); - rotateToHeadingPid = pf.create("DriveHeading", 100, 0, 0); - rotateDecayPid = pf.create("DriveDecay", 100, 0, 1); - } - - public void changePositionalPid(PIDManager p) { - positionalPid = p; - } - - public void changeRotationalPid(PIDManager p) { - rotateToHeadingPid = p; - } - - @Override - public void move(XYPair translate, double rotate) { - if (leftTank != null) { - leftTank.simpleSet(translate.y - rotate); - rightTank.simpleSet(translate.y + rotate); - } - if (fl != null) { - fl.simpleSet(translate.x - translate.y - rotate); - fr.simpleSet(translate.x + translate.y + rotate); - rl.simpleSet(translate.x + translate.y - rotate); - rr.simpleSet(translate.x - translate.y + rotate); - } - } - - public void changeIntoNoDrive() { - leftTank = null; - rightTank = null; - - fl = null; - fr = null; - rl = null; - rr = null; - } - - public void changeIntoTankDrive() { - leftTank = canTalonFactory.create(new CANTalonInfo(0)); - rightTank = canTalonFactory.create(new CANTalonInfo(1)); - } - - public void changeIntoMecanum() { - // for simple tests, assume tank drive. - fl = canTalonFactory.create(new CANTalonInfo(2)); - rl = canTalonFactory.create(new CANTalonInfo(3)); - fr = canTalonFactory.create(new CANTalonInfo(4)); - rr = canTalonFactory.create(new CANTalonInfo(5)); - } - - @Override - public double getLeftTotalDistance() { - return leftTotalDistance; - } - - @Override - public double getRightTotalDistance() { - return rightTotalDistance; - } - - @Override - public double getTransverseDistance() { - return transverseTotalDistance; - } - - @Override - public PIDManager getPositionalPid() { - return positionalPid; - } - - @Override - public PIDManager getRotateToHeadingPid() { - return rotateToHeadingPid; - } - - @Override - public PIDManager getRotateDecayPid() { - return rotateDecayPid; - } -} diff --git a/src/main/java/xbot/common/subsystems/drive/PurePursuitCommand.java b/src/main/java/xbot/common/subsystems/drive/PurePursuitCommand.java deleted file mode 100644 index b8379c7a..00000000 --- a/src/main/java/xbot/common/subsystems/drive/PurePursuitCommand.java +++ /dev/null @@ -1,513 +0,0 @@ -package xbot.common.subsystems.drive; - -import java.util.ArrayList; -import java.util.List; - -import edu.wpi.first.math.geometry.Rotation2d; -import xbot.common.command.BaseCommand; -import xbot.common.math.FieldPose; -import xbot.common.math.MathUtils; -import xbot.common.math.PIDManager; -import xbot.common.math.XYPair; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; -import xbot.common.subsystems.drive.RabbitPoint.PointDriveStyle; -import xbot.common.subsystems.drive.RabbitPoint.PointTerminatingType; -import xbot.common.subsystems.drive.RabbitPoint.PointType; -import xbot.common.subsystems.drive.control_logic.HeadingModule; -import xbot.common.subsystems.drive.control_logic.HeadingModule.HeadingModuleFactory; -import xbot.common.subsystems.pose.BasePoseSubsystem; - -public abstract class PurePursuitCommand extends BaseCommand { - - public enum PointLoadingMode { - Relative, Absolute - } - - public class RabbitChaseInfo { - public double translation; - public double rotation; - public FieldPose rabbit; - public FieldPose target; - public double distanceRemaining; - - public RabbitChaseInfo(double translation, double rotation) { - this(translation, rotation, null, null, 0); - } - - public RabbitChaseInfo(double translation, double rotation, FieldPose target, FieldPose rabbit) { - this(translation, rotation, target, rabbit, 0); - } - - public RabbitChaseInfo(double translation, double rotation, FieldPose target, FieldPose rabbit, double distanceRemaining) { - this.translation = translation; - this.rotation = rotation; - this.rabbit = rabbit; - this.target = target; - this.distanceRemaining = distanceRemaining; - } - } - - protected final BasePoseSubsystem poseSystem; - protected final BaseDriveSubsystem drive; - - protected final DoubleProperty rabbitLookAhead; - protected final DoubleProperty perpindicularRatioProp; - final DoubleProperty pointDistanceThreshold; - final DoubleProperty motionBudget; - - protected HeadingModule headingModule; - protected PIDManager positionalPid; - - HeadingModule defaultHeadingModule; - PIDManager defaultPositionalPid; - - private List pointsToVisit; - protected int pointIndex = 0; - private int processedPointIndex = -1; - private boolean stickyPursueForward = true; - private boolean wasForcingDriveToPoint = false; - private boolean useDotProductDriving = false; - - protected RabbitChaseInfo chaseData; - - /** - * An implementation of Pure Pursuit for FRC. We got the basic idea from here: - * http://www8.cs.umu.se/kurser/TDBD17/VT06/utdelat/Assignment%20Papers/Path%20Tracking%20for%20a%20Miniature%20Robot.pdf - * Fundamentally, you can add field points to this command (x,y, and rotation) and the robot will attempt to reach all those points - * with a smooth path. This works for any drive base, but presumably, holonomic robots can solve this problem more effectively. - * - * You will see references to rabbits, or "chasing the rabbit". This is alluding to how greyhoud races use mechanical rabbits, - * which is designed to always stay ahead of them, regardless of their speed. This is similiar to how, as the robot uses pure - * pursuit, it is always chasing a point it can never reach. - * @param headingModuleFactory HeadingModuleFactory - * @param pose BasePoseSubsystem - * @param drive BaseDriveSubsystem - * @param propMan PropertyManager - */ - public PurePursuitCommand(HeadingModuleFactory headingModuleFactory, BasePoseSubsystem pose, BaseDriveSubsystem drive, - PropertyFactory propMan) { - this.poseSystem = pose; - this.drive = drive; - this.addRequirements(drive); - propMan.setPrefix(this); - - // The lookahead is particularly important - for large values, driving will be very smooth, but it may take a very long time - // to converge to the proper path. Small values converge very quickly, but run a major risk of oscillation. - rabbitLookAhead = propMan.createPersistentProperty("Rabbit lookahead (in)", 12); - // Once under the pointDistanceThreshold, the algorithm prioritizes orientation over position. Essentially, if your point requests - // 15 degrees, and your robot is at 20 degrees by the time it gets here, it will immediately rotate to 15 degrees and drive "straight". - pointDistanceThreshold = propMan.createPersistentProperty("Rabbit distance threshold", 12.0); - // The motion budget was an attempt to smooth out driving. Essentially, requested rotation is subtracted from the budget, - // and translation can have what's left over. - // The goal was to reduce the "whiplash" when the robot tried to head to a point that required an immediate large turn and full speed motion. - // In practice, it didn't really work, but it did help the robot get oriented in roughly the right direction - // before zooming off. - motionBudget = propMan.createPersistentProperty("Motion Budget", 1); - perpindicularRatioProp = propMan.createPersistentProperty("PerpindicularRatio", 1.5); - defaultHeadingModule = headingModuleFactory.create(drive.getRotateToHeadingPid()); - defaultPositionalPid = drive.getPositionalPid(); - setPIDsToDefault(); - } - - /** - * By default, the PurePursuitCommand uses the HeadingModule and PositionalPid from the DriveSubsystem. However, - * if you want to change the PIDs used on the fly, you can here. - * @param headingModule Used for rotation - * @param positionalPid Used for translation - */ - public void setPIDs(HeadingModule headingModule, PIDManager positionalPid) { - this.headingModule = headingModule; - this.positionalPid = positionalPid; - } - - public void setPIDsToDefault() { - this.headingModule = defaultHeadingModule; - this.positionalPid = defaultPositionalPid; - } - - public void setDotProductDrivingEnabled(boolean enabled) { - useDotProductDriving = enabled; - } - - protected abstract List getOriginalPoints(); - protected abstract PointLoadingMode getPursuitMode(); - - /** - * If you want to see where this command is heading in the future (for visualization purposes, perhaps) you can - * get that information here. - * @return List of points to visit - */ - public List getPlannedPointsToVisit() { - return new ArrayList(pointsToVisit); - } - - @Override - public void initialize() { - log.info("Initializing"); - // We'll start at the first (and since this is computer programming, that means the "zeroth") point - pointIndex = 0; - processedPointIndex = -1; - - List originalPoints = this.getOriginalPoints(); - PointLoadingMode mode = this.getPursuitMode(); - - // If we started without any points, we gracefully return. - if (originalPoints == null || originalPoints.isEmpty()) { - log.warn("No target points specified; command will no-op"); - this.pointsToVisit = new ArrayList(); - return; - } - - // There are two main modes for points: Absolute and Relative. - // Absolute: Navigate to these points on the field, regardless of robot current position & orientation - // -- This is useful for navigating to field elements, or setting up repeatable autonomous routines - // Relative: remap these points into a robot-relative frame. - // -- This is useful for setting up repeating commands, like "go foward and right 3 feet, while turning right 90 degrees." - switch(mode) { - case Absolute: - // Nothing to do - points are typically in absolute mode. - pointsToVisit = originalPoints; - break; - case Relative: - // Time to rotate & remap these points. - // The robot always has a sense of where it is (X, Y, rotation). - // We just take the requested points and map them onto our current location to set up some new point goals. - pointsToVisit = new ArrayList<>(); - FieldPose currentRobotPose = poseSystem.getCurrentFieldPose(); - for (RabbitPoint originalPoint : originalPoints) { - // First, rotate the point according to the robot's current heading - XYPair updatedPoint = originalPoint.pose.getPoint().clone().rotate( - currentRobotPose.getHeading().getDegrees()); - - // Then, translate the point according to the robot's current field position - updatedPoint.add(currentRobotPose.getPoint()); - - // Finally, rotate the original's goal heading by the robot's current heading - double updatedHeading = originalPoint.pose.getHeading().getDegrees() - + currentRobotPose.getHeading().getDegrees(); - - FieldPose updatedPose = new FieldPose(updatedPoint, Rotation2d.fromDegrees(updatedHeading)); - pointsToVisit.add(new RabbitPoint( - updatedPose, - originalPoint.pointType, - originalPoint.terminatingType, - originalPoint.driveStyle)); - } - break; - default: - log.error("Tried to initialize a PurePursuitCommand with no proper mode set!"); - } - - log.info("Initialized PurePursuitCommand with " + pointsToVisit.size() + " point(s)"); - - if (pointsToVisit.size() > 0) { - chooseStickyPursuitForward(pointsToVisit.get(0)); - } - } - - @Override - public void execute() { - chaseData = evaluateCurrentPoint(); - drive.drive(new XYPair(0, chaseData.translation), chaseData.rotation); - } - - /** - * The robot tries to be a little smart here - if you want to visit a point behind you, but facing forward, it will - * just drive backwards instead of turning around, driving to the point, and turning around again. - * This needs to be "sticky" so that the robot doesn't turn a bunch if it overshoots the point in either direction. - * @param point Point to be evaulated against the robot's current position - */ - private void chooseStickyPursuitForward(RabbitPoint point) { - double distanceRemainingToPointAlongPath = - -point.pose.getDistanceAlongPoseLine(poseSystem.getCurrentFieldPose().getPoint()); - - if (distanceRemainingToPointAlongPath < 0) { - log.info("After analyzing the upcoming point, robot will attempt to pursue in reverse."); - stickyPursueForward = false; - } else { - log.info("After analyzing the upcoming point, robot will attempt to pursue forward."); - stickyPursueForward = true; - } - } - - public RabbitChaseInfo evaluateCurrentPoint(FieldPose robotPose) { - // If for some reason we have no points, or we go beyond our list, don't do anything. It would be good to add a - // logging latch here. - if (pointsToVisit.size() == 0 || pointIndex == pointsToVisit.size()) { - return new RabbitChaseInfo(0, 0); - } - - // Get our current state, as well as the point that says what we should be doing - RabbitPoint target = pointsToVisit.get(pointIndex); - RabbitChaseInfo recommendedAction = new RabbitChaseInfo(0, 0); - - // Depending on the PointType, take the appropriate action. - // - If we only need to rotate, we don't need the full point logic - we can just turn in place. - // - If we want to drive to the point, we need to "chase the rabbit", which we've encapsulated into another method. - processedPointIndex = pointIndex; - if (target.pointType == PointType.HeadingOnly) { - recommendedAction = rotateToRabbit(target); - } else if (target.pointType == PointType.PositionAndHeading) { - recommendedAction = chaseRabbit(target, robotPose); - } else if (target.pointType == PointType.PositionOnly) { - recommendedAction = driveToPoint(target, robotPose); - } - - return recommendedAction; - } - - /** - * This is the core method that looks at the point list, figures out which point to be heading towards, - * and doing the math on how to get there. - * @return Information about what the robot would like to do in order to reach its points. - */ - public RabbitChaseInfo evaluateCurrentPoint() { - return evaluateCurrentPoint(poseSystem.getCurrentFieldPose()); - } - - /** - * Just uses the HeadingModule to rotate. Nothing special here. - * @param target Point we are rotating to - * @return Information about what the robot would like to do in order to aim at the target point. - */ - private RabbitChaseInfo rotateToRabbit(RabbitPoint target) { - double turnPower = headingModule.calculateHeadingPower(target.pose.getHeading().getDegrees()); - if (headingModule.isOnTarget()) { - advancePointIfNotAtLastPoint(); - } - return new RabbitChaseInfo(0, turnPower); - } - - /** - * Uses the heading module to rotate to aim straight at the target, and drives straight there. This isn't pure - * pursuit at all, but sometimes we want to drive straight towards a point and don't care about our orientation. - * @param target The point you are trying to reach. Will drive straight there. - * @return Information about what the robot should do in order to drive directly at the target point. - */ - private RabbitChaseInfo driveToPoint(RabbitPoint target, FieldPose robotPose) { - RabbitChaseInfo r = driveToPointLogic(target, robotPose); - - if (Math.abs(r.distanceRemaining) < pointDistanceThreshold.get()) { - advancePointIfNotAtLastPoint(); - } - - return r; - } - - private RabbitChaseInfo driveToPointLogic(RabbitPoint target, FieldPose robotPose) { - double desiredHeading = robotPose.getAngleToPoint(target.pose.getPoint()); - double turnPower = headingModule.calculateHeadingPower(desiredHeading); - double distanceRemaining = robotPose.getPoint().getDistanceToPoint(target.pose.getPoint()); - double trueDistanceRemaining = distanceRemaining; - if (target.terminatingType != PointTerminatingType.Stop) { - distanceRemaining = 144; - } - double translationPower = positionalPid.calculate(distanceRemaining, 0); - double constrainedTranslation = constrainTranslation( - turnPower, translationPower, getDotProductWithRabbit(robotPose, target.pose.getPoint(), 1)); - - log.info(String.format("Mode: DriveToPoint. Point: %d, X:%.2f, Y:%.2f, DistanceR: %.2f, Rotate: %.2f, Power: %.2f", - pointIndex, target.pose.getPoint().x, target.pose.getPoint().y, - trueDistanceRemaining, turnPower, - constrainedTranslation)); - return new RabbitChaseInfo(constrainedTranslation, turnPower, target.pose, target.pose, trueDistanceRemaining); - } - - /** - * Advances to the next point in the list. - * If we are at the last point, we just hold onto that current point. - */ - private void advancePointIfNotAtLastPoint() { - if (pointIndex < pointsToVisit.size() && pointsToVisit.get(pointIndex).terminatingType == PointTerminatingType.Stop) { - RabbitPoint currentPoint = pointsToVisit.get(pointIndex); - FieldPose currentPose = currentPoint.pose; - log.info("Completed stop point (index " + pointIndex + "); " - + "goal: " + currentPose.toString() + ", actual: " + poseSystem.getCurrentFieldPose().toString()); - } - - if (pointIndex < pointsToVisit.size() - 1) { - pointIndex++; - chooseStickyPursuitForward(pointsToVisit.get(pointIndex)); - headingModule.reset(); - } - } - - /** - * // If the robot wants to turn, we can lower the translationPower to allow more stable turning. When - // the turn value decreases, we can allow more translationPower. This essentially slows down the robot - // in curves, and gives it full throttle on long stretches. - // Essentially, there is a total motion budget, and turning has first access to this budget. - // If this budget is 2 or higher, that's the same as having no budget at all. - * @param rotation The desired turn power - * @param translation The desired translation power, which will be constrained by the budget. - * @return The translation power, reduced by the rotation power in context of the total budget. - */ - private double constrainTranslation(double rotation, double translation, double dotProduct) { - if (useDotProductDriving) { - if (dotProduct < 0.75) { - return 0; - } - return translation *= dotProduct; - } else { - double remainingBudget = motionBudget.get() - Math.abs(rotation); - double constrainedRemainingBudget = MathUtils.constrainDouble(remainingBudget, 0, 1); - return translation * constrainedRemainingBudget; - } - } - - private double getDotProductWithRabbit(FieldPose robot, XYPair vectorToRabbit, double lookaheadFactor) { - // We want to drive towards the rabbit, but what if the rabbit is behind us and we need to rotate? - // We should perform a quick 3-point maneuver (back up while rotating, then drive forward while rotating) - // rather than turn in place. And, when we are at 90 degrees to the rabbit, we shouldn't be driving forward - // or backward at all. - XYPair robotUnitVector = new XYPair(robot.getHeading()); - return robotUnitVector.dotProduct( - vectorToRabbit.clone().scale(1/vectorToRabbit.getMagnitude())) * lookaheadFactor; - } - - /** - * All the math for rotating/translating towards the rabbit, which should lead us to our desired point. - * @param target The point we want to reach - * @param robot The current pose of the robot - * @return Information about what the robot should do in order to drive towards the target point. - */ - private RabbitChaseInfo chaseRabbit(RabbitPoint target, FieldPose robot) { - double distanceRemainingToPointAlongPath = -target.pose.getDistanceAlongPoseLine(robot.getPoint()); - double distanceRemainingToPointPerpindicularToPath = target.pose.getDistanceToLineFromPoint(robot.getPoint()); - double trueDistanceRemaining = distanceRemainingToPointAlongPath; - double crowFliesDistance = robot.getPoint().getDistanceToPoint(target.pose.getPoint()); - - // Sometimes, we can get into degenerate states where we are commanded to go to a point that is - // directly in front of the robot, but angled about 90 degrees to the robot. This causes two problems: - // 1) The logic to advance points thinks we are very close, so it goes to the next point - // 2) Even if (1) didn't happen, we still are not going to get the smooth change to the proper heading. - // As a solution, if the ratio of "distance to pose line" vs "distance along path" is too high, we instead go into a - // stupider mode until that ratio is reduced, as long as we are far away from the point. - double perpindicularRatio = Math.abs(distanceRemainingToPointPerpindicularToPath / distanceRemainingToPointAlongPath); - if (perpindicularRatio > perpindicularRatioProp.get() && Math.abs(crowFliesDistance) > pointDistanceThreshold.get()) { - log.info("Perpindicular ratio: " + perpindicularRatio + ". Forcing to DriveToPoint."); - FieldPose adjustedPoint = target.pose.getPointAlongPoseLine(-4*12); - RabbitPoint temporaryTarget = new RabbitPoint(adjustedPoint, PointType.HeadingOnly, PointTerminatingType.Continue); - wasForcingDriveToPoint = true; - return driveToPointLogic(temporaryTarget, robot); - } - if (wasForcingDriveToPoint) { - // We force drive to point in situations where we are highly perpindicular. Our sticky pursuit may have chosen - // very poorly, so we need to give it one more shot now that we are out of the cone of disaster. - wasForcingDriveToPoint = false; - chooseStickyPursuitForward(target); - } - - // If this distanceRemainingToPointAlongPath is positive, that means there is still some distance to go - // until the robot reaches the point. We will use standard math. - - // if the distance is negative, the goal is behind the robot. This can happen for two reasons: - // 1) We overshoot the point, and need to briefly reverse to get back to it - // 2) The point was intentionally placed behind us, and it's more efficient to reverse towards it - // rather than doing a bunch of turns. - // In both of those cases, we need to - // -flip the rabbit so it is behind the robot instead of ahead of the robot - // -aim at an angle 180* away from the rabbit, instead of towards the rabbit - // -drive backwards, instead of forwards - - // If we are in sticky forward, use normal values. - double lookaheadFactor = 1; - double aimFactor = 0; - // If we are in sticky backward, use the reversed values. - if (!stickyPursueForward) { - lookaheadFactor = -1; - aimFactor = 180; - } - - // If we are in Micro mode, we bring the rabbit much closer. This allows us to converge on the line faster. - // When using Micro mode, it is highly recommended to limit maximum translation speed somehow. - double candidateLookahead = rabbitLookAhead.get(); - if (target.driveStyle == PointDriveStyle.Micro) { - candidateLookahead /= 2; - } - - // These functions calculate the absolute position of the rabbit, and then the angle the robot needs - // to rotate to in order to face the rabbit. - FieldPose rabbitLocation = target.pose.getRabbitPose(robot.getPoint(), candidateLookahead*lookaheadFactor); - XYPair vectorToRabbit = target.pose.getVectorToRabbit(robot, candidateLookahead*lookaheadFactor); - double angleToRabbit = vectorToRabbit.getAngle() + aimFactor; - double goalAngle = angleToRabbit; - - // Once we are very close to the point, we force the final heading. Most of the time, proper rotation is more important than proper - // translation. However, if your task requires very precise lateral positioning, you should consider reducing the pointDistanceThreshold to 0. - // We should only do this on final points - super-precise rotation is not important for intermediate points. - if ((Math.abs(distanceRemainingToPointAlongPath) < pointDistanceThreshold.get()) - && - (target.terminatingType == PointTerminatingType.Stop)) { - goalAngle = target.pose.getHeading().getDegrees(); - } - - double turnPower = headingModule.calculateHeadingPower(goalAngle); - - // To avoid stopping at every point on a path, intermediate points are commonly marked as Continue. Here, - // we blow away the previous distance calculation to the point and replace it with 12 feet. This will implicitly - // make any translation PID use full power. - // However, what if somebody accidentially made the last point in a series a continuing point? The robot could be damaged, or damage something - // else. - // As a precaution, we enforce that the last point is a terminating point. - if (target.terminatingType == PointTerminatingType.Continue) { - if (pointIndex < pointsToVisit.size() - 1) { - distanceRemainingToPointAlongPath = 144 * lookaheadFactor; - } - } - - - double dotProduct = getDotProductWithRabbit(robot, vectorToRabbit, lookaheadFactor); - double translationPower = positionalPid.calculate(distanceRemainingToPointAlongPath, 0); - double constrainedTranslation = constrainTranslation(turnPower, translationPower, dotProduct); - - // Log the output. This could be commented out, but for now, it has been very useful for debugging why the robot is driving - // somewhere... unexpected. - log.info(String.format("Mode: PurePursuit. Point: %d, X:%.2f, Y:%.2f, DistanceR: %.2f, Rotate: %.2f, Power: %.2f", - pointIndex, target.pose.getPoint().x, target.pose.getPoint().y, - trueDistanceRemaining, turnPower, - constrainedTranslation)); - - // In Micro mode, we want to be very, very sure we get to these points accurately, so we reduce the threshold to 25%. - double distanceThreshold = pointDistanceThreshold.get(); - if (target.driveStyle == PointDriveStyle.Micro) { - distanceThreshold /= 4; - } - - // Once we're close enough to an intermediate point, we may as well start working on the next one. - if (Math.abs(trueDistanceRemaining) < distanceThreshold) { - advancePointIfNotAtLastPoint(); - } - - return new RabbitChaseInfo(constrainedTranslation, turnPower, target.pose, rabbitLocation); - } - - @Override - public void end(boolean interrupted) { - drive.stop(); - } - - @Override - public boolean isFinished() { - if (pointsToVisit == null || pointsToVisit.isEmpty()) { - return true; - } - - if (processedPointIndex != pointIndex) { - return false; - } - - // if the PID is stable, and we're at the last point, we're done. - if (pointsToVisit.get(pointIndex).pointType == PointType.HeadingOnly) { - return headingModule.isOnTarget() && (pointIndex == pointsToVisit.size() - 1); - } - else { - return drive.getPositionalPid().isOnTarget() && (pointIndex == pointsToVisit.size() - 1); - } - } - - public double getMotionBudget() { - return motionBudget.get(); - } -} diff --git a/src/main/java/xbot/common/subsystems/drive/RabbitPoint.java b/src/main/java/xbot/common/subsystems/drive/RabbitPoint.java deleted file mode 100644 index 339dd32a..00000000 --- a/src/main/java/xbot/common/subsystems/drive/RabbitPoint.java +++ /dev/null @@ -1,60 +0,0 @@ -package xbot.common.subsystems.drive; - -import java.util.ArrayList; -import java.util.List; - -import edu.wpi.first.math.geometry.Rotation2d; -import xbot.common.math.FieldPose; -import xbot.common.math.XYPair; - -public class RabbitPoint { - - public enum PointType { - PositionAndHeading, HeadingOnly, PositionOnly - } - - public enum PointTerminatingType { - Continue, Stop - } - - public enum PointDriveStyle { - Macro, Micro - } - - public PointType pointType; - public PointTerminatingType terminatingType; - public PointDriveStyle driveStyle; - public FieldPose pose; - - public RabbitPoint(double x, double y, double heading) { - this(new FieldPose(new XYPair(x, y), Rotation2d.fromDegrees(heading))); - } - - public RabbitPoint(FieldPose pose) { - this(pose, PointType.PositionAndHeading, PointTerminatingType.Continue, PointDriveStyle.Macro); - } - - public RabbitPoint(FieldPose pose, PointType pointType, PointTerminatingType terminatingType) { - this(pose, pointType, terminatingType, PointDriveStyle.Macro); - } - - public RabbitPoint(FieldPose pose, PointType pointType, PointTerminatingType terminatingType, - PointDriveStyle driveStyle) { - this.pose = pose; - this.pointType = pointType; - this.terminatingType = terminatingType; - this.driveStyle = driveStyle; - } - - public static List upgradeFieldPoseList(List oldPoints) { - List rabbitPoints = new ArrayList<>(); - oldPoints.stream().forEach(point -> rabbitPoints.add(new RabbitPoint(point))); - return rabbitPoints; - } - - public static List downgradeRabbitPointList(List rabbitPoints) { - List fieldPoints = new ArrayList<>(); - rabbitPoints.stream().forEach(rabbitPoint -> fieldPoints.add(rabbitPoint.pose)); - return fieldPoints; - } -} diff --git a/src/main/java/xbot/common/subsystems/drive/RabbitPointBuilder.java b/src/main/java/xbot/common/subsystems/drive/RabbitPointBuilder.java deleted file mode 100644 index 1505a948..00000000 --- a/src/main/java/xbot/common/subsystems/drive/RabbitPointBuilder.java +++ /dev/null @@ -1,46 +0,0 @@ -package xbot.common.subsystems.drive; - -import java.util.ArrayList; -import java.util.List; - -import xbot.common.math.FieldPose; -import xbot.common.subsystems.drive.RabbitPoint.PointDriveStyle; -import xbot.common.subsystems.drive.RabbitPoint.PointTerminatingType; -import xbot.common.subsystems.drive.RabbitPoint.PointType; - -public class RabbitPointBuilder { - - List output; - - private PointType pointType = PointType.PositionAndHeading; - private PointTerminatingType terminatingType = PointTerminatingType.Continue; - private PointDriveStyle driveStyle = PointDriveStyle.Macro; - - public RabbitPointBuilder() { - output = new ArrayList<>(); - } - - public RabbitPointBuilder addPose(FieldPose pose) { - output.add(new RabbitPoint(pose, pointType, terminatingType, driveStyle)); - return this; - } - - public RabbitPointBuilder changePointType(PointType newPointType) { - pointType = newPointType; - return this; - } - - public RabbitPointBuilder changeTerminatingType(PointTerminatingType newTerminatingType) { - terminatingType = newTerminatingType; - return this; - } - - public RabbitPointBuilder changeDriveStyle(PointDriveStyle newStyle) { - driveStyle = newStyle; - return this; - } - - public List build() { - return output; - } -} diff --git a/src/main/java/xbot/common/subsystems/drive/SimulatedPurePursuitCommand.java b/src/main/java/xbot/common/subsystems/drive/SimulatedPurePursuitCommand.java deleted file mode 100644 index 7d969d06..00000000 --- a/src/main/java/xbot/common/subsystems/drive/SimulatedPurePursuitCommand.java +++ /dev/null @@ -1,58 +0,0 @@ -package xbot.common.subsystems.drive; - -import javax.inject.Inject; - -import edu.wpi.first.wpilibj.util.Color; -import xbot.common.math.FieldPose; -import xbot.common.math.XYPair; -import xbot.common.properties.PropertyFactory; -import xbot.common.simulation.WebotsClient; -import xbot.common.subsystems.drive.control_logic.HeadingModule.HeadingModuleFactory; -import xbot.common.subsystems.pose.BasePoseSubsystem; - -public class SimulatedPurePursuitCommand extends ConfigurablePurePursuitCommand { - - private final WebotsClient webots; - - @Inject - public SimulatedPurePursuitCommand(HeadingModuleFactory headingModuleFactory, BasePoseSubsystem pose, BaseDriveSubsystem drive, - PropertyFactory propMan, WebotsClient webots) { - super(headingModuleFactory, pose, drive, propMan); - this.webots = webots; - } - - @Override - public void execute() { - super.execute(); - - // Draw a line from the robot to the "Rabbit" - webots.drawLine("RabbitLine", poseSystem.getCurrentFieldPose().getPoint(), chaseData.rabbit.getPoint(), Color.kGreen, 60); - - // Draw a line from the Rabbit to the goal point - webots.drawLine("PoseLine", chaseData.rabbit.getPoint(), chaseData.target.getPoint(), Color.kYellow, 60); - - // Draw something at all the planned points - // Could be two lines of different color, using the pointAlongPose feature - int i = 1; - for (RabbitPoint plannedPoint : this.getPlannedPointsToVisit()) { - FieldPose ahead = plannedPoint.pose.getPointAlongPoseLine(12); - FieldPose behind = plannedPoint.pose.getPointAlongPoseLine(-12); - - webots.drawLine("PlannedPointAhead"+i, ahead.getPoint(), plannedPoint.pose.getPoint(), Color.kBlue, 60); - webots.drawLine("PlannedPointBehind"+i, behind.getPoint(), plannedPoint.pose.getPoint(), Color.kRed, 60); - - i++; - } - } - - @Override - public void end(boolean interrupted) { - super.end(interrupted); - // Clear out all the nav markers when this command is no longer active - for (int i = 0; i < this.getPlannedPointsToVisit().size(); i++){ - webots.drawLine("PlannedPointAhead"+i, new XYPair(0,0), new XYPair(0,0), Color.kBlue, 60); - webots.drawLine("PlannedPointBehind"+i, new XYPair(0,0), new XYPair(0,0), Color.kRed, 60); - i++; - } - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/subsystems/drive/control_logic/HeadingAssistModule.java b/src/main/java/xbot/common/subsystems/drive/control_logic/HeadingAssistModule.java deleted file mode 100644 index 77b60299..00000000 --- a/src/main/java/xbot/common/subsystems/drive/control_logic/HeadingAssistModule.java +++ /dev/null @@ -1,166 +0,0 @@ -package xbot.common.subsystems.drive.control_logic; - - -import org.apache.log4j.Logger; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import xbot.common.controls.sensors.XTimer; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; -import xbot.common.subsystems.pose.BasePoseSubsystem; - -/** - * Encaspulates a useful bit of driving logic: - The robot should attempt to - * hold its current heading, even if it's temporarily rotated by outside forces. - * - If the human driver wants the robot to turn (above some small threshold), - * then the robot should turn according to human desires. - After a few moments, - * the robot should memorize its current heading, and attempt to hold it again. - * - * The automatic response can take one of two forms: - Hold a specific heading, - * as mentioned above, using a PID controller - Resist changes in rotational - * velocity using a D-only controller. - * - * @author jogilber - * - */ -public class HeadingAssistModule { - - final BasePoseSubsystem pose; - final HeadingModule headingModule; - final HeadingModule decayModule; - - final DoubleProperty humanThreshold; - final DoubleProperty coastTime; - double desiredHeading; - double lastHumanInput; - boolean inAutomaticMode; - private HeadingAssistMode headingMode; - - public enum HeadingAssistMode { - HoldOrientation, - DecayVelocity - } - - private Logger log = Logger.getLogger("HeadingAssistModule"); - - @AssistedFactory - public abstract static class HeadingAssistModuleFactory { - /** - * Creates a heading assist module. Can either hold an orientation, or resist - * rotational motion. - * - * @param headingModule Tune this one to rotate to a target orientation (PD, or - * PID controller) - * @param decayModule Tune this one to resist rotation (D controller) - * @return HeadingAssistModule instance - */ - public abstract HeadingAssistModule create( - @Assisted("headingModule") HeadingModule headingModule, - @Assisted("decayModule") HeadingModule decayModule, - @Assisted("prefix") String prefix); - - public HeadingAssistModule create(HeadingModule headingModule, String prefix) { - return create(headingModule, null, prefix); - } - } - - @AssistedInject - public HeadingAssistModule( - @Assisted("headingModule") HeadingModule headingModule, - @Assisted("decayModule") HeadingModule decayModule, - @Assisted("prefix") String prefix, - PropertyFactory propMan, - BasePoseSubsystem pose) { - this.headingModule = headingModule; - this.decayModule = decayModule; - this.pose = pose; - propMan.setPrefix(prefix); - humanThreshold = propMan.createPersistentProperty("HeadingAssistModule/Human Threshold", 0.05); - coastTime = propMan.createPersistentProperty("Heading Assist Module/Coast Time", 0.5); - lastHumanInput = 0; - this.headingMode = HeadingAssistMode.HoldOrientation; - } - - public void setMode(HeadingAssistMode mode) { - this.headingMode = mode; - } - - public void reset() { - headingModule.reset(); - if (decayModule != null) { - decayModule.reset(); - } - inAutomaticMode = false; - } - - /** - * Core method of the HeadingAssistModule. You input the human rotational power - * input, - * and this will determine whether or not to have the human drive the robot or - * whether the robot - * should continue on its last heading. - * - * In either case, it will return the suggested power output to the drive - * subsystem in order to achieve - * those goals. - * - * @param humanRotationalPower - values between -1 and 1, in terms of "maximum - * rotational power" - * @return values between -1 and 1, in terms of "how hard you should try in - * order to satisfy rotational goals." - */ - public double calculateHeadingPower(double humanRotationalPower) { - - if (pose.getHeadingResetRecently()) { - reset(); - return humanRotationalPower; - } - - // if human rotational power above some threshold, return that. - // Also, update a timestamp that says this happened recently - if (Math.abs(humanRotationalPower) > humanThreshold.get()) { - inAutomaticMode = false; - lastHumanInput = XTimer.getFPGATimestamp(); - return humanRotationalPower; - } - - // If not under threshold, but too close to timestamp, - // "coast" - double timeSinceHumanInput = XTimer.getFPGATimestamp() - lastHumanInput; - - if (timeSinceHumanInput < coastTime.get()) { - return 0; - } else if (timeSinceHumanInput >= coastTime.get() && !inAutomaticMode) { - desiredHeading = pose.getCurrentHeading().getDegrees(); - inAutomaticMode = true; - headingModule.reset(); - if (decayModule != null) { - decayModule.reset(); - } - return 0; - } - // by this point, the only option left is that the machine is in automatic mode. - else { - if (headingMode == null) { - log.warn("Heading module did not have any mode set. Forcing to HoldOrientation."); - this.headingMode = HeadingAssistMode.HoldOrientation; - } - - switch (headingMode) { - case HoldOrientation: - return headingModule.calculateHeadingPower(desiredHeading); - case DecayVelocity: - if (decayModule != null) { - return decayModule.calculateHeadingPower(0); - } else { - return 0; - } - default: - return 0; - } - } - } -} diff --git a/src/main/java/xbot/common/subsystems/drive/control_logic/HeadingModule.java b/src/main/java/xbot/common/subsystems/drive/control_logic/HeadingModule.java deleted file mode 100644 index 72b521cc..00000000 --- a/src/main/java/xbot/common/subsystems/drive/control_logic/HeadingModule.java +++ /dev/null @@ -1,75 +0,0 @@ -package xbot.common.subsystems.drive.control_logic; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.math.geometry.Rotation2d; -import xbot.common.math.PIDManager; -import xbot.common.properties.PropertyFactory; -import xbot.common.subsystems.pose.BasePoseSubsystem; - -/** - * Encapsulates the logic needed to rotate the robot to a specific angle. - * When using a PD or PID controller, it will attempt to reach that angle. - * When using a D-only controller, it will just resist any rotational motion. - * @author John - * - */ -public class HeadingModule { - - final BasePoseSubsystem pose; - private final PIDManager headingDrivePid; - - private Rotation2d targetHeading; - - public final double defaultPValue = 1/80d; - - @AssistedFactory - public abstract static class HeadingModuleFactory { - public abstract HeadingModule create(@Assisted("headingDrivePid") PIDManager headingDrivePid); - } - - @AssistedInject - public HeadingModule( - @Assisted("headingDrivePid") PIDManager headingDrivePid, - BasePoseSubsystem pose, - PropertyFactory propMan) - { - this.pose = pose; - - this.headingDrivePid = headingDrivePid; - targetHeading = new Rotation2d(); - } - - public boolean isOnTarget() { - return headingDrivePid.isOnTarget(); - } - - public void reset() { - headingDrivePid.reset(); - } - - public double calculateHeadingPower(double desiredHeading) { - // We need to calculate our own error function. Why? - // PID works great, but it assumes there is a linear relationship between your current state and - // your target state. Since rotation is circular, that's not the case: if you are at 170 degrees, - // and you want to go to -170 degrees, you could travel -340 degrees... or just +20. - - // So, we perform our own error calculation here that takes that into account (thanks to the ContiguousDouble - // class, which is aware of such circular effects), and then feed that into a PID where - // Goal is 0 and Current is our error. - - targetHeading = Rotation2d.fromDegrees(desiredHeading); - double errorInDegrees = pose.getCurrentHeading().minus(targetHeading).getDegrees(); - - // Now we feed it into a PID system, where the goal is to have 0 error. - double rotationalPower = headingDrivePid.calculate(0, errorInDegrees); - - return rotationalPower; - } - - public double calculateHeadingPower(Rotation2d desiredHeading) { - return calculateHeadingPower(desiredHeading.getDegrees()); - } -} \ No newline at end of file diff --git a/src/main/java/xbot/common/subsystems/feedback/IRumbler.java b/src/main/java/xbot/common/subsystems/feedback/IRumbler.java deleted file mode 100644 index 38a94f5a..00000000 --- a/src/main/java/xbot/common/subsystems/feedback/IRumbler.java +++ /dev/null @@ -1,5 +0,0 @@ -package xbot.common.subsystems.feedback; - -public interface IRumbler { - public XRumbleManager getRumbleManager(); -} \ No newline at end of file diff --git a/src/main/java/xbot/common/subsystems/feedback/RumbleManager.java b/src/main/java/xbot/common/subsystems/feedback/RumbleManager.java deleted file mode 100644 index cf9f685c..00000000 --- a/src/main/java/xbot/common/subsystems/feedback/RumbleManager.java +++ /dev/null @@ -1,71 +0,0 @@ -package xbot.common.subsystems.feedback; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import edu.wpi.first.wpilibj.GenericHID; -import edu.wpi.first.wpilibj.GenericHID.RumbleType; -import xbot.common.controls.sensors.XJoystick; -import xbot.common.controls.sensors.XTimer; - -/** - * Wrappers around gamepad rumble behavior to control intensity and duration. - */ -public class RumbleManager implements XRumbleManager { - private double lastRequestEndTime = -1; - private XJoystick gamepad; - private boolean isRumbling; - - @AssistedFactory - public abstract static class RumbleManagerFactory implements XRumbleManagerFactory { - public abstract RumbleManager create(@Assisted("gamepad") XJoystick gamepad); - } - - /** - * Creates a new RumbleManager instance. - * @param gamepad The gamepad in which to control rumble on. - */ - @AssistedInject - public RumbleManager(@Assisted("gamepad") XJoystick gamepad) { - this.gamepad = gamepad; - } - - public void stopGamepadRumble() { - writeRumble(gamepad, 0); - lastRequestEndTime = -1; - } - - public void rumbleGamepad(double intensity, double length) { - writeRumble(gamepad, intensity); - lastRequestEndTime = XTimer.getFPGATimestamp() + length; - } - - public boolean getIsRumbling() { - return isRumbling; - } - - public void periodic() { - if (isRumbling && lastRequestEndTime > 0 && XTimer.getFPGATimestamp() > lastRequestEndTime) { - writeRumble(gamepad, 0); - lastRequestEndTime = -1; - isRumbling = false; - } - } - - /** - * Writes the rumble value to the specified joystick. - * @param joystick Joystick to set the rumble value on. - * @param intensity Rumble intensity, between 0 and 1. - */ - private void writeRumble(XJoystick joystick, double intensity) { - - GenericHID internalJoystick = joystick.getGenericHID(); - isRumbling = intensity > 0; - if (internalJoystick == null) { - return; - } - internalJoystick.setRumble(RumbleType.kLeftRumble, intensity); - internalJoystick.setRumble(RumbleType.kRightRumble, intensity); - } -} diff --git a/src/main/java/xbot/common/subsystems/feedback/XRumbleManager.java b/src/main/java/xbot/common/subsystems/feedback/XRumbleManager.java deleted file mode 100644 index fbbf6e9c..00000000 --- a/src/main/java/xbot/common/subsystems/feedback/XRumbleManager.java +++ /dev/null @@ -1,33 +0,0 @@ -package xbot.common.subsystems.feedback; - -import xbot.common.controls.sensors.XJoystick; - -public interface XRumbleManager { - - public interface XRumbleManagerFactory { - XRumbleManager create(XJoystick gamepad); - } - - /** - * Rumbles the gamepad at the specified intensity for the given duration. - * @param intensity Rumble intensity, between 0 and 1. - * @param length Rumble duration, in seconds - */ - void rumbleGamepad(double intensity, double length); - - /** - * Immediately stops rumbling on the gamepad. - */ - void stopGamepadRumble(); - - /** - * Gets the current rumble state. - * @return true if the gamepad is currently rumbling. - */ - boolean getIsRumbling(); - - /** - * Called periodically to update the rumble state. - */ - void periodic(); -} diff --git a/src/main/java/xbot/common/subsystems/pose/BasePoseSubsystem.java b/src/main/java/xbot/common/subsystems/pose/BasePoseSubsystem.java deleted file mode 100644 index 658d0b03..00000000 --- a/src/main/java/xbot/common/subsystems/pose/BasePoseSubsystem.java +++ /dev/null @@ -1,290 +0,0 @@ -package xbot.common.subsystems.pose; - -import edu.wpi.first.math.geometry.Pose2d; -import edu.wpi.first.math.geometry.Rotation2d; -import edu.wpi.first.math.geometry.Translation2d; -import xbot.common.command.BaseSubsystem; -import xbot.common.controls.sensors.XGyro; -import xbot.common.controls.sensors.XTimer; -import xbot.common.controls.sensors.XGyro.XGyroFactory; -import xbot.common.math.FieldPose; -import xbot.common.math.WrappedRotation2d; -import xbot.common.math.XYPair; -import xbot.common.properties.BooleanProperty; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; - -public abstract class BasePoseSubsystem extends BaseSubsystem { - - public final XGyro imu; - - protected final DoubleProperty leftDriveDistance; - protected final DoubleProperty rightDriveDistance; - - protected final DoubleProperty totalDistanceX; - protected final DoubleProperty totalDistanceY; - protected final DoubleProperty totalDistanceYRobotPerspective; - public final DoubleProperty velocityX; - public final DoubleProperty velocityY; - protected final DoubleProperty totalVelocity; - - protected WrappedRotation2d currentHeading; - protected final DoubleProperty currentHeadingProp; - protected final DoubleProperty currentCompassHeadingProp; - protected final DoubleProperty headingAngularVelocityProp; - protected double headingOffset; - - // These are two common robot starting positions - kept here as convenient shorthand. - public static final double FACING_AWAY_FROM_DRIVERS = 0; - public static final double FACING_TOWARDS_DRIVERS = -180; - public static final double INCHES_IN_A_METER = 39.3701; - - protected final DoubleProperty currentPitch; - protected final DoubleProperty currentRoll; - - protected final DoubleProperty inherentRioPitch; - protected final DoubleProperty inherentRioRoll; - - protected double previousLeftDistance; - protected double previousRightDistance; - - protected final double classInstantiationTime; - protected boolean isNavXReady = false; - - protected BooleanProperty rioRotated; - protected boolean firstUpdate = true; - - protected double lastSetHeadingTime; - - public BasePoseSubsystem(XGyroFactory gyroFactory, PropertyFactory propManager) { - log.info("Creating"); - propManager.setPrefix(this); - imu = gyroFactory.create(); - this.classInstantiationTime = XTimer.getFPGATimestamp(); - - // Right when the system is initialized, we need to have the old value be - // the same as the current value, to avoid any sudden changes later - currentHeading = WrappedRotation2d.fromDegrees(0); - - currentHeadingProp = propManager.createEphemeralProperty("CurrentHeading", currentHeading.getDegrees()); - currentCompassHeadingProp = propManager.createEphemeralProperty("Current compass heading", getCompassHeading(currentHeading)); - headingAngularVelocityProp = propManager.createEphemeralProperty("Heading Rotational Velocity", 0.0); - - currentPitch = propManager.createEphemeralProperty("Current pitch", 0.0); - currentRoll = propManager.createEphemeralProperty("Current roll", 0.0); - - leftDriveDistance = propManager.createEphemeralProperty("Left drive distance", 0.0); - rightDriveDistance = propManager.createEphemeralProperty("Right drive distance", 0.0); - - totalDistanceX = propManager.createEphemeralProperty("Total distance X", 0.0); - totalDistanceY = propManager.createEphemeralProperty("Total distance Y", 0.0); - totalDistanceYRobotPerspective = propManager.createEphemeralProperty("Total distance Y Robot Perspective", 0.0); - - velocityX = propManager.createEphemeralProperty("X Velocity", 0.0); - velocityY = propManager.createEphemeralProperty("Y Velocity", 0.0); - totalVelocity = propManager.createEphemeralProperty("Total Velocity", 0.0); - - rioRotated = propManager.createPersistentProperty("RIO rotated", false); - inherentRioPitch = propManager.createPersistentProperty("Inherent RIO pitch", 0.0); - inherentRioRoll = propManager.createPersistentProperty("Inherent RIO roll", 0.0); - } - - protected double getCompassHeading(Rotation2d standardHeading) { - return Rotation2d.fromDegrees(currentHeading.getDegrees()).getDegrees(); - } - - protected void updateCurrentHeading() { - currentHeading = WrappedRotation2d.fromDegrees(getRobotYaw().getDegrees() + headingOffset); - - currentHeadingProp.set(currentHeading.getDegrees()); - currentCompassHeadingProp.set(getCompassHeading(currentHeading)); - - headingAngularVelocityProp.set(getYawAngularVelocity()); - - currentPitch.set(getRobotPitch()); - currentRoll.set(getRobotRoll()); - } - - protected void updateOdometry() { - - double currentLeftDistance = getLeftDriveDistance(); - double currentRightDistance = getRightDriveDistance(); - - leftDriveDistance.set(currentLeftDistance); - rightDriveDistance.set(currentRightDistance); - - if (firstUpdate) - { - // For the very first update, we set the previous distance to the current distance - that way, - // if the drive system initially reports non-zero travel distance, we will still report 0 initial - // distance traveled. - firstUpdate = false; - previousLeftDistance = currentLeftDistance; - previousRightDistance = currentRightDistance; - } - - double deltaLeft = currentLeftDistance - previousLeftDistance; - double deltaRight = currentRightDistance - previousRightDistance; - - double totalDistance = (deltaLeft + deltaRight) / 2; - totalDistanceYRobotPerspective.set(totalDistanceYRobotPerspective.get() + totalDistance); - - // get X and Y - double deltaY = currentHeading.getSin() * totalDistance; - double deltaX = currentHeading.getCos() * totalDistance; - - double instantVelocity = Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)); - - totalDistanceX.set(totalDistanceX.get() + deltaX); - totalDistanceY.set(totalDistanceY.get() + deltaY); - - velocityX.set(deltaX); - velocityY.set(deltaY); - totalVelocity.set(instantVelocity); - - // save values for next round - previousLeftDistance = currentLeftDistance; - previousRightDistance = currentRightDistance; - } - - /** - * @return Current heading but if the navX is still booting up it will return 0 - */ - public WrappedRotation2d getCurrentHeading() { - updateCurrentHeading(); - return currentHeading; - } - - public XYPair getFieldOrientedTotalDistanceTraveled() { - return getTravelVector().clone(); - } - - protected XYPair getTravelVector() { - return new XYPair(totalDistanceX.get(), totalDistanceY.get()); - } - - public FieldPose getCurrentFieldPose() { - return new FieldPose(getTravelVector(), getCurrentHeading()); - } - - public Pose2d getCurrentPose2d() { - var travelVector = getTravelVector(); - return new Pose2d( - travelVector.x, - travelVector.y, - Rotation2d.fromDegrees(getCurrentHeading().getDegrees()) - ); - } - - public XYPair getCurrentVelocity() { - return new XYPair(velocityX.get(), velocityY.get()); - } - - public double getCurrentHeadingAngularVelocity() { - return headingAngularVelocityProp.get(); - } - - /** - * Returns the distance the robot has traveled forward. Rotations are ignored - if you drove forward 100 inches, - * then turned 180 degrees and drove another 100 inches, this would tell you that you have traveled 200 inches. - * @return Distance in inches traveled forward from the robot perspective - */ - public double getRobotOrientedTotalDistanceTraveled() { - return totalDistanceYRobotPerspective.get(); - } - - public void resetDistanceTraveled() { - totalDistanceX.set(0); - totalDistanceY.set(0); - totalDistanceYRobotPerspective.set(0); - } - - public void setCurrentHeading(double headingInDegrees){ - log.info("Forcing heading to: " + headingInDegrees); - double rawHeading = getRobotYaw().getDegrees(); - log.info("Raw heading is: " + rawHeading); - headingOffset = -rawHeading + headingInDegrees; - log.info("Offset calculated to be: " + headingOffset); - - lastSetHeadingTime = XTimer.getFPGATimestamp(); - } - - public void setCurrentPosition(double newXPosition, double newYPosition) { - log.info("Setting Robot Position. X:" + newXPosition + ", Y:" +newYPosition); - totalDistanceX.set(newXPosition); - totalDistanceY.set(newYPosition); - } - - public boolean getHeadingResetRecently() { - return XTimer.getFPGATimestamp() - lastSetHeadingTime < 1; - } - - /** - * This should be called as often as reasonably possible, to increase accuracy - * of the "distance traveled" calculation. - * - * The PoseSubsystem can't directly own positional sensors, so some command will need to feed in the - * distance values coming from the DriveSubsystem. In order to have accurate calculations, these - * values need to be in inches, and should never be reset - any resetting should be done here - * in the PoseSubsystem - */ - protected void updatePose() { - updateCurrentHeading(); - updateOdometry(); - } - - protected abstract double getLeftDriveDistance(); - protected abstract double getRightDriveDistance(); - - public double getRobotPitch() { - return getUntrimmedPitch() - inherentRioPitch.get(); - } - - public double getRobotRoll() { - return getUntrimmedRoll() - inherentRioRoll.get(); - } - - /** - * If the RoboRIO is mounted in a position other than "flat" (e.g. with the pins facing upward) - * then this method will need to be overridden. - */ - protected WrappedRotation2d getRobotYaw() { - return imu.getHeading(); - } - - protected double getUntrimmedPitch() { - if (rioRotated.get()) { - return imu.getRoll(); - } - return imu.getPitch(); - } - - protected double getUntrimmedRoll() { - if (rioRotated.get()) { - return imu.getPitch(); - } - return imu.getRoll(); - } - - public void calibrateInherentRioOrientation() { - inherentRioPitch.set(getUntrimmedPitch()); - inherentRioRoll.set(getUntrimmedRoll()); - } - - public double getYawAngularVelocity(){ - return imu.getYawAngularVelocity(); - } - - public boolean getNavXReady() { - return isNavXReady; - } - - @Override - public void periodic() { - if (!isNavXReady && (classInstantiationTime + 1 < XTimer.getFPGATimestamp())) { - setCurrentHeading(FACING_AWAY_FROM_DRIVERS); - isNavXReady = true; - } - updatePose(); - } -} diff --git a/src/main/java/xbot/common/subsystems/pose/MockBasePoseSubsystem.java b/src/main/java/xbot/common/subsystems/pose/MockBasePoseSubsystem.java deleted file mode 100644 index 7c1886d8..00000000 --- a/src/main/java/xbot/common/subsystems/pose/MockBasePoseSubsystem.java +++ /dev/null @@ -1,52 +0,0 @@ -package xbot.common.subsystems.pose; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import com.ctre.phoenix.motorcontrol.FeedbackDevice; - -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.controls.actuators.mock_adapters.MockCANTalon; -import xbot.common.controls.sensors.XGyro.XGyroFactory; -import xbot.common.properties.PropertyFactory; - -@Singleton -public class MockBasePoseSubsystem extends BasePoseSubsystem { - - private XCANTalon left; - private XCANTalon right; - - @Inject - public MockBasePoseSubsystem(XGyroFactory gyroFactory, PropertyFactory propManager) { - super(gyroFactory, propManager); - } - - public void setDriveTalons(XCANTalon left, XCANTalon right) { - this.left = left; - this.right = right; - - left.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder, 0, 0); - right.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder, 0, 0); - } - - @Override - protected double getLeftDriveDistance() { - return ((MockCANTalon)left).getPosition(); - } - - @Override - protected double getRightDriveDistance() { - return ((MockCANTalon)right).getPosition(); - } - - public void setDriveEncoderDistances(int left, int right) { - ((MockCANTalon)this.left).setPosition(left); - ((MockCANTalon)this.right).setPosition(right); - periodic(); - } - - public void forceTotalXandY(double x, double y) { - totalDistanceX.set(x); - totalDistanceY.set(y); - } -} diff --git a/src/main/java/xbot/common/subsystems/pose/commands/ResetDistanceCommand.java b/src/main/java/xbot/common/subsystems/pose/commands/ResetDistanceCommand.java deleted file mode 100644 index 858d171d..00000000 --- a/src/main/java/xbot/common/subsystems/pose/commands/ResetDistanceCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package xbot.common.subsystems.pose.commands; - -import javax.inject.Inject; - -import xbot.common.command.BaseCommand; -import xbot.common.subsystems.pose.BasePoseSubsystem; - -public class ResetDistanceCommand extends BaseCommand { - - protected final BasePoseSubsystem poseSubsystem; - - @Inject - public ResetDistanceCommand(BasePoseSubsystem poseSubsystem) { - this.poseSubsystem = poseSubsystem; - } - - @Override - public boolean runsWhenDisabled() { - return true; - } - - @Override - public void initialize() { - log.info("Initializing"); - poseSubsystem.resetDistanceTraveled(); - } - - @Override - public void execute() { - - } - - @Override - public boolean isFinished() { - return true; - } -} diff --git a/src/main/java/xbot/common/subsystems/pose/commands/SetRobotHeadingCommand.java b/src/main/java/xbot/common/subsystems/pose/commands/SetRobotHeadingCommand.java deleted file mode 100644 index f33e67a3..00000000 --- a/src/main/java/xbot/common/subsystems/pose/commands/SetRobotHeadingCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -package xbot.common.subsystems.pose.commands; - -import javax.inject.Inject; - -import xbot.common.command.BaseCommand; -import xbot.common.subsystems.pose.BasePoseSubsystem; - -import java.util.function.Supplier; - -public class SetRobotHeadingCommand extends BaseCommand { - - protected final BasePoseSubsystem poseSubsystem; - private Supplier headingSupplier; - - @Inject - public SetRobotHeadingCommand(BasePoseSubsystem poseSubsystem) { - this.poseSubsystem = poseSubsystem; - headingSupplier = () -> BasePoseSubsystem.FACING_AWAY_FROM_DRIVERS; - } - - @Override - public boolean runsWhenDisabled() { - return true; - } - - public void setHeadingToApply(double heading) { - this.headingSupplier = () -> heading; - } - - public void setHeadingToApply(Supplier headingSupplier) { - this.headingSupplier = headingSupplier; - } - - @Override - public void initialize() { - log.info("Initializing"); - log.info("Setting heading to " + headingSupplier.get()); - poseSubsystem.setCurrentHeading(headingSupplier.get()); - } - - @Override - public void execute() {} - - @Override - public boolean isFinished() { - return true; - } -} diff --git a/src/main/java/xbot/common/subsystems/simplemotor/SimpleMotorSubsystem.java b/src/main/java/xbot/common/subsystems/simplemotor/SimpleMotorSubsystem.java deleted file mode 100644 index 346da678..00000000 --- a/src/main/java/xbot/common/subsystems/simplemotor/SimpleMotorSubsystem.java +++ /dev/null @@ -1,69 +0,0 @@ -package xbot.common.subsystems.simplemotor; - -import edu.wpi.first.wpilibj2.command.Command; -import xbot.common.command.BaseSubsystem; -import xbot.common.command.NamedRunCommand; -import xbot.common.properties.DoubleProperty; -import xbot.common.properties.PropertyFactory; - -/** - * Generic subsystem that handles a single motor which can be drivven in forward and reverse. - */ -public abstract class SimpleMotorSubsystem extends BaseSubsystem { - final DoubleProperty forwardPower; - final DoubleProperty reversePower; - - /** - * Create an instance with the specified default forward and reverse power. - * @param name The name of the subsystem - * @param pf The property factory - * @param defaultForwardPower The default power to use in the forward direction - * @param defaultReversePower The default power to use in the reverse direction - */ - public SimpleMotorSubsystem(String name, PropertyFactory pf, double defaultForwardPower, double defaultReversePower) { - setName(name); - pf.setPrefix(name); - this.forwardPower = pf.createPersistentProperty("Forward Power", defaultForwardPower); - this.reversePower = pf.createPersistentProperty("Reverse Power", defaultReversePower); - setDefaultCommand(getStopCommand()); - } - - /** - * Create an instance with default power settings. - * @param name The name of the subsystem - * @param pf The property factory - */ - public SimpleMotorSubsystem(String name, PropertyFactory pf) { - this(name, pf, 1.0, -1.0); - } - - /** - * Sets the motor output power. - * @param power The output power, from -1.0 to 1.0 - */ - public abstract void setPower(double power); - - public void setForward() { - setPower(forwardPower.get()); - } - - public void setReverse() { - setPower(reversePower.get()); - } - - public void stop() { - setPower(0); - } - - public Command getForwardCommand() { - return new NamedRunCommand(getName() + "-Forward", ()->setPower(forwardPower.get()), this); - } - - public Command getReverseCommand() { - return new NamedRunCommand(getName() + "-Reverse", ()->setPower(reversePower.get()), this); - } - - public Command getStopCommand() { - return new NamedRunCommand(getName() + "-Stop", ()->setPower(0), this); - } -} diff --git a/src/main/resources/10k.txt b/src/main/resources/10k.txt deleted file mode 100644 index df9ff085..00000000 --- a/src/main/resources/10k.txt +++ /dev/null @@ -1,5460 +0,0 @@ -about -search -other -which -their -there -contact -business -online -first -would -services -these -click -service -price -people -state -email -health -world -products -music -should -product -system -policy -number -please -support -message -after -software -video -where -rights -public -books -school -through -links -review -years -order -privacy -items -company -group -under -general -research -january -reviews -program -games -could -great -united -hotel -center -store -travel -comments -report -member -details -terms -before -hotels -right -because -local -those -using -results -office -national -design -posted -internet -address -within -states -phone -shipping -reserved -subject -between -forum -family -based -black -check -special -prices -website -index -being -women -today -south -project -pages -version -section -found -sports -house -related -security -county -american -photo -members -power -while -network -computer -systems -three -total -place -download -without -access -think -north -current -posts -media -control -water -history -pictures -personal -since -guide -board -location -change -white -small -rating -children -during -return -students -shopping -account -times -sites -level -digital -profile -previous -events -hours -image -title -another -shall -property -class -still -money -quality -every -listing -content -country -private -little -visit -tools -reply -customer -december -compare -movies -include -college -value -article -provide -source -author -press -learn -around -print -course -canada -process -stock -training -credit -point -science -advanced -sales -english -estate -select -windows -photos -thread -category -large -gallery -table -register -however -october -november -market -library -really -action -start -series -model -features -industry -human -provided -required -second -movie -forums -march -better -yahoo -going -medical -friend -server -study -staff -articles -feedback -again -looking -issues -april -never -users -complete -street -topic -comment -things -working -against -standard -person -below -mobile -party -payment -login -student -programs -offers -legal -above -recent -stores -problem -memory -social -august -quote -language -story -options -rates -create -young -america -field -paper -single -example -girls -password -latest -question -changes -night -texas -poker -status -browse -issue -range -building -seller -court -february -always -result -audio -light -write -offer -groups -given -files -event -release -analysis -request -china -making -picture -needs -possible -might -month -major -areas -future -space -cards -problems -london -meeting -become -interest -child -enter -share -similar -garden -schools -million -added -listed -learning -energy -delivery -popular -stories -journal -reports -welcome -central -images -notice -original -radio -until -color -council -includes -track -archive -others -format -least -society -months -safety -friends -trade -edition -messages -further -updated -having -provides -david -already -green -studies -close -common -drive -specific -several -living -called -short -display -limited -powered -means -director -daily -beach -natural -whether -period -planning -database -official -weather -average -window -france -region -island -record -direct -records -district -calendar -costs -style -front -update -parts -early -miles -sound -resource -present -either -document -works -material -written -federal -hosting -rules -final -adult -tickets -thing -centre -cheap -finance -minutes -third -gifts -europe -reading -topics -cover -usually -together -videos -percent -function -getting -global -economic -player -projects -lyrics -often -submit -germany -amount -watch -included -though -thanks -deals -various -words -linux -james -weight -heart -received -choose -archives -points -magazine -error -camera -clear -receive -domain -methods -chapter -makes -policies -beauty -manager -india -position -taken -listings -models -michael -known -cases -florida -simple -quick -wireless -license -friday -whole -annual -later -basic -shows -google -church -method -purchase -active -response -practice -hardware -figure -holiday -enough -designed -along -among -death -writing -speed -brand -discount -higher -effects -created -remember -yellow -increase -kingdom -thought -stuff -french -storage -japan -doing -loans -shoes -entry -nature -orders -africa -summary -growth -notes -agency -monday -european -activity -although -western -income -force -overall -river -package -contents -players -engine -album -regional -supplies -started -views -plans -double -build -screen -exchange -types -lines -continue -across -benefits -needed -season -apply -someone -anything -printer -believe -effect -asked -sunday -casino -volume -cross -anyone -mortgage -silver -inside -solution -mature -rather -weeks -addition -supply -nothing -certain -running -lower -union -jewelry -clothing -names -robert -homepage -skills -islands -advice -career -military -rental -decision -leave -british -teens -woman -sellers -middle -cable -taking -values -division -coming -tuesday -object -lesbian -machine -length -actually -score -client -returns -capital -follow -sample -shown -saturday -england -culture -flash -george -choice -starting -thursday -courses -consumer -airport -foreign -artist -outside -levels -channel -letter -phones -ideas -summer -allow -degree -contract -button -releases -homes -super -matter -custom -virginia -almost -located -multiple -asian -editor -cause -focus -featured -rooms -female -thomas -primary -cancer -numbers -reason -browser -spring -answer -voice -friendly -schedule -purpose -feature -comes -police -everyone -approach -cameras -brown -physical -medicine -ratings -chicago -forms -glass -happy -smith -wanted -thank -unique -survey -prior -sport -ready -animal -sources -mexico -regular -secure -simply -evidence -station -round -paypal -favorite -option -master -valley -recently -probably -rentals -built -blood -improve -larger -networks -earth -parents -nokia -impact -transfer -kitchen -strong -carolina -wedding -hospital -ground -overview -owners -disease -italy -perfect -classic -basis -command -cities -william -express -award -distance -peter -ensure -involved -extra -partners -budget -rated -guides -success -maximum -existing -quite -selected -amazon -patients -warning -horse -forward -flowers -stars -lists -owner -retail -animals -useful -directly -housing -takes -bring -catalog -searches -trying -mother -traffic -joined -input -strategy -agent -valid -modern -senior -ireland -teaching -grand -testing -trial -charge -units -instead -canadian -normal -wrote -ships -entire -leading -metal -positive -fitness -chinese -opinion -football -abstract -output -funds -greater -likely -develop -artists -guest -seems -trust -contains -session -multi -republic -vacation -century -academic -graphics -indian -expected -grade -dating -pacific -mountain -filter -mailing -vehicle -longer -consider -northern -behind -panel -floor -german -buying -match -proposed -default -require -outdoor -morning -allows -protein -plant -reported -politics -partner -authors -boards -faculty -parties -mission -string -sense -modified -released -stage -internal -goods -unless -richard -detailed -japanese -approved -target -except -ability -maybe -moving -brands -places -pretty -spain -southern -yourself -winter -battery -youth -pressure -boston -keywords -medium -break -purposes -dance -itself -defined -papers -playing -awards -studio -reader -virtual -device -answers -remote -external -apple -offered -theory -enjoy -remove -surface -minimum -visual -variety -teachers -martin -manual -block -subjects -agents -repair -civil -steel -songs -fixed -wrong -hands -finally -updates -desktop -classes -paris -sector -capacity -requires -jersey -fully -father -electric -quotes -officer -driver -respect -unknown -worth -teacher -workers -georgia -peace -campus -showing -creative -coast -benefit -progress -funding -devices -grant -agree -fiction -watches -careers -beyond -families -museum -blogs -accepted -former -complex -agencies -parent -spanish -michigan -columbia -setting -scale -stand -economy -highest -helpful -monthly -critical -frame -musical -angeles -employee -chief -gives -bottom -packages -detail -changed -heard -begin -colorado -royal -clean -switch -russian -largest -african -titles -relevant -justice -connect -bible -basket -applied -weekly -demand -suite -vegas -square -chris -advance -auction -allowed -correct -charles -nation -selling -piece -sheet -seven -older -illinois -elements -species -cells -module -resort -facility -random -pricing -minister -motion -looks -fashion -visitors -monitor -trading -forest -calls -whose -coverage -couple -giving -chance -vision -ending -clients -actions -listen -discuss -accept -naked -clinical -sciences -markets -lowest -highly -appear -lives -currency -leather -patient -actual -stone -commerce -perhaps -persons -tests -village -accounts -amateur -factors -coffee -settings -buyer -cultural -steve -easily -poster -closed -holidays -zealand -balance -graduate -replies -initial -label -thinking -scott -canon -league -waste -minute -provider -optional -sections -chair -fishing -effort -phase -fields -fantasy -letters -motor -context -install -shirt -apparel -crime -count -breast -johnson -quickly -dollars -websites -religion -claim -driving -surgery -patch -measures -kansas -chemical -doctor -reduce -brought -himself -enable -exercise -santa -leader -diamond -israel -servers -alone -meetings -seconds -jones -arizona -keyword -flight -congress -username -produced -italian -pocket -saint -freedom -argument -creating -drugs -joint -premium -fresh -attorney -upgrade -factor -growing -stream -hearing -eastern -auctions -therapy -entries -dates -signed -upper -serious -prime -samsung -limit -began -louis -steps -errors -shops -efforts -informed -thoughts -creek -worked -quantity -urban -sorted -myself -tours -platform -labor -admin -nursing -defense -machines -heavy -covered -recovery -merchant -expert -protect -solid -became -orange -vehicles -prevent -theme -campaign -marine -guitar -finding -examples -saying -spirit -claims -motorola -affairs -touch -intended -towards -goals -election -suggest -branch -charges -serve -reasons -magic -mount -smart -talking -latin -avoid -manage -corner -oregon -element -birth -virus -abuse -requests -separate -quarter -tables -define -racing -facts -column -plants -faith -chain -identify -avenue -missing -domestic -sitemap -moved -houston -reach -mental -viewed -moment -extended -sequence -attack -sorry -centers -opening -damage -reserve -recipes -gamma -plastic -produce -placed -truth -counter -failure -follows -weekend -dollar -ontario -films -bridge -native -williams -movement -printing -baseball -owned -approval -draft -chart -played -contacts -jesus -readers -clubs -jackson -equal -matching -offering -shirts -profit -leaders -posters -variable -expect -parking -compared -workshop -russia -codes -kinds -seattle -golden -teams -lighting -senate -forces -funny -brother -turned -portable -tried -returned -pattern -named -theatre -laser -earlier -sponsor -warranty -indiana -harry -objects -delete -evening -assembly -nuclear -taxes -mouse -signal -criminal -issued -brain -sexual -powerful -dream -obtained -false -flower -passed -supplied -falls -opinions -promote -stated -stats -hawaii -appears -carry -decided -covers -hello -designs -maintain -tourism -priority -adults -clips -savings -graphic -payments -binding -brief -ended -winning -eight -straight -script -served -wants -prepared -dining -alert -atlanta -dakota -queen -credits -clearly -handle -sweet -criteria -pubmed -diego -truck -behavior -enlarge -revenue -measure -changing -votes -looked -festival -ocean -flights -experts -signs -depth -whatever -logged -laptop -vintage -train -exactly -explore -maryland -concept -nearly -eligible -checkout -reality -forgot -handling -origin -gaming -feeds -billion -scotland -faster -dallas -bought -nations -route -followed -broken -frank -alaska -battle -anime -speak -protocol -query -equity -speech -rural -shared -sounds -judge -bytes -forced -fight -height -speaker -filed -obtain -offices -designer -remain -managed -failed -marriage -korea -banks -secret -kelly -leads -negative -austin -toronto -theater -springs -missouri -andrew -perform -healthy -assets -injury -joseph -ministry -drivers -lawyer -figures -married -proposal -sharing -portal -waiting -birthday -gratis -banking -brian -toward -slightly -assist -conduct -lingerie -calling -serving -profiles -miami -comics -matters -houses -postal -controls -breaking -combined -ultimate -wales -minor -finish -noted -reduced -physics -spent -extreme -samples -davis -daniel -reviewed -forecast -removed -helps -singles -cycle -amounts -contain -accuracy -sleep -pharmacy -brazil -creation -static -scene -hunter -crystal -famous -writer -chairman -violence -oklahoma -speakers -drink -academy -dynamic -gender -cleaning -concerns -vendor -intel -officers -referred -supports -regions -junior -rings -meaning -ladies -henry -ticket -guess -agreed -soccer -import -posting -presence -instant -viewing -majority -christ -aspects -austria -ahead -scheme -utility -preview -manner -matrix -devel -despite -strength -turkey -proper -degrees -delta -seeking -inches -phoenix -shares -daughter -standing -comfort -colors -cisco -ordering -alpha -appeal -cruise -bonus -bookmark -specials -disney -adobe -smoking -becomes -drives -alabama -improved -trees -achieve -dress -dealer -nearby -carried -happen -exposure -gambling -refer -miller -outdoors -clothes -caused -luxury -babes -frames -indeed -circuit -layer -printed -removal -easier -printers -adding -kentucky -mostly -taylor -prints -spend -factory -interior -revised -optical -relative -amazing -clock -identity -suites -feeling -hidden -victoria -serial -relief -revision -ratio -planet -copies -recipe -permit -seeing -proof -tennis -bedroom -empty -instance -licensed -orlando -bureau -maine -ideal -specs -recorded -pieces -finished -parks -dinner -lawyers -sydney -stress -cream -trends -discover -patterns -boxes -hills -fourth -advisor -aware -wilson -shape -irish -stations -remains -greatest -firms -operator -generic -usage -charts -mixed -census -exist -wheel -transit -compact -poetry -lights -tracking -angel -keeping -attempt -matches -width -noise -engines -forget -array -accurate -stephen -climate -alcohol -greek -managing -sister -walking -explain -smaller -newest -happened -extent -sharp -lesbians -export -managers -aircraft -modules -sweden -conflict -versions -employer -occur -knows -describe -concern -backup -citizens -heritage -holding -trouble -spread -coach -kevin -expand -audience -assigned -jordan -affect -virgin -raised -directed -dealers -sporting -helping -affected -totally -plate -expenses -indicate -blonde -anderson -organic -albums -cheats -guests -hosted -diseases -nevada -thailand -agenda -anyway -tracks -advisory -logic -template -prince -circle -grants -anywhere -atlantic -edward -investor -leaving -wildlife -cooking -speaking -sponsors -respond -sizes -plain -entered -launch -checking -costa -belgium -guidance -trail -symbol -crafts -highway -buddy -observed -setup -booking -glossary -fiscal -styles -denver -filled -channels -ericsson -appendix -notify -blues -portion -scope -supplier -cables -cotton -biology -dental -killed -border -ancient -debate -starts -causes -arkansas -leisure -learned -notebook -explorer -historic -attached -opened -husband -disabled -crazy -upcoming -britain -concert -scores -comedy -adopted -weblog -linear -bears -carrier -edited -constant -mouth -jewish -meter -linked -portland -concepts -reflect -deliver -wonder -lessons -fruit -begins -reform -alerts -treated -mysql -relating -assume -alliance -confirm -neither -lewis -howard -offline -leaves -engineer -replace -checks -reached -becoming -safari -sugar -stick -allen -relation -enabled -genre -slide -montana -tested -enhance -exact -bound -adapter -formal -hockey -storm -micro -colleges -laptops -showed -editors -threads -supreme -brothers -presents -dolls -estimate -cancel -limits -weapons -paint -delay -pilot -outlet -czech -novel -ultra -winner -idaho -episode -potter -plays -bulletin -modify -oxford -truly -epinions -painting -universe -patent -eating -planned -watching -lodge -mirror -sterling -sessions -kernel -stocks -buyers -journals -jennifer -antonio -charged -broad -taiwan -chosen -greece -swiss -sarah -clark -terminal -nights -behalf -liquid -nebraska -salary -foods -gourmet -guard -properly -orleans -saving -empire -resume -twenty -newly -raise -prepare -avatar -illegal -hundreds -lincoln -helped -premier -tomorrow -decide -consent -drama -visiting -downtown -keyboard -contest -bands -suitable -millions -lunch -audit -chamber -guinea -findings -muscle -clicking -polls -typical -tower -yours -chicken -attend -shower -sending -jason -tonight -holdem -shell -province -catholic -governor -seemed -swimming -spyware -formula -solar -catch -pakistan -reliable -doubt -finder -unable -periods -tasks -attacks -const -doors -symptoms -resorts -biggest -memorial -visitor -forth -insert -gateway -alumni -drawing -ordered -fighting -happens -romance -bruce -split -themes -powers -heaven -pregnant -twice -focused -egypt -bargain -cellular -norway -vermont -asking -blocks -normally -hunting -diabetes -shift -bodies -cutting -simon -writers -marks -flexible -loved -mapping -numerous -birds -indexed -superior -saved -paying -cartoon -shots -moore -granted -choices -carbon -spending -magnetic -registry -crisis -outlook -massive -denmark -employed -bright -treat -header -poverty -formed -piano -sheets -patrick -puerto -displays -plasma -allowing -earnings -mystery -journey -delaware -bidding -risks -banner -charter -barbara -counties -ports -dreams -blogger -stands -teach -occurred -rapid -hairy -reverse -deposit -seminar -latina -wheels -specify -dutch -formats -depends -boots -holds -router -concrete -editing -poland -folder -womens -upload -pulse -voting -courts -notices -detroit -metro -toshiba -strip -pearl -accident -resident -possibly -airline -regard -exists -smooth -strike -flashing -narrow -threat -surveys -sitting -putting -vietnam -trailer -castle -gardens -missed -malaysia -antique -labels -willing -acting -heads -stored -logos -antiques -density -hundred -strange -mention -parallel -honda -amended -operate -bills -bathroom -stable -opera -doctors -lesson -cinema -asset -drinking -reaction -blank -enhanced -entitled -severe -generate -deluxe -humor -monitors -lived -duration -pursuant -fabric -visits -tight -domains -contrast -flying -berlin -siemens -adoption -meant -capture -pounds -buffalo -plane -desire -camping -meets -welfare -caught -marked -driven -measured -medline -bottle -marshall -massage -rubber -closing -tampa -thousand -legend -grace -susan -adams -python -monster -villa -columns -hamilton -cookies -inner -tutorial -entity -cruises -holder -portugal -lawrence -roman -duties -valuable -ethics -forever -dragon -captain -imagine -brings -heating -scripts -stereo -taste -dealing -commit -airlines -liberal -livecam -trips -sides -turns -cache -jacket -oracle -matthew -lease -aviation -hobbies -proud -excess -disaster -console -commands -giant -achieved -injuries -shipped -seats -alarm -voltage -anthony -nintendo -usual -loading -stamps -appeared -franklin -angle -vinyl -mining -ongoing -worst -imaging -betting -liberty -wyoming -convert -analyst -garage -exciting -thongs -ringtone -finland -morgan -derived -pleasure -honor -oriented -eagle -desktops -pants -columbus -nurse -prayer -quiet -postage -producer -cheese -comic -crown -maker -crack -picks -semester -fetish -applies -casinos -smoke -apache -filters -craft -apart -fellow -blind -lounge -coins -gross -strongly -hilton -proteins -horror -familiar -capable -douglas -debian -epson -elected -carrying -victory -madison -editions -mainly -ethnic -actor -finds -fifth -citizen -vertical -prize -occurs -absolute -consists -anytime -soldiers -guardian -lecture -layout -classics -horses -dirty -wayne -donate -taught -worker -alive -temple -prove -wings -breaks -genetic -waters -promise -prefer -ridge -cabinet -modem -harris -bringing -evaluate -tiffany -tropical -collect -toyota -streets -vector -shaved -turning -buffer -purple -larry -mutual -pipeline -syntax -prison -skill -chairs -everyday -moves -inquiry -ethernet -checked -exhibit -throw -trend -sierra -visible -desert -oldest -rhode -mercury -steven -handbook -navigate -worse -summit -victims -spaces -burning -escape -coupons -somewhat -receiver -cialis -boats -glance -scottish -arcade -richmond -russell -tells -obvious -fiber -graph -covering -platinum -judgment -bedrooms -talks -filing -foster -modeling -passing -awarded -trials -tissue -clinton -masters -bonds -alberta -commons -fraud -spectrum -arrival -pottery -emphasis -roger -aspect -awesome -mexican -counts -priced -crash -desired -inter -closer -assumes -heights -shadow -riding -firefox -expense -grove -venture -clinic -korean -healing -princess -entering -packet -spray -studios -buttons -funded -thompson -winners -extend -roads -dublin -rolling -memories -nelson -arrived -creates -faces -tourist -mayor -murder -adequate -senator -yield -grades -cartoons -digest -lodging -hence -entirely -replaced -radar -rescue -losses -combat -reducing -stopped -lakes -closely -diary -kings -shooting -flags -baker -launched -shock -walls -abroad -ebony -drawn -arthur -visited -walker -suggests -beast -operated -targets -overseas -dodge -counsel -pizza -invited -yards -gordon -farmers -queries -ukraine -absence -nearest -cluster -vendors -whereas -serves -woods -surprise -partial -shoppers -couples -ranking -jokes -simpson -twiki -sublime -palace -verify -globe -trusted -copper -dicke -kerry -receipt -supposed -ordinary -nobody -ghost -applying -pride -knowing -reporter -keith -champion -cloudy -linda -chile -plenty -sentence -throat -ignore -maria -uniform -wealth -vacuum -dancing -brass -writes -plaza -outcomes -survival -quest -publish -trans -jonathan -whenever -lifetime -pioneer -booty -acrobat -plates -acres -venue -athletic -thermal -essays -vital -telling -fairly -coastal -config -charity -excel -modes -campbell -stupid -harbor -hungary -traveler -segment -realize -enemy -puzzle -rising -aluminum -wells -wishlist -opens -insight -secrets -lucky -latter -thick -trailers -repeat -syndrome -philips -penalty -glasses -enables -iraqi -builder -vista -jessica -chips -terry -flood -arena -pupils -stewart -outcome -expanded -casual -grown -polish -lovely -extras -centres -jerry -clause -smile -lands -troops -indoor -bulgaria -armed -broker -charger -believed -cooling -trucks -divorce -laura -shopper -tokyo -partly -nikon -candy -pills -tiger -donald -folks -sensor -exposed -telecom -angels -deputy -sealed -loaded -scenes -boost -spanking -founded -chronic -icons -moral -catering -finger -keeps -pound -locate -trained -roses -bread -tobacco -wooden -motors -tough -roberts -incident -gonna -dynamics -decrease -chest -pension -billy -revenues -emerging -worship -craig -herself -churches -damages -reserves -solve -shorts -minority -diverse -johnny -recorder -facing -nancy -tones -passion -sight -defence -patches -refund -towns -trembl -divided -emails -cyprus -insider -seminars -makers -hearts -worry -carter -legacy -pleased -danger -vitamin -widely -phrase -genuine -raising -paradise -hybrid -reads -roles -glory -bigger -billing -diesel -versus -combine -exceed -saudi -fault -babies -karen -compiled -romantic -revealed -albert -examine -jimmy -graham -bristol -margaret -compaq -slowly -rugby -portions -infant -sectors -samuel -fluid -grounds -regards -unlike -equation -baskets -wright -barry -proven -cached -warren -studied -reviewer -involves -profits -devil -grass -comply -marie -florist -cherry -deutsch -kenya -webcam -funeral -nutten -earrings -enjoyed -chapters -charlie -quebec -dennis -francis -sized -manga -noticed -socket -silent -literary -signals -theft -swing -symbols -humans -analog -facial -choosing -talent -dated -seeker -wisdom -shoot -boundary -packard -offset -payday -philip -elite -holders -believes -swedish -poems -deadline -robot -witness -collins -equipped -stages -winds -powder -broadway -acquired -assess -stones -entrance -gnome -roots -losing -attempts -gadgets -noble -glasgow -impacts -gospel -shore -loves -induced -knight -loose -linking -appeals -earned -illness -islamic -pending -parker -lebanon -kennedy -teenage -triple -cooper -vincent -secured -unusual -answered -slots -disorder -routine -toolbar -rocks -titans -wearing -sought -genes -mounted -habitat -firewall -median -scanner -herein -animated -judicial -integer -bachelor -attitude -engaged -falling -basics -montreal -carpet -struct -lenses -binary -genetics -attended -dropped -walter -besides -hosts -moments -atlas -strings -feels -torture -deleted -mitchell -ralph -warner -embedded -inkjet -wizard -corps -actors -liver -liable -brochure -morris -petition -eminem -recall -antenna -picked -assumed -belief -killing -bikini -memphis -shoulder -decor -lookup -texts -harvard -brokers -diameter -ottawa -podcast -seasons -refine -bidder -singer -evans -herald -literacy -fails -aging -plugin -diving -invite -alice -latinas -suppose -involve -moderate -terror -younger -thirty -opposite -rapidly -dealtime -intro -mercedes -clerk -mills -outline -tramadol -holland -receives -jeans -fonts -refers -favor -veterans -sigma -xhtml -occasion -victim -demands -sleeping -careful -arrive -sunset -tracked -moreover -minimal -lottery -framed -aside -licence -michelle -essay -dialogue -camps -declared -aaron -handheld -trace -disposal -florists -packs -switches -romania -consult -greatly -blogging -cycling -midnight -commonly -inform -turkish -pentium -quantum -murray -intent -largely -pleasant -announce -spoke -arrow -sampling -rough -weird -inspired -holes -weddings -blade -suddenly -oxygen -cookie -meals -canyon -meters -merely -passes -pointer -stretch -durham -permits -muslim -sleeve -netscape -cleaner -cricket -feeding -stroke -township -rankings -robin -robinson -strap -sharon -crowd -olympic -remained -entities -customs -rainbow -roulette -decline -gloves -israeli -medicare -skiing -cloud -valve -hewlett -explains -proceed -flickr -feelings -knife -jamaica -shelf -timing -liked -adopt -denied -fotos -britney -freeware -donation -outer -deaths -rivers -tales -katrina -islam -nodes -thumbs -seeds -cited -targeted -skype -realized -twelve -founder -decade -gamecube -dispute -tired -titten -adverse -excerpt -steam -drinks -voices -acute -climbing -stood -perfume -carol -honest -albany -restore -stack -somebody -curve -creator -amber -museums -coding -tracker -passage -trunk -hiking -pierre -jelsoft -headset -oakland -colombia -waves -camel -lamps -suicide -archived -arabia -juice -chase -logical -sauce -extract -panama -payable -courtesy -athens -judges -retired -remarks -detected -decades -walked -arising -nissan -bracelet -juvenile -afraid -acoustic -railway -cassette -pointed -causing -mistake -norton -locked -fusion -mineral -steering -beads -fortune -canvas -parish -claimed -screens -cemetery -planner -croatia -flows -stadium -fewer -coupon -nurses -proxy -lanka -edwards -contests -costume -tagged -berkeley -voted -killer -bikes -gates -adjusted -bishop -pulled -shaped -seasonal -farmer -counters -slave -cultures -norfolk -coaching -examined -encoding -heroes -painted -lycos -zdnet -artwork -cosmetic -resulted -portrait -ethical -carriers -mobility -floral -builders -struggle -schemes -neutral -fisher -spears -bedding -joining -heading -equally -bearing -combo -seniors -worlds -guilty -haven -tablet -charm -violent -basin -ranch -crossing -cottage -drunk -crimes -resolved -mozilla -toner -latex -branches -anymore -delhi -holdings -alien -locator -broke -nepal -zimbabwe -browsing -resolve -melissa -moscow -thesis -nylon -discs -rocky -bargains -frequent -nigeria -ceiling -pixels -ensuring -hispanic -anybody -diamonds -fleet -untitled -bunch -totals -marriott -singing -afford -starring -referral -optimal -distinct -turner -sucking -cents -reuters -spoken -omega -stayed -civic -manuals -watched -saver -thereof -grill -redeem -rogers -grain -regime -wanna -wishes -depend -differ -ranging -monica -repairs -breath -candle -hanging -colored -verified -formerly -situated -seeks -herbal -loving -strictly -routing -stanley -retailer -vitamins -elegant -gains -renewal -opposed -deemed -scoring -brooklyn -sisters -critics -spots -hacker -madrid -margin -solely -salon -norman -turbo -headed -voters -madonna -murphy -thinks -thats -soldier -phillips -aimed -justin -interval -mirrors -tricks -reset -brush -expansys -panels -repeated -assault -spare -kodak -tongue -bowling -danish -monkey -filename -skirt -florence -invest -honey -analyzes -drawings -scenario -lovers -atomic -approx -arabic -gauge -junction -faced -rachel -solving -weekends -produces -chains -kingston -sixth -engage -deviant -quoted -adapters -farms -imports -cheat -bronze -sandy -suspect -macro -sender -crucial -adjacent -tuition -spouse -exotic -viewer -signup -threats -puzzles -reaching -damaged -receptor -laugh -surgical -destroy -citation -pitch -autos -premises -perry -proved -imperial -dozen -benjamin -teeth -cloth -studying -stamp -lotus -salmon -olympus -cargo -salem -starter -upgrades -likes -butter -pepper -weapon -luggage -burden -tapes -zones -races -stylish -maple -grocery -offshore -depot -kenneth -blend -harrison -julie -emission -finest -realty -janet -apparent -phpbb -autumn -probe -toilet -ranked -jackets -routes -packed -excited -outreach -helen -mounting -recover -lopez -balanced -timely -talked -debug -delayed -chuck -explicit -villas -ebook -exclude -peeing -brooks -newton -anxiety -bingo -whilst -spatial -ceramic -prompt -precious -minds -annually -scanners -xanax -fingers -sunny -ebooks -delivers -necklace -leeds -cedar -arranged -theaters -advocacy -raleigh -threaded -qualify -blair -hopes -mason -diagram -burns -pumps -footwear -beijing -peoples -victor -mario -attach -licenses -utils -removing -advised -spider -ranges -pairs -trails -hudson -isolated -calgary -interim -assisted -divine -approve -chose -compound -abortion -dialog -venues -blast -wellness -calcium -newport -indians -shield -harvest -membrane -prague -previews -locally -pickup -mothers -nascar -iceland -candles -sailing -sacred -morocco -chrome -tommy -refused -brake -exterior -greeting -ecology -oliver -congo -botswana -delays -olive -cyber -verizon -scored -clone -dicks -velocity -lambda -relay -composed -tears -oasis -baseline -angry -silicon -compete -lover -belong -honolulu -beatles -rolls -thomson -barnes -malta -daddy -ferry -rabbit -seating -exports -omaha -electron -loads -heather -passport -motel -unions -treasury -warrant -solaris -frozen -occupied -royalty -scales -rally -observer -sunshine -strain -ceremony -somehow -arrested -yamaha -hebrew -gained -dying -laundry -stuck -solomon -placing -stops -homework -adjust -assessed -enabling -filling -imposed -silence -focuses -soviet -treaty -vocal -trainer -organ -stronger -volumes -advances -lemon -toxic -darkness -bizrate -vienna -implied -stanford -packing -statute -rejected -satisfy -shelter -chapel -gamespot -layers -guided -bahamas -powell -mixture -bench -rider -radius -logging -hampton -borders -butts -bobby -sheep -railroad -lectures -wines -nursery -harder -cheapest -travesti -stuart -salvador -salad -monroe -tender -paste -clouds -tanzania -preserve -unsigned -staying -easter -theories -praise -jeremy -venice -estonia -veteran -streams -landing -signing -executed -katie -showcase -integral -relax -namibia -synopsis -hardly -prairie -reunion -composer -sword -absent -sells -ecuador -hoping -accessed -spirits -coral -pixel -float -colin -imported -paths -bubble -acquire -contrary -tribune -vessel -acids -focusing -viruses -cheaper -admitted -dairy -admit -fancy -equality -samoa -stickers -leasing -lauren -beliefs -squad -analyze -ashley -scroll -relate -wages -suffer -forests -invalid -concerts -martial -males -retain -execute -tunnel -genres -cambodia -patents -chaos -wheat -beaver -updating -readings -kijiji -confused -compiler -eagles -bases -accused -unity -bride -defines -airports -begun -brunette -packets -anchor -socks -parade -trigger -gathered -essex -slovenia -notified -beaches -folders -dramatic -surfaces -terrible -routers -pendant -dresses -baptist -hiring -clocks -females -wallace -reflects -taxation -fever -cuisine -surely -myspace -theorem -stylus -drums -arnold -chicks -cattle -radical -rover -treasure -reload -flame -levitra -tanks -assuming -monetary -elderly -floating -bolivia -spell -hottest -stevens -kuwait -emily -alleged -compile -webster -struck -plymouth -warnings -bridal -annex -tribal -curious -freight -rebate -meetup -eclipse -sudan -shuttle -stunning -cycles -affects -detect -actively -ampland -fastest -butler -injured -payroll -cookbook -courier -uploaded -hints -collapse -americas -unlikely -techno -beverage -tribute -wired -elvis -immune -latvia -forestry -barriers -rarely -infected -martha -genesis -barrier -argue -trains -metals -bicycle -letting -arise -celtic -thereby -jamie -particle -minerals -advise -humidity -bottles -boxing -bangkok -hughes -jeffrey -chess -operates -brisbane -survive -oscar -menus -reveal -canal -amino -herbs -clinics -manitoba -missions -watson -lying -costumes -strict -saddam -drill -offense -bryan -protest -hobby -tries -nickname -inline -washing -staffing -trick -enquiry -closure -timber -intense -playlist -showers -ruling -steady -statutes -myers -drops -wider -plugins -enrolled -sensors -screw -publicly -hourly -blame -geneva -freebsd -reseller -handed -suffered -intake -informal -tucson -heavily -swingers -fifty -headers -mistakes -uncle -defining -counting -assure -devoted -jacob -sodium -randy -hormone -timothy -brick -naval -medieval -bridges -captured -thehun -decent -casting -dayton -shortly -cameron -carlos -donna -andreas -warrior -diploma -cabin -innocent -scanning -valium -copying -cordless -patricia -eddie -uganda -fired -trivia -adidas -perth -grammar -syria -disagree -klein -harvey -tires -hazard -retro -gregory -episodes -boolean -circular -anger -mainland -suits -chances -interact -bizarre -glenn -auckland -olympics -fruits -ribbon -startup -suzuki -trinidad -kissing -handy -exempt -crops -reduces -geometry -slovakia -guild -gorgeous -capitol -dishes -barbados -chrysler -nervous -refuse -extends -mcdonald -replica -plumbing -brussels -tribe -trades -superb -trinity -handled -legends -floors -exhaust -shanghai -speaks -burton -davidson -copied -scotia -farming -gibson -roller -batch -organize -alter -nicole -latino -ghana -edges -mixing -handles -skilled -fitted -harmony -asthma -twins -triangle -amend -oriental -reward -windsor -zambia -hydrogen -webshots -sprint -chick -advocate -inputs -genome -escorts -thong -medal -coaches -vessels -walks -knives -arrange -artistic -honors -booth -indie -unified -bones -breed -detector -ignored -polar -fallen -precise -sussex -msgid -invoice -gather -backed -alfred -colonial -carey -motels -forming -embassy -danny -rebecca -slight -proceeds -indirect -amongst -msgstr -arrest -adipex -horizon -deeply -toolbox -marina -prizes -bosnia -browsers -patio -surfing -lloyd -optics -pursue -overcome -attract -brighton -beans -ellis -disable -snake -succeed -leonard -lending -reminder -searched -plains -raymond -insights -sullivan -midwest -karaoke -lonely -hereby -observe -julia -berry -collar -racial -bermuda -amanda -mobiles -kelkoo -exhibits -terrace -bacteria -replied -seafood -novels -ought -safely -finite -kidney -fixes -sends -durable -mazda -allied -throws -moisture -roster -symantec -spencer -wichita -nasdaq -uruguay -timer -tablets -tuning -gotten -tyler -futures -verse -highs -wanting -custody -scratch -launches -ellen -rocket -bullet -towers -racks -nasty -latitude -tumor -deposits -beverly -mistress -trustees -watts -duncan -reprints -bernard -forty -tubes -midlands -priest -floyd -ronald -analysts -queue -trance -locale -nicholas -bundle -hammer -invasion -runner -notion -skins -mailed -fujitsu -spelling -arctic -exams -rewards -beneath -defend -medicaid -infrared -seventh -welsh -belly -quarters -stolen -soonest -haiti -naturals -lenders -fitting -fixtures -bloggers -agrees -surplus -elder -sonic -cheers -belarus -zoning -gravity -thumb -guitars -essence -flooring -ethiopia -mighty -athletes -humanity -holmes -scholars -galaxy -chester -snapshot -caring -segments -dominant -twist -itunes -stomach -buried -newbie -minimize -darwin -ranks -debut -bradley -anatomy -fraction -defects -milton -marker -clarity -sandra -adelaide -monaco -settled -folding -emirates -airfare -vaccine -belize -promised -volvo -penny -robust -bookings -minolta -porter -jungle -ivory -alpine -andale -fabulous -remix -alias -newer -spice -implies -cooler -maritime -periodic -overhead -ascii -prospect -shipment -breeding -donor -tension -trash -shapes -manor -envelope -diane -homeland -excluded -andrea -breeds -rapids -disco -bailey -endif -emotions -incoming -lexmark -cleaners -eternal -cashiers -rotation -eugene -metric -minus -bennett -hotmail -joshua -armenia -varied -grande -closest -actress -assign -tigers -aurora -slides -milan -premiere -lender -villages -shade -chorus -rhythm -digit -argued -dietary -symphony -clarke -sudden -marilyn -lions -findlaw -pools -lyric -claire -speeds -matched -carroll -rational -fighters -chambers -warming -vocals -fountain -chubby -grave -burner -finnish -gentle -deeper -muslims -footage -howto -worthy -reveals -saints -carries -devon -helena -saves -regarded -marion -lobby -egyptian -tunisia -outlined -headline -treating -punch -gotta -cowboy -bahrain -enormous -karma -consist -betty -queens -lucas -tribes -defeat -clicks -honduras -naughty -hazards -insured -harper -mardi -tenant -cabinets -tattoo -shake -algebra -shadows -holly -silly -mercy -hartford -freely -marcus -sunrise -wrapping -weblogs -timeline -belongs -readily -fence -nudist -infinite -diana -ensures -lindsay -legally -shame -civilian -fatal -remedy -realtors -briefly -genius -fighter -flesh -retreat -adapted -barely -wherever -estates -democrat -borough -failing -retained -pamela -andrews -marble -jesse -logitech -surrey -briefing -belkin -highland -modular -brandon -giants -balloon -winston -solved -hawaiian -gratuit -consoles -qatar -magnet -porsche -cayman -jaguar -sheer -posing -hopkins -urgent -infants -gothic -cylinder -witch -cohen -puppy -kathy -graphs -surround -revenge -expires -enemies -finances -accepts -enjoying -patrol -smell -italiano -carnival -roughly -sticker -promises -divide -cornell -satin -deserve -mailto -promo -worried -tunes -garbage -combines -bradford -phrases -chelsea -boring -reynolds -speeches -reaches -schema -catalogs -quizzes -prefix -lucia -savannah -barrel -typing -nerve -planets -deficit -boulder -pointing -renew -coupled -myanmar -metadata -harold -circuits -floppy -texture -handbags -somerset -incurred -antigua -thunder -caution -locks -namely -euros -pirates -aerial -rebel -origins -hired -makeup -textile -nathan -tobago -indexes -hindu -licking -markers -weights -albania -lasting -wicked -kills -roommate -webcams -pushed -slope -reggae -failures -surname -theology -nails -evident -whats -rides -rehab -saturn -allergy -twisted -merit -enzyme -zshops -planes -edmonton -tackle -disks -condo -pokemon -ambien -retrieve -vernon -worldcat -titanium -fairy -builds -shaft -leslie -casio -deutsche -postings -kitty -drain -monte -fires -algeria -blessed -cardiff -cornwall -favors -potato -panic -sticks -leone -excuse -reforms -basement -onion -strand -sandwich -lawsuit -cheque -banners -reject -circles -italic -beats -merry -scuba -passive -valued -courage -verde -gazette -hitachi -batman -hearings -coleman -anaheim -textbook -dried -luther -frontier -settle -stopping -refugees -knights -palmer -derby -peaceful -altered -pontiac -doctrine -scenic -trainers -sewing -conclude -munich -celebs -propose -lighter -advisors -pavilion -tactics -trusts -talented -annie -pillow -derek -shorter -harley -relying -finals -paraguay -steal -parcel -refined -fifteen -fears -predict -boutique -acrylic -rolled -tuner -peterson -shannon -toddler -flavor -alike -homeless -horrible -hungry -metallic -blocked -warriors -cadillac -malawi -sagem -curtis -parental -strikes -lesser -marathon -pressing -gasoline -dressed -scout -belfast -dealt -niagara -warcraft -charms -catalyst -trader -bucks -denial -thrown -prepaid -raises -electro -badge -wrist -analyzed -heath -ballot -lexus -varying -remedies -validity -trustee -weighted -angola -performs -plastics -realm -jenny -helmet -salaries -postcard -elephant -yemen -tsunami -scholar -nickel -buses -expedia -geology -coating -wallet -cleared -smilies -boating -drainage -shakira -corners -broader -rouge -yeast -clearing -coated -intend -louise -kenny -routines -hitting -yukon -beings -aquatic -reliance -habits -striking -podcasts -singh -gilbert -ferrari -brook -outputs -ensemble -insulin -assured -biblical -accent -mysimon -eleven -wives -ambient -utilize -mileage -prostate -adaptor -auburn -unlock -hyundai -pledge -vampire -angela -relates -nitrogen -xerox -merger -softball -firewire -nextel -framing -musician -blocking -rwanda -sorts -vsnet -limiting -dispatch -papua -restored -armor -riders -chargers -remark -dozens -varies -rendered -picking -guards -openings -councils -kruger -pockets -granny -viral -inquire -pipes -laden -aruba -cottages -realtor -merge -edgar -develops -chassis -dubai -pushing -fleece -pierce -allan -dressing -sperm -filme -craps -frost -sally -yacht -tracy -prefers -drilling -breach -whale -tomatoes -bedford -mustang -clusters -antibody -momentum -wiring -pastor -calvin -shark -phases -grateful -emerald -laughing -grows -cliff -tract -ballet -abraham -bumper -webpage -garlic -hostels -shine -senegal -banned -wendy -briefs -diffs -mumbai -ozone -radios -tariff -nvidia -opponent -pasta -muscles -serum -wrapped -swift -runtime -inbox -focal -distant -decimal -propecia -samba -hostel -employ -mongolia -penguin -magical -miracle -manually -reprint -centered -yearly -wound -belle -writings -hamburg -cindy -fathers -charging -marvel -lined -petite -terrain -strips -gossip -rangers -rotary -discrete -beginner -boxed -cubic -sapphire -kinase -skirts -crawford -labeled -marking -serbia -sheriff -griffin -declined -guyana -spies -neighbor -elect -highways -thinkpad -intimate -preston -deadly -bunny -chevy -rounds -longest -tions -dentists -flyer -dosage -variance -cameroon -baking -adaptive -computed -needle -baths -brakes -nirvana -invision -sticky -destiny -generous -madness -emacs -climb -blowing -heated -jackie -sparc -cardiac -dover -adrian -vatican -brutal -learners -token -seekers -yields -suited -numeric -skating -kinda -aberdeen -emperor -dylan -belts -blacks -educated -rebates -burke -proudly -inserted -pulling -basename -obesity -curves -suburban -touring -clara -vertex -tomato -andorra -expired -travels -flush -waiver -hayes -delight -survivor -garcia -cingular -moses -counted -declare -johns -valves -impaired -donors -jewel -teddy -teaches -ventures -bufing -stranger -tragedy -julian -dryer -painful -velvet -tribunal -ruled -pensions -prayers -funky -nowhere -joins -wesley -lately -scary -mattress -mpegs -brunei -likewise -banana -slovak -cakes -mixer -remind -sbjct -charming -tooth -annoying -stays -disclose -affair -drove -washer -upset -restrict -springer -beside -mines -rebound -logan -mentor -fought -baghdad -metres -pencil -freeze -titled -sphere -ratios -concord -endorsed -walnut -lance -ladder -italia -liberia -sherman -maximize -hansen -senators -workout -bleeding -colon -lanes -purse -optimize -stating -caroline -align -bless -engaging -crest -triumph -welding -deferred -alloy -condos -plots -polished -gently -tulsa -locking -casey -draws -fridge -blanket -bloom -simpsons -elliott -fraser -justify -blades -loops -surge -trauma -tahoe -advert -possess -flashers -subaru -vanilla -picnic -souls -arrivals -spank -hollow -vault -securely -fioricet -groove -pursuit -wires -mails -backing -sleeps -blake -travis -endless -figured -orbit -niger -bacon -heater -colony -cannon -circus -promoted -forbes -moldova -paxil -spine -trout -enclosed -cooked -thriller -transmit -apnic -fatty -gerald -pressed -scanned -hunger -mariah -joyce -surgeon -cement -planners -disputes -textiles -missile -intranet -closes -deborah -marco -assists -gabriel -auditor -aquarium -violin -prophet -bracket -isaac -oxide -naples -promptly -modems -harmful -prozac -sexually -dividend -newark -glucose -phantom -playback -turtle -warned -neural -fossil -hometown -badly -apollo -persian -handmade -greene -robots -grenada -scoop -earning -mailman -sanyo -nested -somalia -movers -verbal -blink -carlo -workflow -novelty -bryant -tiles -voyuer -switched -tamil -garmin -fuzzy -grams -richards -budgets -toolkit -render -carmen -hardwood -erotica -temporal -forge -dense -brave -awful -airplane -istanbul -impose -viewers -asbestos -meyer -enters -savage -willow -resumes -throwing -existed -wagon -barbie -knock -potatoes -thorough -peers -roland -optimum -quilt -creature -mounts -syracuse -refresh -webcast -michel -subtle -notre -maldives -stripes -firmware -shepherd -canberra -cradle -mambo -flour -sympathy -choir -avoiding -blond -expects -jumping -fabrics -polymer -hygiene -poultry -virtue -burst -surgeons -bouquet -promotes -mandate -wiley -corpus -johnston -fibre -shades -indices -adware -zoloft -prisoner -daisy -halifax -ultram -cursor -earliest -donated -stuffed -insects -crude -morrison -maiden -examines -viking -myrtle -bored -cleanup -bother -budapest -knitting -attacked -bhutan -mating -compute -redhead -arrives -tractor -allah -unwrap -fares -resist -hoped -safer -wagner -touched -cologne -wishing -ranger -smallest -newman -marsh -ricky -scared -theta -monsters -asylum -lightbox -robbie -stake -cocktail -outlets -arbor -poison diff --git a/src/main/resources/log4j4unitTesting.xml b/src/main/resources/log4j4unitTesting.xml deleted file mode 100644 index 768a4648..00000000 --- a/src/main/resources/log4j4unitTesting.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/java/xbot/common/command/BaseCommandTest.java b/src/test/java/xbot/common/command/BaseCommandTest.java deleted file mode 100644 index 7f5cdc63..00000000 --- a/src/test/java/xbot/common/command/BaseCommandTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package xbot.common.command; - -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class BaseCommandTest extends BaseCommonLibTest { - - @Test - public void testPuttingOnSmartDashboardDoesntCrashTest() { - BaseCommand command = new MockCommand(); - command.includeOnSmartDashboard("label"); - command.includeOnSmartDashboard(); - } - -} \ No newline at end of file diff --git a/src/test/java/xbot/common/command/BaseWaitForMaintainerCommandTest.java b/src/test/java/xbot/common/command/BaseWaitForMaintainerCommandTest.java deleted file mode 100644 index 73e3bd7b..00000000 --- a/src/test/java/xbot/common/command/BaseWaitForMaintainerCommandTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package xbot.common.command; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class BaseWaitForMaintainerCommandTest extends BaseCommonLibTest { - - @Test - public void testReachedGoal() { - BaseSetpointSubsystem subsystem = getInjectorComponent().mockSetpointSubsystem(); - BaseWaitForMaintainerCommand command = getInjectorComponent().mockWaitForMaintainerCommand(); - - command.initialize(); - - subsystem.setMaintainerIsAtGoal(false); - assertFalse(command.isFinished()); - - subsystem.setMaintainerIsAtGoal(true); - assertTrue(command.isFinished()); - } - - @Test - public void testTimeout() { - BaseSetpointSubsystem subsystem = getInjectorComponent().mockSetpointSubsystem(); - BaseWaitForMaintainerCommand command = getInjectorComponent().mockWaitForMaintainerCommand(); - - command.initialize(); - - subsystem.setMaintainerIsAtGoal(false); - assertFalse(command.isFinished()); - - this.timer.advanceTimeInSecondsBy(10); - assertTrue(command.isFinished()); - } - -} \ No newline at end of file diff --git a/src/test/java/xbot/common/command/MockCommand.java b/src/test/java/xbot/common/command/MockCommand.java deleted file mode 100644 index 2ac5fd00..00000000 --- a/src/test/java/xbot/common/command/MockCommand.java +++ /dev/null @@ -1,11 +0,0 @@ -package xbot.common.command; - -public class MockCommand extends BaseCommand { - @Override - public void initialize() { - } - - @Override - public void execute() { - } -} diff --git a/src/test/java/xbot/common/command/MockSetpointCommand.java b/src/test/java/xbot/common/command/MockSetpointCommand.java deleted file mode 100644 index 6cb2e1ea..00000000 --- a/src/test/java/xbot/common/command/MockSetpointCommand.java +++ /dev/null @@ -1,19 +0,0 @@ -package xbot.common.command; - -import javax.inject.Inject; - -public class MockSetpointCommand extends BaseSetpointCommand { - - @Inject - public MockSetpointCommand(MockSetpointSubsystem system) { - super(system); - } - - @Override - public void initialize() { - } - - @Override - public void execute() { - } -} diff --git a/src/test/java/xbot/common/command/MockSetpointSubsystem.java b/src/test/java/xbot/common/command/MockSetpointSubsystem.java deleted file mode 100644 index a753e5fb..00000000 --- a/src/test/java/xbot/common/command/MockSetpointSubsystem.java +++ /dev/null @@ -1,35 +0,0 @@ -package xbot.common.command; - -import javax.inject.Inject; -import javax.inject.Singleton; - -@Singleton -public class MockSetpointSubsystem extends BaseSetpointSubsystem { - - @Inject - public MockSetpointSubsystem() {} - - @Override - public Double getCurrentValue() { - return 0.0; - } - - @Override - public Double getTargetValue() { - return 0.0; - } - - @Override - public void setTargetValue(Double value) { - - } - - @Override - public void setPower(Double power) { - } - - @Override - public boolean isCalibrated() { - return false; - } -} diff --git a/src/test/java/xbot/common/command/MockWaitForMaintainerCommand.java b/src/test/java/xbot/common/command/MockWaitForMaintainerCommand.java deleted file mode 100644 index 103065ec..00000000 --- a/src/test/java/xbot/common/command/MockWaitForMaintainerCommand.java +++ /dev/null @@ -1,13 +0,0 @@ -package xbot.common.command; - -import javax.inject.Inject; - -import xbot.common.properties.PropertyFactory; - -public class MockWaitForMaintainerCommand extends BaseWaitForMaintainerCommand { - - @Inject - public MockWaitForMaintainerCommand(MockSetpointSubsystem system, PropertyFactory pf) { - super(system, pf, 1); - } -} diff --git a/src/test/java/xbot/common/command/SetpointSystemTest.java b/src/test/java/xbot/common/command/SetpointSystemTest.java deleted file mode 100644 index 469d1e72..00000000 --- a/src/test/java/xbot/common/command/SetpointSystemTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package xbot.common.command; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Ignore; -import org.junit.Test; - -import edu.wpi.first.wpilibj2.command.CommandScheduler; -import xbot.common.injection.BaseCommonLibTest; - -public class SetpointSystemTest extends BaseCommonLibTest { - - @SuppressWarnings("unused") - @Test - public void testSetpointSystemCanBeCreated() { - MockSetpointCommand first = getInjectorComponent().mockSetpointCommand(); - } - - // I think this test is failing because the robot isn't "enabled." - // Yep, that's the issue. Setting these commands to RunWhenDisabled lets this test pass as - // expected. Is there some way we can deal with this problem? - // This is also impacted by other tests, somehow - it works in isolation - // but fails when other tests are running. - @Test - @Ignore - public void testSetpointCommandsCollide() { - XScheduler xScheduler = getInjectorComponent().scheduler(); - xScheduler.removeAll(); - xScheduler.removeAll(); - xScheduler.removeAll(); - xScheduler.run(); - xScheduler.run(); - xScheduler.run(); - - MockSetpointCommand first = getInjectorComponent().mockSetpointCommand(); - MockSetpointCommand second = getInjectorComponent().mockSetpointCommand(); - - first.setRunsWhenDisabled(true); - second.setRunsWhenDisabled(true); - - - assertFalse("First command is not running", first.isScheduled()); - assertFalse("Second command is not running", second.isScheduled()); - - CommandScheduler.getInstance().schedule(first); - xScheduler.run(); - assertTrue("First command is running", first.isScheduled()); - - CommandScheduler.getInstance().schedule(second); - xScheduler.run(); - - assertTrue("Second command is running", second.isScheduled()); - assertFalse("First command is no longer running", first.isScheduled()); - } - - -} diff --git a/src/test/java/xbot/common/command/XSchedulerTest.java b/src/test/java/xbot/common/command/XSchedulerTest.java deleted file mode 100644 index e6d06201..00000000 --- a/src/test/java/xbot/common/command/XSchedulerTest.java +++ /dev/null @@ -1,98 +0,0 @@ -package xbot.common.command; -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import edu.wpi.first.wpilibj2.command.CommandScheduler; -import xbot.common.injection.BaseCommonLibTest; - -public class XSchedulerTest extends BaseCommonLibTest { - - @Before - public void setUp() { - super.setUp(); - } - - @After - public void tearDown() { - getInjectorComponent().scheduler().removeAll(); - } - - @Test - public void testXSchedulerDoesntCrash() { - BaseCommand crashingCommand = new CrashingOnInitCommand(); - CommandScheduler.getInstance().schedule(crashingCommand); - XScheduler xScheduler = getInjectorComponent().scheduler(); - xScheduler.run(); - xScheduler.run(); - // shouldn't have crashed - } - - @Test - public void testXSchedulerDoesntCrashAndRecovers() { - BaseCommand crashingCommand = new CrashingInExecCommand(); - CommandScheduler.getInstance().schedule(crashingCommand); - XScheduler xScheduler = getInjectorComponent().scheduler(); - xScheduler.run(); - xScheduler.run(); - // shouldn't have crashed - - // scheduler should have been emptied. - } - - @Test - @Ignore("I can't make the scheduler crash - this needs more investigation later.") - public void testSchedulerCrashes() { - BaseCommand crashingCommand = new CrashingInExecCommand(); - CommandScheduler.getInstance().schedule(crashingCommand); - - boolean hitCrash = false; - - CommandScheduler.getInstance().run(); - - try { - // Note - the below call will never fully execute (and show up red on - CommandScheduler.getInstance().run(); - CommandScheduler.getInstance().run(); - CommandScheduler.getInstance().run(); - CommandScheduler.getInstance().run(); - - } catch (Exception e) { - hitCrash = true; - } - - assertTrue("We should have crashed", hitCrash); - } - -} - -// CHECKSTYLE:OFF -class CrashingOnInitCommand extends BaseCommand { - - @Override - public void initialize() { - throw new RuntimeException(); - } - - @Override - public void execute() { - - } -} - -class CrashingInExecCommand extends BaseCommand { - - @Override - public void initialize() { - - } - - @Override - public void execute() { - throw new RuntimeException(); - } -} -// CHECKSTYLE:ON diff --git a/src/test/java/xbot/common/controls/actuators/MockCANTalonTest.java b/src/test/java/xbot/common/controls/actuators/MockCANTalonTest.java deleted file mode 100644 index 8141592f..00000000 --- a/src/test/java/xbot/common/controls/actuators/MockCANTalonTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package xbot.common.controls.actuators; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.FeedbackDevice; - -import org.junit.Test; - -import xbot.common.controls.actuators.mock_adapters.MockCANTalon; -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.injection.electrical_contract.CANTalonInfo; - -public class MockCANTalonTest extends BaseCommonLibTest { - - @Test - public void testSpeedControl() { - XCANTalon talon = getInjectorComponent().canTalonFactory().create(new CANTalonInfo(1)); - - talon.config_kP(0, 0.5, 0); - - talon.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder, 0, 0); - - talon.set(ControlMode.Velocity, 1); - assertTrue("Should be going forward", talon.getMotorOutputPercent() > 0); - ((MockCANTalon)talon).setRate(2); - talon.set(ControlMode.Velocity, 1); - assertTrue("Should be going backward", talon.getMotorOutputPercent() < 0); - } - - @Test - public void testPositionControl() { - XCANTalon talon = getInjectorComponent().canTalonFactory().create(new CANTalonInfo(1)); - - talon.config_kP(0, 0.5, 0); - - talon.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder, 0, 0); - - talon.set(ControlMode.Position, 1); - assertTrue("Should be going forward", talon.getMotorOutputPercent() > 0); - ((MockCANTalon)talon).setPosition(2); - talon.set(ControlMode.Position, 1); - assertTrue("Should be going backward", talon.getMotorOutputPercent() < 0); - } - - @Test - public void internalEncoderTest() { - MockCANTalon motor = (MockCANTalon)getInjectorComponent().canTalonFactory().create(new CANTalonInfo(1)); - motor.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder, 0, 0); - motor.setPosition(100); - - assertEquals(100, motor.getPosition(), 0.001); - assertEquals(100, motor.getSelectedSensorPosition(0), 0.001); - } -} diff --git a/src/test/java/xbot/common/controls/actuators/XDoubleSolenoidTest.java b/src/test/java/xbot/common/controls/actuators/XDoubleSolenoidTest.java deleted file mode 100644 index 5bba3466..00000000 --- a/src/test/java/xbot/common/controls/actuators/XDoubleSolenoidTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package xbot.common.controls.actuators; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; - -import org.junit.Before; -import org.junit.Test; - -import edu.wpi.first.wpilibj.MockSolenoid; -import xbot.common.controls.actuators.XDoubleSolenoid.DoubleSolenoidMode; -import xbot.common.injection.BaseCommonLibTest; - -public class XDoubleSolenoidTest extends BaseCommonLibTest { - - MockSolenoid forwardSolenoid; - MockSolenoid reverseSolenoid; - XDoubleSolenoid xDoubleSol; - - @Before - public void setup() - { - super.setUp(); - - forwardSolenoid = (MockSolenoid)getInjectorComponent().solenoidFactory().create(1); - reverseSolenoid = (MockSolenoid)getInjectorComponent().solenoidFactory().create(2); - xDoubleSol = getInjectorComponent().doubleSolenoidFactory().create(forwardSolenoid, reverseSolenoid); - } - - @Test - public void testXDoubleSolenoidIfInverted() { - xDoubleSol.setInverted(true); - - xDoubleSol.setDoubleSolenoid(DoubleSolenoidMode.FORWARD); - assertFalse(forwardSolenoid.get()); - assertTrue(reverseSolenoid.get()); - - xDoubleSol.setDoubleSolenoid(DoubleSolenoidMode.REVERSE); - assertTrue(forwardSolenoid.get()); - assertFalse(reverseSolenoid.get()); - } - - @Test - public void testXDoubleSolenoidNotInverted() { - xDoubleSol.setInverted(false); - - xDoubleSol.setDoubleSolenoid(DoubleSolenoidMode.FORWARD); - assertTrue(forwardSolenoid.get()); - assertFalse(reverseSolenoid.get()); - - xDoubleSol.setDoubleSolenoid(DoubleSolenoidMode.REVERSE); - assertFalse(forwardSolenoid.get()); - assertTrue(reverseSolenoid.get()); - - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/controls/sensors/AnalogDistanceSensorTest.java b/src/test/java/xbot/common/controls/sensors/AnalogDistanceSensorTest.java deleted file mode 100644 index aac78d9f..00000000 --- a/src/test/java/xbot/common/controls/sensors/AnalogDistanceSensorTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package xbot.common.controls.sensors; - -import org.junit.Before; -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class AnalogDistanceSensorTest extends BaseCommonLibTest { - - AnalogDistanceSensor sensor; - - @Before - public void setup() { - //sensor = (AnalogDistanceSensor)clf.createAnalogDistanceSensor(0, AnalogDistanceSensor.VoltageMaps::sharp0A51SK, "Test"); - } - - @Test - public void testSensor() { - //((MockAnalogInput)sensor.input).setVoltage(0.6d); - //assertEquals(3.93700787d, sensor.getDistance(), 0.2); - } -} diff --git a/src/test/java/xbot/common/controls/sensors/DutyCycleEncoderTest.java b/src/test/java/xbot/common/controls/sensors/DutyCycleEncoderTest.java deleted file mode 100644 index fb761300..00000000 --- a/src/test/java/xbot/common/controls/sensors/DutyCycleEncoderTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package xbot.common.controls.sensors; - -import org.junit.Assert; -import org.junit.Test; -import xbot.common.controls.sensors.mock_adapters.MockDutyCycleEncoder; -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.injection.BaseWPITest; -import xbot.common.injection.electrical_contract.DeviceInfo; -import static org.junit.Assert.assertEquals; - -public class DutyCycleEncoderTest extends BaseCommonLibTest { - - @Test - public void simpleScaling() { - MockDutyCycleEncoder encoder = (MockDutyCycleEncoder)this.getInjectorComponent().dutyCycleEncoderFactory().create(new DeviceInfo(0, false)); - - encoder.setRawPosition(0); - assertEquals(0, encoder.getAbsolutePosition().getDegrees(), 0.001); - assertEquals(0, encoder.getWrappedPosition().getDegrees(), 0.001); - - encoder.setRawPosition(0.499999999999999999); - assertEquals(180, encoder.getAbsolutePosition().getDegrees(), 0.001); - assertEquals(180, encoder.getWrappedPosition().getDegrees(), 0.001); - - encoder.setRawPosition(1.00000000001); - assertEquals(360, encoder.getAbsolutePosition().getDegrees(), 0.001); - assertEquals(0, encoder.getWrappedPosition().getDegrees(), 0.001); - } -} diff --git a/src/test/java/xbot/common/controls/sensors/JoystickButtonManagerTest.java b/src/test/java/xbot/common/controls/sensors/JoystickButtonManagerTest.java deleted file mode 100644 index a55bb927..00000000 --- a/src/test/java/xbot/common/controls/sensors/JoystickButtonManagerTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package xbot.common.controls.sensors; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.junit.Before; -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.logging.RobotAssertionManager; - - -public class JoystickButtonManagerTest extends BaseCommonLibTest { - - XJoystick testJoystick; - RobotAssertionManager assertion; - - @Before - public void setup() { - super.setUp(); - - testJoystick = getInjectorComponent().joystickFactory().create(1, 12); - assertion = getInjectorComponent().robotAssertionManager(); - } - - @Test(expected = RuntimeException.class) - public void testButtonBelowRange() { - testJoystick.getifAvailable(13); - } - - @Test(expected = RuntimeException.class) - public void testButtonZero() { - testJoystick.getifAvailable(0); - } - - @Test(expected = RuntimeException.class) - public void testButtonNegative() { - testJoystick.getifAvailable(-1); - } - - @Test - public void testAllValidButtons() { - for (int x = 1; x <= 12; x++) { - assertTrue("Button " + x + " should not be null.", null != testJoystick.getifAvailable(x)); - } - for (int x = 1; x <= 12; x++) { - assertButtonUnavailable(x); - } - } - - private void assertButtonUnavailable(int i) { - try { - testJoystick.getifAvailable(i); - fail(); - } - catch (Exception e) { - // nice! - } - } - -} diff --git a/src/test/java/xbot/common/controls/sensors/JoystickTest.java b/src/test/java/xbot/common/controls/sensors/JoystickTest.java deleted file mode 100644 index 4046fdf6..00000000 --- a/src/test/java/xbot/common/controls/sensors/JoystickTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package xbot.common.controls.sensors; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import xbot.common.controls.sensors.buttons.AnalogHIDButtonTrigger.AnalogHIDDescription; -import xbot.common.controls.sensors.mock_adapters.MockJoystick; -import xbot.common.injection.BaseCommonLibTest; - -public class JoystickTest extends BaseCommonLibTest { - - MockJoystick joystick; - - @Override - public void setUp() { - super.setUp(); - - joystick = (MockJoystick)getInjectorComponent().joystickFactory().create(0, 10); - } - - @Test - public void testAnalogButton() { - AnalogHIDDescription desc = new AnalogHIDDescription(0, -1, -.1); - joystick.addAnalogButton(desc); - assertTrue(joystick.getAnalogIfAvailable(desc) != null); - } -} diff --git a/src/test/java/xbot/common/controls/sensors/TalonCurrentMonitorTest.java b/src/test/java/xbot/common/controls/sensors/TalonCurrentMonitorTest.java deleted file mode 100644 index 3c8d0ca1..00000000 --- a/src/test/java/xbot/common/controls/sensors/TalonCurrentMonitorTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package xbot.common.controls.sensors; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.controls.actuators.mock_adapters.MockCANTalon; -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.injection.electrical_contract.CANTalonInfo; - -public class TalonCurrentMonitorTest extends BaseCommonLibTest { - - TalonCurrentMonitor currentMonitor; - XCANTalon talon; - - @Override - public void setUp() { - super.setUp(); - talon = getInjectorComponent().canTalonFactory().create(new CANTalonInfo(1)); - currentMonitor = new TalonCurrentMonitor(talon); - } - - @Test - public void overAveragingWindowTest() { - for (int i = 1; i <= currentMonitor.current_averaging_window + 1; i++) { - ((MockCANTalon) talon).setOutputCurrent(i); - currentMonitor.updateCurrent(); - currentMonitor.calculateAverageCurrent(); - } - assertEquals(14, currentMonitor.calculateAverageCurrent(), 1e-5); - assertEquals(25, currentMonitor.currentHistory.size(), 0); - } - - @Test - public void atAveragingWindowTest() { - for (int i = 1; i <= currentMonitor.current_averaging_window ; i++) { - ((MockCANTalon) talon).setOutputCurrent(i); - currentMonitor.updateCurrent(); - currentMonitor.calculateAverageCurrent(); - } - - assertEquals(13, currentMonitor.calculateAverageCurrent(), 1e-5); - assertEquals(25, currentMonitor.currentHistory.size(), 0); - } - - @Test - public void underAveragingWindowTest() { - for (int i = 1; i <= currentMonitor.current_averaging_window - 1; i++) { - ((MockCANTalon) talon).setOutputCurrent(i); - currentMonitor.updateCurrent(); - currentMonitor.calculateAverageCurrent(); - } - assertEquals(12.5, currentMonitor.calculateAverageCurrent(), 1e-5); - assertEquals(24, currentMonitor.currentHistory.size(), 0); - } - - @Test - public void trackPeakCurrentOverAveragingWindowTest() { - for (int i = 1; i <= currentMonitor.current_averaging_window; i++) { - ((MockCANTalon) talon).setOutputCurrent(i); - } - ((MockCANTalon) talon).setOutputCurrent(26); - assertEquals(26, currentMonitor.calculatePeakCurrent(), 1e-5); - } - - @Test - public void trackPeakCurrentEqualAveragingWindowTest() { - for (int i = 1; i <= currentMonitor.current_averaging_window; i++) { - ((MockCANTalon) talon).setOutputCurrent(i); - } - ((MockCANTalon) talon).setOutputCurrent(25); - assertEquals(25, currentMonitor.calculatePeakCurrent(), 1e-5); - } - - @Test - public void trackPeakCurrentUnderAveragingWindowTest() { - for (int i = 1; i <= currentMonitor.current_averaging_window; i++) { - ((MockCANTalon) talon).setOutputCurrent(i); - } - ((MockCANTalon) talon).setOutputCurrent(24); - assertEquals(24, currentMonitor.calculatePeakCurrent(), 1e-5); - } -} - - diff --git a/src/test/java/xbot/common/controls/sensors/XboxControllerTest.java b/src/test/java/xbot/common/controls/sensors/XboxControllerTest.java deleted file mode 100644 index 8865247d..00000000 --- a/src/test/java/xbot/common/controls/sensors/XboxControllerTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package xbot.common.controls.sensors; - -import org.junit.Test; - -import xbot.common.controls.sensors.XXboxController.XboxButton; -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.logging.RobotAssertionException; - -public class XboxControllerTest extends BaseCommonLibTest { - - @Test(expected = RobotAssertionException.class) - public void doubleAllocateButton() { - XXboxController controller = getInjectorComponent().xboxControllerFactory().create(0); - - // We expect the robot to get mad if we try to get the same button twice - //thrown.expect(RobotAssertionException.class); - controller.getifAvailable(XboxButton.A); - controller.getifAvailable(XboxButton.A); - } -} diff --git a/src/test/java/xbot/common/injection/BaseCommonLibTest.java b/src/test/java/xbot/common/injection/BaseCommonLibTest.java deleted file mode 100644 index 85fce66c..00000000 --- a/src/test/java/xbot/common/injection/BaseCommonLibTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package xbot.common.injection; - -import xbot.common.injection.components.CommonLibTestComponent; -import xbot.common.injection.components.DaggerCommonLibTestComponent; - -public class BaseCommonLibTest extends BaseWPITest { - - protected CommonLibTestComponent getInjectorComponent() { - return (CommonLibTestComponent)super.getInjectorComponent(); - } - - @Override - protected CommonLibTestComponent createDaggerComponent() { - return DaggerCommonLibTestComponent.create(); - } - -} diff --git a/src/test/java/xbot/common/injection/MockTimerTest.java b/src/test/java/xbot/common/injection/MockTimerTest.java deleted file mode 100644 index 6db60fbb..00000000 --- a/src/test/java/xbot/common/injection/MockTimerTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package xbot.common.injection; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import edu.wpi.first.wpilibj.MockTimer; -import edu.wpi.first.wpilibj2.command.Command; -import edu.wpi.first.wpilibj2.command.CommandScheduler; -import edu.wpi.first.wpilibj2.command.WaitCommand; -import xbot.common.command.XScheduler; - -public class MockTimerTest extends BaseCommonLibTest { - - MockTimer timer; - - @Before - public void setup() { - timer = (MockTimer)getInjectorComponent().timerImplementation(); - } - - @Test - public void test_starts_zero() { - assertEquals(0.0, timer.getFPGATimestamp(), 0.001); - } - - @Test - public void updated_by_mock() { - timer.setTimeInSeconds(10.0); - assertEquals(10.0, timer.getFPGATimestamp(), 0.001); - } - - @Test - @Ignore("Changes to WPI's Timer render this non-functional, until we find a way to inject depeer into their library") - public void test_command_timed_out() { - Command timeOut = new WaitCommand(5); - XScheduler xScheduler = getInjectorComponent().scheduler(); - - CommandScheduler.getInstance().schedule(timeOut); - // Okay, so this is kind of weird. Basically, you need to call the scheduler twice for it - // to actually pull information about the timer from the mock timer. - xScheduler.run(); - xScheduler.run(); - // and currently, due to side effects from the Xscheduler tests, we need to run more times - // to clear evil commands or something. (CrashOnInit command is still running) - xScheduler.run(); - - timer.setTimeInSeconds(11.0); - assertTrue(timeOut.isFinished()); - } - -} diff --git a/src/test/java/xbot/common/injection/TestDevicePolice.java b/src/test/java/xbot/common/injection/TestDevicePolice.java deleted file mode 100644 index 1cd6449d..00000000 --- a/src/test/java/xbot/common/injection/TestDevicePolice.java +++ /dev/null @@ -1,52 +0,0 @@ -package xbot.common.injection; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import xbot.common.injection.DevicePolice.DeviceType; -import xbot.common.logging.RobotAssertionException; -import xbot.common.logging.RobotAssertionManager; - -/** - * Unit tests for DevicePolice - */ -public class TestDevicePolice extends BaseCommonLibTest { - - /** - * Test that the same device cannot be registered twice - */ - @Test(expected = RobotAssertionException.class) - public void doubleAllocate() { - RobotAssertionManager ram = getInjectorComponent().robotAssertionManager(); - DevicePolice police = new DevicePolice(ram); - - police.registerDevice(DeviceType.Solenoid, 0, this); - police.registerDevice(DeviceType.Solenoid, 0, this); - assertTrue("You shouldn't be able to double-allocate!", false); - } - - /** - * Test that a device cannot be registered with an id greater than the maximum allowed - */ - @Test(expected = RobotAssertionException.class) - public void allocateGreaterThanMax() { - RobotAssertionManager ram = getInjectorComponent().robotAssertionManager(); - DevicePolice police = new DevicePolice(ram); - - police.registerDevice(DeviceType.Solenoid, 9000, 0, 7); - assertTrue("You shouldn't be able to allocate a value greater than the maximum!", false); - } - - /** - * Test that a device cannot be registered with an id less than the minimum allowed - */ - @Test(expected = RobotAssertionException.class) - public void allocateLessThanMin() { - RobotAssertionManager ram = getInjectorComponent().robotAssertionManager(); - DevicePolice police = new DevicePolice(ram); - - police.registerDevice(DeviceType.Solenoid, 0, 3, 7); - assertTrue("You shouldn't be able to allocate a value less than the minimum!", false); - } -} diff --git a/src/test/java/xbot/common/injection/components/CommonLibTestComponent.java b/src/test/java/xbot/common/injection/components/CommonLibTestComponent.java deleted file mode 100644 index 689f4fdd..00000000 --- a/src/test/java/xbot/common/injection/components/CommonLibTestComponent.java +++ /dev/null @@ -1,31 +0,0 @@ -package xbot.common.injection.components; - -import javax.inject.Singleton; - -import dagger.Component; -import xbot.common.command.MockSetpointCommand; -import xbot.common.command.MockSetpointSubsystem; -import xbot.common.command.MockWaitForMaintainerCommand; -import xbot.common.injection.modules.MockControlsModule; -import xbot.common.injection.modules.MockDevicesModule; -import xbot.common.injection.modules.UnitTestModule; -import xbot.common.injection.modules.UnitTestRobotModule; -import xbot.common.subsystems.pose.commands.ResetDistanceCommand; -import xbot.common.subsystems.pose.commands.SetRobotHeadingCommand; - -/** - * Do not use this directly. Use auto-generated class DaggerUnitTestComponent. - */ -@Singleton -@Component(modules = { UnitTestModule.class, MockDevicesModule.class, MockControlsModule.class, UnitTestRobotModule.class }) -public abstract class CommonLibTestComponent extends PurePursuitTestComponent { - public abstract MockSetpointCommand mockSetpointCommand(); - - public abstract MockSetpointSubsystem mockSetpointSubsystem(); - - public abstract MockWaitForMaintainerCommand mockWaitForMaintainerCommand(); - - public abstract ResetDistanceCommand resetDistanceCommand(); - - public abstract SetRobotHeadingCommand setRobotHeadingCommand(); -} diff --git a/src/test/java/xbot/common/injection/factories/TestAllFactoryClasses.java b/src/test/java/xbot/common/injection/factories/TestAllFactoryClasses.java deleted file mode 100644 index a37c949d..00000000 --- a/src/test/java/xbot/common/injection/factories/TestAllFactoryClasses.java +++ /dev/null @@ -1,72 +0,0 @@ -package xbot.common.injection.factories; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import edu.wpi.first.wpilibj.I2C; -import xbot.common.controls.actuators.XCANSparkMaxPIDProperties; -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.controls.sensors.XJoystick; -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.injection.electrical_contract.CANTalonInfo; -import xbot.common.injection.electrical_contract.DeviceInfo; -import xbot.common.logging.RobotAssertionException; -import xbot.common.subsystems.drive.control_logic.HeadingModule; - -public class TestAllFactoryClasses extends BaseCommonLibTest { - - @Test - public void makeOneOfEverything() { - getInjectorComponent().pidFactory().create("pid"); - getInjectorComponent().pidPropertyManagerFactory().create("pid", 0, 0, 0, 0); - getInjectorComponent().powerDistributionPanelFactory().create(); - getInjectorComponent().encoderFactory().create("foo", 1, 2, 1); - getInjectorComponent().digitalInputFactory().create(5); - getInjectorComponent().analogInputFactory().create(1); - getInjectorComponent().xboxControllerFactory().create(2); - getInjectorComponent().solenoidFactory().create(1); - getInjectorComponent().digitalOutputFactory().create(3); - getInjectorComponent().servoFactory().create(1); - getInjectorComponent().speedControllerFactory().create(2); - getInjectorComponent().gyroFactory().create(I2C.Port.kMXP); - getInjectorComponent().lidarLiteFactory().create(I2C.Port.kOnboard, "Test"); - XJoystick j = getInjectorComponent().joystickFactory().create(1, 12); - getInjectorComponent().joystickButtonFactory().create(j, 1); - getInjectorComponent().analogHidButtonFactory().create(j, 1, -1, 1); - getInjectorComponent().povButtonFactory().create(j, 1); - getInjectorComponent().ftcGamepadFactory().create(3, 10); - getInjectorComponent().humanVsMachineDeciderFactory().create("Agent Smith"); - HeadingModule h = getInjectorComponent().headingModuleFactory().create(pf.create("bar", 1, 0, 0)); - getInjectorComponent().headingAssistModuleFactory().create(h, "heading"); - getInjectorComponent().calibrationDeciderFactory().create("calibration"); - getInjectorComponent().velocityThrottleModuleFactory().create("velocityThrottleThing", pf.create("velocity", 1, 0, 0)); - getInjectorComponent().compressorFactory().create(); - getInjectorComponent().relayFactory().create(5); - getInjectorComponent().pwmFactory().create(3); - getInjectorComponent().fieldPosePropertyManagerFactory().create("testo", 1, 2, 3); - getInjectorComponent().zeromqListenerFactory().create("testo", "testo"); - getInjectorComponent().chordButtonFactory().create( - getInjectorComponent().joystickButtonFactory().create(j, 2), - getInjectorComponent().joystickButtonFactory().create(j, 3)); - getInjectorComponent().virtualButtonFactory().create(); - getInjectorComponent().doubleSolenoidFactory().create( - getInjectorComponent().solenoidFactory().create(2), - getInjectorComponent().solenoidFactory().create(3)); - getInjectorComponent().canSparkMaxFactory().create(new DeviceInfo(10), "drive", "left"); - getInjectorComponent().canSparkMaxFactory().create(new DeviceInfo(11), "drive", "left", new XCANSparkMaxPIDProperties(1, 0, 0, 0, 0, 0.5, -0.5)); - XCANTalon talon = getInjectorComponent().canTalonFactory().create(new CANTalonInfo(1)); - getInjectorComponent().as5600Factory().create(talon); - getInjectorComponent().canVictorSpxFactory().create(5); - getInjectorComponent().absoluteEncoderFactory().create(new DeviceInfo(6), "test"); - getInjectorComponent().stallDetectorFactory().create("owningSystem"); - getInjectorComponent().canCoderFactory().create(new DeviceInfo(7), "test"); - } - - @Test(expected = RobotAssertionException.class) - public void doubleAllocate() { - getInjectorComponent().canTalonFactory().create(new CANTalonInfo(1)); - getInjectorComponent().canTalonFactory().create(new CANTalonInfo(1)); - assertTrue("You shouldn't be able to double-allocate!", false); - } -} diff --git a/src/test/java/xbot/common/logging/RobotSessionTest.java b/src/test/java/xbot/common/logging/RobotSessionTest.java deleted file mode 100644 index c7ee8fb8..00000000 --- a/src/test/java/xbot/common/logging/RobotSessionTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package xbot.common.logging; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class RobotSessionTest extends BaseCommonLibTest { - - RobotSession rs; - - @Before - @Override - public void setUp() { - super.setUp(); - rs = getInjectorComponent().robotSession(); - } - - @Test - public void simpleTest() { - String id = rs.getSessionId(); - System.out.println("SessionId: " + id); - } - - @Test - public void testTypicalProgression() { - String id1 = rs.getSessionId(); - rs.autoInit(); - String id2 = rs.getSessionId(); - - assertFalse("New ID should have been generated when starting auto", id1.equals(id2)); - - rs.teleopInit(); - String id3 = rs.getSessionId(); - - assertTrue("Id should remain the same when entering teleop from auto", id2.equals(id3)); - - rs.teleopInit(); - String id4 = rs.getSessionId(); - - assertFalse("New ID should have been generated when starting teleop from teleop", id3.equals(id4)); - } - - @Test - public void testEnteringTeleopFromNothing() { - String id1 = rs.getSessionId(); - rs.teleopInit(); - String id2 = rs.getSessionId(); - rs.teleopInit(); - String id3 = rs.getSessionId(); - - assertTrue("First teleop entry (from nothing) should keep the ID", id1.equals(id2)); - assertFalse("New ID should have been generated when entering telepo again", id2.equals(id3)); - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/logging/SafeRobotAssertionTest.java b/src/test/java/xbot/common/logging/SafeRobotAssertionTest.java deleted file mode 100644 index 689fe590..00000000 --- a/src/test/java/xbot/common/logging/SafeRobotAssertionTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package xbot.common.logging; - -import org.apache.log4j.Logger; -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class SafeRobotAssertionTest extends BaseCommonLibTest { - - private static Logger log = Logger.getLogger(SafeRobotAssertionTest.class); - - @Test - public void testNoExceptionOnRobot() { - RobotAssertionManager assertMan = new SilentRobotAssertionManager(); - - assertMan.throwException(new RuntimeException("Something really bad happened (...but robots never die)")); - } - - @Test(expected=RuntimeException.class) - public void testExceptionThrownInTests() { - RobotAssertionManager assertMan = new LoudRobotAssertionManager(); - - assertMan.throwException(new RuntimeException("Something really bad happened (tests are free to die as necessary)")); - } - - @Test - public void testAssertionContinuesOnRobot() { - RobotAssertionManager assertMan = new SilentRobotAssertionManager(); - - assertMan.assertTrue(true, "The world is ending"); - assertMan.assertTrue(false, "false != true"); - log.info("Yet the world keeps turning"); - } - - @Test(expected=RobotAssertionException.class) - public void testAssertionFailedInTests() { - RobotAssertionManager assertMan = new LoudRobotAssertionManager(); - - assertMan.assertTrue(false, "false != true"); - } - - @Test() - public void testAssertionPassedInTests() { - RobotAssertionManager assertMan = new LoudRobotAssertionManager(); - - assertMan.assertTrue(true, "The world is ending"); - } -} diff --git a/src/test/java/xbot/common/logging/TimeLoggerTest.java b/src/test/java/xbot/common/logging/TimeLoggerTest.java deleted file mode 100644 index 337c7a99..00000000 --- a/src/test/java/xbot/common/logging/TimeLoggerTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package xbot.common.logging; - -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class TimeLoggerTest extends BaseCommonLibTest { - - TimeLogger tl; - - @Override - public void setUp() { - super.setUp(); - tl = new TimeLogger("Examplo", 1); - } - - @Test - public void simpleTest() { - tl.start(); - - timer.advanceTimeInSecondsBy(2); - tl.stop(); - } - - @Test - public void testMultipleMeasurements() { - tl.start(); - timer.advanceTimeInSecondsBy(0.25); - tl.stop(); - - timer.advanceTimeInSecondsBy(1); - - tl.start(); - timer.advanceTimeInSecondsBy(0.75); - tl.stop(); - } - - @Test - public void testOutOfOrder() { - tl.stop(); - tl.stop(); - tl.stop(); - - tl.start(); - tl.start(); - tl.start(); - - tl.stop(); - tl.stop(); - tl.stop(); - } -} diff --git a/src/test/java/xbot/common/logging/WordGeneratorTest.java b/src/test/java/xbot/common/logging/WordGeneratorTest.java deleted file mode 100644 index cde76193..00000000 --- a/src/test/java/xbot/common/logging/WordGeneratorTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package xbot.common.logging; - -import static org.junit.Assert.assertFalse; - -import org.junit.Before; -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class WordGeneratorTest extends BaseCommonLibTest { - - @Before - public void setUp() { - super.setUp(); - } - - @Test - public void testWords() { - WordGenerator wg = new WordGenerator(); - String chain = wg.getRandomWordChain(3, "-"); - System.out.println(chain); - } - - @Test - public void testOneWord() { - WordGenerator wg = new WordGenerator(); - String chain = wg.getRandomWordChain(1, "-"); - assertFalse("Should only contain one word with no separator", chain.contains("-")); - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/logic/HumanVsMachineDeciderTest.java b/src/test/java/xbot/common/logic/HumanVsMachineDeciderTest.java deleted file mode 100644 index b8dda949..00000000 --- a/src/test/java/xbot/common/logic/HumanVsMachineDeciderTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package xbot.common.logic; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.logic.HumanVsMachineDecider.HumanVsMachineMode; - -public class HumanVsMachineDeciderTest extends BaseCommonLibTest { - - HumanVsMachineDecider decider; - - @Override - public void setUp() { - super.setUp(); - decider = getInjectorComponent().humanVsMachineDeciderFactory().create("Test"); - } - - @Test - public void testStandardPath() { - assertTrue("Start in machine control", decider.getRecommendedMode(0) == HumanVsMachineMode.MachineControl); - - assertTrue("Human input brings us back out", decider.getRecommendedMode(1) == HumanVsMachineMode.HumanControl); - timer.advanceTimeInSecondsBy(0.01); - assertTrue("Then we coast", decider.getRecommendedMode(0.01) == HumanVsMachineMode.Coast); - timer.advanceTimeInSecondsBy(1); - assertTrue("Advance to initialize", decider.getRecommendedMode(0) == HumanVsMachineMode.InitializeMachineControl); - assertTrue("Machine Control", decider.getRecommendedMode(0) == HumanVsMachineMode.MachineControl); - } -} diff --git a/src/test/java/xbot/common/logic/LatchTest.java b/src/test/java/xbot/common/logic/LatchTest.java deleted file mode 100644 index 8c383b6b..00000000 --- a/src/test/java/xbot/common/logic/LatchTest.java +++ /dev/null @@ -1,174 +0,0 @@ -package xbot.common.logic; - -import static junit.framework.TestCase.assertEquals; - -import java.util.function.Consumer; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import xbot.common.logic.Latch.EdgeType; - -public class LatchTest { - - private LatchTestObserver latchTestObserver; - - @Before - public void setUp() { - latchTestObserver = new LatchTestObserver(); - } - - @After - public void tearDown() { - latchTestObserver = null; - } - - @Test - public void testRisingEdge() { - Latch latch = new Latch(false, Latch.EdgeType.RisingEdge); - latch.addObserver(latchTestObserver); - verifyEdgeType(null); - verifyTimesUpdateWasCalled(0); - latch.setValue(true); - verifyEdgeType(Latch.EdgeType.RisingEdge); - verifyTimesUpdateWasCalled(1); - } - - @Test - public void testFallingEdge() { - Latch latch = new Latch(true, Latch.EdgeType.FallingEdge); - latch.addObserver(latchTestObserver); - verifyEdgeType(null); - verifyTimesUpdateWasCalled(0); - latch.setValue(false); - verifyEdgeType(Latch.EdgeType.FallingEdge); - verifyTimesUpdateWasCalled(1); - } - - @Test - public void testRiseFallRiseObservingRisingEdge() { - Latch latch = new Latch(false, Latch.EdgeType.RisingEdge); - latch.addObserver(latchTestObserver); - verifyEdgeType(null); - verifyTimesUpdateWasCalled(0); - latch.setValue(true); - verifyEdgeType(Latch.EdgeType.RisingEdge); - verifyTimesUpdateWasCalled(1); - latch.setValue(false); - verifyEdgeType(Latch.EdgeType.RisingEdge); - verifyTimesUpdateWasCalled(1); - latch.setValue(true); - verifyTimesUpdateWasCalled(2); - } - - @Test - public void testFallRiseFallObservingFallingEdge() { - Latch latch = new Latch(true, Latch.EdgeType.FallingEdge); - latch.addObserver(latchTestObserver); - verifyEdgeType(null); - verifyTimesUpdateWasCalled(0); - latch.setValue(false); - verifyEdgeType(Latch.EdgeType.FallingEdge); - verifyTimesUpdateWasCalled(1); - latch.setValue(true); - verifyEdgeType(Latch.EdgeType.FallingEdge); - verifyTimesUpdateWasCalled(1); - latch.setValue(false); - verifyTimesUpdateWasCalled(2); - } - - @Test - public void testFallRiseRiseFallRiseFallObservingRisingEdge() { - Latch latch = new Latch(false, Latch.EdgeType.RisingEdge); - latch.addObserver(latchTestObserver); - verifyEdgeType(null); - latch.setValue(false); - verifyEdgeType(null); - verifyTimesUpdateWasCalled(0); - latch.setValue(true); - verifyEdgeType(Latch.EdgeType.RisingEdge); - verifyTimesUpdateWasCalled(1); - latch.setValue(true); - verifyEdgeType(Latch.EdgeType.RisingEdge); - verifyTimesUpdateWasCalled(1); - latch.setValue(false); - verifyEdgeType(Latch.EdgeType.RisingEdge); - verifyTimesUpdateWasCalled(1); - latch.setValue(true); - verifyEdgeType(Latch.EdgeType.RisingEdge); - verifyTimesUpdateWasCalled(2); - latch.setValue(false); - verifyEdgeType(Latch.EdgeType.RisingEdge); - verifyTimesUpdateWasCalled(2); - } - - @Test - public void testFallRiseRiseFallRiseFallObservingFallingEdge() { - Latch latch = new Latch(true, Latch.EdgeType.FallingEdge); - latch.addObserver(latchTestObserver); - verifyEdgeType(null); - latch.setValue(true); - verifyEdgeType(null); - verifyTimesUpdateWasCalled(0); - latch.setValue(false); - verifyEdgeType(Latch.EdgeType.FallingEdge); - verifyTimesUpdateWasCalled(1); - latch.setValue(false); - verifyEdgeType(Latch.EdgeType.FallingEdge); - verifyTimesUpdateWasCalled(1); - latch.setValue(true); - verifyEdgeType(Latch.EdgeType.FallingEdge); - verifyTimesUpdateWasCalled(1); - latch.setValue(false); - verifyEdgeType(Latch.EdgeType.FallingEdge); - verifyTimesUpdateWasCalled(2); - latch.setValue(true); - verifyEdgeType(Latch.EdgeType.FallingEdge); - verifyTimesUpdateWasCalled(2); - } - - @Test - public void testRiseFallRiseObservingBothEdges() { - Latch latch = new Latch(true, Latch.EdgeType.Both); - latch.addObserver(latchTestObserver); - verifyTimesUpdateWasCalled(0); - latch.setValue(false); - verifyEdgeType(Latch.EdgeType.FallingEdge); - verifyTimesUpdateWasCalled(1); - latch.setValue(true); - verifyEdgeType(Latch.EdgeType.RisingEdge); - verifyTimesUpdateWasCalled(2); - latch.setValue(false); - verifyEdgeType(Latch.EdgeType.FallingEdge); - verifyTimesUpdateWasCalled(3); - } - - private void verifyTimesUpdateWasCalled(int expected) { - assertEquals(expected, latchTestObserver.getNumTimesUpdated()); - } - - private void verifyEdgeType(Latch.EdgeType expected) { - assertEquals(expected, latchTestObserver.getLastUpdateEdgeType()); - } - - class LatchTestObserver implements Consumer { - - private Latch.EdgeType lastUpdateEdgeType = null; - private int numTimesUpdated = 0; - - public Latch.EdgeType getLastUpdateEdgeType() { - return lastUpdateEdgeType; - } - - public int getNumTimesUpdated() { - return numTimesUpdated; - } - - @Override - public void accept(EdgeType e) { - numTimesUpdated++; - lastUpdateEdgeType = e; - } - } -} diff --git a/src/test/java/xbot/common/logic/StallDetectorTest.java b/src/test/java/xbot/common/logic/StallDetectorTest.java deleted file mode 100644 index aa5819c2..00000000 --- a/src/test/java/xbot/common/logic/StallDetectorTest.java +++ /dev/null @@ -1,97 +0,0 @@ -package xbot.common.logic; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.logic.StallDetector.StallState; - -public class StallDetectorTest extends BaseCommonLibTest { - - StallDetector stallDetector; - - @Override - public void setUp() { - super.setUp(); - stallDetector = getInjectorComponent().stallDetectorFactory().create("OwningSystem"); - - stallDetector.setAllParameters( - 1.0, // current time window - 10, // current limit - 1.0, // no motion time window - 0.5, // voltage limit - 7, // velocity limit - 2.0); // stall cool down - } - - @Test - public void testCurrentStallConditions() { - // Way over current limit - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(100, 0,0)); - // Needs to be that way for a little while - timer.advanceTimeInSecondsBy(1.1); - assertEquals(StallState.STALLED, stallDetector.getIsStalled(100, 0,0)); - timer.advanceTimeInSecondsBy(0.1); - assertEquals(StallState.STALLED, stallDetector.getIsStalled(100, 0,0)); - - // Now, stop forcing the mechanism - assertEquals(StallState.WAS_STALLED_RECENTLY, stallDetector.getIsStalled(0,0,0)); - // Wait a while - timer.advanceTimeInSecondsBy(1.9); - assertEquals(StallState.WAS_STALLED_RECENTLY, stallDetector.getIsStalled(0,0,0)); - // Wait across the stall cool down - timer.advanceTimeInSecondsBy(0.2); - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,0,0)); - } - - @Test - public void testMotionStallConditions() { - // Large voltage but no motion - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,1,0)); - timer.advanceTimeInSecondsBy(1.1); - assertEquals(StallState.STALLED, stallDetector.getIsStalled(0,1,0)); - // Stop applying voltage, but only go forwards in time a little - timer.advanceTimeInSecondsBy(0.1); - assertEquals(StallState.WAS_STALLED_RECENTLY, stallDetector.getIsStalled(0,0,0)); - // Wait a while for the system to cool down - timer.advanceTimeInSecondsBy(2.5); - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,0,0)); - } - - @Test - public void testNegativeVoltageMotionStallConditions() { - // Large voltage but no motion - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,-1,0)); - timer.advanceTimeInSecondsBy(1.1); - assertEquals(StallState.STALLED, stallDetector.getIsStalled(0,-1,0)); - // Stop applying voltage, but only go forwards in time a little - timer.advanceTimeInSecondsBy(0.1); - assertEquals(StallState.WAS_STALLED_RECENTLY, stallDetector.getIsStalled(0,0,0)); - // Wait a while for the system to cool down - timer.advanceTimeInSecondsBy(2.5); - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,0,0)); - } - - @Test - public void testNormalMotion() { - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,1, 100)); - timer.advanceTimeInSecondsBy(1.5); - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,1, 100)); - timer.advanceTimeInSecondsBy(1.5); - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,1, 100)); - timer.advanceTimeInSecondsBy(1.5); - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,1, 100)); - - timer.advanceTimeInSecondsBy(50); - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,-1, -100)); - timer.advanceTimeInSecondsBy(1.5); - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,-1, -100)); - timer.advanceTimeInSecondsBy(1.5); - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,-1, -100)); - timer.advanceTimeInSecondsBy(1.5); - assertEquals(StallState.NOT_STALLED, stallDetector.getIsStalled(0,-1, -100)); - - } - -} diff --git a/src/test/java/xbot/common/logic/TimeStableValidatorTest.java b/src/test/java/xbot/common/logic/TimeStableValidatorTest.java deleted file mode 100644 index 242fe25a..00000000 --- a/src/test/java/xbot/common/logic/TimeStableValidatorTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package xbot.common.logic; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class TimeStableValidatorTest extends BaseCommonLibTest { - - TimeStableValidator tsv; - - @Override - public void setUp() { - super.setUp(); - tsv = new TimeStableValidator(1); - } - - @Test - public void simpleTest() { - boolean result = tsv.checkStable(true); - assertFalse(result); - - timer.advanceTimeInSecondsBy(0.5); - result = tsv.checkStable(true); - assertFalse(result); - - timer.advanceTimeInSecondsBy(0.6); - result = tsv.checkStable(true); - assertTrue(result); - } - - @Test - public void negativeWindow() { - tsv = new TimeStableValidator(-1); - - boolean result = tsv.checkStable(true); - assertTrue(result); - } - - @Test - public void trueFalseTrue() { - boolean result = tsv.checkStable(true); - assertFalse(result); - - timer.advanceTimeInSecondsBy(0.5); - result = tsv.checkStable(false); - assertFalse(result); - - timer.advanceTimeInSecondsBy(0.6); - result = tsv.checkStable(true); - assertFalse(result); - - timer.advanceTimeInSecondsBy(1.1); - result = tsv.checkStable(true); - assertTrue(result); - } - - @Test - public void stableThenUnstable() { - boolean result = tsv.checkStable(true); - assertFalse(result); - - timer.advanceTimeInSecondsBy(1.1); - result = tsv.checkStable(true); - assertTrue(result); - - result = tsv.checkStable(false); - assertFalse(result); - - result = tsv.checkStable(true); - assertFalse(result); - - timer.advanceTimeInSecondsBy(1.1); - result = tsv.checkStable(true); - assertTrue(result); - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/logic/VelocityThrottleModuleTest.java b/src/test/java/xbot/common/logic/VelocityThrottleModuleTest.java deleted file mode 100644 index 4880a93e..00000000 --- a/src/test/java/xbot/common/logic/VelocityThrottleModuleTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package xbot.common.logic; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class VelocityThrottleModuleTest extends BaseCommonLibTest { - - VelocityThrottleModule module; - - @Override - public void setUp() { - super.setUp(); - module = getInjectorComponent().velocityThrottleModuleFactory().create("testModule", pf.create("testVelocityPid", 1, 0, 0)); - } - - @Test - public void simpleTest() { - // Just making sure no exceptions in standard operation. - module.calculateThrottle(1, 0); - } - - @Test - public void testResponse() { - assertEquals(1, module.calculateThrottle(1, 0), 0.001); - } - - @Test - public void testIteratedResponse() { - assertEquals(0.5, module.calculateThrottle(0.5, 0), 0.001); - assertEquals(1, module.calculateThrottle(0.5, 0), 0.001); - } - - @Test - public void testSaturation() { - assertEquals(1, module.calculateThrottle(1, 0), 0.001); - assertEquals(1, module.calculateThrottle(1, 0), 0.001); - assertEquals(1, module.calculateThrottle(1, 0), 0.001); - - // The first run is zero, since the internal pid can only change by 1 unit maximum. - assertEquals(0, module.calculateThrottle(-100, 0), 0.001); - // After that, we should see it stuck at -1. - assertEquals(-1, module.calculateThrottle(-100, 0), 0.001); - assertEquals(-1, module.calculateThrottle(-100, 0), 0.001); - } - - @Test - public void testReset() { - assertEquals(0.5, module.calculateThrottle(0.5, 0), 0.001); - assertEquals(1, module.calculateThrottle(0.5, 0), 0.001); - - module.reset(); - assertEquals(0.5, module.calculateThrottle(0.5, 0), 0.001); - } -} diff --git a/src/test/java/xbot/common/logic/WatchdogTimerTest.java b/src/test/java/xbot/common/logic/WatchdogTimerTest.java deleted file mode 100644 index 4a972d9f..00000000 --- a/src/test/java/xbot/common/logic/WatchdogTimerTest.java +++ /dev/null @@ -1,128 +0,0 @@ -package xbot.common.logic; - -import org.junit.Before; -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -import static junit.framework.TestCase.assertEquals; - -public class WatchdogTimerTest extends BaseCommonLibTest { - - private WatchdogTimer watchdog; - int upCount; - int downCount; - - @Before - public void setUp() { - super.setUp(); - upCount = 0; - downCount = 0; - watchdog = new WatchdogTimer(5, () -> upCount++, () -> downCount++); - } - - @Test - public void testBasic() { - watchdog.check(); - assertEquals(0, upCount); - assertEquals(0, downCount); - - timer.advanceTimeInSecondsBy(10); - - watchdog.check(); - assertEquals(0, upCount); - assertEquals(0, downCount); - - watchdog.kick(); - watchdog.check(); - - assertEquals(1, upCount); - assertEquals(0, downCount); - - timer.advanceTimeInSecondsBy(4); - - watchdog.check(); - assertEquals(1, upCount); - assertEquals(0, downCount); - - timer.advanceTimeInSecondsBy(1.5); - - watchdog.check(); - assertEquals(1, upCount); - assertEquals(1, downCount); - } - - @Test - public void testSustained() { - watchdog.check(); - assertEquals(0, upCount); - assertEquals(0, downCount); - - timer.advanceTimeInSecondsBy(1); - - watchdog.kick(); - - watchdog.check(); - assertEquals(1, upCount); - assertEquals(0, downCount); - - timer.advanceTimeInSecondsBy(1); - - watchdog.check(); - assertEquals(1, upCount); - assertEquals(0, downCount); - - timer.advanceTimeInSecondsBy(3); - watchdog.kick(); - - watchdog.check(); - assertEquals(1, upCount); - assertEquals(0, downCount); - - timer.advanceTimeInSecondsBy(3); - - watchdog.check(); - assertEquals(1, upCount); - assertEquals(0, downCount); - - timer.advanceTimeInSecondsBy(3); - - watchdog.check(); - assertEquals(1, upCount); - assertEquals(1, downCount); - } - - @Test - public void testRepeated() { - watchdog.check(); - assertEquals(0, upCount); - assertEquals(0, downCount); - - timer.advanceTimeInSecondsBy(5); - - watchdog.kick(); - - watchdog.check(); - assertEquals(1, upCount); - assertEquals(0, downCount); - - timer.advanceTimeInSecondsBy(6); - - watchdog.check(); - assertEquals(1, upCount); - assertEquals(1, downCount); - - timer.advanceTimeInSecondsBy(1.5); - watchdog.kick(); - - watchdog.check(); - assertEquals(2, upCount); - assertEquals(1, downCount); - - timer.advanceTimeInSecondsBy(6); - - watchdog.check(); - assertEquals(2, upCount); - assertEquals(2, downCount); - } -} diff --git a/src/test/java/xbot/common/math/ContiguousDoubleTest.java b/src/test/java/xbot/common/math/ContiguousDoubleTest.java deleted file mode 100644 index e31b41e0..00000000 --- a/src/test/java/xbot/common/math/ContiguousDoubleTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package xbot.common.math; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class ContiguousDoubleTest extends BaseCommonLibTest { - @Test - public void testCore() { - ContiguousDouble testInstance = new ContiguousDouble(5, 0, 10); - assertEquals(5, testInstance.getValue(), 0); - } - - @Test - public void testWrapping() { - ContiguousDouble testInstance = new ContiguousDouble(-4, 0, 10); - assertEquals("Test wrapping #1", 6, testInstance.getValue(), 0); - - testInstance.setValue(16); - assertEquals("Test wrapping #2", 6, testInstance.getValue(), 0); - - testInstance.setValue(28); - assertEquals("Test wrapping #3", 8, testInstance.getValue(), 0); - } - - @Test - public void testDifference() { - ContiguousDouble testInstance = new ContiguousDouble(2, 0, 10); - assertEquals("Test difference #1", 2, testInstance.difference(4), 0); - assertEquals("Test difference #2", -1, testInstance.difference(11), 0); - - testInstance.setValue(9); - assertEquals("Test difference #3", 2, testInstance.difference(11), 0); - - testInstance.setValue(10); - assertEquals("Test difference #4", 1, testInstance.difference(1), 0); - testInstance.setValue(1); - assertEquals("Test difference #5", -1, testInstance.difference(10), 0); - } - - @Test - public void testRotationBounds() { - ContiguousDouble testInstance = new ContiguousDouble(150, -180, 180); - - assertEquals("+40", 40, testInstance.difference(190), 0.001); - assertEquals("+40 wrapped", 40, testInstance.difference(-170), 0.001); - - assertEquals("+40", 40, testInstance.difference(190), 0.001); - assertEquals("+40 wrapped", 40, testInstance.difference(-170), 0.001); - - testInstance.setValue(180); - - assertEquals("180", 180, testInstance.getValue(), 0.001); - assertEquals("NoDiff", 0, testInstance.difference(-180), 0.001); - - testInstance = new ContiguousDouble(40, -180, 180); - assertEquals("+40", -140, testInstance.difference(-100), 0.001); - } - - @Test - public void testShiftingValue() { - ContiguousDouble testInstance = new ContiguousDouble(150, -180, 180); - testInstance.shiftValue(40); - assertEquals("+40", -170, testInstance.getValue(), 0.001); - - testInstance.shiftValue(40); - assertEquals("+40 again", -130, testInstance.getValue(), 0.001); - - testInstance.shiftValue(360); - assertEquals("+360 again", -130, testInstance.getValue(), 0.001); - - testInstance.shiftValue(0); - assertEquals("+0", -130, testInstance.getValue(), 0.001); - } - - @Test - public void testBadBounds() { - ContiguousDouble testInstance = new ContiguousDouble(150, 180, -180); - assertEquals("lower", -180, testInstance.getLowerBound(), 0.001); - assertEquals("upper", 180, testInstance.getUpperBound(), 0.001); - } - - @Test - public void extraFeatures() { - ContiguousDouble testInstance = new ContiguousDouble(150, -180, 180); - assertEquals("Above", 510, testInstance.unwrapAbove(), 0.001); - assertEquals("Below", -210, testInstance.unwrapBelow(), 0.001); - } -} diff --git a/src/test/java/xbot/common/math/FieldPoseManagerTest.java b/src/test/java/xbot/common/math/FieldPoseManagerTest.java deleted file mode 100644 index 781da296..00000000 --- a/src/test/java/xbot/common/math/FieldPoseManagerTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package xbot.common.math; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class FieldPoseManagerTest extends BaseCommonLibTest { - - @Test - public void testCreation() { - FieldPosePropertyManager fppm = getInjectorComponent().fieldPosePropertyManagerFactory().create("Suffix", 1, 2, 3); - fppm.getPose(); - assertEquals(1, fppm.getPose().getPoint().x, 0.001); - assertEquals(2, fppm.getPose().getPoint().y, 0.001); - assertEquals(3, fppm.getPose().getHeading().getDegrees(), 0.001); - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/math/FieldPoseTest.java b/src/test/java/xbot/common/math/FieldPoseTest.java deleted file mode 100644 index 319d6c1c..00000000 --- a/src/test/java/xbot/common/math/FieldPoseTest.java +++ /dev/null @@ -1,167 +0,0 @@ -package xbot.common.math; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import edu.wpi.first.math.geometry.Rotation2d; - -public class FieldPoseTest { - - @Test - public void testHorizontal() { - FieldPose pose = new FieldPose(new XYPair(0, 0), Rotation2d.fromDegrees(0)); - assertEquals(10, pose.getDistanceToLineFromPoint(new XYPair(10, 10)), 10e-5); - } - - @Test - public void testVertical() { - FieldPose pose = new FieldPose(new XYPair(0, 0), Rotation2d.fromDegrees(90)); - assertEquals(10, pose.getDistanceToLineFromPoint(new XYPair(10, 10)), 10e-5); - - pose = new FieldPose(new XYPair(0, 0), Rotation2d.fromDegrees(-90)); - assertEquals(10, pose.getDistanceToLineFromPoint(new XYPair(10, 10)), 10e-5); - } - - @Test - public void test45deg() { - FieldPose pose = new FieldPose(new XYPair(0, 0), Rotation2d.fromDegrees(45)); - assertEquals(Math.hypot(4.5 - 3, 6 - 4.5), pose.getDistanceToLineFromPoint(new XYPair(6, 3)), 10e-5); - } - - @Test - public void testHorizontalWithOffset() { - FieldPose pose = new FieldPose(new XYPair(0, 10), Rotation2d.fromDegrees(0)); - assertEquals(5, pose.getDistanceToLineFromPoint(new XYPair(10, 5)), 10e-5); - } - - @Test - public void testVerticalWithOffset() { - FieldPose pose = new FieldPose(new XYPair(10, 0), Rotation2d.fromDegrees(90)); - assertEquals(5, pose.getDistanceToLineFromPoint(new XYPair(5, 10)), 10e-5); - } - - @Test - public void test45degWithOffset() { - FieldPose pose = new FieldPose(new XYPair(10, 0), Rotation2d.fromDegrees(45)); - assertEquals(Math.hypot(20 - 17.5, 7.5 - 5), pose.getDistanceToLineFromPoint(new XYPair(20, 5)), 10e-5); - assertEquals(Math.hypot(8 - 7, -1 + 2), pose.getDistanceToLineFromPoint(new XYPair(7, -1)), 10e-5); - } - - @Test - public void testNegAngle() { - FieldPose pose = new FieldPose(new XYPair(10, 0), Rotation2d.fromDegrees(-45)); - assertEquals(Math.hypot(9 - 8, 3 - 2), pose.getDistanceToLineFromPoint(new XYPair(9, 3)), 10e-5); - } - - @Test - public void testRabbitOffsetVertical() { - FieldPose robotPose = new FieldPose(new XYPair(0, 0), Rotation2d.fromDegrees(90)); - FieldPose goal = new FieldPose(new XYPair(10, 10), Rotation2d.fromDegrees(90)); - assertEquals(10, goal.getDistanceToLineFromPoint(new XYPair(0, 0)), 10e-5); - - FieldPose rabbitLocation = goal.getRabbitPose(robotPose.getPoint(), 5); - assertEquals(10, rabbitLocation.getPoint().x, 0.001); - assertEquals(5, rabbitLocation.getPoint().y, 0.001); - - double angle = goal.getDeltaAngleToRabbit(robotPose, 5); - assertEquals(-63, angle, 1); - } - - @Test - public void testRabbitOnPath() { - FieldPose robotPose = new FieldPose(new XYPair(10, 0), Rotation2d.fromDegrees(90)); - FieldPose goal = new FieldPose(new XYPair(10, 10), Rotation2d.fromDegrees(90)); - assertEquals(10, goal.getDistanceToLineFromPoint(new XYPair(0, 0)), 10e-5); - - FieldPose rabbitLocation = goal.getRabbitPose(robotPose.getPoint(), 5); - assertEquals(10, rabbitLocation.getPoint().x, 0.001); - assertEquals(5, rabbitLocation.getPoint().y, 0.001); - - double angle = goal.getDeltaAngleToRabbit(robotPose, 5); - assertEquals(0, angle, 1); - } - - @Test - public void testRabbitSlightlyOffPath() { - FieldPose robotPose = new FieldPose(new XYPair(9.99, 0), Rotation2d.fromDegrees(90)); - FieldPose goal = new FieldPose(new XYPair(10, 10), Rotation2d.fromDegrees(90)); - assertEquals(10, goal.getDistanceToLineFromPoint(new XYPair(0, 0)), 10e-5); - - FieldPose rabbitLocation = goal.getRabbitPose(robotPose.getPoint(), 5); - assertEquals(10, rabbitLocation.getPoint().x, 0.001); - assertEquals(5, rabbitLocation.getPoint().y, 0.001); - - double angle = goal.getDeltaAngleToRabbit(robotPose, 5); - assertEquals(0, angle, 1); - } - - @Test - public void testRabbitHilariouslyOffPath() { - FieldPose robotPose = new FieldPose(new XYPair(-1000, 0), Rotation2d.fromDegrees(90)); - FieldPose goal = new FieldPose(new XYPair(10, 10), Rotation2d.fromDegrees(90)); - assertEquals(10, goal.getDistanceToLineFromPoint(new XYPair(0, 0)), 10e-5); - - FieldPose rabbitLocation = goal.getRabbitPose(robotPose.getPoint(), 5); - assertEquals(10, rabbitLocation.getPoint().x, 0.001); - assertEquals(5, rabbitLocation.getPoint().y, 0.001); - - double angle = goal.getDeltaAngleToRabbit(robotPose, 5); - assertEquals(-90, angle, 1); - } - - @Test - public void testGetAngleToPoint() { - FieldPose robotPose = new FieldPose(new XYPair(0, 0), Rotation2d.fromDegrees(90)); - XYPair goalPoint = new XYPair(10, 10); - assertEquals(45, robotPose.getAngleToPoint(goalPoint), 0.001); - - robotPose = new FieldPose(new XYPair(10, 0), Rotation2d.fromDegrees(90)); - assertEquals(90, robotPose.getAngleToPoint(goalPoint), 0.001); - - robotPose = new FieldPose(new XYPair(10, 10), Rotation2d.fromDegrees(90)); - assertEquals(0, robotPose.getAngleToPoint(goalPoint), 0.001); - - robotPose = new FieldPose(new XYPair(10, 9.99999999), Rotation2d.fromDegrees(90)); - assertEquals(90, robotPose.getAngleToPoint(goalPoint), 0.001); - - robotPose = new FieldPose(new XYPair(20, 20), Rotation2d.fromDegrees(90)); - assertEquals(-135, robotPose.getAngleToPoint(goalPoint), 0.001); - } - - @Test - public void testGetPointAlongPose() { - FieldPose robotPose = new FieldPose(new XYPair(0, 0), Rotation2d.fromDegrees(90)); - FieldPose slidPose = robotPose.getPointAlongPoseLine(10); - assertEquals(0, slidPose.getPoint().x, 0.001); - assertEquals(10, slidPose.getPoint().y, 0.001); - - slidPose = robotPose.getPointAlongPoseLine(-10); - assertEquals(0, slidPose.getPoint().x, 0.001); - assertEquals(-10, slidPose.getPoint().y, 0.001); - - robotPose = new FieldPose(new XYPair(Math.sqrt(2), Math.sqrt(2)), Rotation2d.fromDegrees(45)); - slidPose = robotPose.getPointAlongPoseLine(-2); - assertEquals(0, slidPose.getPoint().x, 0.001); - assertEquals(0, slidPose.getPoint().y, 0.001); - } - - @Test - public void testDistanceAlongPoseLine() { - FieldPose startingPose = new FieldPose(0, 0, 90); - FieldPose endingPose = new FieldPose(290, 40, -90); - double distance = endingPose.getDistanceAlongPoseLine(startingPose.getPoint()); - - assertEquals(40, distance, 0.001); - } - - @Test - public void testFieldPoseOffset() { - FieldPose startingPose = new FieldPose(10, 10, 90); - FieldPose offsetpPose = new FieldPose(7,8, 90); - - FieldPose deltaPose = startingPose.getFieldPoseOffsetBy(offsetpPose); - assertEquals(3, deltaPose.getPoint().x, 0.001); - assertEquals(2, deltaPose.getPoint().y, 0.001); - } -} diff --git a/src/test/java/xbot/common/math/HistoryBufferTests.java b/src/test/java/xbot/common/math/HistoryBufferTests.java deleted file mode 100644 index dc58e9ce..00000000 --- a/src/test/java/xbot/common/math/HistoryBufferTests.java +++ /dev/null @@ -1,41 +0,0 @@ -package xbot.common.math; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import xbot.common.controls.sensors.XTimer; -import xbot.common.injection.BaseCommonLibTest; - -public class HistoryBufferTests extends BaseCommonLibTest { - - @Test - public void simpleBufferTest() { - InterpolatingHistoryBuffer b = new InterpolatingHistoryBuffer(3, 5); - timer.advanceTimeInSecondsBy(2); - b.insert(XTimer.getFPGATimestamp(), 10); - assertEquals(7.5, b.getValAtTime(1), 0.001); - } - - @Test - public void simplePoseBufferTest() { - FieldPose startingPose = new FieldPose(0, 0, 90); - InterpolatingFieldPoseBuffer b = new InterpolatingFieldPoseBuffer(startingPose); - timer.advanceTimeInSecondsBy(1); - b.insert(new FieldPose(20, 20, 180)); - assertEquals(10, b.getPoseAtTime(0.5).getPoint().x, 0.001); - assertEquals(10, b.getPoseAtTime(0.5).getPoint().y, 0.001); - assertEquals(135, b.getPoseAtTime(0.5).getHeading().getDegrees(), 0.001); - } - - @Test - public void acrossBoundaryTest() { - FieldPose startingPose = new FieldPose(0, 0, 140); - InterpolatingFieldPoseBuffer b = new InterpolatingFieldPoseBuffer(startingPose); - timer.advanceTimeInSecondsBy(1); - b.insert(new FieldPose(20, 20, -130)); - assertEquals(10, b.getPoseAtTime(0.5).getPoint().x, 0.001); - assertEquals(10, b.getPoseAtTime(0.5).getPoint().y, 0.001); - assertEquals(-175, b.getPoseAtTime(0.5).getHeading().getDegrees(), 0.001); - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/math/MathUtilsTest.java b/src/test/java/xbot/common/math/MathUtilsTest.java deleted file mode 100644 index b0352c56..00000000 --- a/src/test/java/xbot/common/math/MathUtilsTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package xbot.common.math; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class MathUtilsTest extends BaseCommonLibTest { - - @Test - public void testSquareRetainSign() { - assertEquals(0.75*0.75, MathUtils.squareAndRetainSign(0.75), 0.001); - assertEquals(-0.75*0.75, MathUtils.squareAndRetainSign(-0.75), 0.001); - } - - @Test - public void testExponentRetainSign() { - assertEquals(0.5*0.5*0.5, MathUtils.exponentAndRetainSign(0.5, 3), 0.001); - assertEquals(-0.5*0.5*0.5, MathUtils.exponentAndRetainSign(-0.5, 3), 0.001); - - assertEquals(0.5*0.5*0.5*0.5, MathUtils.exponentAndRetainSign(0.5, 4), 0.001); - assertEquals(-0.5*0.5*0.5*0.5, MathUtils.exponentAndRetainSign(-0.5, 4), 0.001); - } -} diff --git a/src/test/java/xbot/common/math/PIDManagerTest.java b/src/test/java/xbot/common/math/PIDManagerTest.java deleted file mode 100644 index 8388c469..00000000 --- a/src/test/java/xbot/common/math/PIDManagerTest.java +++ /dev/null @@ -1,263 +0,0 @@ -package xbot.common.math; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.Test; - -import edu.wpi.first.wpilibj.MockTimer; -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.logging.RobotAssertionException; -import xbot.common.math.PID.OffTargetReason; -import xbot.common.math.PIDManager.PIDManagerFactory; - -public class PIDManagerTest extends BaseCommonLibTest { - - PIDManagerFactory factory; - MockTimer mockTimer; - - @Before - public void setUp() { - super.setUp(); - factory = getInjectorComponent().pidFactory(); - mockTimer = (MockTimer)getInjectorComponent().timerImplementation(); - } - - @Test - public void testDefaultOutputLimits() { - PIDManager manager = factory.create("test", 1, 0, 0); - double output = manager.calculate(100, 0); - assertEquals(1.0, output, 0.001); - - output = manager.calculate(-100, 0); - assertEquals(-1.0, output, 0.001); - } - - @Test - public void testOverrideOutputLimits() { - PIDManager manager = factory.create("test", 1, 0, 0, 0, 0.5, -0.25); - double output = manager.calculate(100, 0); - assertEquals(0.5, output, 0.001); - - output = manager.calculate(-100, 0); - assertEquals(-0.25, output, 0.001); - assertEquals(OffTargetReason.OffTargetNotConfigured, manager.getOffTargetReason()); - } - - @Test - public void testIsOnTargetStartsFalse() { - PIDManager manager = factory.create("test", 1, 0, 0, 0, 0.5, -0.25, 1, 0, -1); - assertFalse(manager.isOnTarget()); - } - - @Test - public void testIsOnTargetUsingError() { - PIDManager manager = factory.create("test", 1, 0, 0, 0, 0.5, -0.25, 1, 0, -1); - - manager.calculate(100, 0); - assertFalse(manager.isOnTarget()); - - manager.calculate(100, 99.5); - assertTrue(manager.isOnTarget()); - } - - @Test - public void testIsOnTargetUsingDerivative() { - PIDManager manager = factory.create("test", 1, 0, 0, 0, 0.5, -0.25, 0, 1, -1); - - manager.calculate(100, 0); - assertFalse(manager.isOnTarget()); - assertEquals(OffTargetReason.DerivativeTooLarge, manager.getOffTargetReason()); - - manager.calculate(100, 99.5); - assertFalse(manager.isOnTarget()); - assertEquals(OffTargetReason.DerivativeTooLarge, manager.getOffTargetReason()); - - manager.calculate(100, 100); - assertTrue(manager.isOnTarget()); - assertEquals(OffTargetReason.OnTarget, manager.getOffTargetReason()); - } - - @Test - public void testIsOnTargetUsingErrorAndDerivative() { - PIDManager manager = factory.create("test", 1, 0, 0, 0, 0.5, -0.25, 1, 1, -1); - - manager.calculate(100, 0); - assertFalse(manager.isOnTarget()); - - manager.calculate(100, 99.5); - assertFalse(manager.isOnTarget()); - - manager.calculate(100, 100); - assertTrue(manager.isOnTarget()); - } - - @Test - public void testIsOnTargetThenNot() { - PIDManager manager = factory.create("test", 1, 0, 0, 0, 0.5, -0.25, 1, 0, -1); - manager.calculate(100, 0); - assertFalse(manager.isOnTarget()); - - manager.calculate(100, 99.5); - assertTrue(manager.isOnTarget()); - - manager.calculate(100, 90); - assertFalse(manager.isOnTarget()); - } - - @Test - public void testNotSettingThresholds() { - PIDManager manager = factory.create("test", 1, 0, 0, 0, 0.5, -0.25); - - assertFalse(manager.isOnTarget()); - } - - @Test(expected=RobotAssertionException.class) - public void testAttemptNegativeThreshold() { - PIDManager manager = factory.create("test", 1, 0, 0, 0, 0.5, -0.25, 1, 1, -1); - - manager.setErrorThreshold(-10); - } - - @Test - public void disableEnableErrorTolerance() { - PIDManager manager = factory.create("test", 1, 0, 0, 0, 0.5, -0.25, 1, 0, -1); - - manager.calculate(100, 100); - - assertTrue(manager.isOnTarget()); - - manager.setEnableErrorThreshold(false); - manager.calculate(100, 100); - - assertFalse(manager.isOnTarget()); - - manager.setEnableErrorThreshold(true); - manager.calculate(100, 100); - - assertTrue(manager.isOnTarget()); - } - - @Test - public void disableEnableDerivativeTolerance() { - PIDManager manager = factory.create("test", 1, 0, 0, 0, 0.5, -0.25, 0, 1, -1); - - manager.calculate(100, 100); - manager.calculate(100, 100); - - assertTrue(manager.isOnTarget()); - - manager.setEnableDerivativeThreshold(false); - manager.calculate(100, 100); - - assertFalse(manager.isOnTarget()); - - manager.setEnableDerivativeThreshold(true); - manager.calculate(100, 100); - - assertTrue(manager.isOnTarget()); - } - - @Test - public void testIMask() { - PIDManager manager = factory.create("test", 0, 0.003, 0); - - double output = manager.calculate(100, 0); - assertEquals(0.3, output, 1e-6); - - output = manager.calculate(100, 0); - assertEquals(0.3 * 2, output, 1e-6); - - manager.setIMask(true); - - output = manager.calculate(100, 0); - assertEquals(0, output, 1e-6); - - output = manager.calculate(100, 0); - assertEquals(0, output, 1e-6); - - manager.setIMask(false); - - output = manager.calculate(100, 0); - assertEquals(0.3 * 3, output, 1e-6); - } - - @Test - public void testIZone() { - double iZone = 100; - PIDManager manager = factory.create("test", 0, 1, 0, 0, 1, -1, 0, 0, 0, iZone); - // build up some error history - manager.calculate(1000, 0); - manager.calculate(1000, 0); - // with error outside the iZone, i is not applied - double output = manager.calculate(iZone + 1, 0); - assertEquals(0, output, 1e-6); - - output = manager.calculate(-(iZone + 1), 0); - assertEquals(0, output, 1e-6); - - // with error inside the iZone, i is applied - output = manager.calculate(iZone -1, 0); - assertTrue(output > 0); - - output = manager.calculate(-(iZone -1), 0); - assertTrue(output < 0); - } - - @Test - public void testSimpleTimeThresholding() { - PIDManager manager = factory.create("test", 1, 0, 0, 0, 0.5, -0.25, 1, 0, 1); - // start with large error - manager.calculate(100, 0); - assertFalse(manager.isOnTarget()); - - // get within error bounds, but no time has passed, so should not be on target - manager.calculate(100, 100); - assertFalse(manager.isOnTarget()); - - // advance time a little bit, but not the full second, so should still be off target - mockTimer.setTimeInSeconds(.75); - manager.calculate(100, 100); - assertFalse(manager.isOnTarget()); - - // advance time past the 1 second mark, so should finally report on target. - mockTimer.setTimeInSeconds(1.1); - manager.calculate(100, 100); - assertTrue(manager.isOnTarget()); - } - - @Test - public void testTimeThresholdOnTargetThenOffTargetThenOnTarget() { - PIDManager manager = factory.create("test", 1, 0, 0, 0, 0.5, -0.25, 1, 0, 1); - - manager.calculate(100, 0); - assertFalse(manager.isOnTarget()); - assertEquals(OffTargetReason.ErrorTooLarge, manager.getOffTargetReason()); - - // Get within error threshold, and for some time - manager.calculate(100, 100); - assertEquals(OffTargetReason.NotTimeStable, manager.getOffTargetReason()); - mockTimer.setTimeInSeconds(1.5); - manager.calculate(100, 100); - assertTrue(manager.isOnTarget()); - assertEquals(OffTargetReason.OnTarget, manager.getOffTargetReason()); - - // Lose error threshold, should no longer be on target - manager.calculate(100, 50); - assertFalse(manager.isOnTarget()); - assertEquals(OffTargetReason.ErrorTooLarge, manager.getOffTargetReason()); - - // get within error threshold, should still be off target - manager.calculate(100, 100); - assertFalse(manager.isOnTarget()); - assertEquals(OffTargetReason.NotTimeStable, manager.getOffTargetReason()); - - // then wait a bit - mockTimer.setTimeInSeconds(3.0); - manager.calculate(100, 100); - assertTrue(manager.isOnTarget()); - assertEquals(OffTargetReason.OnTarget, manager.getOffTargetReason()); - } -} diff --git a/src/test/java/xbot/common/math/XYPairTest.java b/src/test/java/xbot/common/math/XYPairTest.java deleted file mode 100644 index f3f1fe4e..00000000 --- a/src/test/java/xbot/common/math/XYPairTest.java +++ /dev/null @@ -1,139 +0,0 @@ -package xbot.common.math; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; - -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class XYPairTest extends BaseCommonLibTest { - - @Test - public void testClone() { - XYPair originalPair = new XYPair(1, 2); - XYPair clonedPair = originalPair.clone(); - - assertNotSame(clonedPair, originalPair); - assertEquals(originalPair.x, clonedPair.x, 0.0); - assertEquals(originalPair.y, clonedPair.y, 0.0); - } - - @Test - public void testFromPolar() { - XYPair a = XYPair.fromPolar(0, 1); - assertEquals(1.0, a.x, 0.001); - assertEquals(0.0, a.y, 0.001); - - XYPair b = XYPair.fromPolar(90, 1); - assertEquals(0.0, b.x, 0.001); - assertEquals(1.0, b.y, 0.001); - - XYPair c = XYPair.fromPolar(180, 1); - assertEquals(-1.0, c.x, 0.001); - assertEquals(0.0, c.y, 0.001); - - XYPair d = XYPair.fromPolar(270, 1); - assertEquals(0.0, d.x, 0.001); - assertEquals(-1.0, d.y, 0.001); - } - - @Test - public void testFromUnitPolar() { - XYPair a = XYPair.fromUnitPolar(45); - assertEquals(Math.sqrt(2)/2.0, a.x, 0.001); - assertEquals(Math.sqrt(2)/2.0, a.y, 0.001); - } - - @Test - public void testScale() { - XYPair a = new XYPair(1.5, -1.5); - - a.scale(2.0); - assertEquals(3.0, a.x, 0.001); - assertEquals(-3.0, a.y, 0.001); - - a = new XYPair(1.5, -1.5); - a.scale(0.5); - assertEquals(0.75, a.x, 0.001); - assertEquals(-0.75, a.y, 0.001); - - a = new XYPair(1.0, 1.0); - a.scale(0.5, 2.0); - assertEquals(0.5, a.x, 0.001); - assertEquals(2.0, a.y, 0.001); - } - - @Test - public void testAdd() { - XYPair a = new XYPair(-1,2); - XYPair b = new XYPair(2, 3); - - a.add(b); - assertEquals(1, a.x, 0.001); - assertEquals(5, a.y, 0.001); - } - - @Test - public void testGetMagnitude() { - XYPair a = new XYPair(-4.0, 3.0); - assertEquals(5.0, a.getMagnitude(), 0.001); - } - - @Test - public void testGetAngle() { - XYPair a = new XYPair(1.0, 1.0); - assertEquals(45.0, a.getAngle(), 0.001); - - a.rotate(-5.0); - assertEquals(40.0, a.getAngle(), 0.001); - } - - @Test - public void testAddMagnitude() { - XYPair vector = new XYPair(3.0, 4.0); - assertEquals(5.0, vector.getMagnitude(), 0.001); - vector.addMagnitude(5.0); - assertEquals(10.0, vector.getMagnitude(), 0.001); - - XYPair zeroVector = new XYPair(); - zeroVector.addMagnitude(1.0); - assertEquals(1.0, zeroVector.getMagnitude(), 0.001); - assertEquals(90.0, zeroVector.getAngle(), 0.001); - } - - @Test - public void testGetDistanceToPoint() { - XYPair a = new XYPair(); - - assertEquals(1.0, a.getDistanceToPoint(new XYPair(1.0, 0)), 0.001); - assertEquals(5.0, a.getDistanceToPoint(new XYPair(-3.0, 4.0)), 0.001); - } - - @Test - public void testDotProduct() { - XYPair a = new XYPair(5,5); - XYPair b = new XYPair(10,10); - - a.scale(1/a.getMagnitude()); - b.scale(1/b.getMagnitude()); - - assertEquals(1, a.dotProduct(b), 0.001); - - a = new XYPair(1,0); - b = new XYPair(0,1); - - assertEquals(0, a.dotProduct(b), 0.001); - - a = new XYPair(1,0); - b = new XYPair(-1,0); - - assertEquals(-1, a.dotProduct(b), 0.001); - } - - @Test - public void testToString() { - XYPair a = new XYPair(1.0, 2.0); - assertEquals("(X:1.0, Y:2.0)", a.toString()); - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/networking/ZeromqListenerTest.java b/src/test/java/xbot/common/networking/ZeromqListenerTest.java deleted file mode 100644 index 478ac91e..00000000 --- a/src/test/java/xbot/common/networking/ZeromqListenerTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package xbot.common.networking; - -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class ZeromqListenerTest extends BaseCommonLibTest { - - int packets = 0; - - @Test - public void pubsub() throws InterruptedException { - ZeromqTestServer server = new ZeromqTestServer(); - Thread serverThread = new Thread(server); - serverThread.start(); - - ZeromqListener client = new ZeromqListener("tcp://localhost:5556", "10001 "); - client.setNewPacketHandler(packet -> handlePacket(packet)); - - - client.start(); - - while (true) { - if (packets > 10) { - break; - } - System.out.println("Packet count at : " + packets); - Thread.sleep(100); - } - } - - @Test - public void startWithNoHandler() { - ZeromqTestServer server = new ZeromqTestServer(); - Thread serverThread = new Thread(server); - serverThread.start(); - - ZeromqListener client = new ZeromqListener("tcp://localhost:5556", "10001 "); - client.start(); - } - - @Test - public void stopBeforeStart() { - ZeromqListener client = new ZeromqListener("tcp://localhost:5556", "10001 "); - client.stop(); - } - - private void handlePacket(String packet) { - System.out.println(packet); - packets++; - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/networking/ZeromqTestServer.java b/src/test/java/xbot/common/networking/ZeromqTestServer.java deleted file mode 100644 index 33bbcdbf..00000000 --- a/src/test/java/xbot/common/networking/ZeromqTestServer.java +++ /dev/null @@ -1,40 +0,0 @@ -package xbot.common.networking; - -import java.util.Random; - -import org.zeromq.SocketType; -import org.zeromq.ZMQ; - -public class ZeromqTestServer implements Runnable { - - @Override - public void run() { - // Prepare our context and publisher - ZMQ.Context context = ZMQ.context(1); - - ZMQ.Socket publisher = context.socket(SocketType.PUB); - publisher.setConflate(true); - publisher.bind("tcp://*:5556"); - publisher.bind("ipc://weather"); - - // Initialize random number generator - Random srandom = new Random(System.currentTimeMillis()); - while (!Thread.currentThread ().isInterrupted ()) { - // Get values that will fool the boss - int zipcode; - int temperature; - int relhumidity; - zipcode = 10000 + srandom.nextInt(10000) ; - temperature = srandom.nextInt(215) - 80 + 1; - relhumidity = srandom.nextInt(50) + 10 + 1; - - // Send message to all subscribers - String update = String.format("%05d %d %d", zipcode, temperature, relhumidity); - publisher.send(update, 0); - } - - publisher.close (); - context.term (); - } - -} \ No newline at end of file diff --git a/src/test/java/xbot/common/properties/PropertyFactoryTest.java b/src/test/java/xbot/common/properties/PropertyFactoryTest.java deleted file mode 100644 index d16209e0..00000000 --- a/src/test/java/xbot/common/properties/PropertyFactoryTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package xbot.common.properties; - -import xbot.common.injection.BaseCommonLibTest; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class PropertyFactoryTest extends BaseCommonLibTest { - - @Test - public void testNoDoubleSlashes() { - PropertyFactory factory = getInjectorComponent().propertyFactory(); - assertEquals(-1, factory.createFullKey("my//mykey").indexOf("//")); - - factory.setPrefix("prefix"); - assertEquals(-1, factory.createFullKey("/mykey").indexOf("//")); - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/properties/PropertyTest.java b/src/test/java/xbot/common/properties/PropertyTest.java deleted file mode 100644 index 3fe02a18..00000000 --- a/src/test/java/xbot/common/properties/PropertyTest.java +++ /dev/null @@ -1,139 +0,0 @@ -package xbot.common.properties; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; - -import org.junit.Before; -import org.junit.Test; - -import xbot.common.injection.BaseCommonLibTest; - -public class PropertyTest extends BaseCommonLibTest { - - XPropertyManager propertyManager; - - @Before - public void setUp() { - super.setUp(); - this.propertyManager = getInjectorComponent().propertyManager(); - propertyFactory.setTopLevelPrefix(); - } - - @Test - public void testDefaultValue() { - DoubleProperty dbl = propertyFactory.createEphemeralProperty("speed", 1.0); - BooleanProperty bool = propertyFactory.createEphemeralProperty("isTrue", true); - StringProperty str = propertyFactory.createEphemeralProperty("string", "teststring"); - - assertEquals(1.0, dbl.get(), 0.001); - assertEquals(true, bool.get()); - assertEquals("teststring", str.get()); - } - - @Test - public void testChangingValue() { - DoubleProperty dbl = propertyFactory.createEphemeralProperty("speed", 1.0); - BooleanProperty bool = propertyFactory.createEphemeralProperty("isTrue", true); - StringProperty str = propertyFactory.createEphemeralProperty("string", "teststring"); - - dbl.set(0.5); - bool.set(false); - str.set("test2"); - - assertEquals(0.5, dbl.get(), 0.001); - assertEquals(false, bool.get()); - assertEquals("test2", str.get()); - } - - @Test - public void testSavingValue() { - DoubleProperty dbl = propertyFactory.createPersistentProperty("speed", 0.5); - BooleanProperty bool = propertyFactory.createPersistentProperty("isTrue", false); - StringProperty str = propertyFactory.createPersistentProperty("string", "test2"); - - assertSame(null, propertyManager.permanentStore.getDouble("speed")); - assertSame(null, propertyManager.permanentStore.getBoolean("isTrue")); - assertSame(null, propertyManager.permanentStore.getString("string")); - - assertEquals(0.5, dbl.get(), 0.001); - assertEquals(false, bool.get()); - assertEquals("test2", str.get()); - - propertyManager.saveOutAllProperties(); - - // default values shouldn't exist in permanent store - assertNull(propertyManager.permanentStore.getDouble("speed")); - assertNull(propertyManager.permanentStore.getBoolean("isTrue")); - assertNull(propertyManager.permanentStore.getString("string")); - - dbl.set(1.0); - bool.set(true); - str.set("new"); - - propertyManager.saveOutAllProperties(); - - // non-defaults should save - assertEquals(1.0, propertyManager.permanentStore.getDouble("speed").doubleValue(), 0.001); - assertEquals(true, propertyManager.permanentStore.getBoolean("isTrue").booleanValue()); - assertEquals("new", propertyManager.permanentStore.getString("string")); - - dbl.set(0.5); - bool.set(false); - str.set("test2"); - - propertyManager.saveOutAllProperties(); - - // default values should be removed from permanent store - assertNull(propertyManager.permanentStore.getDouble("speed")); - assertNull(propertyManager.permanentStore.getBoolean("isTrue")); - assertNull(propertyManager.permanentStore.getString("string")); - } - - @Test - public void testBadPropertyName() { - DoubleProperty dbl = propertyFactory.createEphemeralProperty("commas are bad ,", 0.5); - assertEquals("commas are bad ", dbl.key); - - DoubleProperty dbl2 = propertyFactory.createEphemeralProperty("new lines are bad too\n", 0.5); - assertEquals("new lines are bad too", dbl2.key); - - } - - @Test - public void testLoadingValue() { - propertyManager.permanentStore.setDouble("speed", 0.5); - propertyManager.permanentStore.setBoolean("isTrue", true); - propertyManager.permanentStore.setString("string", "teststring"); - - propertyManager.loadPropertiesFromStorage(); - - DoubleProperty dbl = propertyFactory.createPersistentProperty("speed", 1.0); - BooleanProperty bool = propertyFactory.createPersistentProperty("isTrue", false); - StringProperty str = propertyFactory.createPersistentProperty("string", "blahblah"); - - assertEquals(0.5, dbl.get(), 0.001); - assertEquals(true, bool.get()); - assertEquals("teststring", str.get()); - } - - @Test - public void testLoadingValueAfterCreation() { - - propertyFactory.createPersistentProperty("speed", 0.5); - propertyFactory.createPersistentProperty("isTrue", true); - propertyFactory.createPersistentProperty("string", "teststring"); - - propertyManager.saveOutAllProperties(); - - DoubleProperty dbl = propertyFactory.createPersistentProperty("speed", 1.0); - BooleanProperty bool = propertyFactory.createPersistentProperty("isTrue", false); - StringProperty str = propertyFactory.createPersistentProperty("string", "blahblah"); - - propertyManager.loadPropertiesFromStorage(); - - assertEquals(1.0, dbl.get(), 0.001); - assertEquals(false, bool.get()); - assertEquals("blahblah", str.get()); - } -} diff --git a/src/test/java/xbot/common/simulation/SimulateMockCANTalonTest.java b/src/test/java/xbot/common/simulation/SimulateMockCANTalonTest.java deleted file mode 100644 index c90fbcb2..00000000 --- a/src/test/java/xbot/common/simulation/SimulateMockCANTalonTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package xbot.common.simulation; - -import static org.junit.Assert.assertEquals; - -import java.math.BigDecimal; - -import com.ctre.phoenix.motorcontrol.FeedbackDevice; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.Test; - -import xbot.common.controls.actuators.mock_adapters.MockCANTalon; -import xbot.common.injection.electrical_contract.CANTalonInfo; - -public class SimulateMockCANTalonTest extends BaseSimulationTest { - - MockCANTalon mockCANTalon; - - @Override - public void setUp() { - super.setUp(); - - mockCANTalon = (MockCANTalon)injectorComponent.canTalonFactory().create(new CANTalonInfo(34, false, FeedbackDevice.CTRE_MagEncoder_Absolute, false, 1)); - } - - @Test - public void basicTest() { - - JSONObject overallPayload = new JSONObject(); - JSONObject singleSensor = new JSONObject(); - singleSensor.put("ID", "CAN34"); - JSONObject singleSensorPayload = new JSONObject(); - singleSensorPayload.put("EncoderTicks", new BigDecimal("123.002")); - singleSensor.put("Payload", singleSensorPayload); - JSONArray sensorList = new JSONArray(); - sensorList.put(singleSensor); - overallPayload.put("Sensors", sensorList); - - distributor.distributeSimulationPayload(overallPayload); - - assertEquals(123.0, mockCANTalon.getPosition(), 0.001); - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/simulation/SimulatedDistanceSensorTest.java b/src/test/java/xbot/common/simulation/SimulatedDistanceSensorTest.java deleted file mode 100644 index ca84f1c9..00000000 --- a/src/test/java/xbot/common/simulation/SimulatedDistanceSensorTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package xbot.common.simulation; - -import xbot.common.controls.sensors.SimulatedAnalogDistanceSensor; - -public class SimulatedDistanceSensorTest extends BaseSimulationTest { - - SimulatedAnalogDistanceSensor distanceSensor; - - @Override - public void setUp() { - super.setUp(); -// -// distanceSensor = (SimulatedAnalogDistanceSensor) clf.createAnalogDistanceSensor(1, -// xbot.common.controls.sensors.XAnalogDistanceSensor.VoltageMaps::sharp0A51SK, "Test"); - } -/* - @Test - public void basicTest() { - - JSONObject overallPayload = new JSONObject(); - JSONObject singleSensor = new JSONObject(); - singleSensor.put("ID", "Analog1"); - JSONObject singleSensorPayload = new JSONObject(); - singleSensorPayload.put("Distance", new BigDecimal("123.002")); - singleSensor.put("Payload", singleSensorPayload); - JSONArray sensorList = new JSONArray(); - sensorList.put(singleSensor); - overallPayload.put("Sensors", sensorList); - - distributor.distributeSimulationPayload(overallPayload); - - assertEquals(123.002, distanceSensor.getDistance(), 0.001); - } - */ -} \ No newline at end of file diff --git a/src/test/java/xbot/common/simulation/SimulatedIMUTest.java b/src/test/java/xbot/common/simulation/SimulatedIMUTest.java deleted file mode 100644 index e9ca2a02..00000000 --- a/src/test/java/xbot/common/simulation/SimulatedIMUTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package xbot.common.simulation; - -import static org.junit.Assert.assertEquals; - -import java.math.BigDecimal; - -import org.json.JSONObject; -import org.junit.Test; - -import edu.wpi.first.wpilibj.SerialPort; -import xbot.common.controls.sensors.mock_adapters.MockGyro; - -public class SimulatedIMUTest extends BaseSimulationTest { - - MockGyro simulatedGyro; - - @Override - public void setUp() { - super.setUp(); - - simulatedGyro = (MockGyro)injectorComponent.gyroFactory().create(SerialPort.Port.kMXP); - } - - @Test - public void basicTest() { - JSONObject imuPayload = new JSONObject(); - imuPayload.put("Roll", new BigDecimal(45.223 / 180.0 * Math.PI)); - imuPayload.put("YawVelocity", new BigDecimal(12 / 180.0 * Math.PI)); - JSONObject fullSensorPayload = createSimpleSensorPayload("IMU1", imuPayload); - - this.distributor.distributeSimulationPayload(fullSensorPayload); - - assertEquals(45.223, simulatedGyro.getHeading().getDegrees(), 0.001); - assertEquals(12, simulatedGyro.getYawAngularVelocity(), 0.001); - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/simulation/SimulatedMockAbsoluteEncoderTest.java b/src/test/java/xbot/common/simulation/SimulatedMockAbsoluteEncoderTest.java deleted file mode 100644 index c60abf78..00000000 --- a/src/test/java/xbot/common/simulation/SimulatedMockAbsoluteEncoderTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package xbot.common.simulation; - -import static org.junit.Assert.assertEquals; - -import java.math.BigDecimal; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.Test; - -import xbot.common.controls.sensors.mock_adapters.MockAbsoluteEncoder; -import xbot.common.injection.electrical_contract.DeviceInfo; - -public class SimulatedMockAbsoluteEncoderTest extends BaseSimulationTest { - - MockAbsoluteEncoder simulatedEncoder; - - @Override - public void setUp() { - super.setUp(); - - simulatedEncoder = (MockAbsoluteEncoder)injectorComponent.absoluteEncoderFactory().create(new DeviceInfo(34, false, 360.0), "test"); - } - - @Test - public void basicTest() { - JSONObject overallPayload = new JSONObject(); - JSONObject singleSensor = new JSONObject(); - singleSensor.put("ID", "CAN34"); - JSONObject singleSensorPayload = new JSONObject(); - singleSensorPayload.put("EncoderTicks", new BigDecimal("1.12")); - singleSensor.put("Payload", singleSensorPayload); - JSONArray sensorList = new JSONArray(); - sensorList.put(singleSensor); - overallPayload.put("Sensors", sensorList); - - distributor.distributeSimulationPayload(overallPayload); - - assertEquals(43.2, this.simulatedEncoder.getAbsolutePosition(), 0.001); - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/simulation/SimulatedSolenoidTest.java b/src/test/java/xbot/common/simulation/SimulatedSolenoidTest.java deleted file mode 100644 index 6f2c0c42..00000000 --- a/src/test/java/xbot/common/simulation/SimulatedSolenoidTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package xbot.common.simulation; - -import static org.junit.Assert.assertEquals; - -import org.json.JSONObject; -import org.junit.Test; - -import edu.wpi.first.wpilibj.MockSolenoid; - -public class SimulatedSolenoidTest extends BaseSimulationTest { - - MockSolenoid mockSolenoid; - final int channel = 1; - - @Override - public void setUp() { - super.setUp(); - - mockSolenoid = (MockSolenoid)injectorComponent.solenoidFactory().create(channel); - } - - @Test - public void testOn() { - mockSolenoid.set(true); - JSONObject result = mockSolenoid.getSimulationData(); - - assertEquals("Solenoid1", result.get("id")); - assertEquals("VIRTUAL_SOLENOID", result.get("mode")); - assertEquals("ON", result.get("val")); - } - - @Test - public void testOff() { - mockSolenoid.set(false); - JSONObject result = mockSolenoid.getSimulationData(); - - assertEquals("Solenoid1", result.get("id")); - assertEquals("VIRTUAL_SOLENOID", result.get("mode")); - assertEquals("OFF", result.get("val")); - } -} diff --git a/src/test/java/xbot/common/simulation/SimulatedTimerTest.java b/src/test/java/xbot/common/simulation/SimulatedTimerTest.java deleted file mode 100644 index a085e7f3..00000000 --- a/src/test/java/xbot/common/simulation/SimulatedTimerTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package xbot.common.simulation; - -import static org.junit.Assert.assertEquals; - -import java.math.BigDecimal; - -import org.json.JSONObject; -import org.junit.Test; - -import edu.wpi.first.wpilibj.MockTimer; - -public class SimulatedTimerTest extends BaseSimulationTest { - - MockTimer simulatedTimer; - - @Override - public void setUp() { - super.setUp(); - - simulatedTimer = (MockTimer)injectorComponent.timerImplementation(); - } - - @Test - public void basicTest() { - final double[] times = new double[] { - 0, - 1.23, - 4.56, - 1.23, - 0 - }; - - // Check that we can set any positive time value - for (double time : times) { - JSONObject worldPosePayload = new JSONObject(); - worldPosePayload.put("Time", new BigDecimal(time)); - JSONObject fullSensorPayload = createSimpleWorldPosePayload(worldPosePayload); - - this.distributor.distributeSimulationPayload(fullSensorPayload); - - assertEquals(time, simulatedTimer.getFPGATimestamp(), 0.001); - assertEquals(time, simulatedTimer.getMatchTime(), 0.001); - } - - // Check that negative or missing time values are ignored - JSONObject worldPosePayload = new JSONObject(); - worldPosePayload.put("Time", new BigDecimal(1.23)); - JSONObject fullSensorPayload = createSimpleWorldPosePayload(worldPosePayload); - - this.distributor.distributeSimulationPayload(fullSensorPayload); - assertEquals(1.23, simulatedTimer.getFPGATimestamp(), 0.001); - - worldPosePayload = new JSONObject(); - worldPosePayload.put("Time", new BigDecimal(-1)); - fullSensorPayload = createSimpleWorldPosePayload(worldPosePayload); - this.distributor.distributeSimulationPayload(fullSensorPayload); - assertEquals(1.23, simulatedTimer.getFPGATimestamp(), 0.001); - - fullSensorPayload = createSimpleWorldPosePayload(new JSONObject()); - this.distributor.distributeSimulationPayload(fullSensorPayload); - assertEquals(1.23, simulatedTimer.getFPGATimestamp(), 0.001); - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/simulation/SimulationPayloadDistributorTest.java b/src/test/java/xbot/common/simulation/SimulationPayloadDistributorTest.java deleted file mode 100644 index 7ff5b73e..00000000 --- a/src/test/java/xbot/common/simulation/SimulationPayloadDistributorTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package xbot.common.simulation; - -import static org.junit.Assert.assertEquals; - -import java.math.BigDecimal; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.Test; - -import xbot.common.controls.sensors.XTimerImpl; -import xbot.common.controls.sensors.mock_adapters.MockEncoder; - -public class SimulationPayloadDistributorTest extends BaseSimulationTest { - - MockEncoder encoder; - XTimerImpl timer; - - @Override - public void setUp() { - super.setUp(); - - encoder = (MockEncoder)injectorComponent.encoderFactory().create("Test", 3, 4, 1); - timer = injectorComponent.timerImplementation(); - } - - @Test - public void simpleTest() { - JSONObject overallPayload = new JSONObject(); - JSONObject singleSensor = new JSONObject(); - singleSensor.put("ID", "DigitalIO3"); - JSONObject singleSensorPayload = new JSONObject(); - singleSensorPayload.put("EncoderTicks", 123.0); - singleSensor.put("Payload", singleSensorPayload); - JSONArray sensorList = new JSONArray(); - sensorList.put(singleSensor); - overallPayload.put("Sensors", sensorList); - JSONObject worldPose = new JSONObject(); - worldPose.put("Time", new BigDecimal(1.23)); - overallPayload.put("WorldPose", worldPose); - - System.out.println(overallPayload.toString()); - - distributor.distributeSimulationPayload(overallPayload); - - assertEquals(123.0, encoder.getAdjustedDistance(), 0.001); - assertEquals(1.23, timer.getFPGATimestamp(), 0.001); - assertEquals(1.23, timer.getMatchTime(), 0.001); - } -} \ No newline at end of file diff --git a/src/test/java/xbot/common/subsystems/drive/DriveSubsystemTest.java b/src/test/java/xbot/common/subsystems/drive/DriveSubsystemTest.java deleted file mode 100644 index 43f17c4c..00000000 --- a/src/test/java/xbot/common/subsystems/drive/DriveSubsystemTest.java +++ /dev/null @@ -1,152 +0,0 @@ -package xbot.common.subsystems.drive; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.math.XYPair; - -public class DriveSubsystemTest extends BaseCommonLibTest { - - MockDriveSubsystem drive; - - @Override - public void setUp() { - super.setUp(); - - this.drive = (MockDriveSubsystem)getInjectorComponent().driveSubsystem(); - } - - @Test - public void testComplexTankDrive() { - verifyTankDrive(0, 0); - - drive.drive(new XYPair(0, 1), 0); - verifyTankDrive(1, 1); - - drive.drive(new XYPair(0, 0), 0); - verifyTankDrive(0, 0); - - drive.drive(new XYPair(0, 2), 0); - verifyTankDrive(1, 1); - - drive.drive(new XYPair(0, 0), 1); - verifyTankDrive(-1, 1); - } - - @Test - public void testSimpleHolonomicDrive() { - drive.changeIntoMecanum(); - - verifyHolonomicDrive(0, 0, 0, 0); - - drive.drive(new XYPair(1, 0), 0); - verifyHolonomicDrive(1, 1, 1, 1); - - drive.drive(new XYPair(0, -1), 0); - verifyHolonomicDrive(1, -1, -1, 1); - - drive.drive(new XYPair(0, 0), 1); - verifyHolonomicDrive(-1, 1, -1, 1); - } - - @Test - public void testFieldOrientedHolonomicDrive() { - drive.changeIntoMecanum(); - verifyHolonomicDrive(0, 0, 0, 0); - - // robot pointed right (0 degrees) but wants to go away from driver station (+Y) - drive.fieldOrientedDrive(new XYPair(0, 1), 0, 0, false); - // this should command the robot to strafe left from it's own perspective - verifyHolonomicDrive(-1, 1, 1, -1); - - // robot pointed down and right, commanded to go down and left - drive.fieldOrientedDrive(new XYPair(-1,-1), 0, -45, false); - // locally, this should be a strafe right - verifyHolonomicDrive(1, -1, -1, 1); - - // robot pointed down and right, commanded to go up and right - drive.fieldOrientedDrive(new XYPair(1,1), 0, -45, false); - // from its local perspective, this is another strafe left. - verifyHolonomicDrive(-1, 1, 1, -1); - } - - @Test - public void testScaledDrive() { - - verifyTankDrive(0, 0); - - drive.drive(new XYPair(0, 1), 0, true); - verifyTankDrive(1, 1); - - drive.drive(new XYPair(0, 1), 2, true); - verifyTankDrive(-.3333, 1); - } - - @Test - public void testSimpleTankDrive() { - drive.drive(0, 0); - verifyTankDrive(0, 0); - - drive.drive(1, 1); - verifyTankDrive(1, 1); - - drive.drive(1, 0); - verifyTankDrive(1, 0); - - drive.drive(-.25, .6668); - verifyTankDrive(-.25, 0.6668); - } - - - @Test - public void testNoTalonsAvailable() { - // Here, we're just checking the robot does not crash. - drive.changeIntoNoDrive(); - - drive.drive(new XYPair(1, 1), 1); - } - - @Test - public void testCheesyDriveNoQuickTurn() { - drive.cheesyDrive(0, 1); - verifyTankDrive(0, 0); - } - - @Test - public void testCheesyDriveYesQuickTurn() { - drive.setQuickTurn(true); - drive.cheesyDrive(0, 1); - verifyTankDrive(-1, 1); - } - - @Test - public void testCheesyDriveTypicalDrive() { - drive.cheesyDrive(1, 0); - verifyTankDrive(1, 1); - - drive.cheesyDrive(0.5, 0); - verifyTankDrive(0.5, 0.5); - - drive.cheesyDrive(0.5, 0.5); - verifyTankDrive(0.25, 0.75); - } - - protected void verifyTankDrive(double left, double right) { - assertEquals(left, getOutputPercent(drive.leftTank), 0.001); - assertEquals(right, getOutputPercent(drive.rightTank), 0.001); - } - - protected void verifyHolonomicDrive(double fl, double fr, double rl, double rr) { - assertEquals(fl, getOutputPercent(drive.fl), 0.001); - assertEquals(fr, getOutputPercent(drive.fr), 0.001); - assertEquals(rl, getOutputPercent(drive.rl), 0.001); - assertEquals(rr, getOutputPercent(drive.rr), 0.001); - } - - protected double getOutputPercent(XCANTalon t) { - return t.getMotorOutputPercent(); - } -} diff --git a/src/test/java/xbot/common/subsystems/drive/HeadingAssistModuleTest.java b/src/test/java/xbot/common/subsystems/drive/HeadingAssistModuleTest.java deleted file mode 100644 index c5395e77..00000000 --- a/src/test/java/xbot/common/subsystems/drive/HeadingAssistModuleTest.java +++ /dev/null @@ -1,158 +0,0 @@ -package xbot.common.subsystems.drive; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import xbot.common.controls.sensors.mock_adapters.MockGyro; -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.subsystems.drive.control_logic.HeadingAssistModule; -import xbot.common.subsystems.drive.control_logic.HeadingAssistModule.HeadingAssistMode; -import xbot.common.subsystems.drive.control_logic.HeadingModule; -import xbot.common.subsystems.pose.BasePoseSubsystem; - -public class HeadingAssistModuleTest extends BaseCommonLibTest { - - HeadingAssistModule ham; - BasePoseSubsystem pose; - - @Override - public void setUp() { - super.setUp(); - pose = getInjectorComponent().poseSubsystem(); - - HeadingModule hold = getInjectorComponent().headingModuleFactory().create(pf.create("Hold", 1000, 0, 0)); - HeadingModule decay = getInjectorComponent().headingModuleFactory().create(pf.create("Decay", 0, 0, 1000)); - ham = getInjectorComponent().headingAssistModuleFactory().create(hold, decay, "Test"); - ham.setMode(HeadingAssistMode.HoldOrientation); - } - - @Test - public void testNoConfig() { - ham.setMode(null); - step1_humanDrive(); - step2_humanStops(); - step3_timePasses(); - step4_robotRotated(); - } - @Test - public void testFullStateMachine() { - step1_humanDrive(); - step2_humanStops(); - step3_timePasses(); - step4_robotRotated(); - - // robot is returned to original position - setHeading(0); - double power = ham.calculateHeadingPower(0); - assertEquals(0, power, 0.001); - } - - @Test - public void interruptedAfterStep1() { - step1_humanDrive(); - - // system then recovers - interruptingInput(); - - step2_humanStops(); - step3_timePasses(); - step4_robotRotated(); - } - - @Test - public void interruptedAfterStep2() { - step1_humanDrive(); - step2_humanStops(); - - interruptingInput(); - - step2_humanStops(); - step3_timePasses(); - step4_robotRotated(); - } - - @Test - public void interruptedAfterStep3() { - step1_humanDrive(); - step2_humanStops(); - step3_timePasses(); - interruptingInput(); - step2_humanStops(); - step3_timePasses(); - step4_robotRotated(); - } - - @Test - public void interruptedAfterStep4() { - step1_humanDrive(); - step2_humanStops(); - step3_timePasses(); - step4_robotRotated(); - - interruptingInput(); - step2_humanStops(); - step3_timePasses(); - step4_robotRotated(); - } - - private void interruptingInput() { - - double power = ham.calculateHeadingPower(.6627); - assertEquals(.6627, power, 0.001); - - } - - private void step1_humanDrive() { - - // human is trying to rotate the robot - double power = ham.calculateHeadingPower(1); - assertEquals(1, power, 0.001); - - } - - private void step2_humanStops() { - - // human stops trying to rotate the robot - double power = ham.calculateHeadingPower(0); - assertEquals(0, power, 0.001); - - } - - private void step3_timePasses() { - - // time passes, this should "set" the desired angle - timer.advanceTimeInSecondsBy(1); - double power = ham.calculateHeadingPower(0); - assertEquals(0, power, 0.001); - } - - private void step4_robotRotated() { - - // the robot undergoes some automatic rotation - setHeading(pose.getCurrentHeading().getDegrees()+90); - double power = ham.calculateHeadingPower(0); - assertEquals(-1, power, 0.001); - } - - - @Test - public void testDecay() { - ham.setMode(HeadingAssistMode.DecayVelocity); - step1_humanDrive(); - step2_humanStops(); - step3_timePasses(); - - // just like the position-based one, this should try to turn right if the robot is suddenly rotated left - step4_robotRotated(); - - // However, unlike the position-based one, this one will try and turn left if the robot is suddenly rotated right. - setHeading(pose.getCurrentHeading().getDegrees()-90); - double power = ham.calculateHeadingPower(0); - assertEquals(1, power, 0.001); - } - - protected void setHeading(double heading) { - ((MockGyro)pose.imu).setYaw(heading); - } -} diff --git a/src/test/java/xbot/common/subsystems/drive/HeadingModuleTest.java b/src/test/java/xbot/common/subsystems/drive/HeadingModuleTest.java deleted file mode 100644 index 534c7812..00000000 --- a/src/test/java/xbot/common/subsystems/drive/HeadingModuleTest.java +++ /dev/null @@ -1,67 +0,0 @@ -package xbot.common.subsystems.drive; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import xbot.common.controls.sensors.mock_adapters.MockGyro; -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.math.PIDManager; -import xbot.common.subsystems.drive.control_logic.HeadingModule; -import xbot.common.subsystems.pose.BasePoseSubsystem; - -public class HeadingModuleTest extends BaseCommonLibTest { - - HeadingModule headingModule; - BasePoseSubsystem pose; - - @Override - public void setUp() { - super.setUp(); - - PIDManager pid = pf.create("Testo", 100, 0, 0); - pid.setErrorThreshold(3); - pid.setEnableErrorThreshold(true); - - headingModule = getInjectorComponent().headingModuleFactory().create(pid); - pose = getInjectorComponent().poseSubsystem(); - } - - @Test - public void testTurnLeft() { - setHeading(0); - double power = headingModule.calculateHeadingPower(90); - assertEquals(1, power, 0.001); - - setHeading(179); - power = headingModule.calculateHeadingPower(-179); - assertEquals(1, power, 0.001); - } - - @Test - public void testTurnRight() { - setHeading(0); - double power = headingModule.calculateHeadingPower(-90); - assertEquals(-1, power, 0.001); - - setHeading(-179); - power = headingModule.calculateHeadingPower(179); - assertEquals(-1, power, 0.001); - } - - @Test - public void onTarget() { - setHeading(0); - headingModule.reset(); - assertFalse(headingModule.isOnTarget()); - - headingModule.calculateHeadingPower(1); - assertTrue(headingModule.isOnTarget()); - } - - protected void setHeading(double heading) { - ((MockGyro)pose.imu).setYaw(heading); - } -} diff --git a/src/test/java/xbot/common/subsystems/drive/PurePursuitCommandTest.java b/src/test/java/xbot/common/subsystems/drive/PurePursuitCommandTest.java deleted file mode 100644 index 61ea4903..00000000 --- a/src/test/java/xbot/common/subsystems/drive/PurePursuitCommandTest.java +++ /dev/null @@ -1,215 +0,0 @@ -package xbot.common.subsystems.drive; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; - -import org.junit.Ignore; -import org.junit.Test; - -import edu.wpi.first.math.geometry.Rotation2d; -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.math.FieldPose; -import xbot.common.math.XYPair; -import xbot.common.subsystems.drive.PurePursuitCommand.PointLoadingMode; -import xbot.common.subsystems.drive.RabbitPoint.PointTerminatingType; -import xbot.common.subsystems.drive.RabbitPoint.PointType; -import xbot.common.subsystems.pose.MockBasePoseSubsystem; - -public class PurePursuitCommandTest extends BaseCommonLibTest { - - ConfigurablePurePursuitCommand command; - MockDriveSubsystem drive; - MockBasePoseSubsystem pose; - - @Override - public void setUp() { - super.setUp(); - command = getInjectorComponent().configurablePurePursuitCommand(); - this.drive = (MockDriveSubsystem)getInjectorComponent().driveSubsystem(); - this.pose = (MockBasePoseSubsystem)getInjectorComponent().poseSubsystem(); - - pose.setDriveTalons(drive.leftTank, drive.rightTank); - - timer.advanceTimeInSecondsBy(10); - - pose.periodic(); - pose.setCurrentHeading(90); - - drive.getPositionalPid().setMaxOutput(1); - drive.getPositionalPid().setMinOutput(-1); - } - - @Test - public void simpleTest() { - command.initialize(); - command.execute(); - } - - @Test - public void goStraightAheadTest() { - command.addPoint(new FieldPose(new XYPair(0, 10), Rotation2d.fromDegrees(90))); - - command.initialize(); - command.execute(); - - verifyTankDrive(1, 1); - } - - @Test - public void turnRightTest() { - command.addPoint(new FieldPose(new XYPair(10, 10), Rotation2d.fromDegrees(0))); - - command.initialize(); - command.execute(); - - verifyTankDrive(1, -1); - } - - @Test - public void changePoints() { - command.addPoint(new FieldPose(new XYPair(0, 0.1), Rotation2d.fromDegrees(90))); - command.addPoint(new FieldPose(new XYPair(-10, 0), Rotation2d.fromDegrees(180))); - - command.initialize(); - - command.execute(); - verifyTankDrive(1, 1); - - command.execute(); - command.execute(); - command.execute(); - verifyTankDrive(-1, 1); - } - - @Test - public void testSimpleRelative() { - pose.setCurrentHeading(0); - command.addPoint(new FieldPose(new XYPair(0, 10), Rotation2d.fromDegrees(90))); - command.addPoint(new FieldPose(new XYPair(10, 10), Rotation2d.fromDegrees(90))); - - command.setMode(PointLoadingMode.Relative); - command.initialize(); - - verifyPose(command.getPlannedPointsToVisit().get(0), 0, 10, 90); - verifyPose(command.getPlannedPointsToVisit().get(1), 10, 10, 90); - } - - @Test - public void testComplexRelative() { - pose.setCurrentHeading(0); - command.addPoint(new FieldPose(new XYPair(10, 0), Rotation2d.fromDegrees(0))); - command.addPoint(new FieldPose(new XYPair(10, 10), Rotation2d.fromDegrees(90))); - - // rotate the robot - pose.setCurrentHeading(90); - pose.setDriveEncoderDistances(10, 10); - - command.setMode(PointLoadingMode.Relative); - command.initialize(); - - verifyPose(command.getPlannedPointsToVisit().get(0), 0, 20, 90); - verifyPose(command.getPlannedPointsToVisit().get(1), -10, 20, 180); - } - - //@SuppressWarnings("serial") - public void testSupplier() { - command.addPoint(new FieldPose(new XYPair(0, 10), Rotation2d.fromDegrees(90))); - command.addPoint(new FieldPose(new XYPair(10, 10), Rotation2d.fromDegrees(90))); - - command.setPointSupplier(() -> - new ArrayList() {{ - add(new RabbitPoint(1, 2, 3)); - }} - ); - - command.initialize(); - - verifyPose(command.getPlannedPointsToVisit().get(0), 1, 2, 3); - } - - @Test - public void testStickyMode() { - command.addPoint(new FieldPose(new XYPair(0, 10), Rotation2d.fromDegrees(90))); - command.initialize(); - command.execute(); - verifyTankDrive(1, 1); - - pose.forceTotalXandY(1000000, 30); - command.execute(); - command.execute(); - - // too far forward, so -1, -1 - // Need to turn hard to the left, so -1, 1 - // should balance to -1, 0 - verifyTankDrive(-1, 1); - } - - @Test - public void testDriveToPoint() { - command.addPoint( - new RabbitPoint(new FieldPose(new XYPair(10, 10), Rotation2d.fromDegrees(90)), PointType.PositionOnly, PointTerminatingType.Stop)); - command.initialize(); - command.execute(); - verifyTankDrive(1, -1); - } - - @Test - public void testDriveOffset() { - pose.setCurrentHeading(0); - command.addPoint( - new RabbitPoint(new FieldPose(new XYPair(100, 0), Rotation2d.fromDegrees(-90)), PointType.PositionAndHeading, PointTerminatingType.Stop)); - command.initialize(); - command.execute(); - // Even though we're pointed right at the goal, we should veer left because we are completely perpindicular to it. - verifyTankDrive(-1, 1); - } - - @Test - public void testThreePointBehind() { - command.addPoint( - new RabbitPoint(new FieldPose(new XYPair(100, -100), Rotation2d.fromDegrees(90)), PointType.PositionAndHeading, PointTerminatingType.Stop)); - command.setDotProductDrivingEnabled(true); - command.initialize(); - command.execute(); - - verifyDirection(false); - verifyRotation(true); - } - - @Test - @Ignore - public void testThreePointDirect() { - command.addPoint( - new RabbitPoint(new FieldPose(new XYPair(100, 0), Rotation2d.fromDegrees(-90)), PointType.PositionAndHeading, PointTerminatingType.Stop)); - command.setDotProductDrivingEnabled(true); - command.initialize(); - command.execute(); - - verifyDirection(true); - verifyRotation(false); - } - - protected void verifyPose(RabbitPoint poseToTest, double x, double y, double heading) { - assertEquals("Looking at X", x, poseToTest.pose.getPoint().x, 0.001); - assertEquals("Looking at Y", y, poseToTest.pose.getPoint().y, 0.001); - assertEquals("Looking at Heading", heading, poseToTest.pose.getHeading().getDegrees(), 0.001); - } - - protected void verifyTankDrive(double left, double right) { - assertEquals("Checking Left Drive", left, drive.leftTank.getMotorOutputPercent(), 0.001); - assertEquals("Checking Right Drive", right, drive.rightTank.getMotorOutputPercent(), 0.001); - } - - protected void verifyDirection(boolean forward) { - double translation = drive.leftTank.getMotorOutputPercent() + drive.rightTank.getMotorOutputPercent(); - assertTrue("Checking Driving Forward", translation > 0 == forward); - } - - protected void verifyRotation(boolean turningLeft) { - double rotation = -drive.leftTank.getMotorOutputPercent() + drive.rightTank.getMotorOutputPercent(); - assertTrue("Checking Driving Forward", rotation > 0 == turningLeft); - } -} - diff --git a/src/test/java/xbot/common/subsystems/feedback/RumbleManagerTest.java b/src/test/java/xbot/common/subsystems/feedback/RumbleManagerTest.java deleted file mode 100644 index 1ba15444..00000000 --- a/src/test/java/xbot/common/subsystems/feedback/RumbleManagerTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package xbot.common.subsystems.feedback; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import edu.wpi.first.wpilibj.MockTimer; -import xbot.common.controls.sensors.mock_adapters.MockFTCGamepad; -import xbot.common.injection.BaseCommonLibTest; - -/** - * Unit tests for RumbleManager - */ -public class RumbleManagerTest extends BaseCommonLibTest { - - MockFTCGamepad gamepad; - RumbleManager rumbleManager; - MockTimer timer; - - @Override - public void setUp() { - super.setUp(); - - this.gamepad = (MockFTCGamepad)getInjectorComponent().ftcGamepadFactory().create(0, 10); - this.rumbleManager = new RumbleManager(this.gamepad); - this.timer = (MockTimer)getInjectorComponent().timerImplementation(); - } - - @Test - public void testGetIsRumbling() { - assertFalse(rumbleManager.getIsRumbling()); - - rumbleManager.rumbleGamepad(5, 10); - assertTrue(rumbleManager.getIsRumbling()); - - rumbleManager.stopGamepadRumble(); - assertFalse(rumbleManager.getIsRumbling()); - } - - @Test - public void testRumbleGamepad() { - double rumbleDuration = 10; - rumbleManager.rumbleGamepad(5, rumbleDuration); - assertTrue(rumbleManager.getIsRumbling()); - - timer.advanceTimeInSecondsBy(rumbleDuration + 0.01); - rumbleManager.periodic(); - assertFalse(rumbleManager.getIsRumbling()); - } -} diff --git a/src/test/java/xbot/common/subsystems/pose/BasePoseTest.java b/src/test/java/xbot/common/subsystems/pose/BasePoseTest.java deleted file mode 100644 index 14442015..00000000 --- a/src/test/java/xbot/common/subsystems/pose/BasePoseTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package xbot.common.subsystems.pose; - -import static org.junit.Assert.assertEquals; - -import com.ctre.phoenix.motorcontrol.FeedbackDevice; - -import org.junit.Before; -import org.junit.Ignore; - -import edu.wpi.first.wpilibj.MockTimer; -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.injection.BaseCommonLibTest; -import xbot.common.injection.electrical_contract.CANTalonInfo; - -@Ignore -public class BasePoseTest extends BaseCommonLibTest { - - protected MockBasePoseSubsystem pose; - protected MockTimer mockTimer; - - @Before - public void setup() { - mockTimer = (MockTimer)getInjectorComponent().timerImplementation(); - pose = (MockBasePoseSubsystem)getInjectorComponent().poseSubsystem(); - - XCANTalon left = getInjectorComponent().canTalonFactory().create(new CANTalonInfo(0)); - left.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder, 0, 0); - XCANTalon right = getInjectorComponent().canTalonFactory().create(new CANTalonInfo(1)); - right.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder, 0, 0); - - pose.setDriveTalons(left, right); - - mockTimer.advanceTimeInSecondsBy(10); - pose.periodic(); - } - - protected void verifyRobotHeading(double expectedHeading) { - assertEquals(expectedHeading, pose.getCurrentHeading().getDegrees(), 0.001); - } - - protected void verifyRobotOrientedDistance(double expectedDistance) { - assertEquals(expectedDistance, pose.getRobotOrientedTotalDistanceTraveled(), 0.001); - } - - protected void verifyAbsoluteDistance(double x, double y) { - assertEquals(x, pose.getFieldOrientedTotalDistanceTraveled().x, 0.001); - assertEquals(y, pose.getFieldOrientedTotalDistanceTraveled().y, 0.001); - } -} diff --git a/src/test/java/xbot/common/subsystems/pose/PoseSubsystemTest.java b/src/test/java/xbot/common/subsystems/pose/PoseSubsystemTest.java deleted file mode 100644 index 85b7ab09..00000000 --- a/src/test/java/xbot/common/subsystems/pose/PoseSubsystemTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package xbot.common.subsystems.pose; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import xbot.common.controls.sensors.mock_adapters.MockGyro; - -public class PoseSubsystemTest extends BasePoseTest { - - MockBasePoseSubsystem pose; - - public void setup() { - super.setup(); - pose = (MockBasePoseSubsystem)getInjectorComponent().poseSubsystem(); - } - - @Test - public void testInitialHeading() { - // IMU initially starts at 0, robot starts at 0. - verifyRobotHeading(BasePoseSubsystem.FACING_AWAY_FROM_DRIVERS); - } - - @Test - public void testGyroRotate() { - changeMockGyroHeading(45); - verifyRobotHeading(BasePoseSubsystem.FACING_AWAY_FROM_DRIVERS + 45); - - changeMockGyroHeading(-45); - verifyRobotHeading(BasePoseSubsystem.FACING_AWAY_FROM_DRIVERS); - } - - @Test - public void testCalibrate() { - changeMockGyroHeading(45); - verifyRobotHeading(BasePoseSubsystem.FACING_AWAY_FROM_DRIVERS+45); - - pose.setCurrentHeading(90); - verifyRobotHeading(90); - } - - @Test - public void testCalibrateAndMove() { - changeMockGyroHeading(45); - verifyRobotHeading(BasePoseSubsystem.FACING_AWAY_FROM_DRIVERS+45); - - pose.setCurrentHeading(90); - verifyRobotHeading(90); - - changeMockGyroHeading(-45); - verifyRobotHeading(45); - } - - @Test - public void testCrossBounds () { - pose.setCurrentHeading(90); - - changeMockGyroHeading(180); - verifyRobotHeading(-90); - - changeMockGyroHeading(100); - verifyRobotHeading(10); - } - - @Test - public void testTilt() { - setMockGyroPitch(100); - assertEquals(100, pose.getRobotPitch(), 0.001); - } - - @Test - public void testRobotOrientedMotion() { - // If we drive forward 100, we should see 100 units of travel - pose.setCurrentHeading(90); - verifyRobotOrientedDistance(0); - pose.setDriveEncoderDistances(100, 100); - verifyRobotOrientedDistance(100); - - // If we turn around and drive forward 100 more, we should see 200 total units of travel - pose.setCurrentHeading(270); - pose.setDriveEncoderDistances(200, 200); - verifyRobotOrientedDistance(200); - - // If we turn "with encoders", this should not appear as any motion at all. - pose.setDriveEncoderDistances(300, 100); - verifyRobotOrientedDistance(200); - - // Reset should reset this too. - pose.resetDistanceTraveled(); - verifyRobotOrientedDistance(0); - } - - protected void setMockGyroHeading(double heading) { - ((MockGyro)pose.imu).setYaw(heading); - } - - protected void setMockGyroPitch(double pitch) { - ((MockGyro)pose.imu).setPitch(pitch); - } - - protected void changeMockGyroHeading(double delta) { - double oldHeading = ((MockGyro)pose.imu).getDeviceYaw(); - double newHeading = oldHeading + delta; - setMockGyroHeading(newHeading); - } - - protected void verifyRobotHeading(double expectedHeading) { - assertEquals(expectedHeading, pose.getCurrentHeading().getDegrees(), 0.001); - } - - @Test - public void setPosition() { - pose.setCurrentPosition(0, 0); - assertEquals(0, pose.getFieldOrientedTotalDistanceTraveled().x, .01); - assertEquals(0, pose.getFieldOrientedTotalDistanceTraveled().y, .01); - - pose.setCurrentPosition(20, 30); - assertEquals(20, pose.getFieldOrientedTotalDistanceTraveled().x, .01); - assertEquals(30, pose.getFieldOrientedTotalDistanceTraveled().y, .01); - } -} diff --git a/src/test/java/xbot/common/subsystems/pose/commands/ResetDistanceCommandTest.java b/src/test/java/xbot/common/subsystems/pose/commands/ResetDistanceCommandTest.java deleted file mode 100644 index fd938ed2..00000000 --- a/src/test/java/xbot/common/subsystems/pose/commands/ResetDistanceCommandTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package xbot.common.subsystems.pose.commands; - -import org.junit.Before; -import org.junit.Test; - -import xbot.common.subsystems.pose.BasePoseTest; - -public class ResetDistanceCommandTest extends BasePoseTest { - - ResetDistanceCommand reset; - - @Before - public void setup() { - super.setup(); - reset = getInjectorComponent().resetDistanceCommand(); - } - - @Test - public void testPositionReset() { - verifyRobotOrientedDistance(0); - verifyAbsoluteDistance(0, 0); - - pose.setDriveEncoderDistances(100, 100); - verifyRobotOrientedDistance(100); - verifyAbsoluteDistance(100, 0); - - reset.isFinished(); - reset.initialize(); - reset.execute(); - - verifyRobotOrientedDistance(0); - verifyAbsoluteDistance(0, 0); - } - - @Test - public void testResetTwiceInSuccession() { - verifyRobotOrientedDistance(0); - verifyAbsoluteDistance(0, 0); - - pose.setDriveEncoderDistances(100, 100); - verifyRobotOrientedDistance(100); - verifyAbsoluteDistance(100, 0); - - reset.isFinished(); - reset.initialize(); - reset.execute(); - reset.isFinished(); - reset.initialize(); - reset.execute(); - - verifyRobotOrientedDistance(0); - verifyAbsoluteDistance(0, 0); - } - - @Test - public void testResetTwice() { - verifyRobotOrientedDistance(0); - verifyAbsoluteDistance(0, 0); - - pose.setDriveEncoderDistances(100, 100); - verifyRobotOrientedDistance(100); - verifyAbsoluteDistance(100, 0); - - reset.isFinished(); - reset.initialize(); - reset.execute(); - - pose.setDriveEncoderDistances(200, 200); - verifyRobotOrientedDistance(100); - verifyAbsoluteDistance(100, 0); - - reset.isFinished(); - reset.initialize(); - reset.execute(); - - verifyRobotOrientedDistance(0); - verifyAbsoluteDistance(0, 0); - } - -} diff --git a/src/test/java/xbot/common/subsystems/pose/commands/SetRobotHeadingCommandTest.java b/src/test/java/xbot/common/subsystems/pose/commands/SetRobotHeadingCommandTest.java deleted file mode 100644 index 69423987..00000000 --- a/src/test/java/xbot/common/subsystems/pose/commands/SetRobotHeadingCommandTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package xbot.common.subsystems.pose.commands; - -import org.junit.Before; -import org.junit.Test; - -import xbot.common.subsystems.pose.BasePoseSubsystem; -import xbot.common.subsystems.pose.BasePoseTest; - -public class SetRobotHeadingCommandTest extends BasePoseTest { - - SetRobotHeadingCommand setHeading; - - @Before - public void setup() { - super.setup(); - setHeading = getInjectorComponent().setRobotHeadingCommand(); - } - - @Test - public void testSetHeading() { - mockTimer.setTimeInSeconds(mockTimer.getFPGATimestamp() + 1); - verifyRobotHeading(BasePoseSubsystem.FACING_AWAY_FROM_DRIVERS); - - setHeading.setHeadingToApply(74); - setHeading.isFinished(); - setHeading.initialize(); - setHeading.execute(); - - verifyRobotHeading(74); - } - - @Test - public void testSetHeadingLargeValues() { - mockTimer.setTimeInSeconds(2); - verifyRobotHeading(BasePoseSubsystem.FACING_AWAY_FROM_DRIVERS); - - setHeading.setHeadingToApply(361); - setHeading.isFinished(); - setHeading.initialize(); - setHeading.execute(); - - verifyRobotHeading(1); - - setHeading.setHeadingToApply(-361); - setHeading.isFinished(); - setHeading.initialize(); - setHeading.execute(); - - verifyRobotHeading(-1); - } -} diff --git a/vendordeps/NavX.json b/vendordeps/NavX.json deleted file mode 100644 index 29ec93aa..00000000 --- a/vendordeps/NavX.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "fileName": "NavX.json", - "name": "KauaiLabs_navX_FRC", - "version": "2023.0.3", - "uuid": "cb311d09-36e9-4143-a032-55bb2b94443b", - "mavenUrls": [ - "https://dev.studica.com/maven/release/2023/" - ], - "jsonUrl": "https://dev.studica.com/releases/2023/NavX.json", - "javaDependencies": [ - { - "groupId": "com.kauailabs.navx.frc", - "artifactId": "navx-frc-java", - "version": "2023.0.3" - } - ], - "jniDependencies": [], - "cppDependencies": [ - { - "groupId": "com.kauailabs.navx.frc", - "artifactId": "navx-frc-cpp", - "version": "2023.0.3", - "headerClassifier": "headers", - "sourcesClassifier": "sources", - "sharedLibrary": false, - "libName": "navx_frc", - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "linuxathena", - "linuxraspbian", - "linuxarm32", - "linuxarm64", - "linux86-64", - "osxuniversal", - "windowsx86-64" - ] - } - ] -} \ No newline at end of file diff --git a/vendordeps/Phoenix.json b/vendordeps/Phoenix.json deleted file mode 100644 index 4f74b5ac..00000000 --- a/vendordeps/Phoenix.json +++ /dev/null @@ -1,423 +0,0 @@ -{ - "fileName": "Phoenix.json", - "name": "CTRE-Phoenix (v5)", - "version": "5.30.3+23.0.4", - "frcYear": 2023, - "uuid": "ab676553-b602-441f-a38d-f1296eff6537", - "mavenUrls": [ - "https://maven.ctr-electronics.com/release/" - ], - "jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix/Phoenix5-frc2023-latest.json", - "javaDependencies": [ - { - "groupId": "com.ctre.phoenix", - "artifactId": "api-java", - "version": "5.30.3" - }, - { - "groupId": "com.ctre.phoenix", - "artifactId": "wpiapi-java", - "version": "5.30.3" - } - ], - "jniDependencies": [ - { - "groupId": "com.ctre.phoenix", - "artifactId": "cci", - "version": "5.30.3", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "linuxathena" - ], - "simMode": "hwsim" - }, - { - "groupId": "com.ctre.phoenix.sim", - "artifactId": "cci-sim", - "version": "5.30.3", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro", - "artifactId": "tools", - "version": "23.0.4", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "linuxathena" - ], - "simMode": "hwsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "tools-sim", - "version": "23.0.4", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simTalonSRX", - "version": "23.0.4", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simTalonFX", - "version": "23.0.4", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simVictorSPX", - "version": "23.0.4", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simPigeonIMU", - "version": "23.0.4", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simCANCoder", - "version": "23.0.4", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simProTalonFX", - "version": "23.0.4", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simProCANcoder", - "version": "23.0.4", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simProPigeon2", - "version": "23.0.4", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - } - ], - "cppDependencies": [ - { - "groupId": "com.ctre.phoenix", - "artifactId": "wpiapi-cpp", - "version": "5.30.3", - "libName": "CTRE_Phoenix_WPI", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "linuxathena" - ], - "simMode": "hwsim" - }, - { - "groupId": "com.ctre.phoenix", - "artifactId": "api-cpp", - "version": "5.30.3", - "libName": "CTRE_Phoenix", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "linuxathena" - ], - "simMode": "hwsim" - }, - { - "groupId": "com.ctre.phoenix", - "artifactId": "cci", - "version": "5.30.3", - "libName": "CTRE_PhoenixCCI", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "linuxathena" - ], - "simMode": "hwsim" - }, - { - "groupId": "com.ctre.phoenixpro", - "artifactId": "tools", - "version": "23.0.4", - "libName": "CTRE_PhoenixTools", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "linuxathena" - ], - "simMode": "hwsim" - }, - { - "groupId": "com.ctre.phoenix.sim", - "artifactId": "wpiapi-cpp-sim", - "version": "5.30.3", - "libName": "CTRE_Phoenix_WPISim", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenix.sim", - "artifactId": "api-cpp-sim", - "version": "5.30.3", - "libName": "CTRE_PhoenixSim", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenix.sim", - "artifactId": "cci-sim", - "version": "5.30.3", - "libName": "CTRE_PhoenixCCISim", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "tools-sim", - "version": "23.0.4", - "libName": "CTRE_PhoenixTools_Sim", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simTalonSRX", - "version": "23.0.4", - "libName": "CTRE_SimTalonSRX", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simTalonFX", - "version": "23.0.4", - "libName": "CTRE_SimTalonFX", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simVictorSPX", - "version": "23.0.4", - "libName": "CTRE_SimVictorSPX", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simPigeonIMU", - "version": "23.0.4", - "libName": "CTRE_SimPigeonIMU", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simCANCoder", - "version": "23.0.4", - "libName": "CTRE_SimCANCoder", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simProTalonFX", - "version": "23.0.4", - "libName": "CTRE_SimProTalonFX", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simProCANcoder", - "version": "23.0.4", - "libName": "CTRE_SimProCANcoder", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenixpro.sim", - "artifactId": "simProPigeon2", - "version": "23.0.4", - "libName": "CTRE_SimProPigeon2", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ], - "simMode": "swsim" - } - ] -} \ No newline at end of file diff --git a/vendordeps/REVLib.json b/vendordeps/REVLib.json deleted file mode 100644 index cdbbe6ed..00000000 --- a/vendordeps/REVLib.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "fileName": "REVLib.json", - "name": "REVLib", - "version": "2023.1.2", - "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", - "mavenUrls": [ - "https://maven.revrobotics.com/" - ], - "jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2023.json", - "javaDependencies": [ - { - "groupId": "com.revrobotics.frc", - "artifactId": "REVLib-java", - "version": "2023.1.2" - } - ], - "jniDependencies": [ - { - "groupId": "com.revrobotics.frc", - "artifactId": "REVLib-driver", - "version": "2023.1.2", - "skipInvalidPlatforms": true, - "isJar": false, - "validPlatforms": [ - "windowsx86-64", - "windowsx86", - "linuxarm64", - "linuxx86-64", - "linuxathena", - "linuxarm32", - "osxuniversal" - ] - } - ], - "cppDependencies": [ - { - "groupId": "com.revrobotics.frc", - "artifactId": "REVLib-cpp", - "version": "2023.1.2", - "libName": "REVLib", - "headerClassifier": "headers", - "sharedLibrary": false, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "windowsx86", - "linuxarm64", - "linuxx86-64", - "linuxathena", - "linuxarm32", - "osxuniversal" - ] - }, - { - "groupId": "com.revrobotics.frc", - "artifactId": "REVLib-driver", - "version": "2023.1.2", - "libName": "REVLibDriver", - "headerClassifier": "headers", - "sharedLibrary": false, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "windowsx86", - "linuxarm64", - "linuxx86-64", - "linuxathena", - "linuxarm32", - "osxuniversal" - ] - } - ] -} \ No newline at end of file diff --git a/vendordeps/WPILibNewCommands.json b/vendordeps/WPILibNewCommands.json deleted file mode 100644 index 462a01cf..00000000 --- a/vendordeps/WPILibNewCommands.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "fileName": "WPILibNewCommands.json", - "name": "WPILib-New-Commands", - "version": "1.0.0", - "uuid": "111e20f7-815e-48f8-9dd6-e675ce75b266", - "mavenUrls": [], - "jsonUrl": "", - "javaDependencies": [ - { - "groupId": "edu.wpi.first.wpilibNewCommands", - "artifactId": "wpilibNewCommands-java", - "version": "wpilib" - } - ], - "jniDependencies": [], - "cppDependencies": [ - { - "groupId": "edu.wpi.first.wpilibNewCommands", - "artifactId": "wpilibNewCommands-cpp", - "version": "wpilib", - "libName": "wpilibNewCommands", - "headerClassifier": "headers", - "sourcesClassifier": "sources", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "linuxathena", - "linuxarm32", - "linuxarm64", - "windowsx86-64", - "windowsx86", - "linuxx86-64", - "osxuniversal" - ] - } - ] - } - \ No newline at end of file diff --git a/xbotcheckstyle.xml b/xbotcheckstyle.xml deleted file mode 100644 index 9b994fec..00000000 --- a/xbotcheckstyle.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xboteclipseprofile.xml b/xboteclipseprofile.xml deleted file mode 100644 index 6c532ca4..00000000 --- a/xboteclipseprofile.xml +++ /dev/null @@ -1,295 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -