From 9a87a616557cd85cc020634b231ab8fcb94e7edb Mon Sep 17 00:00:00 2001 From: Computer 3 <6758@devjoe.net> Date: Thu, 27 Feb 2020 18:43:00 -0600 Subject: [PATCH 1/5] rename and works --- src/main/cpp/Auton/{Auton.h => Autown.h} | 6 +++--- src/main/cpp/Robot.cpp | 8 ++++---- src/main/cpp/Variables/Variables.h | 20 ++++++++++---------- src/main/include/Robot.h | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) rename src/main/cpp/Auton/{Auton.h => Autown.h} (97%) diff --git a/src/main/cpp/Auton/Auton.h b/src/main/cpp/Auton/Autown.h similarity index 97% rename from src/main/cpp/Auton/Auton.h rename to src/main/cpp/Auton/Autown.h index c1554af..177bfe5 100644 --- a/src/main/cpp/Auton/Auton.h +++ b/src/main/cpp/Auton/Autown.h @@ -1,8 +1,8 @@ #pragma once #include -#include +#include -void Robot::AutonomousInit2() +void Robot::AutownInit() { m_autoSelected = m_chooser.GetSelected(); // m_autoSelected = SmartDashboard::GetString("Auto Selector", @@ -23,7 +23,7 @@ void Robot::AutonomousInit2() driveboi6.Follow(driveboi3, /*invert*/ false); } -void Robot::AutonomousPeriodic2() +void Robot::AutownPeriodic() { double forwardBackward = spinReader1.GetPosition() - spinReader3.GetPosition(); diff --git a/src/main/cpp/Robot.cpp b/src/main/cpp/Robot.cpp index e7ad5a4..d4f8901 100644 --- a/src/main/cpp/Robot.cpp +++ b/src/main/cpp/Robot.cpp @@ -1,6 +1,6 @@ #include "Robot.h" -#include -#include +#include +#include void Robot::RobotInit() { @@ -53,12 +53,12 @@ void Robot::RobotPeriodic() void Robot::AutonomousInit() { - Robot::AutonomousInit2(); + Robot::AutownInit(); } void Robot::AutonomousPeriodic() { - Robot::AutonomousPeriodic2(); + Robot::AutownPeriodic(); } void Robot::TeleopInit() diff --git a/src/main/cpp/Variables/Variables.h b/src/main/cpp/Variables/Variables.h index 94298e2..e657001 100644 --- a/src/main/cpp/Variables/Variables.h +++ b/src/main/cpp/Variables/Variables.h @@ -64,16 +64,16 @@ double speed; //auton steps variable thing enum Auton { - forward1 = 1, - dump = 2, - back1 = 3, - turn1 = 4, - forward2 = 5, - back2 = 6, - turn2 = 7, - forward3 = 8, - null = 9 - /*forwardfromside = 10 (for the UltraSonic Side Shot) + forward1 = 1, + dump = 2, + back1 = 3, + turn1 = 4, + forward2 = 5, + back2 = 6, + turn2 = 7, + forward3 = 8, + null = 9 + /*forwardfromside = 10 (for the UltraSonic Side Shot) turnsideshot = 11 */ }; diff --git a/src/main/include/Robot.h b/src/main/include/Robot.h index 732f282..37c2eac 100644 --- a/src/main/include/Robot.h +++ b/src/main/include/Robot.h @@ -36,9 +36,9 @@ class Robot : public frc::TimedRobot void RobotInit() override; void RobotPeriodic() override; void AutonomousInit() override; - void AutonomousInit2(); + void AutownInit(); void AutonomousPeriodic() override; - void AutonomousPeriodic2(); + void AutownPeriodic(); void TeleopInit() override; void TeleopPeriodic() override; void TestPeriodic() override; From 4d0573d50ba987dc540d3911b576f9ae08ef419d Mon Sep 17 00:00:00 2001 From: Computer 3 <6758@devjoe.net> Date: Thu, 27 Feb 2020 19:20:28 -0600 Subject: [PATCH 2/5] clean up --- src/main/cpp/Robot.cpp | 37 +++++++----------------------- src/main/cpp/Variables/Variables.h | 1 + 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/src/main/cpp/Robot.cpp b/src/main/cpp/Robot.cpp index d4f8901..1a7c61a 100644 --- a/src/main/cpp/Robot.cpp +++ b/src/main/cpp/Robot.cpp @@ -4,13 +4,11 @@ void Robot::RobotInit() { - //m_chooser.SetDefaultOption(kAutoNameDefault, kAutoNameDefault); - //m_chooser.AddOption(kAutoNameCustom, kAutoNameCustom); - //frc::SmartDashboard::PutData("Auto Modes", &m_chooser); - - //setting up camera + //setting up cameras fbi = frc::CameraServer::GetInstance()->StartAutomaticCapture(0); fbi.SetVideoMode(cs::VideoMode::PixelFormat::kYUYV, 320, 240, 10); + cia = frc::CameraServer::GetInstance()->StartAutomaticCapture(1); + cia.SetVideoMode(cs::VideoMode::PixelFormat::kYUYV, 320, 240, 10); //setting up controller neighborlyInputDevice = new frc::XboxController(1); @@ -28,28 +26,9 @@ void Robot::RobotInit() brit = new frc::DifferentialDrive(speedyboiL, speedyboiR); } -/** - * 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 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 line to get the - * auto name from the text box below the Gyro. - * - * You can add additional auto modes by adding additional comparisons to the - * if-else structure below with additional strings. If using the SendableChooser - * make sure to add them to the chooser code above as well. - */ void Robot::AutonomousInit() { @@ -89,12 +68,13 @@ void Robot::TeleopPeriodic() frc::SmartDashboard::PutNumber("Encoder5 Position", spinReader5.GetPosition()); frc::SmartDashboard::PutNumber("Encoder6 Position", spinReader6.GetPosition()); frc::SmartDashboard::PutNumber("climber position", -gwen.GetPosition()); + //read sensor double distance = batman.GetValue() * 0.393701; //multiplying by 0.393701 converts the sonar value to inches (hopefully) frc::SmartDashboard::PutNumber("Range Sensor 1", distance); // Code for deadzones on joystick - notFarEnough = .05; /*todo: Adjust to driver's needs*/ + notFarEnough = .05; if (-lonelyStick->GetY() < notFarEnough || -lonelyStick->GetY() > -notFarEnough) { lonelyY = lonelyStick->GetY(); @@ -119,8 +99,7 @@ void Robot::TeleopPeriodic() roboMyRio.Set(false); } - //mike - //intake code + //mike whipper and intake code if (neighborlyInputDevice->GetAButtonReleased()) { toggle = -toggle; @@ -130,13 +109,13 @@ void Robot::TeleopPeriodic() { viagra.Set(false); simp.Set(0); - whippedCheese.Set(ControlMode::PercentOutput, 0); //should be 0 just testing + whippedCheese.Set(ControlMode::PercentOutput, 0); } else if (toggle == -1) { viagra.Set(true); simp.Set(.5); - whippedCheese.Set(ControlMode::PercentOutput, .8); //should be .1 just testing + whippedCheese.Set(ControlMode::PercentOutput, .8); } //winch code diff --git a/src/main/cpp/Variables/Variables.h b/src/main/cpp/Variables/Variables.h index e657001..6993d39 100644 --- a/src/main/cpp/Variables/Variables.h +++ b/src/main/cpp/Variables/Variables.h @@ -53,6 +53,7 @@ rev::CANEncoder gwen = spoodermoon.GetEncoder(); //camera creation cs::UsbCamera fbi; +cs::UsbCamera cia; //ultrasonic range sensor creation frc::AnalogInput batman(0); // 230 - 630 is usable range From 5ce186dc8d08e57cd8c94d698122e997197a3aed Mon Sep 17 00:00:00 2001 From: Computer 3 <6758@devjoe.net> Date: Fri, 28 Feb 2020 15:56:35 -0600 Subject: [PATCH 3/5] ? --- src/main/cpp/Auton/Autown.h | 48 +++++++++++++++++++++++++++++- src/main/cpp/Robot.cpp | 2 ++ src/main/cpp/Variables/Variables.h | 1 + 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/main/cpp/Auton/Autown.h b/src/main/cpp/Auton/Autown.h index 177bfe5..dbfb019 100644 --- a/src/main/cpp/Auton/Autown.h +++ b/src/main/cpp/Auton/Autown.h @@ -273,4 +273,50 @@ switch (step) break; } */ -} \ No newline at end of file + + //basic auton to collect 2 balls only + switch (step) + { + case forward1: + { + if (forwardBackward < 198.49) + { + Robot::Forwards(); + } + else + { + ZeroMotors(); + step = backwards1; + } + break; + } + case back1: + if (forwardBackward > 198.49) + { + Robot::Backwards(); + } + else + { + ZeroMotors(); + step = null; + } + break; + } + + //auton using the limit switch to dump + switch (step) + { + case forward2: + { + if (stopIt == false) + { + Robot::Forwards(); + } + else + { + ZeroMotors(); + step = back1; + } + break; + } + } \ No newline at end of file diff --git a/src/main/cpp/Robot.cpp b/src/main/cpp/Robot.cpp index 1a7c61a..37b5b87 100644 --- a/src/main/cpp/Robot.cpp +++ b/src/main/cpp/Robot.cpp @@ -109,12 +109,14 @@ void Robot::TeleopPeriodic() { viagra.Set(false); simp.Set(0); + simp2.Set(0); whippedCheese.Set(ControlMode::PercentOutput, 0); } else if (toggle == -1) { viagra.Set(true); simp.Set(.5); + simp.Set(-0.5); whippedCheese.Set(ControlMode::PercentOutput, .8); } diff --git a/src/main/cpp/Variables/Variables.h b/src/main/cpp/Variables/Variables.h index 6993d39..21950c1 100644 --- a/src/main/cpp/Variables/Variables.h +++ b/src/main/cpp/Variables/Variables.h @@ -38,6 +38,7 @@ ctre::phoenix::motorcontrol::can::VictorSPX whippedCheese = {25}; frc::Solenoid viagra(3); //intake motor creation rev::CANSparkMax simp(1, rev::CANSparkMax::MotorType::kBrushless); +rev::CANSparkMax simp2(3, rev::CANSparkMax::MotorType::kBrushless); //Encoder creation rev::CANEncoder spinReader1 = driveboi1.GetEncoder(); From 36622932f1e9a9458703f0feed32fcb738548393 Mon Sep 17 00:00:00 2001 From: 6758Guy <46696216+6758Guy@users.noreply.github.com> Date: Fri, 28 Feb 2020 18:02:54 -0600 Subject: [PATCH 4/5] idk what is wrong --- src/main/cpp/Auton/Autown.h | 43 +++++++++++++++++++++++++++++++- src/main/cpp/Robot.cpp | 49 +++---------------------------------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/main/cpp/Auton/Autown.h b/src/main/cpp/Auton/Autown.h index dbfb019..e4386d4 100644 --- a/src/main/cpp/Auton/Autown.h +++ b/src/main/cpp/Auton/Autown.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include void Robot::AutownInit() { @@ -319,4 +319,45 @@ switch (step) } break; } + + void Robot::ZeroMotors() + { + driveboi1.Set(0); + driveboi3.Set(0); + spinReader1.SetPosition(0); + spinReader2.SetPosition(0); + spinReader3.SetPosition(0); + spinReader4.SetPosition(0); + spinReader5.SetPosition(0); + spinReader6.SetPosition(0); + } + + void Robot::Forwards() + { + driveboi1.Set(-.5); + driveboi3.Set(.5); + } + void Robot::Backwards() + { + driveboi1.Set(.5); + driveboi3.Set(-.5); + } + void Robot::Clock() + { + driveboi1.Set(.5); + driveboi3.Set(.5); + } + void Robot::CounterClock() + { + driveboi1.Set(-.5); + driveboi3.Set(-.5); + } + void Robot::Wait(double seconds) + { + clock_t endwait; + endwait = clock() + seconds * CLOCKS_PER_SEC; + while (clock() < endwait) + { + } + } } \ No newline at end of file diff --git a/src/main/cpp/Robot.cpp b/src/main/cpp/Robot.cpp index 37b5b87..29dbea4 100644 --- a/src/main/cpp/Robot.cpp +++ b/src/main/cpp/Robot.cpp @@ -1,6 +1,6 @@ #include "Robot.h" -#include -#include +#include +#include void Robot::RobotInit() { @@ -115,8 +115,8 @@ void Robot::TeleopPeriodic() else if (toggle == -1) { viagra.Set(true); - simp.Set(.5); - simp.Set(-0.5); + simp.Set(-.5); + simp.Set(0.5); whippedCheese.Set(ControlMode::PercentOutput, .8); } @@ -174,47 +174,6 @@ void Robot::TeleopPeriodic() void Robot::TestPeriodic() {} -void Robot::ZeroMotors() -{ - driveboi1.Set(0); - driveboi3.Set(0); - spinReader1.SetPosition(0); - spinReader2.SetPosition(0); - spinReader3.SetPosition(0); - spinReader4.SetPosition(0); - spinReader5.SetPosition(0); - spinReader6.SetPosition(0); -} - -void Robot::Forwards() -{ - driveboi1.Set(-.5); - driveboi3.Set(.5); -} -void Robot::Backwards() -{ - driveboi1.Set(.5); - driveboi3.Set(-.5); -} -void Robot::Clock() -{ - driveboi1.Set(.5); - driveboi3.Set(.5); -} -void Robot::CounterClock() -{ - driveboi1.Set(-.5); - driveboi3.Set(-.5); -} -void Robot::Wait(double seconds) -{ - clock_t endwait; - endwait = clock() + seconds * CLOCKS_PER_SEC; - while (clock() < endwait) - { - } -} - #ifndef RUNNING_FRC_TESTS int main() { From 1d897ee33e36c665de1390efc9576dce6cce0558 Mon Sep 17 00:00:00 2001 From: 6758Guy <46696216+6758Guy@users.noreply.github.com> Date: Sat, 29 Feb 2020 11:02:29 -0600 Subject: [PATCH 5/5] wtf is this version anymore --- src/main/cpp/Auton/{Autown.h => Autown.cpp} | 164 ++++++++-------- src/main/cpp/Robot.cpp | 99 +++++++--- src/main/cpp/Variables/Variables.h | 199 ++++++++++---------- src/main/include/Robot.h | 102 ++++++++++ 4 files changed, 359 insertions(+), 205 deletions(-) rename src/main/cpp/Auton/{Autown.h => Autown.cpp} (67%) diff --git a/src/main/cpp/Auton/Autown.h b/src/main/cpp/Auton/Autown.cpp similarity index 67% rename from src/main/cpp/Auton/Autown.h rename to src/main/cpp/Auton/Autown.cpp index e4386d4..414ab23 100644 --- a/src/main/cpp/Auton/Autown.h +++ b/src/main/cpp/Auton/Autown.cpp @@ -1,7 +1,10 @@ -#pragma once #include #include +//#define USSide +//#define USStraight +#define TwoBalls + void Robot::AutownInit() { m_autoSelected = m_chooser.GetSelected(); @@ -17,30 +20,34 @@ void Robot::AutownInit() }*/ step = forward1; - driveboi2.Follow(driveboi1, /*invert*/ false); - driveboi4.Follow(driveboi3, /*invert*/ false); - driveboi5.Follow(driveboi1, /*invert*/ false); - driveboi6.Follow(driveboi3, /*invert*/ false); + driveboi2->Follow(*driveboi1, /*invert*/ false); + driveboi4->Follow(*driveboi3, /*invert*/ false); + driveboi5->Follow(*driveboi1, /*invert*/ false); + driveboi6->Follow(*driveboi3, /*invert*/ false); + + //auton variables + forwardBackwardDistance = 46; //23 is about 5 ft + turnDistance = 29; //25 is about 360 degrees on shop floors, 29 is about 360 on carpet } void Robot::AutownPeriodic() { - double forwardBackward = spinReader1.GetPosition() - spinReader3.GetPosition(); - double turn = spinReader1.GetPosition() + spinReader3.GetPosition(); - /*if (m_autoSelected == kAutoNameCustom) { +/*if (m_autoSelected == kAutoNameCustom) { // Custom Auto goes here } else { // Default Auto goes here }*/ - // Ultra Sonic Straight Shot (Best Option) (Not Tested) +// Ultra Sonic Straight Shot (Best Option) (Not Tested) +#ifdef USStraight + double turn = spinReader1.GetPosition() + spinReader3.GetPosition(); switch (step) { case forward1: { - if (batman.GetValue() > 375) //230 - 630 usable range + if (batman->GetValue() > 375) //230 - 630 usable range { Robot::Forwards(); } @@ -53,9 +60,9 @@ void Robot::AutownPeriodic() } case dump: { - roboMyRio.Set(true); + roboMyRio->Set(true); Wait(.5); - roboMyRio.Set(false); + roboMyRio->Set(false); step = back1; break; } @@ -87,7 +94,7 @@ void Robot::AutownPeriodic() } case forward2: { - if (batman.GetValue() > 250) + if (batman->GetValue() > 250) { Robot::Forwards(); } @@ -140,25 +147,27 @@ void Robot::AutownPeriodic() default: break; } +#endif - //UltraSonic Side Shot (2nd Best Option) (Not Tested) - /* -switch (step) +//UltraSonic Side Shot (2nd Best Option) (Not Tested) +#ifdef USSide + double turn = spinReader1.GetPosition() + spinReader3.GetPosition(); + switch (step) { - case forwardfromside: + case forward1: { if (forwardBackward < 92) { - Robot::Forwards(); - } + Robot::Forwards(); + } else { ZeroMotors(); - step = turnsideshot; + step = turn1; } break; } - case turnsideshot: + case turn1: { if (turn < 14.5) { @@ -172,7 +181,7 @@ switch (step) } case forward1: { - if (batman.GetValue() > 375) //230 - 630 usable range + if (batman->GetValue() > 375) //230 - 630 usable range { Robot::Forwards(); } @@ -185,9 +194,9 @@ switch (step) } case dump: { - roboMyRio.Set(true); + roboMyRio->Set(true); Wait(.5); - roboMyRio.Set(false); + roboMyRio->Set(false); step = back1; break; } @@ -219,7 +228,7 @@ switch (step) } case forward2: { - if (batman.GetValue() > 250) + if (batman->GetValue() > 250) { Robot::Forwards(); } @@ -272,9 +281,10 @@ switch (step) default: break; } -*/ +#endif - //basic auton to collect 2 balls only +//basic auton to collect 2 balls only +#ifdef TwoBalls switch (step) { case forward1: @@ -286,7 +296,7 @@ switch (step) else { ZeroMotors(); - step = backwards1; + step = back1; } break; } @@ -301,63 +311,51 @@ switch (step) step = null; } break; - } - //auton using the limit switch to dump - switch (step) - { - case forward2: - { - if (stopIt == false) - { - Robot::Forwards(); - } - else - { - ZeroMotors(); - step = back1; - } + default: + break; } +#endif +} - void Robot::ZeroMotors() - { - driveboi1.Set(0); - driveboi3.Set(0); - spinReader1.SetPosition(0); - spinReader2.SetPosition(0); - spinReader3.SetPosition(0); - spinReader4.SetPosition(0); - spinReader5.SetPosition(0); - spinReader6.SetPosition(0); - } +void Robot::ZeroMotors() +{ + driveboi1->Set(0); + driveboi3->Set(0); + spinReader1.SetPosition(0); + spinReader2.SetPosition(0); + spinReader3.SetPosition(0); + spinReader4.SetPosition(0); + spinReader5.SetPosition(0); + spinReader6.SetPosition(0); +} - void Robot::Forwards() - { - driveboi1.Set(-.5); - driveboi3.Set(.5); - } - void Robot::Backwards() - { - driveboi1.Set(.5); - driveboi3.Set(-.5); - } - void Robot::Clock() - { - driveboi1.Set(.5); - driveboi3.Set(.5); - } - void Robot::CounterClock() - { - driveboi1.Set(-.5); - driveboi3.Set(-.5); - } - void Robot::Wait(double seconds) - { - clock_t endwait; - endwait = clock() + seconds * CLOCKS_PER_SEC; - while (clock() < endwait) - { - } - } - } \ No newline at end of file +void Robot::Forwards() +{ + driveboi1->Set(-.5); + driveboi3->Set(.5); +} +void Robot::Backwards() +{ + driveboi1->Set(.5); + driveboi3->Set(-.5); +} +void Robot::Clock() +{ + driveboi1->Set(.5); + driveboi3->Set(.5); +} +void Robot::CounterClock() +{ + driveboi1->Set(-.5); + driveboi3->Set(-.5); +} +void Robot::Wait(double seconds) +{ + clock_t endwait; + endwait = clock() + seconds * CLOCKS_PER_SEC; + while (clock() < endwait) + { + } +} diff --git a/src/main/cpp/Robot.cpp b/src/main/cpp/Robot.cpp index 29dbea4..c5326a5 100644 --- a/src/main/cpp/Robot.cpp +++ b/src/main/cpp/Robot.cpp @@ -1,5 +1,4 @@ #include "Robot.h" -#include #include void Robot::RobotInit() @@ -22,8 +21,62 @@ void Robot::RobotInit() moreSpeed = new frc::JoystickButton(lonelyStick, 3); putItIn = new frc::JoystickButton(lonelyStick, 1); + //brit motors + driveboi1 = new rev::CANSparkMax(7, rev::CANSparkMax::MotorType::kBrushless); + driveboi2 = new rev::CANSparkMax(10, rev::CANSparkMax::MotorType::kBrushless); + driveboi3 = new rev::CANSparkMax(13, rev::CANSparkMax::MotorType::kBrushless); + driveboi4 = new rev::CANSparkMax(2, rev::CANSparkMax::MotorType::kBrushless); + driveboi5 = new rev::CANSparkMax(8, rev::CANSparkMax::MotorType::kBrushless); + driveboi6 = new rev::CANSparkMax(9, rev::CANSparkMax::MotorType::kBrushless); + + //brit motor groups + speedyboiL = new frc::SpeedControllerGroup(*driveboi1, *driveboi2, *driveboi3); + speedyboiR = new frc::SpeedControllerGroup(*driveboi4, *driveboi5, *driveboi6); + + //Encoder creation + spinReader1 = driveboi1->GetEncoder(); + spinReader2 = driveboi2->GetEncoder(); + spinReader3 = driveboi3->GetEncoder(); + spinReader4 = driveboi4->GetEncoder(); + spinReader5 = driveboi5->GetEncoder(); + spinReader6 = driveboi6->GetEncoder(); + + //winch encoder creation + pimp = whench->GetEncoder(); + //climber encoder creation + gwen = spoodermoon->GetEncoder(); + + //winch motor creation + whench = new rev::CANSparkMax(12, rev::CANSparkMax::MotorType::kBrushless); + //climber motor creation + spoodermoon = new rev::CANSparkMax(11, rev::CANSparkMax::MotorType::kBrushless); + //mike whipper motor creation + whippedCheese = new ctre::phoenix::motorcontrol::can::VictorSPX(25); + //mike whipper up/down solenoid + viagra = new frc::Solenoid(3); + //intake motor creation + simp = new rev::CANSparkMax(1, rev::CANSparkMax::MotorType::kBrushless); + egirl = new rev::CANSparkMax(3, rev::CANSparkMax::MotorType::kBrushless); + //setting up drivetrain - brit = new frc::DifferentialDrive(speedyboiL, speedyboiR); + brit = new frc::DifferentialDrive(*speedyboiL, *speedyboiR); + + //sonlenoid + peerPressure1 = new frc::Solenoid(0); + peerPressure2 = new frc::Solenoid(1); + roboMyRio = new frc::Solenoid(2); + + //compressor + bonusPressure = new frc::Compressor(0); + + //limit switch + stopIt = new frc::DigitalInput(9); + + //setting up us sensor + batman = new frc::AnalogInput(0); + + //mike whipper and intake variable + toggle = 1; } void Robot::RobotPeriodic() @@ -70,7 +123,7 @@ void Robot::TeleopPeriodic() frc::SmartDashboard::PutNumber("climber position", -gwen.GetPosition()); //read sensor - double distance = batman.GetValue() * 0.393701; //multiplying by 0.393701 converts the sonar value to inches (hopefully) + double distance = batman->GetValue() * 0.393701; //multiplying by 0.393701 converts the sonar value to inches (hopefully) frc::SmartDashboard::PutNumber("Range Sensor 1", distance); // Code for deadzones on joystick @@ -85,18 +138,18 @@ void Robot::TeleopPeriodic() } //making the compressor compress - bonusPressure.SetClosedLoopControl(true); + bonusPressure->SetClosedLoopControl(true); //gearbox shifting code - peerPressure2.Set(lessSpeed->Get()); - peerPressure1.Set(moreSpeed->Get()); + peerPressure2->Set(lessSpeed->Get()); + peerPressure1->Set(moreSpeed->Get()); //pneumatic actuator if (putItIn->Get()) { - roboMyRio.Set(true); + roboMyRio->Set(true); Robot::Wait(.5); - roboMyRio.Set(false); + roboMyRio->Set(false); } //mike whipper and intake code @@ -107,51 +160,51 @@ void Robot::TeleopPeriodic() if (toggle == 1) { - viagra.Set(false); - simp.Set(0); - simp2.Set(0); - whippedCheese.Set(ControlMode::PercentOutput, 0); + viagra->Set(false); + simp->Set(0); + egirl->Set(0); + whippedCheese->Set(ControlMode::PercentOutput, 0); } else if (toggle == -1) { - viagra.Set(true); - simp.Set(-.5); - simp.Set(0.5); - whippedCheese.Set(ControlMode::PercentOutput, .8); + viagra->Set(true); + simp->Set(.5); + egirl->Set(-.5); + whippedCheese->Set(ControlMode::PercentOutput, 0.8); } //winch code if (neighborlyInputDevice->GetBButton()) { - whench.Set(1); + whench->Set(1); } else { - whench.Set(0); + whench->Set(0); } //climber code if (neighborlyInputDevice->GetTriggerAxis(frc::GenericHID::JoystickHand::kRightHand) > 0) { - spoodermoon.Set(-neighborlyInputDevice->GetTriggerAxis(frc::GenericHID::JoystickHand::kRightHand) * .2); + spoodermoon->Set(-neighborlyInputDevice->GetTriggerAxis(frc::GenericHID::JoystickHand::kRightHand) * .2); } else if (neighborlyInputDevice->GetTriggerAxis(frc::GenericHID::JoystickHand::kLeftHand) > 0) { - spoodermoon.Set(neighborlyInputDevice->GetTriggerAxis(frc::GenericHID::JoystickHand::kLeftHand) * .2); + spoodermoon->Set(neighborlyInputDevice->GetTriggerAxis(frc::GenericHID::JoystickHand::kLeftHand) * .2); } else { - spoodermoon.Set(0); + spoodermoon->Set(0); } //Bumber to preset climbing positions (63 in and all the way down) if (neighborlyInputDevice->GetBumper(frc::GenericHID::JoystickHand::kRightHand) && -gwen.GetPosition() < 82) { - spoodermoon.Set(-.2); + spoodermoon->Set(-.2); } else if (neighborlyInputDevice->GetBumper(frc::GenericHID::JoystickHand::kLeftHand) && -gwen.GetPosition() > 0) { - spoodermoon.Set(.2); + spoodermoon->Set(.2); } //90 Degree turn code (Not Tested) diff --git a/src/main/cpp/Variables/Variables.h b/src/main/cpp/Variables/Variables.h index 21950c1..abdae00 100644 --- a/src/main/cpp/Variables/Variables.h +++ b/src/main/cpp/Variables/Variables.h @@ -1,105 +1,106 @@ #pragma once #include -//joystick creation -frc::Joystick *lonelyStick; -frc::JoystickButton *nuke; //button 4 -frc::JoystickButton *oneSpin; //button 6 -frc::JoystickButton *lessSpeed; //button 5 -frc::JoystickButton *moreSpeed; //button 3 -frc::JoystickButton *fullCheech; //button 2 -frc::JoystickButton *putItIn; //button 1 - -//tank drive creation -frc::DifferentialDrive *brit; - -//controller creation -frc::XboxController *neighborlyInputDevice; - -//brit motors -rev::CANSparkMax driveboi1(7, rev::CANSparkMax::MotorType::kBrushless); -rev::CANSparkMax driveboi2(10, rev::CANSparkMax::MotorType::kBrushless); -rev::CANSparkMax driveboi3(13, rev::CANSparkMax::MotorType::kBrushless); -rev::CANSparkMax driveboi4(2, rev::CANSparkMax::MotorType::kBrushless); -rev::CANSparkMax driveboi5(8, rev::CANSparkMax::MotorType::kBrushless); -rev::CANSparkMax driveboi6(9, rev::CANSparkMax::MotorType::kBrushless); - -//brit motor groups -frc::SpeedControllerGroup speedyboiL(driveboi1, driveboi2, driveboi3); -frc::SpeedControllerGroup speedyboiR(driveboi4, driveboi5, driveboi6); - -//winch motor creation -rev::CANSparkMax whench(12, rev::CANSparkMax::MotorType::kBrushless); -//climber motor creation -rev::CANSparkMax spoodermoon(11, rev::CANSparkMax::MotorType::kBrushless); -//mike whipper motor creation -ctre::phoenix::motorcontrol::can::VictorSPX whippedCheese = {25}; -//mike whipper up/down solenoid -frc::Solenoid viagra(3); -//intake motor creation -rev::CANSparkMax simp(1, rev::CANSparkMax::MotorType::kBrushless); -rev::CANSparkMax simp2(3, rev::CANSparkMax::MotorType::kBrushless); - -//Encoder creation -rev::CANEncoder spinReader1 = driveboi1.GetEncoder(); -rev::CANEncoder spinReader2 = driveboi2.GetEncoder(); -rev::CANEncoder spinReader3 = driveboi3.GetEncoder(); -rev::CANEncoder spinReader4 = driveboi4.GetEncoder(); -rev::CANEncoder spinReader5 = driveboi5.GetEncoder(); -rev::CANEncoder spinReader6 = driveboi6.GetEncoder(); -//winch encoder creation -rev::CANEncoder pimp = whench.GetEncoder(); -//climber encoder creation -rev::CANEncoder gwen = spoodermoon.GetEncoder(); - -//camera creation -cs::UsbCamera fbi; -cs::UsbCamera cia; - -//ultrasonic range sensor creation -frc::AnalogInput batman(0); // 230 - 630 is usable range -//ultrsonic variable -double distance; - -//speed var -double speed; -//auton steps variable thing -enum Auton -{ - forward1 = 1, - dump = 2, - back1 = 3, - turn1 = 4, - forward2 = 5, - back2 = 6, - turn2 = 7, - forward3 = 8, - null = 9 - /*forwardfromside = 10 (for the UltraSonic Side Shot) - turnsideshot = 11 -*/ -}; -Auton step; - -//sonlenoid creation -frc::Solenoid peerPressure1(0); -frc::Solenoid peerPressure2(1); -frc::Solenoid roboMyRio(2); - -//compressor creation -frc::Compressor bonusPressure(0); - -//limit switch creation -frc::DigitalInput stopIt(9); - -//revolution var -int forwardBackwardDistance = 46; //23 is about 5 ft -int turnDistance = 29; //25 is about 360 degrees on shop floors, 29 is about 360 on carpet +// //joystick creation +// frc::Joystick *lonelyStick; +// frc::JoystickButton *nuke; //button 4 +// frc::JoystickButton *oneSpin; //button 6 +// frc::JoystickButton *lessSpeed; //button 5 +// frc::JoystickButton *moreSpeed; //button 3 +// frc::JoystickButton *fullCheech; //button 2 +// frc::JoystickButton *putItIn; //button 1 + +// //tank drive creation +// frc::DifferentialDrive *brit; + +// //controller creation +// frc::XboxController *neighborlyInputDevice; + +// //brit motors +// rev::CANSparkMax driveboi1(7, rev::CANSparkMax::MotorType::kBrushless); +// rev::CANSparkMax driveboi2(10, rev::CANSparkMax::MotorType::kBrushless); +// rev::CANSparkMax driveboi3(13, rev::CANSparkMax::MotorType::kBrushless); +// rev::CANSparkMax driveboi4(2, rev::CANSparkMax::MotorType::kBrushless); +// rev::CANSparkMax driveboi5(8, rev::CANSparkMax::MotorType::kBrushless); +// rev::CANSparkMax driveboi6(9, rev::CANSparkMax::MotorType::kBrushless); + +// //brit motor groups +// frc::SpeedControllerGroup speedyboiL(driveboi1, driveboi2, driveboi3); +// frc::SpeedControllerGroup speedyboiR(driveboi4, driveboi5, driveboi6); + +// //winch motor creation +// rev::CANSparkMax whench(12, rev::CANSparkMax::MotorType::kBrushless); +// //climber motor creation +// rev::CANSparkMax spoodermoon(11, rev::CANSparkMax::MotorType::kBrushless); +// //mike whipper motor creation +// ctre::phoenix::motorcontrol::can::VictorSPX whippedCheese = {25}; +// //mike whipper up/down solenoid +// frc::Solenoid viagra(3); +// //intake motor creation +// rev::CANSparkMax simp(1, rev::CANSparkMax::MotorType::kBrushless); +// rev::CANSparkMax egirl(3, rev::CANSparkMax::MotorType::kBrushless); + +// //Encoder creation +// rev::CANEncoder spinReader1 = driveboi1.GetEncoder(); +// rev::CANEncoder spinReader2 = driveboi2.GetEncoder(); +// rev::CANEncoder spinReader3 = driveboi3.GetEncoder(); +// rev::CANEncoder spinReader4 = driveboi4.GetEncoder(); +// rev::CANEncoder spinReader5 = driveboi5.GetEncoder(); +// rev::CANEncoder spinReader6 = driveboi6.GetEncoder(); + +// //winch encoder creation +// rev::CANEncoder pimp = whench.GetEncoder(); +// //climber encoder creation +// rev::CANEncoder gwen = spoodermoon.GetEncoder(); + +// //camera creation +// cs::UsbCamera fbi; +// cs::UsbCamera cia; + +// //ultrasonic range sensor creation +// frc::AnalogInput batman; // 230 - 630 is usable range +// //ultrsonic variable +// double distance; + +// //speed var +// double speed; +// //auton steps variable thing +// enum Auton +// { +// forward1 = 1, +// dump = 2, +// back1 = 3, +// turn1 = 4, +// forward2 = 5, +// back2 = 6, +// turn2 = 7, +// forward3 = 8, +// null = 9 +// /*forwardfromside = 10 (for the UltraSonic Side Shot) +// turnsideshot = 11 +// */ +// }; +// Auton step; + +// //sonlenoid creation +// frc::Solenoid peerPressure1(0); +// frc::Solenoid peerPressure2(1); +// frc::Solenoid roboMyRio(2); + +// //compressor creation +// frc::Compressor bonusPressure(0); + +// //limit switch creation +// frc::DigitalInput stopIt(9); + +// //revolution var +// int forwardBackwardDistance = 46; //23 is about 5 ft +// int turnDistance = 29; //25 is about 360 degrees on shop floors, 29 is about 360 on carpet //toggle variable for intake things -int toggle = 1; +// int toggle = 1; -//Dead Zone Variables -double lonelyY; -double lonelyTwist; -double notFarEnough; +// //Dead Zone Variables +// double lonelyY; +// double lonelyTwist; +// double notFarEnough; \ No newline at end of file diff --git a/src/main/include/Robot.h b/src/main/include/Robot.h index 37c2eac..dc6b0f1 100644 --- a/src/main/include/Robot.h +++ b/src/main/include/Robot.h @@ -54,4 +54,106 @@ class Robot : public frc::TimedRobot const std::string kAutoNameDefault = "Default"; const std::string kAutoNameCustom = "My Auto"; std::string m_autoSelected; + + //joystick creation + frc::Joystick *lonelyStick; + frc::JoystickButton *nuke; //button 4 + frc::JoystickButton *oneSpin; //button 6 + frc::JoystickButton *lessSpeed; //button 5 + frc::JoystickButton *moreSpeed; //button 3 + frc::JoystickButton *fullCheech; //button 2 + frc::JoystickButton *putItIn; //button 1 + + //tank drive creation + frc::DifferentialDrive *brit; + + //controller creation + frc::XboxController *neighborlyInputDevice; + + //brit motors + rev::CANSparkMax *driveboi1; + rev::CANSparkMax *driveboi2; + rev::CANSparkMax *driveboi3; + rev::CANSparkMax *driveboi4; + rev::CANSparkMax *driveboi5; + rev::CANSparkMax *driveboi6; + + //brit motor groups + frc::SpeedControllerGroup *speedyboiL; + frc::SpeedControllerGroup *speedyboiR; + + //Encoder creation + rev::CANEncoder spinReader1; + rev::CANEncoder spinReader2; + rev::CANEncoder spinReader3; + rev::CANEncoder spinReader4; + rev::CANEncoder spinReader5; + rev::CANEncoder spinReader6; + + //winch encoder creation + rev::CANEncoder pimp; + //climber encoder creation + rev::CANEncoder gwen; + + //winch motor creation + rev::CANSparkMax *whench; + //climber motor creation + rev::CANSparkMax *spoodermoon; + //mike whipper motor creation + ctre::phoenix::motorcontrol::can::VictorSPX *whippedCheese; + //mike whipper up/down solenoid + frc::Solenoid *viagra; + //intake motor creation + rev::CANSparkMax *simp; + rev::CANSparkMax *egirl; + + //camera creation + cs::UsbCamera fbi; + cs::UsbCamera cia; + + //ultrasonic range sensor creation + frc::AnalogInput *batman; // 230 - 630 is usable range + //ultrsonic variable + double distance; + + //auton steps variable thing + enum Auton + { + forward1 = 1, + dump = 2, + back1 = 3, + turn1 = 4, + forward2 = 5, + back2 = 6, + turn2 = 7, + forward3 = 8, + null = 9 + }; + Auton step; + + //sonlenoid creation + frc::Solenoid *peerPressure1; + frc::Solenoid *peerPressure2; + frc::Solenoid *roboMyRio; + + //compressor creation + frc::Compressor *bonusPressure; + + //limit switch creation + frc::DigitalInput *stopIt; + + //revolution var + int forwardBackwardDistance; + int turnDistance; + + //toggle variable for intake things + int toggle; + + //speed var + double speed; + + //Dead Zone Variables + double lonelyY; + double lonelyTwist; + double notFarEnough; };