diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a80d36153..e1cafeab76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,13 +119,6 @@ FATAL: Cannot build wpilib without wpimath. ") endif() -if (NOT WITH_OLD_COMMANDS AND WITH_EXAMPLES) - message(FATAL_ERROR " -FATAL: Cannot build examples with old commands disabled. - Enable old commands by setting WITH_OLD_COMMANDS=ON -") -endif() - set( wpilib_dest wpilib) set( include_dest wpilib/include ) set( main_lib_dest wpilib/lib ) diff --git a/wpilibcExamples/CMakeLists.txt b/wpilibcExamples/CMakeLists.txt index 3ebb5d04eb..27cff6b4d7 100644 --- a/wpilibcExamples/CMakeLists.txt +++ b/wpilibcExamples/CMakeLists.txt @@ -18,7 +18,7 @@ foreach(example ${EXAMPLES}) target_sources(${example}_test PRIVATE ${sources}) target_include_directories(${example}_test PRIVATE src/test/cpp/examples/${example}/include) target_compile_definitions(${example}_test PUBLIC RUNNING_FRC_TESTS) - target_link_libraries(${example}_test wpilibc wpilibNewCommands wpilibOldCommands gmock_main) + target_link_libraries(${example}_test wpilibc wpilibNewCommands gmock_main) endif() endforeach() @@ -27,5 +27,5 @@ foreach(template ${TEMPLATES}) src/main/cpp/templates/${template}/c/*.c) add_executable(${template} ${sources}) target_include_directories(${template} PUBLIC src/main/cpp/templates/${template}/include) - target_link_libraries(${template} wpilibc wpilibNewCommands wpilibOldCommands) + target_link_libraries(${template} wpilibc wpilibNewCommands) endforeach() diff --git a/wpilibcExamples/build.gradle b/wpilibcExamples/build.gradle index 4cdadc85e7..975e90ae70 100644 --- a/wpilibcExamples/build.gradle +++ b/wpilibcExamples/build.gradle @@ -86,7 +86,6 @@ model { "${key}"(NativeExecutableSpec) { targetBuildTypes 'debug' binaries.all { binary -> - lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'shared' lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared' lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' lib project: ':wpimath', library: 'wpimath', linkage: 'shared' @@ -134,7 +133,6 @@ model { "${key}"(NativeExecutableSpec) { targetBuildTypes 'debug' binaries.all { binary -> - lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'shared' lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared' lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' lib project: ':wpimath', library: 'wpimath', linkage: 'shared' @@ -206,7 +204,6 @@ model { } binaries { withType(GoogleTestTestSuiteBinarySpec) { - lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'shared' lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared' lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' lib project: ':wpimath', library: 'wpimath', linkage: 'shared' diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/OI.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/OI.cpp deleted file mode 100644 index 1aff3fb8cf..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/OI.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "OI.h" - -#include - -#include "commands/Collect.h" -#include "commands/DriveForward.h" -#include "commands/LowGoal.h" -#include "commands/SetCollectionSpeed.h" -#include "commands/SetPivotSetpoint.h" -#include "commands/Shoot.h" -#include "subsystems/Collector.h" -#include "subsystems/Pivot.h" - -OI::OI() { - m_r1.WhenPressed(new LowGoal()); - m_r2.WhenPressed(new Collect()); - - m_l1.WhenPressed(new SetPivotSetpoint(Pivot::kShoot)); - m_l2.WhenPressed(new SetPivotSetpoint(Pivot::kShootNear)); - - m_sticks.WhenActive(new Shoot()); - - // SmartDashboard Buttons - frc::SmartDashboard::PutData("Drive Forward", new DriveForward(2.25)); - frc::SmartDashboard::PutData("Drive Backward", new DriveForward(-2.25)); - frc::SmartDashboard::PutData("Start Rollers", - new SetCollectionSpeed(Collector::kForward)); - frc::SmartDashboard::PutData("Stop Rollers", - new SetCollectionSpeed(Collector::kStop)); - frc::SmartDashboard::PutData("Reverse Rollers", - new SetCollectionSpeed(Collector::kReverse)); -} - -frc::Joystick& OI::GetJoystick() { - return m_joystick; -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/Robot.cpp deleted file mode 100644 index 688560e586..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/Robot.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "Robot.h" - -#include - -#include -#include -#include - -Drivetrain Robot::drivetrain; -Pivot Robot::pivot; -Collector Robot::collector; -Shooter Robot::shooter; -Pneumatics Robot::pneumatics; -OI Robot::oi; - -void Robot::RobotInit() { - // Show what command your subsystem is running on the SmartDashboard - frc::SmartDashboard::PutData(&drivetrain); - frc::SmartDashboard::PutData(&pivot); - frc::SmartDashboard::PutData(&collector); - frc::SmartDashboard::PutData(&shooter); - frc::SmartDashboard::PutData(&pneumatics); - - // instantiate the command used for the autonomous period - m_autoChooser.SetDefaultOption("Drive and Shoot", &m_driveAndShootAuto); - m_autoChooser.AddOption("Drive Forward", &m_driveForwardAuto); - frc::SmartDashboard::PutData("Auto Mode", &m_autoChooser); - - pneumatics.Start(); // Pressurize the pneumatics. -} - -void Robot::AutonomousInit() { - m_autonomousCommand = m_autoChooser.GetSelected(); - m_autonomousCommand->Start(); -} - -void Robot::AutonomousPeriodic() { - frc::Scheduler::GetInstance()->Run(); - Log(); -} - -void Robot::TeleopInit() { - // This makes sure that the autonomous stops running when - // teleop starts running. If you want the autonomous to - // continue until interrupted by another command, remove - // this line or comment it out. - if (m_autonomousCommand != nullptr) { - m_autonomousCommand->Cancel(); - } - fmt::print("Starting Teleop\n"); -} - -void Robot::TeleopPeriodic() { - frc::Scheduler::GetInstance()->Run(); - Log(); -} - -void Robot::TestPeriodic() {} - -void Robot::DisabledInit() { - shooter.Unlatch(); -} - -void Robot::DisabledPeriodic() { - Log(); -} - -/** - * Log interesting values to the SmartDashboard. - */ -void Robot::Log() { - Robot::pneumatics.WritePressure(); - frc::SmartDashboard::PutNumber("Pivot Pot Value", pivot.GetAngle()); - frc::SmartDashboard::PutNumber("Left Distance", - drivetrain.GetLeftEncoder().GetDistance()); - frc::SmartDashboard::PutNumber("Right Distance", - drivetrain.GetRightEncoder().GetDistance()); -} - -#ifndef RUNNING_FRC_TESTS -int main() { - return frc::StartRobot(); -} -#endif diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/CheckForHotGoal.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/CheckForHotGoal.cpp deleted file mode 100644 index 5f2ec8584a..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/CheckForHotGoal.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/CheckForHotGoal.h" - -#include "Robot.h" - -CheckForHotGoal::CheckForHotGoal(units::second_t time) { - SetTimeout(time); -} - -// Make this return true when this Command no longer needs to run execute() -bool CheckForHotGoal::IsFinished() { - return IsTimedOut() || Robot::shooter.GoalIsHot(); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/CloseClaw.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/CloseClaw.cpp deleted file mode 100644 index a1a9d7f4dd..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/CloseClaw.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/CloseClaw.h" - -#include "Robot.h" - -CloseClaw::CloseClaw() { - Requires(&Robot::collector); -} - -// Called just before this Command runs the first time -void CloseClaw::Initialize() { - Robot::collector.Close(); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/Collect.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/Collect.cpp deleted file mode 100644 index 88a1ca2c04..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/Collect.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/Collect.h" - -#include "Robot.h" -#include "commands/CloseClaw.h" -#include "commands/SetCollectionSpeed.h" -#include "commands/SetPivotSetpoint.h" -#include "commands/WaitForBall.h" - -Collect::Collect() { - AddSequential(new SetCollectionSpeed(Collector::kForward)); - AddParallel(new CloseClaw()); - AddSequential(new SetPivotSetpoint(Pivot::kCollect)); - AddSequential(new WaitForBall()); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/DriveAndShootAutonomous.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/DriveAndShootAutonomous.cpp deleted file mode 100644 index 156c64d60d..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/DriveAndShootAutonomous.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/DriveAndShootAutonomous.h" - -#include "Robot.h" -#include "commands/CheckForHotGoal.h" -#include "commands/CloseClaw.h" -#include "commands/DriveForward.h" -#include "commands/SetPivotSetpoint.h" -#include "commands/Shoot.h" -#include "commands/WaitForPressure.h" - -DriveAndShootAutonomous::DriveAndShootAutonomous() { - AddSequential(new CloseClaw()); - AddSequential(new WaitForPressure(), 2_s); -#ifndef SIMULATION - // NOTE: Simulation doesn't currently have the concept of hot. - AddSequential(new CheckForHotGoal(2_s)); -#endif - AddSequential(new SetPivotSetpoint(45)); - AddSequential(new DriveForward(8, 0.3)); - AddSequential(new Shoot()); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/DriveForward.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/DriveForward.cpp deleted file mode 100644 index 083ab53781..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/DriveForward.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/DriveForward.h" - -#include - -#include "Robot.h" - -void DriveForward::init(double dist, double maxSpeed) { - Requires(&Robot::drivetrain); - m_distance = dist; - m_driveForwardSpeed = maxSpeed; -} - -DriveForward::DriveForward() { - init(10, 0.5); -} - -DriveForward::DriveForward(double dist) { - init(dist, 0.5); -} - -DriveForward::DriveForward(double dist, double maxSpeed) { - init(dist, maxSpeed); -} - -// Called just before this Command runs the first time -void DriveForward::Initialize() { - Robot::drivetrain.GetRightEncoder().Reset(); - SetTimeout(2_s); -} - -// Called repeatedly when this Command is scheduled to run -void DriveForward::Execute() { - m_error = (m_distance - Robot::drivetrain.GetRightEncoder().GetDistance()); - if (m_driveForwardSpeed * kP * m_error >= m_driveForwardSpeed) { - Robot::drivetrain.TankDrive(m_driveForwardSpeed, m_driveForwardSpeed); - } else { - Robot::drivetrain.TankDrive(m_driveForwardSpeed * kP * m_error, - m_driveForwardSpeed * kP * m_error); - } -} - -// Make this return true when this Command no longer needs to run execute() -bool DriveForward::IsFinished() { - return (std::fabs(m_error) <= kTolerance) || IsTimedOut(); -} - -// Called once after isFinished returns true -void DriveForward::End() { - Robot::drivetrain.Stop(); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/DriveWithJoystick.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/DriveWithJoystick.cpp deleted file mode 100644 index 42e7cd7172..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/DriveWithJoystick.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/DriveWithJoystick.h" - -#include "Robot.h" - -DriveWithJoystick::DriveWithJoystick() { - Requires(&Robot::drivetrain); -} - -// Called repeatedly when this Command is scheduled to run -void DriveWithJoystick::Execute() { - auto& joystick = Robot::oi.GetJoystick(); - Robot::drivetrain.TankDrive(joystick.GetY(), joystick.GetRawAxis(4)); -} - -// Make this return true when this Command no longer needs to run execute() -bool DriveWithJoystick::IsFinished() { - return false; -} - -// Called once after isFinished returns true -void DriveWithJoystick::End() { - Robot::drivetrain.Stop(); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/ExtendShooter.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/ExtendShooter.cpp deleted file mode 100644 index 11e98a4196..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/ExtendShooter.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/ExtendShooter.h" - -#include "Robot.h" - -ExtendShooter::ExtendShooter() : frc::TimedCommand(1_s) { - Requires(&Robot::shooter); -} - -// Called just before this Command runs the first time -void ExtendShooter::Initialize() { - Robot::shooter.ExtendBoth(); -} - -// Called once after isFinished returns true -void ExtendShooter::End() { - Robot::shooter.RetractBoth(); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/LowGoal.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/LowGoal.cpp deleted file mode 100644 index 0fb0e21e39..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/LowGoal.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/LowGoal.h" - -#include "Robot.h" -#include "commands/ExtendShooter.h" -#include "commands/SetCollectionSpeed.h" -#include "commands/SetPivotSetpoint.h" - -LowGoal::LowGoal() { - AddSequential(new SetPivotSetpoint(Pivot::kLowGoal)); - AddSequential(new SetCollectionSpeed(Collector::kReverse)); - AddSequential(new ExtendShooter()); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/OpenClaw.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/OpenClaw.cpp deleted file mode 100644 index 2bbad93c7b..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/OpenClaw.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/OpenClaw.h" - -#include "Robot.h" - -OpenClaw::OpenClaw() { - Requires(&Robot::collector); -} - -// Called just before this Command runs the first time -void OpenClaw::Initialize() { - Robot::collector.Open(); -} - -// Make this return true when this Command no longer needs to run execute() -bool OpenClaw::IsFinished() { - return Robot::collector.IsOpen(); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/SetCollectionSpeed.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/SetCollectionSpeed.cpp deleted file mode 100644 index d75071c569..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/SetCollectionSpeed.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/SetCollectionSpeed.h" - -#include "Robot.h" - -SetCollectionSpeed::SetCollectionSpeed(double speed) { - Requires(&Robot::collector); - m_speed = speed; -} - -// Called just before this Command runs the first time -void SetCollectionSpeed::Initialize() { - Robot::collector.SetSpeed(m_speed); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/SetPivotSetpoint.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/SetPivotSetpoint.cpp deleted file mode 100644 index 1889008437..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/SetPivotSetpoint.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/SetPivotSetpoint.h" - -#include "Robot.h" - -SetPivotSetpoint::SetPivotSetpoint(double setpoint) { - m_setpoint = setpoint; - Requires(&Robot::pivot); -} - -// Called just before this Command runs the first time -void SetPivotSetpoint::Initialize() { - Robot::pivot.Enable(); - Robot::pivot.SetSetpoint(m_setpoint); -} - -// Make this return true when this Command no longer needs to run execute() -bool SetPivotSetpoint::IsFinished() { - return Robot::pivot.OnTarget(); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/Shoot.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/Shoot.cpp deleted file mode 100644 index 42680bbd63..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/Shoot.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/Shoot.h" - -#include "Robot.h" -#include "commands/ExtendShooter.h" -#include "commands/OpenClaw.h" -#include "commands/SetCollectionSpeed.h" -#include "commands/WaitForPressure.h" - -Shoot::Shoot() { - AddSequential(new WaitForPressure()); - AddSequential(new SetCollectionSpeed(Collector::kStop)); - AddSequential(new OpenClaw()); - AddSequential(new ExtendShooter()); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/WaitForBall.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/WaitForBall.cpp deleted file mode 100644 index 1c028817e7..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/WaitForBall.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/WaitForBall.h" - -#include "Robot.h" - -WaitForBall::WaitForBall() { - Requires(&Robot::collector); -} - -// Make this return true when this Command no longer needs to run execute() -bool WaitForBall::IsFinished() { - return Robot::collector.HasBall(); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/WaitForPressure.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/WaitForPressure.cpp deleted file mode 100644 index 880600b088..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/commands/WaitForPressure.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/WaitForPressure.h" - -#include "Robot.h" - -WaitForPressure::WaitForPressure() { - Requires(&Robot::pneumatics); -} - -// Make this return true when this Command no longer needs to run execute() -bool WaitForPressure::IsFinished() { - return Robot::pneumatics.IsPressurized(); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Collector.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Collector.cpp deleted file mode 100644 index 5d8a0d3cbd..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Collector.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "subsystems/Collector.h" - -#include - -Collector::Collector() : frc::Subsystem("Collector") { - // Put everything to the LiveWindow for testing. - AddChild("Roller Motor", m_rollerMotor); - AddChild("Ball Detector", m_ballDetector); - AddChild("Claw Open Detector", m_openDetector); - AddChild("Piston", m_piston); -} - -bool Collector::HasBall() { - return m_ballDetector.Get(); // TODO: prepend ! to reflect real robot -} - -void Collector::SetSpeed(double speed) { - m_rollerMotor.Set(-speed); -} - -void Collector::Stop() { - m_rollerMotor.Set(0); -} - -bool Collector::IsOpen() { - return m_openDetector.Get(); // TODO: prepend ! to reflect real robot -} - -void Collector::Open() { - m_piston.Set(true); -} - -void Collector::Close() { - m_piston.Set(false); -} - -void Collector::InitDefaultCommand() {} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Drivetrain.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Drivetrain.cpp deleted file mode 100644 index 21e35c6991..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Drivetrain.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "subsystems/Drivetrain.h" - -#include -#include -#include - -#include "commands/DriveWithJoystick.h" - -Drivetrain::Drivetrain() : frc::Subsystem("Drivetrain") { - // AddChild("Front Left CIM", m_frontLeftCIM); - // AddChild("Front Right CIM", m_frontRightCIM); - // AddChild("Back Left CIM", m_backLeftCIM); - // AddChild("Back Right CIM", m_backRightCIM); - - // Configure the DifferentialDrive to reflect the fact that all our - // motors are wired backwards and our drivers sensitivity preferences. - m_robotDrive.SetSafetyEnabled(false); - m_robotDrive.SetExpiration(100_ms); - m_robotDrive.SetMaxOutput(1.0); - m_leftCIMs.SetInverted(true); - m_rightCIMs.SetInverted(true); - -#ifndef SIMULATION - // Converts to feet - m_rightEncoder.SetDistancePerPulse(0.0785398); - m_leftEncoder.SetDistancePerPulse(0.0785398); -#else - // Circumference = diameter * pi. 360 tick simulated encoders. - m_rightEncoder.SetDistancePerPulse(units::foot_t{4_in}.to() * - wpi::numbers::pi / 360.0); - m_leftEncoder.SetDistancePerPulse(units::foot_t{4_in}.to() * - wpi::numbers::pi / 360.0); -#endif - - AddChild("Right Encoder", m_rightEncoder); - AddChild("Left Encoder", m_leftEncoder); - -// Configure gyro -#ifndef SIMULATION - m_gyro.SetSensitivity(0.007); // TODO: Handle more gracefully? -#endif - AddChild("Gyro", m_gyro); -} - -void Drivetrain::InitDefaultCommand() { - SetDefaultCommand(new DriveWithJoystick()); -} - -void Drivetrain::TankDrive(double leftAxis, double rightAxis) { - m_robotDrive.TankDrive(leftAxis, rightAxis); -} - -void Drivetrain::Stop() { - m_robotDrive.TankDrive(0.0, 0.0); -} - -frc::Encoder& Drivetrain::GetLeftEncoder() { - return m_leftEncoder; -} - -frc::Encoder& Drivetrain::GetRightEncoder() { - return m_rightEncoder; -} - -double Drivetrain::GetAngle() { - return m_gyro.GetAngle(); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Pivot.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Pivot.cpp deleted file mode 100644 index ba6f1a6d01..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Pivot.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "subsystems/Pivot.h" - -Pivot::Pivot() : frc::PIDSubsystem("Pivot", 7.0, 0.0, 8.0) { - SetAbsoluteTolerance(0.005); - GetPIDController()->SetContinuous(false); -#ifdef SIMULATION - // PID is different in simulation. - GetPIDController()->SetPID(0.5, 0.001, 2); - SetAbsoluteTolerance(5); -#endif - - // Put everything to the LiveWindow for testing. - AddChild("Upper Limit Switch", m_upperLimitSwitch); - AddChild("Lower Limit Switch", m_lowerLimitSwitch); - AddChild("Pot", m_pot); - AddChild("Motor", m_motor); -} - -void InitDefaultCommand() {} - -double Pivot::ReturnPIDInput() { - return m_pot.Get(); -} - -void Pivot::UsePIDOutput(double output) { - m_motor.Set(output); -} - -bool Pivot::IsAtUpperLimit() { - return m_upperLimitSwitch.Get(); // TODO: inverted from real robot - // (prefix with !) -} - -bool Pivot::IsAtLowerLimit() { - return m_lowerLimitSwitch.Get(); // TODO: inverted from real robot - // (prefix with !) -} - -double Pivot::GetAngle() { - return m_pot.Get(); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Pneumatics.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Pneumatics.cpp deleted file mode 100644 index 4c77f67849..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Pneumatics.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "subsystems/Pneumatics.h" - -#include - -Pneumatics::Pneumatics() : frc::Subsystem("Pneumatics") { - AddChild("Pressure Sensor", m_pressureSensor); -} - -void Pneumatics::InitDefaultCommand() { - // No default command -} - -void Pneumatics::Start() { -#ifndef SIMULATION - m_compressor.Start(); -#endif -} - -bool Pneumatics::IsPressurized() { -#ifndef SIMULATION - return kMaxPressure <= m_pressureSensor.GetVoltage(); -#else - return true; // NOTE: Simulation always has full pressure -#endif -} - -void Pneumatics::WritePressure() { - frc::SmartDashboard::PutNumber("Pressure", m_pressureSensor.GetVoltage()); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Shooter.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Shooter.cpp deleted file mode 100644 index b8449a7333..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/subsystems/Shooter.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "subsystems/Shooter.h" - -Shooter::Shooter() : Subsystem("Shooter") { - // Put everything to the LiveWindow for testing. - AddChild("Hot Goal Sensor", m_hotGoalSensor); - AddChild("Piston1 Reed Switch Front ", m_piston1ReedSwitchFront); - AddChild("Piston1 Reed Switch Back ", m_piston1ReedSwitchBack); - AddChild("Latch Piston", m_latchPiston); -} - -void Shooter::InitDefaultCommand() { - // Set the default command for a subsystem here. - // SetDefaultCommand(new MySpecialCommand()); -} - -void Shooter::ExtendBoth() { - m_piston1.Set(frc::DoubleSolenoid::kForward); - m_piston2.Set(frc::DoubleSolenoid::kForward); -} - -void Shooter::RetractBoth() { - m_piston1.Set(frc::DoubleSolenoid::kReverse); - m_piston2.Set(frc::DoubleSolenoid::kReverse); -} - -void Shooter::Extend1() { - m_piston1.Set(frc::DoubleSolenoid::kForward); -} - -void Shooter::Retract1() { - m_piston1.Set(frc::DoubleSolenoid::kReverse); -} - -void Shooter::Extend2() { - m_piston2.Set(frc::DoubleSolenoid::kReverse); -} - -void Shooter::Retract2() { - m_piston2.Set(frc::DoubleSolenoid::kForward); -} - -void Shooter::Off1() { - m_piston1.Set(frc::DoubleSolenoid::kOff); -} - -void Shooter::Off2() { - m_piston2.Set(frc::DoubleSolenoid::kOff); -} - -void Shooter::Unlatch() { - m_latchPiston.Set(true); -} - -void Shooter::Latch() { - m_latchPiston.Set(false); -} - -void Shooter::ToggleLatchPosition() { - m_latchPiston.Set(!m_latchPiston.Get()); -} - -bool Shooter::Piston1IsExtended() { - return !m_piston1ReedSwitchFront.Get(); -} - -bool Shooter::Piston1IsRetracted() { - return !m_piston1ReedSwitchBack.Get(); -} - -void Shooter::OffBoth() { - m_piston1.Set(frc::DoubleSolenoid::kOff); - m_piston2.Set(frc::DoubleSolenoid::kOff); -} - -bool Shooter::GoalIsHot() { - return m_hotGoalSensor.Get(); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/triggers/DoubleButton.cpp b/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/triggers/DoubleButton.cpp deleted file mode 100644 index 9b4bfa81bc..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/cpp/triggers/DoubleButton.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "triggers/DoubleButton.h" - -#include - -DoubleButton::DoubleButton(frc::GenericHID* joy, int button1, int button2) - : m_joy(*joy) { - m_button1 = button1; - m_button2 = button2; -} - -bool DoubleButton::Get() { - return m_joy.GetRawButton(m_button1) && m_joy.GetRawButton(m_button2); -} diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/OI.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/OI.h deleted file mode 100644 index 90d29a147c..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/OI.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include -#include - -#include "triggers/DoubleButton.h" - -class OI { - public: - OI(); - frc::Joystick& GetJoystick(); - - private: - frc::Joystick m_joystick{0}; - - frc::JoystickButton m_l1{&m_joystick, 11}; - frc::JoystickButton m_l2{&m_joystick, 9}; - frc::JoystickButton m_r1{&m_joystick, 12}; - frc::JoystickButton m_r2{&m_joystick, 10}; - - DoubleButton m_sticks{&m_joystick, 2, 3}; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/Robot.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/Robot.h deleted file mode 100644 index b89201daf8..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/Robot.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include -#include -#include - -#include "OI.h" -#include "commands/DriveAndShootAutonomous.h" -#include "commands/DriveForward.h" -#include "subsystems/Collector.h" -#include "subsystems/Drivetrain.h" -#include "subsystems/Pivot.h" -#include "subsystems/Pneumatics.h" -#include "subsystems/Shooter.h" - -class Robot : public frc::TimedRobot { - public: - static Drivetrain drivetrain; - static Pivot pivot; - static Collector collector; - static Shooter shooter; - static Pneumatics pneumatics; - static OI oi; - - private: - frc::Command* m_autonomousCommand = nullptr; - DriveAndShootAutonomous m_driveAndShootAuto; - DriveForward m_driveForwardAuto; - frc::SendableChooser m_autoChooser; - - void RobotInit() override; - void AutonomousInit() override; - void AutonomousPeriodic() override; - void TeleopInit() override; - void TeleopPeriodic() override; - void TestPeriodic() override; - void DisabledInit() override; - void DisabledPeriodic() override; - - void Log(); -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/CheckForHotGoal.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/CheckForHotGoal.h deleted file mode 100644 index 2dad8f5c0d..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/CheckForHotGoal.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include -#include - -/** - * This command looks for the hot goal and waits until it's detected or timed - * out. The timeout is because it's better to shoot and get some autonomous - * points than get none. When called sequentially, this command will block until - * the hot goal is detected or until it is timed out. - */ -class CheckForHotGoal : public frc::Command { - public: - explicit CheckForHotGoal(units::second_t time); - bool IsFinished() override; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/CloseClaw.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/CloseClaw.h deleted file mode 100644 index 4fa2823a21..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/CloseClaw.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * Close the claw. - * - * NOTE: It doesn't wait for the claw to close since there is no sensor to - * detect that. - */ -class CloseClaw : public frc::InstantCommand { - public: - CloseClaw(); - void Initialize() override; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/Collect.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/Collect.h deleted file mode 100644 index d14440c78c..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/Collect.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * Get the robot set to collect balls. - */ -class Collect : public frc::CommandGroup { - public: - Collect(); -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/DriveAndShootAutonomous.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/DriveAndShootAutonomous.h deleted file mode 100644 index d4d6cb14e0..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/DriveAndShootAutonomous.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * Drive over the line and then shoot the ball. If the hot goal is not detected, - * it will wait briefly. - */ -class DriveAndShootAutonomous : public frc::CommandGroup { - public: - DriveAndShootAutonomous(); -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/DriveForward.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/DriveForward.h deleted file mode 100644 index ac7ebcc0a5..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/DriveForward.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * This command drives the robot over a given distance with simple proportional - * control This command will drive a given distance limiting to a maximum speed. - */ -class DriveForward : public frc::Command { - public: - DriveForward(); - explicit DriveForward(double dist); - DriveForward(double dist, double maxSpeed); - void Initialize() override; - void Execute() override; - bool IsFinished() override; - void End() override; - - private: - double m_driveForwardSpeed; - double m_distance; - double m_error = 0; - static constexpr double kTolerance = 0.1; - static constexpr double kP = -1.0 / 5.0; - - void init(double dist, double maxSpeed); -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/DriveWithJoystick.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/DriveWithJoystick.h deleted file mode 100644 index 637df3aeaa..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/DriveWithJoystick.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * This command allows PS3 joystick to drive the robot. It is always running - * except when interrupted by another command. - */ -class DriveWithJoystick : public frc::Command { - public: - DriveWithJoystick(); - void Execute() override; - bool IsFinished() override; - void End() override; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/ExtendShooter.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/ExtendShooter.h deleted file mode 100644 index 65b22b79b5..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/ExtendShooter.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * Extend the shooter and then retract it after a second. - */ -class ExtendShooter : public frc::TimedCommand { - public: - ExtendShooter(); - void Initialize() override; - void End() override; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/LowGoal.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/LowGoal.h deleted file mode 100644 index 1f015f3736..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/LowGoal.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * Spit the ball out into the low goal assuming that the robot is in front of - * it. - */ -class LowGoal : public frc::CommandGroup { - public: - LowGoal(); -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/OpenClaw.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/OpenClaw.h deleted file mode 100644 index 526702f681..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/OpenClaw.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * Opens the claw - */ -class OpenClaw : public frc::Command { - public: - OpenClaw(); - void Initialize() override; - bool IsFinished() override; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/SetCollectionSpeed.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/SetCollectionSpeed.h deleted file mode 100644 index 301f17a531..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/SetCollectionSpeed.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * This command sets the collector rollers spinning at the given speed. Since - * there is no sensor for detecting speed, it finishes immediately. As a result, - * the spinners may still be adjusting their speed. - */ -class SetCollectionSpeed : public frc::InstantCommand { - public: - explicit SetCollectionSpeed(double speed); - void Initialize() override; - - private: - double m_speed; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/SetPivotSetpoint.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/SetPivotSetpoint.h deleted file mode 100644 index 16fb9188d5..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/SetPivotSetpoint.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * Moves the pivot to a given angle. This command finishes when it is within - * the tolerance, but leaves the PID loop running to maintain the position. - * Other commands using the pivot should make sure they disable PID! - */ -class SetPivotSetpoint : public frc::Command { - public: - explicit SetPivotSetpoint(double setpoint); - void Initialize() override; - bool IsFinished() override; - - private: - double m_setpoint; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/Shoot.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/Shoot.h deleted file mode 100644 index ed3e48b68f..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/Shoot.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * Shoot the ball at the current angle. - */ -class Shoot : public frc::CommandGroup { - public: - Shoot(); -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/WaitForBall.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/WaitForBall.h deleted file mode 100644 index f3bd1a605d..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/WaitForBall.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * Wait until the collector senses that it has the ball. This command does - * nothing and is intended to be used in command groups to wait for this - * condition. - */ -class WaitForBall : public frc::Command { - public: - WaitForBall(); - bool IsFinished() override; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/WaitForPressure.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/WaitForPressure.h deleted file mode 100644 index a206654a55..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/commands/WaitForPressure.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -/** - * Wait until the pneumatics are fully pressurized. This command does nothing - * and is intended to be used in command groups to wait for this condition. - */ -class WaitForPressure : public frc::Command { - public: - WaitForPressure(); - bool IsFinished() override; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Collector.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Collector.h deleted file mode 100644 index 53fc0586f2..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Collector.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include -#include -#include -#include - -/** - * The Collector subsystem has one motor for the rollers, a limit switch for - * ball - * detection, a piston for opening and closing the claw, and a reed switch to - * check if the piston is open. - */ -class Collector : public frc::Subsystem { - public: - // Constants for some useful speeds - static constexpr double kForward = 1; - static constexpr double kStop = 0; - static constexpr double kReverse = -1; - - Collector(); - - /** - * NOTE: The current simulation model uses the the lower part of the - * claw - * since the limit switch wasn't exported. At some point, this will be - * updated. - * - * @return Whether or not the robot has the ball. - */ - bool HasBall(); - - /** - * @param speed The speed to spin the rollers. - */ - void SetSpeed(double speed); - - /** - * Stop the rollers from spinning - */ - void Stop(); - - /** - * @return Whether or not the claw is open. - */ - bool IsOpen(); - - /** - * Open the claw up. (For shooting) - */ - void Open(); - - /** - * Close the claw. (For collecting and driving) - */ - void Close(); - - /** - * No default command. - */ - void InitDefaultCommand() override; - - private: - // Subsystem devices - frc::PWMSparkMax m_rollerMotor{6}; - frc::DigitalInput m_ballDetector{10}; - frc::Solenoid m_piston{frc::PneumaticsModuleType::CTREPCM, 1}; - frc::DigitalInput m_openDetector{6}; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Drivetrain.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Drivetrain.h deleted file mode 100644 index 070bc0c7c0..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Drivetrain.h +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace frc { -class Joystick; -} // namespace frc - -/** - * The Drivetrain subsystem controls the robot's chassis and reads in - * information about it's speed and position. - */ -class Drivetrain : public frc::Subsystem { - public: - Drivetrain(); - - /** - * When other commands aren't using the drivetrain, allow tank drive - * with - * the joystick. - */ - void InitDefaultCommand() override; - - /** - * @param leftAxis Left sides value - * @param rightAxis Right sides value - */ - void TankDrive(double leftAxis, double rightAxis); - - /** - * Stop the drivetrain from moving. - */ - void Stop(); - - /** - * @return The encoder getting the distance and speed of left side of - * the drivetrain. - */ - frc::Encoder& GetLeftEncoder(); - - /** - * @return The encoder getting the distance and speed of right side of - * the drivetrain. - */ - frc::Encoder& GetRightEncoder(); - - /** - * @return The current angle of the drivetrain. - */ - double GetAngle(); - - private: - // Subsystem devices - frc::PWMSparkMax m_frontLeftCIM{1}; - frc::PWMSparkMax m_rearLeftCIM{2}; - frc::MotorControllerGroup m_leftCIMs{m_frontLeftCIM, m_rearLeftCIM}; - - frc::PWMSparkMax m_frontRightCIM{3}; - frc::PWMSparkMax m_rearRightCIM{4}; - frc::MotorControllerGroup m_rightCIMs{m_frontRightCIM, m_rearRightCIM}; - - frc::DifferentialDrive m_robotDrive{m_leftCIMs, m_rightCIMs}; - - frc::Encoder m_rightEncoder{1, 2, true, frc::Encoder::k4X}; - frc::Encoder m_leftEncoder{3, 4, false, frc::Encoder::k4X}; - frc::AnalogGyro m_gyro{0}; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Pivot.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Pivot.h deleted file mode 100644 index 95b3be9eca..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Pivot.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include -#include -#include -#include - -/** - * The Pivot subsystem contains the Van-door motor and the pot for PID control - * of angle of the pivot and claw. - */ -class Pivot : public frc::PIDSubsystem { - public: - // Constants for some useful angles - static constexpr double kCollect = 105; - static constexpr double kLowGoal = 90; - static constexpr double kShoot = 45; - static constexpr double kShootNear = 30; - - Pivot(); - - /** - * No default command, if PID is enabled, the current setpoint will be - * maintained. - */ - void InitDefaultCommand() override {} - - /** - * @return The angle read in by the potentiometer - */ - double ReturnPIDInput() override; - - /** - * Set the motor speed based off of the PID output - */ - void UsePIDOutput(double output) override; - - /** - * @return If the pivot is at its upper limit. - */ - bool IsAtUpperLimit(); - - /** - * @return If the pivot is at its lower limit. - */ - bool IsAtLowerLimit(); - - /** - * @return The current angle of the pivot. - */ - double GetAngle(); - - private: - // Subsystem devices - - // Sensors for measuring the position of the pivot - frc::DigitalInput m_upperLimitSwitch{13}; - frc::DigitalInput m_lowerLimitSwitch{12}; - - /* 0 degrees is vertical facing up. - * Angle increases the more forward the pivot goes. - */ - frc::AnalogPotentiometer m_pot{1}; - - // Motor to move the pivot - frc::PWMSparkMax m_motor{5}; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Pneumatics.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Pneumatics.h deleted file mode 100644 index 53111f95f6..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Pneumatics.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include -#include -#include - -/** - * The Pneumatics subsystem contains the compressor and a pressure sensor. - * - * NOTE: The simulator currently doesn't support the compressor or pressure - * sensors. - */ -class Pneumatics : public frc::Subsystem { - public: - Pneumatics(); - - /** - * No default command - */ - void InitDefaultCommand() override; - - /** - * Start the compressor going. The compressor automatically starts and - * stops as it goes above and below maximum pressure. - */ - void Start(); - - /** - * @return Whether or not the system is fully pressurized. - */ - bool IsPressurized(); - - /** - * Puts the pressure on the SmartDashboard. - */ - void WritePressure(); - - private: - frc::AnalogInput m_pressureSensor{3}; - -#ifndef SIMULATION - frc::Compressor m_compressor{ - 1, frc::PneumaticsModuleType::CTREPCM}; // TODO: (1, 14, 1, 8); -#endif - - static constexpr double kMaxPressure = 2.55; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Shooter.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Shooter.h deleted file mode 100644 index e52a97c693..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/subsystems/Shooter.h +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include -#include -#include -#include - -/** - * The Shooter subsystem handles shooting. The mechanism for shooting is - * slightly complicated because it has to pneumatic cylinders for shooting, and - * a third latch to allow the pressure to partially build up and reduce the - * effect of the airflow. For shorter shots, when full power isn't needed, only - * one cylinder fires. - * - * NOTE: Simulation currently approximates this as as single pneumatic cylinder - * and ignores the latch. - */ -class Shooter : public frc::Subsystem { - public: - Shooter(); - void InitDefaultCommand() override; - - /** - * Extend both solenoids to shoot. - */ - void ExtendBoth(); - - /** - * Retract both solenoids to prepare to shoot. - */ - void RetractBoth(); - - /** - * Extend solenoid 1 to shoot. - */ - void Extend1(); - - /** - * Retract solenoid 1 to prepare to shoot. - */ - void Retract1(); - - /** - * Extend solenoid 2 to shoot. - */ - void Extend2(); - - /** - * Retract solenoid 2 to prepare to shoot. - */ - void Retract2(); - - /** - * Turns off the piston1 double solenoid. This won't actuate anything - * because double solenoids preserve their state when turned off. This - * should be called in order to reduce the amount of time that the coils - * are - * powered. - */ - void Off1(); - - /** - * Turns off the piston1 double solenoid. This won't actuate anything - * because double solenoids preserve their state when turned off. This - * should be called in order to reduce the amount of time that the coils - * are - * powered. - */ - void Off2(); - - /** - * Release the latch so that we can shoot - */ - void Unlatch(); - - /** - * Latch so that pressure can build up and we aren't limited by air - * flow. - */ - void Latch(); - - /** - * Toggles the latch postions - */ - void ToggleLatchPosition(); - - /** - * @return Whether or not piston 1 is fully extended. - */ - bool Piston1IsExtended(); - - /** - * @return Whether or not piston 1 is fully retracted. - */ - bool Piston1IsRetracted(); - - /** - * Turns off all double solenoids. Double solenoids hold their position - * when - * they are turned off. We should turn them off whenever possible to - * extend - * the life of the coils - */ - void OffBoth(); - - /** - * @return Whether or not the goal is hot as read by the banner sensor - */ - bool GoalIsHot(); - - private: - // Devices - frc::DoubleSolenoid m_piston1{frc::PneumaticsModuleType::CTREPCM, 3, 4}; - frc::DoubleSolenoid m_piston2{frc::PneumaticsModuleType::CTREPCM, 5, 6}; - frc::Solenoid m_latchPiston{1, frc::PneumaticsModuleType::CTREPCM, 2}; - frc::DigitalInput m_piston1ReedSwitchFront{9}; - frc::DigitalInput m_piston1ReedSwitchBack{11}; - frc::DigitalInput m_hotGoalSensor{ - 7}; // NOTE: Currently ignored in simulation -}; diff --git a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/triggers/DoubleButton.h b/wpilibcExamples/src/main/cpp/examples/PacGoat/include/triggers/DoubleButton.h deleted file mode 100644 index 5004b8d675..0000000000 --- a/wpilibcExamples/src/main/cpp/examples/PacGoat/include/triggers/DoubleButton.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -namespace frc { -class GenericHID; -} // namespace frc - -class DoubleButton : public frc::Trigger { - public: - DoubleButton(frc::GenericHID* joy, int button1, int button2); - - bool Get() override; - - private: - frc::GenericHID& m_joy; - int m_button1; - int m_button2; -}; diff --git a/wpilibcExamples/src/main/cpp/examples/examples.json b/wpilibcExamples/src/main/cpp/examples/examples.json index b50d564536..b639188418 100644 --- a/wpilibcExamples/src/main/cpp/examples/examples.json +++ b/wpilibcExamples/src/main/cpp/examples/examples.json @@ -282,17 +282,6 @@ "gradlebase": "cpp", "commandversion": 2 }, - { - "name": "PacGoat", - "description": "A fully functional example CommandBased program for FRC Team 190's 2014 robot. This code can run on your computer if it supports simulation.", - "tags": [ - "CommandBased Robot", - "Complete List" - ], - "foldername": "PacGoat", - "gradlebase": "cpp", - "commandversion": 1 - }, { "name": "HAL", "description": "A program created using the HAL exclusively. This example is for advanced users", diff --git a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/OI.cpp b/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/OI.cpp deleted file mode 100644 index c6418660a7..0000000000 --- a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/OI.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "OI.h" - -OI::OI() { - // Process operator interface input here. -} diff --git a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/Robot.cpp deleted file mode 100644 index 111834c215..0000000000 --- a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/Robot.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "Robot.h" - -#include -#include - -ExampleSubsystem Robot::m_subsystem; -OI Robot::m_oi; - -void Robot::RobotInit() { - m_chooser.SetDefaultOption("Default Auto", &m_defaultAuto); - m_chooser.AddOption("My Auto", &m_myAuto); - frc::SmartDashboard::PutData("Auto Modes", &m_chooser); -} - -/** - * This function is called every robot packet, no matter the mode. Use - * this for items like diagnostics that you want ran during disabled, - * autonomous, teleoperated and test. - * - *

This runs after the mode specific periodic functions, but before - * LiveWindow and SmartDashboard integrated updating. - */ -void Robot::RobotPeriodic() {} - -/** - * This function is called once each time the robot enters Disabled mode. You - * can use it to reset any subsystem information you want to clear when the - * robot is disabled. - */ -void Robot::DisabledInit() {} - -void Robot::DisabledPeriodic() { - frc::Scheduler::GetInstance()->Run(); -} - -/** - * This autonomous (along with the chooser code above) shows how to select - * between different autonomous modes using the dashboard. The sendable chooser - * code works with the Java SmartDashboard. If you prefer the LabVIEW Dashboard, - * remove all of the chooser code and uncomment the GetString code to get the - * auto name from the text box below the Gyro. - * - * You can add additional auto modes by adding additional commands to the - * chooser code above (like the commented example) or additional comparisons to - * the if-else structure below with additional strings & commands. - */ -void Robot::AutonomousInit() { - // std::string autoSelected = frc::SmartDashboard::GetString( - // "Auto Selector", "Default"); - // if (autoSelected == "My Auto") { - // m_autonomousCommand = &m_myAuto; - // } else { - // m_autonomousCommand = &m_defaultAuto; - // } - - m_autonomousCommand = m_chooser.GetSelected(); - - if (m_autonomousCommand != nullptr) { - m_autonomousCommand->Start(); - } -} - -void Robot::AutonomousPeriodic() { - frc::Scheduler::GetInstance()->Run(); -} - -void Robot::TeleopInit() { - // This makes sure that the autonomous stops running when - // teleop starts running. If you want the autonomous to - // continue until interrupted by another command, remove - // this line or comment it out. - if (m_autonomousCommand != nullptr) { - m_autonomousCommand->Cancel(); - m_autonomousCommand = nullptr; - } -} - -void Robot::TeleopPeriodic() { - frc::Scheduler::GetInstance()->Run(); -} - -void Robot::TestPeriodic() {} - -#ifndef RUNNING_FRC_TESTS -int main() { - return frc::StartRobot(); -} -#endif diff --git a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/commands/ExampleCommand.cpp b/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/commands/ExampleCommand.cpp deleted file mode 100644 index 1a861ce325..0000000000 --- a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/commands/ExampleCommand.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/ExampleCommand.h" - -#include "Robot.h" - -ExampleCommand::ExampleCommand() { - // Use Requires() here to declare subsystem dependencies - Requires(&Robot::m_subsystem); -} - -// Called just before this Command runs the first time -void ExampleCommand::Initialize() {} - -// Called repeatedly when this Command is scheduled to run -void ExampleCommand::Execute() {} - -// Make this return true when this Command no longer needs to run execute() -bool ExampleCommand::IsFinished() { - return false; -} - -// Called once after isFinished returns true -void ExampleCommand::End() {} - -// Called when another command which requires one or more of the same -// subsystems is scheduled to run -void ExampleCommand::Interrupted() {} diff --git a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/commands/MyAutoCommand.cpp b/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/commands/MyAutoCommand.cpp deleted file mode 100644 index 051e252cde..0000000000 --- a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/commands/MyAutoCommand.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "commands/MyAutoCommand.h" - -#include "Robot.h" - -MyAutoCommand::MyAutoCommand() { - // Use Requires() here to declare subsystem dependencies - Requires(&Robot::m_subsystem); -} - -// Called just before this Command runs the first time -void MyAutoCommand::Initialize() {} - -// Called repeatedly when this Command is scheduled to run -void MyAutoCommand::Execute() {} - -// Make this return true when this Command no longer needs to run execute() -bool MyAutoCommand::IsFinished() { - return false; -} - -// Called once after isFinished returns true -void MyAutoCommand::End() {} - -// Called when another command which requires one or more of the same -// subsystems is scheduled to run -void MyAutoCommand::Interrupted() {} diff --git a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/subsystems/ExampleSubsystem.cpp b/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/subsystems/ExampleSubsystem.cpp deleted file mode 100644 index 88a6994594..0000000000 --- a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/cpp/subsystems/ExampleSubsystem.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "subsystems/ExampleSubsystem.h" - -#include "RobotMap.h" - -ExampleSubsystem::ExampleSubsystem() : frc::Subsystem("ExampleSubsystem") {} - -void ExampleSubsystem::InitDefaultCommand() { - // Set the default command for a subsystem here. - // SetDefaultCommand(new MySpecialCommand()); -} - -// Put methods for controlling this subsystem -// here. Call these from Commands. diff --git a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/OI.h b/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/OI.h deleted file mode 100644 index 0aa8a0eb01..0000000000 --- a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/OI.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -class OI { - public: - OI(); -}; diff --git a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/Robot.h b/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/Robot.h deleted file mode 100644 index 4ed72124e7..0000000000 --- a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/Robot.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include -#include -#include - -#include "OI.h" -#include "commands/ExampleCommand.h" -#include "commands/MyAutoCommand.h" -#include "subsystems/ExampleSubsystem.h" - -class Robot : public frc::TimedRobot { - public: - static ExampleSubsystem m_subsystem; - static OI m_oi; - - void RobotInit() override; - void RobotPeriodic() override; - void DisabledInit() override; - void DisabledPeriodic() override; - void AutonomousInit() override; - void AutonomousPeriodic() override; - void TeleopInit() override; - void TeleopPeriodic() override; - void TestPeriodic() override; - - private: - // Have it null by default so that if testing teleop it - // doesn't have undefined behavior and potentially crash. - frc::Command* m_autonomousCommand = nullptr; - ExampleCommand m_defaultAuto; - MyAutoCommand m_myAuto; - frc::SendableChooser m_chooser; -}; diff --git a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/RobotMap.h b/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/RobotMap.h deleted file mode 100644 index ca9b7468a6..0000000000 --- a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/RobotMap.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -/** - * The RobotMap is a mapping from the ports sensors and actuators are wired into - * to a variable name. This provides flexibility changing wiring, makes checking - * the wiring easier and significantly reduces the number of magic numbers - * floating around. - */ - -// For example to map the left and right motors, you could define the -// following variables to use with your drivetrain subsystem. -// constexpr int kLeftMotor = 1; -// constexpr int kRightMotor = 2; - -// If you are using multiple modules, make sure to define both the port -// number and the module. For example you with a rangefinder: -// constexpr int kRangeFinderPort = 1; -// constexpr int kRangeFinderModule = 1; diff --git a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/commands/ExampleCommand.h b/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/commands/ExampleCommand.h deleted file mode 100644 index 8fe468096a..0000000000 --- a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/commands/ExampleCommand.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -class ExampleCommand : public frc::Command { - public: - ExampleCommand(); - void Initialize() override; - void Execute() override; - bool IsFinished() override; - void End() override; - void Interrupted() override; -}; diff --git a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/commands/MyAutoCommand.h b/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/commands/MyAutoCommand.h deleted file mode 100644 index e74167c207..0000000000 --- a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/commands/MyAutoCommand.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -class MyAutoCommand : public frc::Command { - public: - MyAutoCommand(); - void Initialize() override; - void Execute() override; - bool IsFinished() override; - void End() override; - void Interrupted() override; -}; diff --git a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/subsystems/ExampleSubsystem.h b/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/subsystems/ExampleSubsystem.h deleted file mode 100644 index 6dfba1bcad..0000000000 --- a/wpilibcExamples/src/main/cpp/templates/oldcommandbased/include/subsystems/ExampleSubsystem.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -class ExampleSubsystem : public frc::Subsystem { - public: - ExampleSubsystem(); - void InitDefaultCommand() override; - - private: - // It's desirable that everything possible under private except - // for methods that implement subsystem capabilities -}; diff --git a/wpilibcExamples/src/main/cpp/templates/templates.json b/wpilibcExamples/src/main/cpp/templates/templates.json index 1f92b2df14..59d40842c4 100644 --- a/wpilibcExamples/src/main/cpp/templates/templates.json +++ b/wpilibcExamples/src/main/cpp/templates/templates.json @@ -7,7 +7,7 @@ ], "foldername": "timed", "gradlebase": "cpp", - "commandversion": 1 + "commandversion": 2 }, { "name": "Timed Skeleton (Advanced)", @@ -17,7 +17,7 @@ ], "foldername": "timedskeleton", "gradlebase": "cpp", - "commandversion": 1 + "commandversion": 2 }, { "name": "RobotBase Skeleton (Advanced)", @@ -27,7 +27,7 @@ ], "foldername": "robotbaseskeleton", "gradlebase": "cpp", - "commandversion": 1 + "commandversion": 2 }, { "name": "Command Robot", @@ -39,16 +39,6 @@ "gradlebase": "cpp", "commandversion": 2 }, - { - "name": "Old Command Robot", - "description": "Old-Command style (deprecated)", - "tags": [ - "Command" - ], - "foldername": "oldcommandbased", - "gradlebase": "cpp", - "commandversion": 1 - }, { "name": "Romi - Timed Robot", "description": "Romi - Timed style", diff --git a/wpilibjExamples/build.gradle b/wpilibjExamples/build.gradle index 14148eb500..518b1e86e9 100644 --- a/wpilibjExamples/build.gradle +++ b/wpilibjExamples/build.gradle @@ -107,7 +107,6 @@ model { } } binaries.all { binary -> - lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'shared' lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared' lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' lib project: ':wpimath', library: 'wpimath', linkage: 'shared' diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/examples.json b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/examples.json index 57957cb453..c270fc4329 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/examples.json +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/examples.json @@ -257,17 +257,6 @@ "mainclass": "Main", "commandversion": 2 }, - { - "name": "PacGoat", - "description": "A fully functional example CommandBased program for FRC Team 190's 2014 robot. This code can run on your computer if it supports simulation.", - "tags": [ - "Complete Robot" - ], - "foldername": "pacgoat", - "gradlebase": "java", - "mainclass": "Main", - "commandversion": 1 - }, { "name": "Simple Vision", "description": "Demonstrate the use of the CameraServer class to stream from a USB Webcam without processing the images.", diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/Main.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/Main.java deleted file mode 100644 index 65e9315f2e..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/Main.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat; - -import edu.wpi.first.wpilibj.RobotBase; - -/** - * Do NOT add any static variables to this class, or any initialization at all. Unless you know what - * you are doing, do not modify this file except to change the parameter class to the startRobot - * call. - */ -public final class Main { - private Main() {} - - /** - * Main initialization function. Do not perform any initialization here. - * - *

If you change your main robot class, change the parameter type. - */ - public static void main(String... args) { - RobotBase.startRobot(Robot::new); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/OI.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/OI.java deleted file mode 100644 index b877bcb00a..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/OI.java +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat; - -import edu.wpi.first.wpilibj.Joystick; -import edu.wpi.first.wpilibj.buttons.JoystickButton; -import edu.wpi.first.wpilibj.examples.pacgoat.commands.Collect; -import edu.wpi.first.wpilibj.examples.pacgoat.commands.DriveForward; -import edu.wpi.first.wpilibj.examples.pacgoat.commands.LowGoal; -import edu.wpi.first.wpilibj.examples.pacgoat.commands.SetCollectionSpeed; -import edu.wpi.first.wpilibj.examples.pacgoat.commands.SetPivotSetpoint; -import edu.wpi.first.wpilibj.examples.pacgoat.commands.Shoot; -import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Collector; -import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Pivot; -import edu.wpi.first.wpilibj.examples.pacgoat.triggers.DoubleButton; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; - -/** - * The operator interface of the robot, it has been simplified from the real robot to allow control - * with a single PS3 joystick. As a result, not all functionality from the real robot is available. - */ -public class OI { - public Joystick m_joystick = new Joystick(0); - - /** Create a new OI and all of the buttons on it. */ - public OI() { - new JoystickButton(m_joystick, 12).whenPressed(new LowGoal()); - new JoystickButton(m_joystick, 10).whenPressed(new Collect()); - - new JoystickButton(m_joystick, 11).whenPressed(new SetPivotSetpoint(Pivot.kShoot)); - new JoystickButton(m_joystick, 9).whenPressed(new SetPivotSetpoint(Pivot.kShootNear)); - - new DoubleButton(m_joystick, 2, 3).whenActive(new Shoot()); - - // SmartDashboard Buttons - SmartDashboard.putData("Drive Forward", new DriveForward(2.25)); - SmartDashboard.putData("Drive Backward", new DriveForward(-2.25)); - SmartDashboard.putData("Start Rollers", new SetCollectionSpeed(Collector.kForward)); - SmartDashboard.putData("Stop Rollers", new SetCollectionSpeed(Collector.kStop)); - SmartDashboard.putData("Reverse Rollers", new SetCollectionSpeed(Collector.kReverse)); - } - - public Joystick getJoystick() { - return m_joystick; - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/Robot.java deleted file mode 100644 index b8faf6726b..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/Robot.java +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat; - -import edu.wpi.first.wpilibj.TimedRobot; -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.command.Scheduler; -import edu.wpi.first.wpilibj.examples.pacgoat.commands.DriveAndShootAutonomous; -import edu.wpi.first.wpilibj.examples.pacgoat.commands.DriveForward; -import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Collector; -import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Drivetrain; -import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Pivot; -import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Pneumatics; -import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Shooter; -import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; - -/** - * This is the main class for running the PacGoat code. - * - *

The VM is configured to automatically run this class, and to call the functions corresponding - * to each mode, as described in the TimedRobot documentation. If you change the name of this class - * or the package after creating this project, you must also update the manifest file in the - * resource directory. - */ -public class Robot extends TimedRobot { - Command m_autonomousCommand; - public static OI oi; - - // Initialize the subsystems - public static final Drivetrain drivetrain = new Drivetrain(); - public static final Collector collector = new Collector(); - public static final Shooter shooter = new Shooter(); - public static final Pneumatics pneumatics = new Pneumatics(); - public static final Pivot pivot = new Pivot(); - - public SendableChooser m_autoChooser; - - // This function is run when the robot is first started up and should be - // used for any initialization code. - @Override - public void robotInit() { - SmartDashboard.putData(drivetrain); - SmartDashboard.putData(collector); - SmartDashboard.putData(shooter); - SmartDashboard.putData(pneumatics); - SmartDashboard.putData(pivot); - - // This MUST be here. If the OI creates Commands (which it very likely - // will), constructing it during the construction of CommandBase (from - // which commands extend), subsystems are not guaranteed to be - // yet. Thus, their requires() statements may grab null pointers. Bad - // news. Don't move it. - oi = new OI(); - - // instantiate the command used for the autonomous period - m_autoChooser = new SendableChooser<>(); - m_autoChooser.setDefaultOption("Drive and Shoot", new DriveAndShootAutonomous()); - m_autoChooser.addOption("Drive Forward", new DriveForward()); - SmartDashboard.putData("Auto Mode", m_autoChooser); - } - - @Override - public void autonomousInit() { - m_autonomousCommand = m_autoChooser.getSelected(); - m_autonomousCommand.start(); - } - - // This function is called periodically during autonomous - @Override - public void autonomousPeriodic() { - Scheduler.getInstance().run(); - log(); - } - - @Override - public void teleopInit() { - // This makes sure that the autonomous stops running when - // teleop starts running. If you want the autonomous to - // continue until interrupted by another command, remove - // this line or comment it out. - if (m_autonomousCommand != null) { - m_autonomousCommand.cancel(); - } - } - - // This function is called periodically during operator control - @Override - public void teleopPeriodic() { - Scheduler.getInstance().run(); - log(); - } - - // This function called periodically during test mode - @Override - public void testPeriodic() {} - - @Override - public void disabledInit() { - Robot.shooter.unlatch(); - } - - // This function is called periodically while disabled - @Override - public void disabledPeriodic() { - log(); - } - - /** Log interesting values to the SmartDashboard. */ - private void log() { - Robot.pneumatics.writePressure(); - SmartDashboard.putNumber("Pivot Pot Value", Robot.pivot.getAngle()); - SmartDashboard.putNumber("Left Distance", drivetrain.getLeftEncoder().getDistance()); - SmartDashboard.putNumber("Right Distance", drivetrain.getRightEncoder().getDistance()); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/CheckForHotGoal.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/CheckForHotGoal.java deleted file mode 100644 index a02b780a63..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/CheckForHotGoal.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; - -/** - * This command looks for the hot goal and waits until it's detected or timed out. The timeout is - * because it's better to shoot and get some autonomous points than get none. When called - * sequentially, this command will block until the hot goal is detected or until it is timed out. - */ -public class CheckForHotGoal extends Command { - public CheckForHotGoal(double time) { - setTimeout(time); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return isTimedOut() || Robot.shooter.goalIsHot(); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/CloseClaw.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/CloseClaw.java deleted file mode 100644 index cacffdb17c..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/CloseClaw.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.InstantCommand; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; - -/** - * Close the claw. - * - *

NOTE: It doesn't wait for the claw to close since there is no sensor to detect that. - */ -public class CloseClaw extends InstantCommand { - public CloseClaw() { - requires(Robot.collector); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - Robot.collector.close(); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Collect.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Collect.java deleted file mode 100644 index 33f02437d3..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Collect.java +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Collector; -import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Pivot; - -/** Get the robot set to collect balls. */ -public class Collect extends CommandGroup { - /** Create a new collect command. */ - public Collect() { - addSequential(new SetCollectionSpeed(Collector.kForward)); - addParallel(new CloseClaw()); - addSequential(new SetPivotSetpoint(Pivot.kCollect)); - addSequential(new WaitForBall()); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveAndShootAutonomous.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveAndShootAutonomous.java deleted file mode 100644 index 071d439820..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveAndShootAutonomous.java +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; - -/** - * Drive over the line and then shoot the ball. If the hot goal is not detected, it will wait - * briefly. - */ -public class DriveAndShootAutonomous extends CommandGroup { - /** Create a new drive and shoot autonomous. */ - public DriveAndShootAutonomous() { - addSequential(new CloseClaw()); - addSequential(new WaitForPressure(), 2); - if (Robot.isReal()) { - // NOTE: Simulation doesn't currently have the concept of hot. - addSequential(new CheckForHotGoal(2)); - } - addSequential(new SetPivotSetpoint(45)); - addSequential(new DriveForward(8, 0.3)); - addSequential(new Shoot()); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveForward.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveForward.java deleted file mode 100644 index 78542dcf3d..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveForward.java +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; - -/** - * This command drives the robot over a given distance with simple proportional control This command - * will drive a given distance limiting to a maximum speed. - */ -public class DriveForward extends Command { - private final double m_driveForwardSpeed; - private final double m_distance; - private double m_error; - private static final double kTolerance = 0.1; - private static final double kP = -1.0 / 5.0; - - public DriveForward() { - this(10, 0.5); - } - - public DriveForward(double dist) { - this(dist, 0.5); - } - - /** - * Create a new drive forward command. - * - * @param dist The distance to drive - * @param maxSpeed The maximum speed to drive at - */ - public DriveForward(double dist, double maxSpeed) { - requires(Robot.drivetrain); - m_distance = dist; - m_driveForwardSpeed = maxSpeed; - } - - @Override - protected void initialize() { - Robot.drivetrain.getRightEncoder().reset(); - setTimeout(2); - } - - @Override - protected void execute() { - m_error = m_distance - Robot.drivetrain.getRightEncoder().getDistance(); - if (m_driveForwardSpeed * kP * m_error >= m_driveForwardSpeed) { - Robot.drivetrain.tankDrive(m_driveForwardSpeed, m_driveForwardSpeed); - } else { - Robot.drivetrain.tankDrive( - m_driveForwardSpeed * kP * m_error, m_driveForwardSpeed * kP * m_error); - } - } - - @Override - protected boolean isFinished() { - return Math.abs(m_error) <= kTolerance || isTimedOut(); - } - - @Override - protected void end() { - Robot.drivetrain.stop(); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveWithJoystick.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveWithJoystick.java deleted file mode 100644 index ac73701db1..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveWithJoystick.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; - -/** - * This command allows PS3 joystick to drive the robot. It is always running except when interrupted - * by another command. - */ -public class DriveWithJoystick extends Command { - public DriveWithJoystick() { - requires(Robot.drivetrain); - } - - @Override - protected void execute() { - Robot.drivetrain.tankDrive(Robot.oi.getJoystick()); - } - - @Override - protected boolean isFinished() { - return false; - } - - @Override - protected void end() { - Robot.drivetrain.stop(); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/ExtendShooter.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/ExtendShooter.java deleted file mode 100644 index 166d78c11b..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/ExtendShooter.java +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.TimedCommand; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; - -/** Extend the shooter and then retract it after a second. */ -public class ExtendShooter extends TimedCommand { - public ExtendShooter() { - super(1); - requires(Robot.shooter); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - Robot.shooter.extendBoth(); - } - - // Called once after isFinished returns true - @Override - protected void end() { - Robot.shooter.retractBoth(); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/LowGoal.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/LowGoal.java deleted file mode 100644 index 3f9d0bdce3..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/LowGoal.java +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Collector; -import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Pivot; - -/** Spit the ball out into the low goal assuming that the robot is in front of it. */ -public class LowGoal extends CommandGroup { - /** Create a new low goal command. */ - public LowGoal() { - addSequential(new SetPivotSetpoint(Pivot.kLowGoal)); - addSequential(new SetCollectionSpeed(Collector.kReverse)); - addSequential(new ExtendShooter()); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/OpenClaw.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/OpenClaw.java deleted file mode 100644 index f36ced58bf..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/OpenClaw.java +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; - -/** Opens the claw. */ -public class OpenClaw extends Command { - public OpenClaw() { - requires(Robot.collector); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - Robot.collector.open(); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return Robot.collector.isOpen(); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/SetCollectionSpeed.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/SetCollectionSpeed.java deleted file mode 100644 index 33859d9fa0..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/SetCollectionSpeed.java +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.InstantCommand; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; - -/** - * This command sets the collector rollers spinning at the given speed. Since there is no sensor for - * detecting speed, it finishes immediately. As a result, the spinners may still be adjusting their - * speed. - */ -public class SetCollectionSpeed extends InstantCommand { - private final double m_speed; - - public SetCollectionSpeed(double speed) { - requires(Robot.collector); - this.m_speed = speed; - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - Robot.collector.setSpeed(m_speed); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/SetPivotSetpoint.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/SetPivotSetpoint.java deleted file mode 100644 index 6d839fb972..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/SetPivotSetpoint.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; - -/** - * Moves the pivot to a given angle. This command finishes when it is within the tolerance, but - * leaves the PID loop running to maintain the position. Other commands using the pivot should make - * sure they disable PID! - */ -public class SetPivotSetpoint extends Command { - private final double m_setpoint; - - public SetPivotSetpoint(double setpoint) { - this.m_setpoint = setpoint; - requires(Robot.pivot); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - Robot.pivot.enable(); - Robot.pivot.setSetpoint(m_setpoint); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return Robot.pivot.onTarget(); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Shoot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Shoot.java deleted file mode 100644 index c1594df9ce..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Shoot.java +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Collector; - -/** Shoot the ball at the current angle. */ -public class Shoot extends CommandGroup { - /** Create a new shoot command. */ - public Shoot() { - addSequential(new WaitForPressure()); - addSequential(new SetCollectionSpeed(Collector.kStop)); - addSequential(new OpenClaw()); - addSequential(new ExtendShooter()); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/WaitForBall.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/WaitForBall.java deleted file mode 100644 index 1cceaa4de9..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/WaitForBall.java +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; - -/** - * Wait until the collector senses that it has the ball. This command does nothing and is intended - * to be used in command groups to wait for this condition. - */ -public class WaitForBall extends Command { - public WaitForBall() { - requires(Robot.collector); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return Robot.collector.hasBall(); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/WaitForPressure.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/WaitForPressure.java deleted file mode 100644 index ead238e14a..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/WaitForPressure.java +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.commands; - -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; - -/** - * Wait until the pneumatics are fully pressurized. This command does nothing and is intended to be - * used in command groups to wait for this condition. - */ -public class WaitForPressure extends Command { - public WaitForPressure() { - requires(Robot.pneumatics); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return Robot.pneumatics.isPressurized(); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Collector.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Collector.java deleted file mode 100644 index b9c0c585af..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Collector.java +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.subsystems; - -import edu.wpi.first.wpilibj.DigitalInput; -import edu.wpi.first.wpilibj.PneumaticsModuleType; -import edu.wpi.first.wpilibj.Solenoid; -import edu.wpi.first.wpilibj.command.Subsystem; -import edu.wpi.first.wpilibj.motorcontrol.MotorController; -import edu.wpi.first.wpilibj.motorcontrol.Victor; - -/** - * The Collector subsystem has one motor for the rollers, a limit switch for ball detection, a - * piston for opening and closing the claw, and a reed switch to check if the piston is open. - */ -public class Collector extends Subsystem { - // Constants for some useful speeds - public static final double kForward = 1; - public static final double kStop = 0; - public static final double kReverse = -1; - - // Subsystem devices - private final MotorController m_rollerMotor = new Victor(6); - private final DigitalInput m_ballDetector = new DigitalInput(10); - private final DigitalInput m_openDetector = new DigitalInput(6); - private final Solenoid m_piston = new Solenoid(PneumaticsModuleType.CTREPCM, 1); - - /** Create a new collector subsystem. */ - public Collector() { - // Put everything to the LiveWindow for testing. - addChild("Roller Motor", (Victor) m_rollerMotor); - addChild("Ball Detector", m_ballDetector); - addChild("Claw Open Detector", m_openDetector); - addChild("Piston", m_piston); - } - - /** - * Whether or not the robot has the ball. - * - *

NOTE: The current simulation model uses the the lower part of the claw since the limit - * switch wasn't exported. At some point, this will be updated. - * - * @return Whether or not the robot has the ball. - */ - public boolean hasBall() { - return m_ballDetector.get(); // TODO: prepend ! to reflect real robot - } - - /** - * Set the speed to spin the collector rollers. - * - * @param speed The speed to spin the rollers. - */ - public void setSpeed(double speed) { - m_rollerMotor.set(-speed); - } - - /** Stop the rollers from spinning. */ - public void stop() { - m_rollerMotor.set(0); - } - - /** - * Wether or not the claw is open. - * - * @return Whether or not the claw is open. - */ - public boolean isOpen() { - return m_openDetector.get(); // TODO: prepend ! to reflect real robot - } - - /** Open the claw up (For shooting). */ - public void open() { - m_piston.set(true); - } - - /** Close the claw (For collecting and driving). */ - @Override - public void close() { - m_piston.set(false); - } - - /** No default command. */ - @Override - protected void initDefaultCommand() {} -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Drivetrain.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Drivetrain.java deleted file mode 100644 index 144e93f902..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Drivetrain.java +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.subsystems; - -import edu.wpi.first.wpilibj.AnalogGyro; -import edu.wpi.first.wpilibj.CounterBase.EncodingType; -import edu.wpi.first.wpilibj.Encoder; -import edu.wpi.first.wpilibj.Joystick; -import edu.wpi.first.wpilibj.command.Subsystem; -import edu.wpi.first.wpilibj.drive.DifferentialDrive; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; -import edu.wpi.first.wpilibj.examples.pacgoat.commands.DriveWithJoystick; -import edu.wpi.first.wpilibj.motorcontrol.MotorController; -import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup; -import edu.wpi.first.wpilibj.motorcontrol.Victor; - -/** - * The Drivetrain subsystem controls the robot's chassis and reads in information about it's speed - * and position. - */ -public class Drivetrain extends Subsystem { - // Subsystem devices - private final MotorController m_frontLeftCIM = new Victor(1); - private final MotorController m_frontRightCIM = new Victor(2); - private final MotorController m_rearLeftCIM = new Victor(3); - private final MotorController m_rearRightCIM = new Victor(4); - private final MotorControllerGroup m_leftCIMs = - new MotorControllerGroup(m_frontLeftCIM, m_rearLeftCIM); - private final MotorControllerGroup m_rightCIMs = - new MotorControllerGroup(m_frontRightCIM, m_rearRightCIM); - private final DifferentialDrive m_drive; - private final Encoder m_rightEncoder = new Encoder(1, 2, true, EncodingType.k4X); - private final Encoder m_leftEncoder = new Encoder(3, 4, false, EncodingType.k4X); - private final AnalogGyro m_gyro = new AnalogGyro(0); - - /** Create a new drivetrain subsystem. */ - public Drivetrain() { - // Configure drive motors - addChild("Front Left CIM", (Victor) m_frontLeftCIM); - addChild("Front Right CIM", (Victor) m_frontRightCIM); - addChild("Back Left CIM", (Victor) m_rearLeftCIM); - addChild("Back Right CIM", (Victor) m_rearRightCIM); - - // Configure the DifferentialDrive to reflect the fact that all motors - // are wired backwards (right is inverted in DifferentialDrive). - m_leftCIMs.setInverted(true); - m_rightCIMs.setInverted(true); - m_drive = new DifferentialDrive(m_leftCIMs, m_rightCIMs); - m_drive.setSafetyEnabled(true); - m_drive.setExpiration(0.1); - m_drive.setMaxOutput(1.0); - - if (Robot.isReal()) { // Converts to feet - m_rightEncoder.setDistancePerPulse(0.0785398); - m_leftEncoder.setDistancePerPulse(0.0785398); - } else { - // Circumference = diameter in feet * pi. 360 tick simulated encoders. - m_rightEncoder.setDistancePerPulse((4.0 /* in */ * Math.PI) / (360.0 * 12.0 /* in/ft */)); - m_leftEncoder.setDistancePerPulse((4.0 /* in */ * Math.PI) / (360.0 * 12.0 /* in/ft */)); - } - - addChild("Right Encoder", m_rightEncoder); - addChild("Left Encoder", m_leftEncoder); - - // Configure gyro - if (Robot.isReal()) { - m_gyro.setSensitivity(0.007); // TODO: Handle more gracefully? - } - addChild("Gyro", m_gyro); - } - - /** When other commands aren't using the drivetrain, allow tank drive with the joystick. */ - @Override - public void initDefaultCommand() { - setDefaultCommand(new DriveWithJoystick()); - } - - /** - * Tank drive using a PS3 joystick. - * - * @param joy PS3 style joystick to use as the input for tank drive. - */ - public void tankDrive(Joystick joy) { - m_drive.tankDrive(joy.getY(), joy.getRawAxis(4)); - } - - /** - * Tank drive using individual joystick axes. - * - * @param leftAxis Left sides value - * @param rightAxis Right sides value - */ - public void tankDrive(double leftAxis, double rightAxis) { - m_drive.tankDrive(leftAxis, rightAxis); - } - - /** Stop the drivetrain from moving. */ - public void stop() { - m_drive.tankDrive(0, 0); - } - - /** The encoder getting the distance and speed of left side of the drivetrain. */ - public Encoder getLeftEncoder() { - return m_leftEncoder; - } - - /** The encoder getting the distance and speed of right side of the drivetrain. */ - public Encoder getRightEncoder() { - return m_rightEncoder; - } - - /** The current angle of the drivetrain as measured by the Gyro. */ - public double getAngle() { - return m_gyro.getAngle(); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Pivot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Pivot.java deleted file mode 100644 index 1e65c64068..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Pivot.java +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.subsystems; - -import edu.wpi.first.wpilibj.AnalogPotentiometer; -import edu.wpi.first.wpilibj.DigitalInput; -import edu.wpi.first.wpilibj.command.PIDSubsystem; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; -import edu.wpi.first.wpilibj.motorcontrol.MotorController; -import edu.wpi.first.wpilibj.motorcontrol.Victor; - -/** - * The Pivot subsystem contains the Van-door motor and the pot for PID control of angle of the pivot - * and claw. - */ -public class Pivot extends PIDSubsystem { - // Constants for some useful angles - public static final double kCollect = 105; - public static final double kLowGoal = 90; - public static final double kShoot = 45; - public static final double kShootNear = 30; - - // Sensors for measuring the position of the pivot. - private final DigitalInput m_upperLimitSwitch = new DigitalInput(13); - private final DigitalInput m_lowerLimitSwitch = new DigitalInput(12); - - // 0 degrees is vertical facing up. - // Angle increases the more forward the pivot goes. - private final AnalogPotentiometer m_pot = new AnalogPotentiometer(1); - - // Motor to move the pivot. - private final MotorController m_motor = new Victor(5); - - /** Create a new pivot subsystem. */ - public Pivot() { - super("Pivot", 7.0, 0.0, 8.0); - setAbsoluteTolerance(0.005); - getPIDController().setContinuous(false); - if (Robot.isSimulation()) { // PID is different in simulation. - getPIDController().setPID(0.5, 0.001, 2); - setAbsoluteTolerance(5); - } - - // Put everything to the LiveWindow for testing. - addChild("Upper Limit Switch", m_upperLimitSwitch); - addChild("Lower Limit Switch", m_lowerLimitSwitch); - addChild("Pot", (AnalogPotentiometer) m_pot); - addChild("Motor", (Victor) m_motor); - addChild("PIDSubsystem Controller", getPIDController()); - } - - /** No default command, if PID is enabled, the current setpoint will be maintained. */ - @Override - public void initDefaultCommand() {} - - /** The angle read in by the potentiometer. */ - @Override - protected double returnPIDInput() { - return m_pot.get(); - } - - /** Set the motor speed based off of the PID output. */ - @Override - protected void usePIDOutput(double output) { - m_motor.set(output); - } - - /** If the pivot is at its upper limit. */ - public boolean isAtUpperLimit() { - // TODO: inverted from real robot (prefix with !) - return m_upperLimitSwitch.get(); - } - - /** If the pivot is at its lower limit. */ - public boolean isAtLowerLimit() { - // TODO: inverted from real robot (prefix with !) - return m_lowerLimitSwitch.get(); - } - - /** The current angle of the pivot. */ - public double getAngle() { - return m_pot.get(); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Pneumatics.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Pneumatics.java deleted file mode 100644 index a7a29cda9e..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Pneumatics.java +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.subsystems; - -import edu.wpi.first.wpilibj.AnalogInput; -import edu.wpi.first.wpilibj.command.Subsystem; -import edu.wpi.first.wpilibj.examples.pacgoat.Robot; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; - -/** - * The Pneumatics subsystem contains a pressure sensor. - * - *

NOTE: The simulator currently doesn't support the compressor or pressure sensors. - */ -public class Pneumatics extends Subsystem { - AnalogInput m_pressureSensor = new AnalogInput(3); - - private static final double kMaxPressure = 2.55; - - public Pneumatics() { - addChild("Pressure Sensor", m_pressureSensor); - } - - /** No default command. */ - @Override - public void initDefaultCommand() {} - - /** Whether or not the system is fully pressurized. */ - public boolean isPressurized() { - if (Robot.isReal()) { - return kMaxPressure <= m_pressureSensor.getVoltage(); - } else { - return true; // NOTE: Simulation always has full pressure - } - } - - /** Puts the pressure on the SmartDashboard. */ - public void writePressure() { - SmartDashboard.putNumber("Pressure", m_pressureSensor.getVoltage()); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Shooter.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Shooter.java deleted file mode 100644 index 5e7b28d893..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Shooter.java +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.subsystems; - -import edu.wpi.first.wpilibj.DigitalInput; -import edu.wpi.first.wpilibj.DoubleSolenoid; -import edu.wpi.first.wpilibj.PneumaticsModuleType; -import edu.wpi.first.wpilibj.Solenoid; -import edu.wpi.first.wpilibj.command.Subsystem; - -/** - * The Shooter subsystem handles shooting. The mechanism for shooting is slightly complicated - * because it has to pneumatic cylinders for shooting, and a third latch to allow the pressure to - * partially build up and reduce the effect of the airflow. For shorter shots, when full power isn't - * needed, only one cylinder fires. - * - *

NOTE: Simulation currently approximates this as as single pneumatic cylinder and ignores the - * latch. - */ -public class Shooter extends Subsystem { - // Devices - DoubleSolenoid m_piston1 = new DoubleSolenoid(PneumaticsModuleType.CTREPCM, 3, 4); - DoubleSolenoid m_piston2 = new DoubleSolenoid(PneumaticsModuleType.CTREPCM, 5, 6); - Solenoid m_latchPiston = new Solenoid(PneumaticsModuleType.CTREPCM, 2); - DigitalInput m_piston1ReedSwitchFront = new DigitalInput(9); - DigitalInput m_piston1ReedSwitchBack = new DigitalInput(11); - // NOTE: currently ignored in simulation - DigitalInput m_hotGoalSensor = new DigitalInput(7); - - /** Create a new shooter subsystem. */ - public Shooter() { - // Put everything to the LiveWindow for testing. - addChild("Hot Goal Sensor", m_hotGoalSensor); - addChild("Piston1 Reed Switch Front ", m_piston1ReedSwitchFront); - addChild("Piston1 Reed Switch Back ", m_piston1ReedSwitchBack); - addChild("Latch Piston", m_latchPiston); - } - - /** No default command. */ - @Override - public void initDefaultCommand() {} - - /** Extend both solenoids to shoot. */ - public void extendBoth() { - m_piston1.set(DoubleSolenoid.Value.kForward); - m_piston2.set(DoubleSolenoid.Value.kForward); - } - - /** Retract both solenoids to prepare to shoot. */ - public void retractBoth() { - m_piston1.set(DoubleSolenoid.Value.kReverse); - m_piston2.set(DoubleSolenoid.Value.kReverse); - } - - /** Extend solenoid 1 to shoot. */ - public void extend1() { - m_piston1.set(DoubleSolenoid.Value.kForward); - } - - /** Retract solenoid 1 to prepare to shoot. */ - public void retract1() { - m_piston1.set(DoubleSolenoid.Value.kReverse); - } - - /** Extend solenoid 2 to shoot. */ - public void extend2() { - m_piston2.set(DoubleSolenoid.Value.kReverse); - } - - /** Retract solenoid 2 to prepare to shoot. */ - public void retract2() { - m_piston2.set(DoubleSolenoid.Value.kForward); - } - - /** - * Turns off the piston1 double solenoid. This won't actuate anything because double solenoids - * preserve their state when turned off. This should be called in order to reduce the amount of - * time that the coils are powered. - */ - public void off1() { - m_piston1.set(DoubleSolenoid.Value.kOff); - } - - /** - * Turns off the piston2 double solenoid. This won't actuate anything because double solenoids - * preserve their state when turned off. This should be called in order to reduce the amount of - * time that the coils are powered. - */ - public void off2() { - m_piston2.set(DoubleSolenoid.Value.kOff); - } - - /** Release the latch so that we can shoot. */ - public void unlatch() { - m_latchPiston.set(true); - } - - /** Latch so that pressure can build up and we aren't limited by air flow. */ - public void latch() { - m_latchPiston.set(false); - } - - /** Toggles the latch postions. */ - public void toggleLatchPosition() { - m_latchPiston.set(!m_latchPiston.get()); - } - - /** - * Is Piston 1 extended (after shooting). - * - * @return Whether or not piston 1 is fully extended. - */ - public boolean piston1IsExtended() { - return !m_piston1ReedSwitchFront.get(); - } - - /** - * Is Piston 1 retracted (before shooting). - * - * @return Whether or not piston 1 is fully retracted. - */ - public boolean piston1IsRetracted() { - return !m_piston1ReedSwitchBack.get(); - } - - /** - * Turns off all double solenoids. Double solenoids hold their position when they are turned off. - * We should turn them off whenever possible to extend the life of the coils. - */ - public void offBoth() { - m_piston1.set(DoubleSolenoid.Value.kOff); - m_piston2.set(DoubleSolenoid.Value.kOff); - } - - /** - * Return whether the goal is hot as read by the banner sensor. - * - *

NOTE: doesn't work in simulation. - * - * @return Whether or not the goal is hot - */ - public boolean goalIsHot() { - return m_hotGoalSensor.get(); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/triggers/DoubleButton.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/triggers/DoubleButton.java deleted file mode 100644 index 3d0dc7e01d..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/triggers/DoubleButton.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.examples.pacgoat.triggers; - -import edu.wpi.first.wpilibj.GenericHID; -import edu.wpi.first.wpilibj.buttons.Trigger; - -/** A custom button that is triggered when TWO buttons on a Joystick are simultaneously pressed. */ -public class DoubleButton extends Trigger { - private final GenericHID m_joy; - private final int m_button1; - private final int m_button2; - - /** - * Create a new double button trigger. - * - * @param joy The joystick - * @param button1 The first button - * @param button2 The second button - */ - public DoubleButton(GenericHID joy, int button1, int button2) { - this.m_joy = joy; - this.m_button1 = button1; - this.m_button2 = button2; - } - - @Override - public boolean get() { - return m_joy.getRawButton(m_button1) && m_joy.getRawButton(m_button2); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/Main.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/Main.java deleted file mode 100644 index 69a0078c3b..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/Main.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.templates.oldcommandbased; - -import edu.wpi.first.wpilibj.RobotBase; - -/** - * Do NOT add any static variables to this class, or any initialization at all. Unless you know what - * you are doing, do not modify this file except to change the parameter class to the startRobot - * call. - */ -public final class Main { - private Main() {} - - /** - * Main initialization function. Do not perform any initialization here. - * - *

If you change your main robot class, change the parameter type. - */ - public static void main(String... args) { - RobotBase.startRobot(Robot::new); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/OI.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/OI.java deleted file mode 100644 index 95724cd5d7..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/OI.java +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.templates.oldcommandbased; - -/** - * This class is the glue that binds the controls on the physical operator interface to the commands - * and command groups that allow control of the robot. - */ -public class OI { - //// CREATING BUTTONS - // One type of button is a joystick button which is any button on a - //// joystick. - // You create one by telling it which joystick it's on and which button - // number it is. - // Joystick stick = new Joystick(port); - // Button button = new JoystickButton(stick, buttonNumber); - - // There are a few additional built in buttons you can use. Additionally, - // by subclassing Button you can create custom triggers and bind those to - // commands the same as any other Button. - - //// TRIGGERING COMMANDS WITH BUTTONS - // Once you have a button, it's trivial to bind it to a button in one of - // three ways: - - // Start the command when the button is pressed and let it run the command - // until it is finished as determined by it's isFinished method. - // button.whenPressed(new ExampleCommand()); - - // Run the command while the button is being held down and interrupt it once - // the button is released. - // button.whileHeld(new ExampleCommand()); - - // Start the command when the button is released and let it run the command - // until it is finished as determined by it's isFinished method. - // button.whenReleased(new ExampleCommand()); -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/Robot.java deleted file mode 100644 index 02b46c53fe..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/Robot.java +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.templates.oldcommandbased; - -import edu.wpi.first.wpilibj.TimedRobot; -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.command.Scheduler; -import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import edu.wpi.first.wpilibj.templates.oldcommandbased.commands.ExampleCommand; -import edu.wpi.first.wpilibj.templates.oldcommandbased.subsystems.ExampleSubsystem; - -/** - * The VM is configured to automatically run this class, and to call the functions corresponding to - * each mode, as described in the TimedRobot documentation. If you change the name of this class or - * the package after creating this project, you must also update the build.gradle file in the - * project. - */ -public class Robot extends TimedRobot { - public static final ExampleSubsystem m_subsystem = new ExampleSubsystem(); - public static OI m_oi; - - Command m_autonomousCommand; - SendableChooser m_chooser = new SendableChooser<>(); - - /** - * This function is run when the robot is first started up and should be used for any - * initialization code. - */ - @Override - public void robotInit() { - m_oi = new OI(); - m_chooser.setDefaultOption("Default Auto", new ExampleCommand()); - // chooser.addOption("My Auto", new MyAutoCommand()); - SmartDashboard.putData("Auto mode", m_chooser); - } - - /** - * This function is called every robot packet, no matter the mode. Use this for items like - * diagnostics that you want ran during disabled, autonomous, teleoperated and test. - * - *

This runs after the mode specific periodic functions, but before LiveWindow and - * SmartDashboard integrated updating. - */ - @Override - public void robotPeriodic() {} - - /** - * This function is called once each time the robot enters Disabled mode. You can use it to reset - * any subsystem information you want to clear when the robot is disabled. - */ - @Override - public void disabledInit() {} - - @Override - public void disabledPeriodic() { - Scheduler.getInstance().run(); - } - - /** - * This autonomous (along with the chooser code above) shows how to select between different - * autonomous modes using the dashboard. The sendable chooser code works with the Java - * SmartDashboard. If you prefer the LabVIEW Dashboard, remove all of the chooser code and - * uncomment the getString code to get the auto name from the text box below the Gyro - * - *

You can add additional auto modes by adding additional commands to the chooser code above - * (like the commented example) or additional comparisons to the switch structure below with - * additional strings & commands. - */ - @Override - public void autonomousInit() { - m_autonomousCommand = m_chooser.getSelected(); - - /* - * String autoSelected = SmartDashboard.getString("Auto Selector", - * "Default"); switch(autoSelected) { case "My Auto": autonomousCommand - * = new MyAutoCommand(); break; case "Default Auto": default: - * autonomousCommand = new ExampleCommand(); break; } - */ - - // schedule the autonomous command (example) - if (m_autonomousCommand != null) { - m_autonomousCommand.start(); - } - } - - /** This function is called periodically during autonomous. */ - @Override - public void autonomousPeriodic() { - Scheduler.getInstance().run(); - } - - @Override - public void teleopInit() { - // This makes sure that the autonomous stops running when - // teleop starts running. If you want the autonomous to - // continue until interrupted by another command, remove - // this line or comment it out. - if (m_autonomousCommand != null) { - m_autonomousCommand.cancel(); - } - } - - /** This function is called periodically during operator control. */ - @Override - public void teleopPeriodic() { - Scheduler.getInstance().run(); - } - - /** This function is called periodically during test mode. */ - @Override - public void testPeriodic() {} -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/RobotMap.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/RobotMap.java deleted file mode 100644 index 53d2e95d26..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/RobotMap.java +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.templates.oldcommandbased; - -/** - * The RobotMap is a mapping from the ports sensors and actuators are wired into to a variable name. - * This provides flexibility changing wiring, makes checking the wiring easier and significantly - * reduces the number of magic numbers floating around. - */ -public class RobotMap { - // For example to map the left and right motors, you could define the - // following variables to use with your drivetrain subsystem. - // public static int leftMotor = 1; - // public static int rightMotor = 2; - - // If you are using multiple modules, make sure to define both the port - // number and the module. For example you with a rangefinder: - // public static int rangefinderPort = 1; - // public static int rangefinderModule = 1; -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/commands/ExampleCommand.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/commands/ExampleCommand.java deleted file mode 100644 index 7e4379a6fd..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/commands/ExampleCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.templates.oldcommandbased.commands; - -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.templates.oldcommandbased.Robot; - -/** An example command. You can replace me with your own command. */ -public class ExampleCommand extends Command { - public ExampleCommand() { - // Use requires() here to declare subsystem dependencies - requires(Robot.m_subsystem); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() {} - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() {} - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() {} - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() {} -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/subsystems/ExampleSubsystem.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/subsystems/ExampleSubsystem.java deleted file mode 100644 index 124e4ce87a..0000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/oldcommandbased/subsystems/ExampleSubsystem.java +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.templates.oldcommandbased.subsystems; - -import edu.wpi.first.wpilibj.command.Subsystem; - -/** An example subsystem. You can replace with me with your own subsystem. */ -public class ExampleSubsystem extends Subsystem { - // Put methods for controlling this subsystem - // here. Call these from Commands. - - @Override - protected void initDefaultCommand() { - // Set the default command for a subsystem here. - // setDefaultCommand(new MySpecialCommand()); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/templates.json b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/templates.json index a1a555106c..9dd408f411 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/templates.json +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/templates.json @@ -8,7 +8,7 @@ "foldername": "timed", "gradlebase": "java", "mainclass": "Main", - "commandversion": 1 + "commandversion": 2 }, { "name": "Timed Skeleton (Advanced)", @@ -19,7 +19,7 @@ "foldername": "timedskeleton", "gradlebase": "java", "mainclass": "Main", - "commandversion": 1 + "commandversion": 2 }, { "name": "RobotBase Skeleton (Advanced)", @@ -30,7 +30,7 @@ "foldername": "robotbaseskeleton", "gradlebase": "java", "mainclass": "Main", - "commandversion": 1 + "commandversion": 2 }, { "name": "Command Robot", @@ -43,17 +43,6 @@ "mainclass": "Main", "commandversion": 2 }, - { - "name": "Old Command Robot", - "description": "Old-command style (deprecated)", - "tags": [ - "Command" - ], - "foldername": "oldcommandbased", - "gradlebase": "java", - "mainclass": "Main", - "commandversion": 1 - }, { "name": "Romi - Timed Robot", "description": "Romi - Timed style",