From b474d60175756a39768d5a38d68c6ad60e4317ff Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sat, 1 Feb 2020 16:32:47 -0600 Subject: [PATCH 01/22] Additions of Auton Actions. --- src/{ => auto}/Auton.cpp | 0 src/{ => auto}/Auton.h | 0 src/{ => auto}/AutonActionTest.cpp | 0 src/{ => auto}/AutonActionTest.h | 1 - src/auto/DriveForwardAction.cpp | 2 ++ src/auto/DriveForwardAction.h | 13 +++++++++++++ src/auto/IntakePowerCellsAction.cpp | 2 ++ src/auto/IntakePowerCellsAction.h | 13 +++++++++++++ src/auto/LaunchBallsAction.cpp | 2 ++ src/auto/LaunchBallsAction.h | 14 ++++++++++++++ 10 files changed, 46 insertions(+), 1 deletion(-) rename src/{ => auto}/Auton.cpp (100%) rename src/{ => auto}/Auton.h (100%) rename src/{ => auto}/AutonActionTest.cpp (100%) rename src/{ => auto}/AutonActionTest.h (96%) create mode 100644 src/auto/DriveForwardAction.cpp create mode 100644 src/auto/DriveForwardAction.h create mode 100644 src/auto/IntakePowerCellsAction.cpp create mode 100644 src/auto/IntakePowerCellsAction.h create mode 100644 src/auto/LaunchBallsAction.cpp create mode 100644 src/auto/LaunchBallsAction.h diff --git a/src/Auton.cpp b/src/auto/Auton.cpp similarity index 100% rename from src/Auton.cpp rename to src/auto/Auton.cpp diff --git a/src/Auton.h b/src/auto/Auton.h similarity index 100% rename from src/Auton.h rename to src/auto/Auton.h diff --git a/src/AutonActionTest.cpp b/src/auto/AutonActionTest.cpp similarity index 100% rename from src/AutonActionTest.cpp rename to src/auto/AutonActionTest.cpp diff --git a/src/AutonActionTest.h b/src/auto/AutonActionTest.h similarity index 96% rename from src/AutonActionTest.h rename to src/auto/AutonActionTest.h index 8209730..818d335 100644 --- a/src/AutonActionTest.h +++ b/src/auto/AutonActionTest.h @@ -1,7 +1,6 @@ #pragma once #include -#include using namespace CORE; diff --git a/src/auto/DriveForwardAction.cpp b/src/auto/DriveForwardAction.cpp new file mode 100644 index 0000000..7d1ce9f --- /dev/null +++ b/src/auto/DriveForwardAction.cpp @@ -0,0 +1,2 @@ +#include "Robot.h" +#include \ No newline at end of file diff --git a/src/auto/DriveForwardAction.h b/src/auto/DriveForwardAction.h new file mode 100644 index 0000000..a0598db --- /dev/null +++ b/src/auto/DriveForwardAction.h @@ -0,0 +1,13 @@ +#pragma once +#include +#include + +using namespace CORE; + +class DriveForwardAction : public COREAutonAction { +public: + DriveForwardAction(); + void ActionInit() override; + CORE::COREAutonAction::actionStatus Action() override; + void ActionEnd() override; +}; diff --git a/src/auto/IntakePowerCellsAction.cpp b/src/auto/IntakePowerCellsAction.cpp new file mode 100644 index 0000000..4d6d3ab --- /dev/null +++ b/src/auto/IntakePowerCellsAction.cpp @@ -0,0 +1,2 @@ +#include "Robot.h" +#include \ No newline at end of file diff --git a/src/auto/IntakePowerCellsAction.h b/src/auto/IntakePowerCellsAction.h new file mode 100644 index 0000000..18c5ea1 --- /dev/null +++ b/src/auto/IntakePowerCellsAction.h @@ -0,0 +1,13 @@ +#pragma once +#include +#include + +using namespace CORE; + +class IntakePowerCellsAction : public COREAutonAction { +public: + IntakePowerCellsAction(); + void ActionInit() override; + CORE::COREAutonAction::actionStatus Action() override; + void ActionEnd() override; +}; diff --git a/src/auto/LaunchBallsAction.cpp b/src/auto/LaunchBallsAction.cpp new file mode 100644 index 0000000..95a9b89 --- /dev/null +++ b/src/auto/LaunchBallsAction.cpp @@ -0,0 +1,2 @@ +#include "Robot.h" +#include \ No newline at end of file diff --git a/src/auto/LaunchBallsAction.h b/src/auto/LaunchBallsAction.h new file mode 100644 index 0000000..6443cf0 --- /dev/null +++ b/src/auto/LaunchBallsAction.h @@ -0,0 +1,14 @@ +#pragma once +#include +#include + +using namespace CORE; + + +class LaunchBallsAction : public COREAutonAction { +public: + LaunchBallsAction(); + void ActionInit() override; + CORE::COREAutonAction::actionStatus Action() override; + void ActionEnd() override; +}; \ No newline at end of file From 03254530f714ab6d908c4a9f00c7329461152311 Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Thu, 6 Feb 2020 20:24:55 -0600 Subject: [PATCH 02/22] More work on auto actions Attempting to fix build errors --- .vscode/settings.json | 3 +- build.gradle | 25 ++--------- src/ClimberSubsystem.cpp | 15 ++----- src/ClimberSubsystem.h | 3 +- src/ControlPanelSubsystem.cpp | 66 ++++++++++++----------------- src/ControlPanelSubsystem.h | 5 ++- src/ConveyorSubsystem.cpp | 10 ++--- src/ConveyorSubsystem.h | 3 +- src/DriveSubsystem.cpp | 2 - src/DriveSubsystem.h | 17 ++++---- src/IntakeSubsystem.cpp | 10 +---- src/IntakeSubsystem.h | 9 ++-- src/LauncherSubsystem.cpp | 4 +- src/LauncherSubsystem.h | 2 +- src/Robot.cpp | 34 ++++----------- src/Robot.h | 24 +++++++---- src/TurretSubsystem.h | 2 +- src/auto/Auton.cpp | 1 - src/auto/Auton.h | 1 - src/auto/DriveForwardAction.cpp | 32 +++++++++++++- src/auto/DriveForwardAction.h | 11 ++++- src/auto/IntakePowerCellsAction.cpp | 32 +++++++++++++- src/auto/IntakePowerCellsAction.h | 11 ++++- src/auto/LaunchBallsAction.cpp | 26 +++++++++++- src/auto/LaunchBallsAction.h | 11 ++++- 25 files changed, 203 insertions(+), 156 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index beb2a0a..25eb7b6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -76,6 +76,7 @@ "cinttypes": "cpp", "complex": "cpp", "typeinfo": "cpp", - "valarray": "cpp" + "valarray": "cpp", + "*.inc": "cpp" } } diff --git a/build.gradle b/build.gradle index ded6a12..45668bb 100644 --- a/build.gradle +++ b/build.gradle @@ -57,15 +57,14 @@ model { sources.cpp { source { srcDir 'src' + srcDir 'src/auto' include '**/*.cpp', '**/*.cc' } exportedHeaders { srcDir 'src' - srcDirs '../CORERobotLib/src' - srcDir "../CORERobotLib/3rdparty/json/src/" - if (includeSrcInIncludeRoot) { - srcDir 'src' - } + srcDir 'src/auto' + srcDir '../CORERobotLib/src' + srcDir '../CORERobotLib/3rdparty/json/src/' } } @@ -74,20 +73,4 @@ model { wpi.deps.vendor.cpp(it) } } - testSuites { - frcUserProgramTest(GoogleTestTestSuiteSpec) { - testing $.components.frcUserProgram - - sources.cpp { - source { - srcDir 'src' - include '**/*.cpp' - } - } - - wpi.deps.wpilib(it) - wpi.deps.googleTest(it) - wpi.deps.vendor.cpp(it) - } - } } \ No newline at end of file diff --git a/src/ClimberSubsystem.cpp b/src/ClimberSubsystem.cpp index 32b77bd..ae6cb24 100644 --- a/src/ClimberSubsystem.cpp +++ b/src/ClimberSubsystem.cpp @@ -1,14 +1,7 @@ -#include -#include +#include "ClimberSubsystem.h" -void ClimberSubsystem::robotInit() { +void ClimberSubsystem::robotInit() {} -} +void ClimberSubsystem::teleopInit() {} -void ClimberSubsystem::teleopInit() { - -} - -void ClimberSubsystem::teleop() { - -} +void ClimberSubsystem::teleop() {} diff --git a/src/ClimberSubsystem.h b/src/ClimberSubsystem.h index 8526df6..d9f5e93 100644 --- a/src/ClimberSubsystem.h +++ b/src/ClimberSubsystem.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include "Robot.h" using namespace CORE; @@ -11,5 +11,4 @@ class ClimberSubsystem : public CORESubsystem { void robotInit() override; void teleopInit() override; void teleop() override; -private: }; diff --git a/src/ControlPanelSubsystem.cpp b/src/ControlPanelSubsystem.cpp index 91b8dad..bb59366 100644 --- a/src/ControlPanelSubsystem.cpp +++ b/src/ControlPanelSubsystem.cpp @@ -1,17 +1,10 @@ -#include -#include -#include +#include "ControlPanelSubsystem.h" -void ControlPanelSubsystem::robotInit() { +void ControlPanelSubsystem::robotInit() {} -} - -void ControlPanelSubsystem::teleopInit() { - -} +void ControlPanelSubsystem::teleopInit() {} void ControlPanelSubsystem::teleop() { - /** * The method GetColor() returns a normalized color value from the sensor and can be * useful if outputting the color to an RGB LED or similar. To @@ -22,43 +15,36 @@ void ControlPanelSubsystem::teleop() { * an object is the more light from the surroundings will bleed into the * measurements and make it difficult to accurately determine its color. */ - frc::9890-p;;l/.Color detectedColor = m_colorSensor.GetColor(); + // frc::Color detectedColor = m_colorSensor.GetColor(); /** * The sensor returns a raw IR value of the infrared light detected. */ - double IR = m_colorSensor.GetIR(); + // double IR = m_colorSensor.GetIR(); /** * Open Smart Dashboard or Shuffleboard to see the color detected by the * sensor. */ - frc::SmartDashboard::PutNumber("Red", detectedColor.red); - frc::SmartDashboard::PutNumber("Green", detectedColor.green); - frc::SmartDashboard::PutNumber("Blue", detectedColor.blue); - frc::SmartDashboard::PutNumber("IR", IR); - if((detectedColor.red > 0.29) & (detectedColor.green > 0.5)){ - frc::SmartDashboard::PutString("Color", "Yellow"); - } - else if(detectedColor.red > 0.29){ - frc::SmartDashboard::PutString("Color", "Red"); - } - else if(detectedColor.green > 0.5){ - frc::SmartDashboard::PutString("Color", "Green"); - } - else if(detectedColor.blue > 0.235){ - frc::SmartDashboard::PutString("Color", "Blue"); - } - - uint32_t proximity = m_colorSensor.GetProximity(); - - frc::SmartDashboard::PutNumber("Proximity", proximity); - } - - -#ifndef RUNNING_FRC_TESTS -int main() { return frc::StartRobot(); } -#endif -void Robot::TestPeriodic() {} - + // frc::SmartDashboard::PutNumber("Red", detectedColor.red); + // frc::SmartDashboard::PutNumber("Green", detectedColor.green); + // frc::SmartDashboard::PutNumber("Blue", detectedColor.blue); + // frc::SmartDashboard::PutNumber("IR", IR); + // if((detectedColor.red > 0.29) & (detectedColor.green > 0.5)){ + // frc::SmartDashboard::PutString("Color", "Yellow"); + // } + // else if(detectedColor.red > 0.29){ + // frc::SmartDashboard::PutString("Color", "Red"); + // } + // else if(detectedColor.green > 0.5){ + // frc::SmartDashboard::PutString("Color", "Green"); + // } + // else if(detectedColor.blue > 0.235){ + // frc::SmartDashboard::PutString("Color", "Blue"); + // } + + // uint32_t proximity = m_colorSensor.GetProximity(); + + // frc::SmartDashboard::PutNumber("Proximity", proximity); + // } } diff --git a/src/ControlPanelSubsystem.h b/src/ControlPanelSubsystem.h index 987b90b..1069418 100644 --- a/src/ControlPanelSubsystem.h +++ b/src/ControlPanelSubsystem.h @@ -1,7 +1,9 @@ #pragma once +// #include +#include #include -#include +#include "Robot.h" using namespace CORE; @@ -12,4 +14,5 @@ class ControlPanelSubsystem : public CORESubsystem { void teleopInit() override; void teleop() override; private: + // rev::ColorSensorV3 m_colorSensor{i2cPort}; }; \ No newline at end of file diff --git a/src/ConveyorSubsystem.cpp b/src/ConveyorSubsystem.cpp index b06a3bb..88a74e8 100644 --- a/src/ConveyorSubsystem.cpp +++ b/src/ConveyorSubsystem.cpp @@ -1,12 +1,10 @@ -#include -#include +#include "ConveyorSubsystem.h" using namespace CORE; ConveyorSubsystem::ConveyorSubsystem() : m_conveyorMotor1(CONVEYOR_1_PORT), m_conveyorMotor2(CONVEYOR_2_PORT), - m_conveyorSpeed("Conveyor Speed", 0){ - + m_conveyorSpeed("Conveyor Speed", 0) { } void ConveyorSubsystem::robotInit(){ @@ -18,9 +16,7 @@ void ConveyorSubsystem::robotInit(){ operatorJoystick->RegisterButton(CORE::COREJoystick::JoystickButton::RIGHT_BUTTON); } -void ConveyorSubsystem::teleopInit(){ - -} +void ConveyorSubsystem::teleopInit() {} void ConveyorSubsystem::teleop(){ if(operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::RIGHT_TRIGGER)) { diff --git a/src/ConveyorSubsystem.h b/src/ConveyorSubsystem.h index 0b1f7e7..ec3b450 100644 --- a/src/ConveyorSubsystem.h +++ b/src/ConveyorSubsystem.h @@ -1,9 +1,8 @@ #pragma once #include -#include #include -#include +#include "Robot.h" class ConveyorSubsystem : public CORESubsystem { public: diff --git a/src/DriveSubsystem.cpp b/src/DriveSubsystem.cpp index 6161a06..68b55d3 100644 --- a/src/DriveSubsystem.cpp +++ b/src/DriveSubsystem.cpp @@ -1,6 +1,4 @@ -#include "ctre/Phoenix.h" #include "DriveSubsystem.h" -#include "Robot.h" DriveSubsystem::DriveSubsystem() : m_leftMaster(LEFT_FRONT_PORT), diff --git a/src/DriveSubsystem.h b/src/DriveSubsystem.h index 8ea624a..bfe71d6 100644 --- a/src/DriveSubsystem.h +++ b/src/DriveSubsystem.h @@ -1,14 +1,16 @@ #pragma once -//#include "Robot.h" -#include "ctre/Phoenix.h" -#include -#include "AHRS.h" -#include "COREFramework/COREScheduler.h" - #include #include -#include "COREUtilities/CORETimer.h" +#include +#include +#include +#include +#include +#include "Robot.h" + +using namespace CORE; +using namespace frc; enum class DriveSide{LEFT = 1, RIGHT = 2, BOTH = 3}; @@ -21,7 +23,6 @@ class DriveSubsystem : public CORESubsystem { void teleopEnd() override; void initTalons(); - void setMotorSpeed(double speedInFraction, DriveSide whichSide); void setMotorSpeed(double leftPercent, double rightPercent); void fillCompressor(); diff --git a/src/IntakeSubsystem.cpp b/src/IntakeSubsystem.cpp index 5713f51..2f332c3 100644 --- a/src/IntakeSubsystem.cpp +++ b/src/IntakeSubsystem.cpp @@ -1,10 +1,8 @@ -#include -#include +#include "IntakeSubsystem.h" IntakeSubsystem::IntakeSubsystem() : m_intakeMotor(INTAKE_PORT), m_intakeSolenoid(LEFT_DRIVE_SHIFTER_PCM, INTAKE_DOWN_PORT, INTAKE_UP_PORT), m_intakeSpeed("Intake Speed", 0){ - } void IntakeSubsystem::robotInit(){ @@ -14,9 +12,7 @@ void IntakeSubsystem::robotInit(){ m_isIntakeDown = false; } -void IntakeSubsystem::teleopInit(){ - -} +void IntakeSubsystem::teleopInit() {} void IntakeSubsystem::teleop(){ if(operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::LEFT_TRIGGER)){ @@ -40,5 +36,3 @@ void IntakeSubsystem::ToggleIntake() { m_intakeSolenoid.Set(frc::DoubleSolenoid::kReverse); } } - -using namespace CORE; diff --git a/src/IntakeSubsystem.h b/src/IntakeSubsystem.h index 8292d2e..77d7499 100644 --- a/src/IntakeSubsystem.h +++ b/src/IntakeSubsystem.h @@ -1,12 +1,11 @@ #pragma once -#include -#include +#include #include -#include +#include +#include "Robot.h" using namespace CORE; -using namespace frc; class IntakeSubsystem : public CORESubsystem { public: @@ -18,7 +17,7 @@ class IntakeSubsystem : public CORESubsystem { void ToggleIntake(); private: TalonSRX m_intakeMotor; - DoubleSolenoid m_intakeSolenoid; + frc::DoubleSolenoid m_intakeSolenoid; COREConstant m_intakeSpeed; bool m_isIntakeDown; }; \ No newline at end of file diff --git a/src/LauncherSubsystem.cpp b/src/LauncherSubsystem.cpp index 8da7b80..73f05af 100644 --- a/src/LauncherSubsystem.cpp +++ b/src/LauncherSubsystem.cpp @@ -1,6 +1,4 @@ -#include -#include -#include +#include "LauncherSubsystem.h" using namespace CORE; diff --git a/src/LauncherSubsystem.h b/src/LauncherSubsystem.h index 948d23f..4e80846 100644 --- a/src/LauncherSubsystem.h +++ b/src/LauncherSubsystem.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include using namespace frc; diff --git a/src/Robot.cpp b/src/Robot.cpp index 1778b20..8732af8 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -1,43 +1,27 @@ #include -#include - -#include - -#include - -Robot * Robot::m_instance; +Robot* Robot::m_instance; Robot::Robot() { m_instance = this; } -void Robot::teleop() { +void Robot::teleop() {} -} +void Robot::robotInit() {} -void Robot::robotInit() { +void Robot::teleopInit() {} -} +void Robot::test() {} -void Robot::teleopInit() { - -} - -void Robot::test() { - -} - -void Robot::testInit() { - -} +void Robot::testInit() {} Robot * Robot::GetInstance() { return m_instance; } #ifndef RUNNING_FRC_TESTS -int main() { - return frc::StartRobot(); +int main() { + return frc::StartRobot(); } -#endif \ No newline at end of file +#endif diff --git a/src/Robot.h b/src/Robot.h index 0771424..1bf5c68 100644 --- a/src/Robot.h +++ b/src/Robot.h @@ -1,15 +1,19 @@ #pragma once #include - +#include +#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include "Auton.h" +#include "ClimberSubsystem.h" +#include "ControlPanelSubsystem.h" +#include "ConveyorSubsystem.h" +#include "DriveSubsystem.h" +#include "IntakeSubsystem.h" +#include "LauncherSubsystem.h" +#include "TurretSubsystem.h" /* Drive ports */ #define RIGHT_FRONT_PORT 20 @@ -51,7 +55,11 @@ class Robot : public CORERobot { void testInit() override; static Robot * GetInstance(); DriveSubsystem driveSubsystem; + LauncherSubsystem launcherSubsystem; + IntakeSubsystem intakeSubsystem; + //TurretSubsystem turretSubsystem; + Autonomous controlledAutonomous; private: static Robot * m_instance; -}; \ No newline at end of file +}; diff --git a/src/TurretSubsystem.h b/src/TurretSubsystem.h index 5017a3c..3408f45 100644 --- a/src/TurretSubsystem.h +++ b/src/TurretSubsystem.h @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include diff --git a/src/auto/Auton.cpp b/src/auto/Auton.cpp index 9c529bc..1f4d6fc 100644 --- a/src/auto/Auton.cpp +++ b/src/auto/Auton.cpp @@ -1,6 +1,5 @@ #include "Auton.h" #include -#include Autonomous::Autonomous() : COREAuton("Test Auto") {} diff --git a/src/auto/Auton.h b/src/auto/Auton.h index 088ff5e..5efd415 100644 --- a/src/auto/Auton.h +++ b/src/auto/Auton.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include diff --git a/src/auto/DriveForwardAction.cpp b/src/auto/DriveForwardAction.cpp index 7d1ce9f..0289ace 100644 --- a/src/auto/DriveForwardAction.cpp +++ b/src/auto/DriveForwardAction.cpp @@ -1,2 +1,30 @@ -#include "Robot.h" -#include \ No newline at end of file +#include +#include + +DriveForwardAction::DriveForwardAction(driveForwardAction requestedDriveForwardAction) { + m_driveForwardAction = requestedDriveForwardAction; + +} + +void DriveForwardAction::ActionInit() { + +} + +CORE::COREAutonAction::actionStatus DriveForwardAction::Action() { + switch(m_driveForwardAction) { + case FORWARD: + Robot::GetInstance()->driveSubsystem.setMotorSpeed(0.5, DriveSide::BOTH); + break; + case BACKWARD: + Robot::GetInstance()->driveSubsystem.setMotorSpeed(-0.5, DriveSide::BOTH); + break; + case STOP: + Robot::GetInstance()->driveSubsystem.setMotorSpeed(0, DriveSide::BOTH); + break; + return COREAutonAction::actionStatus::END; + } +} + +void DriveForwardAction::ActionEnd() { + +} \ No newline at end of file diff --git a/src/auto/DriveForwardAction.h b/src/auto/DriveForwardAction.h index a0598db..2c2b950 100644 --- a/src/auto/DriveForwardAction.h +++ b/src/auto/DriveForwardAction.h @@ -1,13 +1,22 @@ #pragma once + #include #include using namespace CORE; +enum driveForwardAction { + FORWARD, + BACKWARD, + STOP +}; + class DriveForwardAction : public COREAutonAction { public: - DriveForwardAction(); + DriveForwardAction(driveForwardAction requestedDriveForwardAction); void ActionInit() override; CORE::COREAutonAction::actionStatus Action() override; void ActionEnd() override; +private: + driveForwardAction m_driveForwardAction; }; diff --git a/src/auto/IntakePowerCellsAction.cpp b/src/auto/IntakePowerCellsAction.cpp index 4d6d3ab..42c4880 100644 --- a/src/auto/IntakePowerCellsAction.cpp +++ b/src/auto/IntakePowerCellsAction.cpp @@ -1,2 +1,30 @@ -#include "Robot.h" -#include \ No newline at end of file +#include +#include + +IntakePowerCellsAction::IntakePowerCellsAction(intakePowerCellsAction requestedIntakePowerCellAction) { + m_intakePowerCellsAction = requestedIntakePowerCellAction; + +} + +void IntakePowerCellsAction::ActionInit() { + +} + +CORE::COREAutonAction::actionStatus IntakePowerCellsAction::Action() { + switch(m_intakePowerCellsAction) { + case INTAKE: + Robot::GetInstance()->intakeSubsystem.SetIntake(0.2); + break; + case OUTTAKE: + Robot::GetInstance()->intakeSubsystem.SetIntake(-0.2); + break; + case STOP: + Robot::GetInstance()->intakeSubsystem.SetIntake(0); + break; + return COREAutonAction::actionStatus::END; + } +} + +void IntakePowerCellsAction::ActionEnd() { + +} \ No newline at end of file diff --git a/src/auto/IntakePowerCellsAction.h b/src/auto/IntakePowerCellsAction.h index 18c5ea1..1edda7f 100644 --- a/src/auto/IntakePowerCellsAction.h +++ b/src/auto/IntakePowerCellsAction.h @@ -1,13 +1,22 @@ #pragma once + #include #include using namespace CORE; +enum intakePowerCellsAction{ + INTAKE, + OUTTAKE, + STOP +}; + class IntakePowerCellsAction : public COREAutonAction { public: - IntakePowerCellsAction(); + IntakePowerCellsAction(intakePowerCellsAction requestedIntakePowerCellAction); void ActionInit() override; CORE::COREAutonAction::actionStatus Action() override; void ActionEnd() override; +private: + intakePowerCellsAction m_intakePowerCellsAction; }; diff --git a/src/auto/LaunchBallsAction.cpp b/src/auto/LaunchBallsAction.cpp index 95a9b89..955737f 100644 --- a/src/auto/LaunchBallsAction.cpp +++ b/src/auto/LaunchBallsAction.cpp @@ -1,2 +1,26 @@ #include "Robot.h" -#include \ No newline at end of file +#include + +LaunchBallsAction::LaunchBallsAction(launchBallsAction requestedLaunchBallsAction) { + m_launchBallsAction = requestedLaunchBallsAction; +} + +void LaunchBallsAction::ActionInit() { +} + +CORE::COREAutonAction::actionStatus LaunchBallsAction::Action() { + switch(m_launchBallsAction) { + case LAUNCH_LOCATION_ONE: + // Robot::GetInstance()->launcherSubsystem. + break; + case LAUNCH_LOCATION_TWO: + // Robot::GetInstance()->launcherSubsystem. + break; + case LAUNCH_LOCATION_THREE: + // Robot::GetInstance()->launcherSubsystem. + break; + case LAUNCHER_OFF: + // Robot::GetInstance()->launcherSubsystem. + break; + } +} \ No newline at end of file diff --git a/src/auto/LaunchBallsAction.h b/src/auto/LaunchBallsAction.h index 6443cf0..1b7da9e 100644 --- a/src/auto/LaunchBallsAction.h +++ b/src/auto/LaunchBallsAction.h @@ -1,14 +1,23 @@ #pragma once + #include #include using namespace CORE; +enum launchBallsAction { + LAUNCH_LOCATION_ONE, + LAUNCH_LOCATION_TWO, + LAUNCH_LOCATION_THREE, + LAUNCHER_OFF +}; class LaunchBallsAction : public COREAutonAction { public: - LaunchBallsAction(); + LaunchBallsAction(launchBallsAction requestedLaunchBallsAction); void ActionInit() override; CORE::COREAutonAction::actionStatus Action() override; void ActionEnd() override; +private: + launchBallsAction m_launchBallsAction; }; \ No newline at end of file From 4c76b8b8d6a575979c1df760c97a1a7fab32b0a4 Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Thu, 13 Feb 2020 18:55:52 -0600 Subject: [PATCH 03/22] Optimized caode and fixed errors --- src/ClimberSubsystem.h | 2 +- src/Config.h | 28 +++++++++++++++++++++++++ src/ControlPanelSubsystem.h | 2 +- src/ConveyorSubsystem.h | 2 +- src/DriveSubsystem.cpp | 12 +++++------ src/DriveSubsystem.h | 2 +- src/IntakeSubsystem.h | 2 +- src/LauncherSubsystem.h | 3 ++- src/Robot.cpp | 2 +- src/Robot.h | 32 +++-------------------------- src/TurretSubsystem.cpp | 5 ++--- src/TurretSubsystem.h | 4 +++- src/auto/Auton.cpp | 17 ++++++++------- src/auto/Auton.h | 28 ++++++++++++------------- src/auto/AutonActionTest.cpp | 1 - src/auto/AutonActionTest.h | 1 + src/auto/DriveForwardAction.cpp | 3 +-- src/auto/DriveForwardAction.h | 3 ++- src/auto/IntakePowerCellsAction.cpp | 3 +-- src/auto/IntakePowerCellsAction.h | 3 ++- src/auto/LaunchBallsAction.cpp | 10 ++++++--- src/auto/LaunchBallsAction.h | 3 ++- 22 files changed, 88 insertions(+), 80 deletions(-) create mode 100644 src/Config.h diff --git a/src/ClimberSubsystem.h b/src/ClimberSubsystem.h index d9f5e93..75f1e8c 100644 --- a/src/ClimberSubsystem.h +++ b/src/ClimberSubsystem.h @@ -1,7 +1,7 @@ #pragma once #include -#include "Robot.h" +#include "Config.h" using namespace CORE; diff --git a/src/Config.h b/src/Config.h new file mode 100644 index 0000000..bb3864a --- /dev/null +++ b/src/Config.h @@ -0,0 +1,28 @@ +#pragma once + +/* Drive ports */ +#define RIGHT_FRONT_PORT 20 +#define RIGHT_BACK_PORT 1 +#define LEFT_FRONT_PORT 19 +#define LEFT_BACK_PORT 32 +#define INTAKE_PORT 14 +#define CONVEYOR_1_PORT 15 +#define CONVEYOR_2_PORT 16 +#define TURRET_PORT 17 + + +/* Solenoids */ +#define LEFT_DRIVE_SHIFTER_PCM 1 +#define RIGHT_DRIVE_SHIFTER_PCM 1 +#define COMPRESSOR_PCM 2 +#define LEFT_DRIVE_SHIFTER_HIGH_GEAR_PORT 0 +#define RIGHT_DRIVE_SHIFTER_HIGH_GEAR_PORT 2 +#define LEFT_DRIVE_SHIFTER_LOW_GEAR_PORT 1 +#define RIGHT_DRIVE_SHIFTER_LOW_GEAR_PORT 3 +#define INTAKE_DOWN_PORT 4 +#define INTAKE_UP_PORT 5 + + +/* Launcher Ports */ +#define TOP_LAUNCHER_MOTOR_PORT 15 +#define BOTTOM_LAUNCHER_MOTOR_PORT 16 diff --git a/src/ControlPanelSubsystem.h b/src/ControlPanelSubsystem.h index 1069418..3a53ad2 100644 --- a/src/ControlPanelSubsystem.h +++ b/src/ControlPanelSubsystem.h @@ -3,7 +3,7 @@ // #include #include #include -#include "Robot.h" +// #include "Robot.h" using namespace CORE; diff --git a/src/ConveyorSubsystem.h b/src/ConveyorSubsystem.h index ec3b450..114e75d 100644 --- a/src/ConveyorSubsystem.h +++ b/src/ConveyorSubsystem.h @@ -2,7 +2,7 @@ #include #include -#include "Robot.h" +#include "Config.h" class ConveyorSubsystem : public CORESubsystem { public: diff --git a/src/DriveSubsystem.cpp b/src/DriveSubsystem.cpp index 68b55d3..bf2469a 100644 --- a/src/DriveSubsystem.cpp +++ b/src/DriveSubsystem.cpp @@ -1,17 +1,17 @@ #include "DriveSubsystem.h" DriveSubsystem::DriveSubsystem() : - m_leftMaster(LEFT_FRONT_PORT), - m_rightMaster(RIGHT_FRONT_PORT), - m_leftSlave(LEFT_BACK_PORT), - m_rightSlave(RIGHT_BACK_PORT), m_etherAValue("Ether A Value", .6), m_etherBValue("Ether B Value", .4), m_etherQuickTurnValue("Ether Quick Turn Value", 1.0), m_ticksPerInch("Ticks Per Inch", (4 * 3.1415) / 1024), - compressor(COMPRESSOR_PCM), + m_leftMaster(LEFT_FRONT_PORT), + m_rightMaster(RIGHT_FRONT_PORT), + m_leftSlave(LEFT_BACK_PORT), + m_rightSlave(RIGHT_BACK_PORT), m_leftDriveShifter(LEFT_DRIVE_SHIFTER_PCM, LEFT_DRIVE_SHIFTER_HIGH_GEAR_PORT, LEFT_DRIVE_SHIFTER_LOW_GEAR_PORT), - m_rightDriveShifter(RIGHT_DRIVE_SHIFTER_PCM, RIGHT_DRIVE_SHIFTER_HIGH_GEAR_PORT, RIGHT_DRIVE_SHIFTER_LOW_GEAR_PORT) + m_rightDriveShifter(RIGHT_DRIVE_SHIFTER_PCM, RIGHT_DRIVE_SHIFTER_HIGH_GEAR_PORT, RIGHT_DRIVE_SHIFTER_LOW_GEAR_PORT), + compressor(COMPRESSOR_PCM) { } diff --git a/src/DriveSubsystem.h b/src/DriveSubsystem.h index bfe71d6..8596e18 100644 --- a/src/DriveSubsystem.h +++ b/src/DriveSubsystem.h @@ -7,7 +7,7 @@ #include #include #include -#include "Robot.h" +#include "Config.h" using namespace CORE; using namespace frc; diff --git a/src/IntakeSubsystem.h b/src/IntakeSubsystem.h index 77d7499..3ee4a9c 100644 --- a/src/IntakeSubsystem.h +++ b/src/IntakeSubsystem.h @@ -3,7 +3,7 @@ #include #include #include -#include "Robot.h" +#include "Config.h" using namespace CORE; diff --git a/src/LauncherSubsystem.h b/src/LauncherSubsystem.h index 4e80846..ecc260b 100644 --- a/src/LauncherSubsystem.h +++ b/src/LauncherSubsystem.h @@ -1,8 +1,9 @@ #pragma once -#include #include #include +#include +#include "Config.h" using namespace frc; diff --git a/src/Robot.cpp b/src/Robot.cpp index 8732af8..feba64e 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -1,4 +1,4 @@ -#include +#include "Robot.h" Robot* Robot::m_instance; diff --git a/src/Robot.h b/src/Robot.h index 1bf5c68..63ad39f 100644 --- a/src/Robot.h +++ b/src/Robot.h @@ -14,33 +14,7 @@ #include "IntakeSubsystem.h" #include "LauncherSubsystem.h" #include "TurretSubsystem.h" - -/* Drive ports */ -#define RIGHT_FRONT_PORT 20 -#define RIGHT_BACK_PORT 1 -#define LEFT_FRONT_PORT 19 -#define LEFT_BACK_PORT 32 -#define INTAKE_PORT 14 -#define CONVEYOR_1_PORT 15 -#define CONVEYOR_2_PORT 16 -#define TURRET_PORT 17 - - -/* Solenoids */ -#define LEFT_DRIVE_SHIFTER_PCM 1 -#define RIGHT_DRIVE_SHIFTER_PCM 1 -#define COMPRESSOR_PCM 2 -#define LEFT_DRIVE_SHIFTER_HIGH_GEAR_PORT 0 -#define RIGHT_DRIVE_SHIFTER_HIGH_GEAR_PORT 2 -#define LEFT_DRIVE_SHIFTER_LOW_GEAR_PORT 1 -#define RIGHT_DRIVE_SHIFTER_LOW_GEAR_PORT 3 -#define INTAKE_DOWN_PORT 4 -#define INTAKE_UP_PORT 5 - - -/* Launcher Ports */ -#define TOP_LAUNCHER_MOTOR_PORT 15 -#define BOTTOM_LAUNCHER_MOTOR_PORT 16 +#include "Config.h" using namespace CORE; using namespace std; @@ -57,9 +31,9 @@ class Robot : public CORERobot { DriveSubsystem driveSubsystem; LauncherSubsystem launcherSubsystem; IntakeSubsystem intakeSubsystem; - //TurretSubsystem turretSubsystem; + TurretSubsystem turretSubsystem; + // Autonomous controlledAutonomous; - Autonomous controlledAutonomous; private: static Robot * m_instance; }; diff --git a/src/TurretSubsystem.cpp b/src/TurretSubsystem.cpp index d8670c5..d572591 100644 --- a/src/TurretSubsystem.cpp +++ b/src/TurretSubsystem.cpp @@ -1,6 +1,5 @@ -#include -#include -#include +#include "TurretSubsystem.h" + TurretSubsystem::TurretSubsystem(): m_turret(TURRET_PORT), m_KP("KP", 0.0005), m_KI("KI", 0), diff --git a/src/TurretSubsystem.h b/src/TurretSubsystem.h index 3408f45..d115371 100644 --- a/src/TurretSubsystem.h +++ b/src/TurretSubsystem.h @@ -1,12 +1,14 @@ #pragma once +#include #include #include -#include #include #include +#include "Config.h" using namespace CORE; +using namespace frc; class TurretSubsystem : public CORESubsystem { private: diff --git a/src/auto/Auton.cpp b/src/auto/Auton.cpp index 1f4d6fc..77f4679 100644 --- a/src/auto/Auton.cpp +++ b/src/auto/Auton.cpp @@ -1,11 +1,10 @@ -#include "Auton.h" -#include +// #include "Auton.h" -Autonomous::Autonomous() : COREAuton("Test Auto") {} +// Autonomous::Autonomous() : COREAuton("Test Auto") {} -void Autonomous::AddNodes() { - autonNode1 = new Node(5, new AutonomousAction1()); - autonNode2 = new Node(5, new AutonomousAction2()); - AddFirstNode(autonNode1); - autonNode1->AddNext(autonNode2); -} +// void Autonomous::AddNodes() { +// autonNode1 = new Node(5, new AutonomousAction1()); +// autonNode2 = new Node(5, new AutonomousAction2()); +// AddFirstNode(autonNode1); +// autonNode1->AddNext(autonNode2); +// } diff --git a/src/auto/Auton.h b/src/auto/Auton.h index 5efd415..badb38d 100644 --- a/src/auto/Auton.h +++ b/src/auto/Auton.h @@ -1,17 +1,17 @@ -#pragma once +// #pragma once -#include -#include -#include +// #include +// #include +// // #include "AutonActionTest.h" -using namespace CORE; -using namespace std; +// using namespace CORE; +// using namespace std; -class Autonomous: public COREAuton { -public: - Autonomous(); - void AddNodes() override; -private: - Node * autonNode1; - Node * autonNode2; -}; +// class Autonomous: public COREAuton { +// public: +// Autonomous(); +// void AddNodes() override; +// private: +// Node * autonNode1; +// Node * autonNode2; +// }; diff --git a/src/auto/AutonActionTest.cpp b/src/auto/AutonActionTest.cpp index 836d6be..d7b8bf9 100644 --- a/src/auto/AutonActionTest.cpp +++ b/src/auto/AutonActionTest.cpp @@ -1,5 +1,4 @@ #include "AutonActionTest.h" -#include "Robot.h" AutonomousAction1::AutonomousAction1() {} diff --git a/src/auto/AutonActionTest.h b/src/auto/AutonActionTest.h index 818d335..47cb6b8 100644 --- a/src/auto/AutonActionTest.h +++ b/src/auto/AutonActionTest.h @@ -1,6 +1,7 @@ #pragma once #include +#include "Robot.h" using namespace CORE; diff --git a/src/auto/DriveForwardAction.cpp b/src/auto/DriveForwardAction.cpp index 0289ace..37d6ca1 100644 --- a/src/auto/DriveForwardAction.cpp +++ b/src/auto/DriveForwardAction.cpp @@ -1,5 +1,4 @@ -#include -#include +#include "DriveForwardAction.h" DriveForwardAction::DriveForwardAction(driveForwardAction requestedDriveForwardAction) { m_driveForwardAction = requestedDriveForwardAction; diff --git a/src/auto/DriveForwardAction.h b/src/auto/DriveForwardAction.h index 2c2b950..a9f7339 100644 --- a/src/auto/DriveForwardAction.h +++ b/src/auto/DriveForwardAction.h @@ -1,7 +1,8 @@ #pragma once -#include #include +#include "DriveSubsystem.h" +#include "Robot.h" using namespace CORE; diff --git a/src/auto/IntakePowerCellsAction.cpp b/src/auto/IntakePowerCellsAction.cpp index 42c4880..e89d429 100644 --- a/src/auto/IntakePowerCellsAction.cpp +++ b/src/auto/IntakePowerCellsAction.cpp @@ -1,5 +1,4 @@ -#include -#include +#include "IntakePowerCellsAction.h" IntakePowerCellsAction::IntakePowerCellsAction(intakePowerCellsAction requestedIntakePowerCellAction) { m_intakePowerCellsAction = requestedIntakePowerCellAction; diff --git a/src/auto/IntakePowerCellsAction.h b/src/auto/IntakePowerCellsAction.h index 1edda7f..5ed1548 100644 --- a/src/auto/IntakePowerCellsAction.h +++ b/src/auto/IntakePowerCellsAction.h @@ -1,7 +1,8 @@ #pragma once -#include #include +#include "IntakeSubsystem.h" +#include "Robot.h" using namespace CORE; diff --git a/src/auto/LaunchBallsAction.cpp b/src/auto/LaunchBallsAction.cpp index 955737f..55df7e0 100644 --- a/src/auto/LaunchBallsAction.cpp +++ b/src/auto/LaunchBallsAction.cpp @@ -1,5 +1,4 @@ -#include "Robot.h" -#include +#include "LaunchBallsAction.h" LaunchBallsAction::LaunchBallsAction(launchBallsAction requestedLaunchBallsAction) { m_launchBallsAction = requestedLaunchBallsAction; @@ -22,5 +21,10 @@ CORE::COREAutonAction::actionStatus LaunchBallsAction::Action() { case LAUNCHER_OFF: // Robot::GetInstance()->launcherSubsystem. break; + return COREAutonAction::actionStatus::END; } -} \ No newline at end of file +} + +void LaunchBallsAction::ActionEnd() { + +} diff --git a/src/auto/LaunchBallsAction.h b/src/auto/LaunchBallsAction.h index 1b7da9e..5eb4416 100644 --- a/src/auto/LaunchBallsAction.h +++ b/src/auto/LaunchBallsAction.h @@ -1,7 +1,8 @@ #pragma once #include -#include +#include "LauncherSubsystem.h" +#include "Robot.h" using namespace CORE; From 351bd3278d1a5a4453652b53de467cfb21c1d18c Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sat, 15 Feb 2020 10:17:53 -0600 Subject: [PATCH 04/22] finished auton actions and fixed launcher --- src/LauncherSubsystem.cpp | 59 ++++++++-------------------------- src/LauncherSubsystem.h | 5 +-- src/auto/LaunchBallsAction.cpp | 10 +++--- 3 files changed, 22 insertions(+), 52 deletions(-) diff --git a/src/LauncherSubsystem.cpp b/src/LauncherSubsystem.cpp index 73f05af..e418006 100644 --- a/src/LauncherSubsystem.cpp +++ b/src/LauncherSubsystem.cpp @@ -2,66 +2,35 @@ using namespace CORE; -LauncherSubsystem::LauncherSubsystem() : m_topMotor(TOP_LAUNCHER_MOTOR_PORT), - m_bottomMotor(BOTTOM_LAUNCHER_MOTOR_PORT) { +LauncherSubsystem::LauncherSubsystem() : m_launcherMotor(BOTTOM_LAUNCHER_MOTOR_PORT) { } void LauncherSubsystem::robotInit() { - // Registers joystick axis and buttons, does inital setup for talons - // speed adustment code start #1 - operatorJoystick->RegisterButton(CORE::COREJoystick::JoystickButton::A_BUTTON); - operatorJoystick->RegisterButton(CORE::COREJoystick::JoystickButton::B_BUTTON); - operatorJoystick->RegisterButton(CORE::COREJoystick::JoystickButton::X_BUTTON); - operatorJoystick->RegisterButton(CORE::COREJoystick::JoystickButton::Y_BUTTON); - // speed adustment code end #1 operatorJoystick->RegisterButton(CORE::COREJoystick::JoystickButton::RIGHT_TRIGGER); } void LauncherSubsystem::teleopInit() { - m_topMotorSpeed = 0.50; - m_bottomMotorSpeed = 0.50; } void LauncherSubsystem::teleop() { - bool launcherOn = false; - // speed adustment code start #2 - bool m_yButtonPressed = operatorJoystick->GetRisingEdge(CORE::COREJoystick::JoystickButton::Y_BUTTON); - bool m_aButtonPressed = operatorJoystick->GetRisingEdge(CORE::COREJoystick::JoystickButton::A_BUTTON); - bool m_xButtonPressed = operatorJoystick->GetRisingEdge(CORE::COREJoystick::JoystickButton::X_BUTTON); - bool m_bButtonPressed = operatorJoystick->GetRisingEdge(CORE::COREJoystick::JoystickButton::B_BUTTON); - // speed adustment code end #2 + m_launcherOn = false; - if (!launcherOn && operatorJoystick->GetRisingEdge(CORE::COREJoystick::JoystickButton::RIGHT_TRIGGER)) { - launcherOn = true; - } else if (launcherOn && operatorJoystick->GetRisingEdge(CORE::COREJoystick::JoystickButton::RIGHT_TRIGGER)) { - launcherOn = false; + if (!m_launcherOn && operatorJoystick->GetRisingEdge(CORE::COREJoystick::JoystickButton::RIGHT_TRIGGER)) { + m_launcherOn = true; + } else if (m_launcherOn && operatorJoystick->GetRisingEdge(CORE::COREJoystick::JoystickButton::RIGHT_TRIGGER)) { + m_launcherOn = false; } - // speed adustment code start #3 - // Changes motor speeds - if (m_yButtonPressed && m_topMotorSpeed < 1) { - // Increases top motor speed by 1 percent - m_topMotorSpeed = m_topMotorSpeed + 0.05; - } else if (m_aButtonPressed && (m_topMotorSpeed > -1)) { - // Decreases top motor speed by 1 percent - m_topMotorSpeed = m_topMotorSpeed - 0.05; - } else if (m_xButtonPressed && (m_bottomMotorSpeed < 1)) { - // Increases top motor speed by 1 percent - m_bottomMotorSpeed = m_bottomMotorSpeed + 0.05; - } else if (m_bButtonPressed && (m_bottomMotorSpeed > -1)) { - // Decreases top motor speed by 1 percent - m_bottomMotorSpeed = m_bottomMotorSpeed - 0.05; - } - // speed adustment code end #3 + launcherOn(m_launcherOn); + + SmartDashboard::PutNumber("Motor Percent Speed", 0.38); +} - if (launcherOn) { - m_topMotor.Set(ControlMode::PercentOutput, m_topMotorSpeed); - m_bottomMotor.Set(ControlMode::PercentOutput, m_bottomMotorSpeed); +void LauncherSubsystem::launcherOn(bool m_launcherOn) { + if (m_launcherOn) { + m_launcherMotor.Set(ControlMode::PercentOutput, 0.38); } else { - m_topMotor.Set(ControlMode::PercentOutput, 0.0); - m_bottomMotor.Set(ControlMode::PercentOutput, 0.0); + m_launcherMotor.Set(ControlMode::PercentOutput, 0.0); } - SmartDashboard::PutNumber("Top Motor Percent Speed", m_topMotorSpeed); - SmartDashboard::PutNumber("Bottom Motor Percent Speed", m_bottomMotorSpeed); } diff --git a/src/LauncherSubsystem.h b/src/LauncherSubsystem.h index ecc260b..0b7f3d5 100644 --- a/src/LauncherSubsystem.h +++ b/src/LauncherSubsystem.h @@ -13,7 +13,8 @@ class LauncherSubsystem : public CORESubsystem { void robotInit() override; void teleopInit() override; void teleop() override; + void launcherOn(bool m_launcherOn); private: - TalonSRX m_topMotor, m_bottomMotor; - double m_topMotorSpeed, m_bottomMotorSpeed; + TalonSRX m_launcherMotor; + bool m_launcherOn; }; \ No newline at end of file diff --git a/src/auto/LaunchBallsAction.cpp b/src/auto/LaunchBallsAction.cpp index 55df7e0..150ae9e 100644 --- a/src/auto/LaunchBallsAction.cpp +++ b/src/auto/LaunchBallsAction.cpp @@ -10,20 +10,20 @@ void LaunchBallsAction::ActionInit() { CORE::COREAutonAction::actionStatus LaunchBallsAction::Action() { switch(m_launchBallsAction) { case LAUNCH_LOCATION_ONE: - // Robot::GetInstance()->launcherSubsystem. + Robot::GetInstance()->launcherSubsystem.launcherOn(true); break; case LAUNCH_LOCATION_TWO: - // Robot::GetInstance()->launcherSubsystem. + Robot::GetInstance()->launcherSubsystem.launcherOn(true); break; case LAUNCH_LOCATION_THREE: - // Robot::GetInstance()->launcherSubsystem. + Robot::GetInstance()->launcherSubsystem.launcherOn(true); break; case LAUNCHER_OFF: - // Robot::GetInstance()->launcherSubsystem. + Robot::GetInstance()->launcherSubsystem.launcherOn(false); break; return COREAutonAction::actionStatus::END; } -} +} void LaunchBallsAction::ActionEnd() { From cbe4ff24998e1bc8ef5b2d0ee28cdfc369340cf9 Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sat, 15 Feb 2020 10:27:52 -0600 Subject: [PATCH 05/22] Fixed warnings --- src/auto/DriveForwardAction.cpp | 2 +- src/auto/IntakePowerCellsAction.cpp | 2 +- src/auto/LaunchBallsAction.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/auto/DriveForwardAction.cpp b/src/auto/DriveForwardAction.cpp index 37d6ca1..6d4f47d 100644 --- a/src/auto/DriveForwardAction.cpp +++ b/src/auto/DriveForwardAction.cpp @@ -20,8 +20,8 @@ CORE::COREAutonAction::actionStatus DriveForwardAction::Action() { case STOP: Robot::GetInstance()->driveSubsystem.setMotorSpeed(0, DriveSide::BOTH); break; - return COREAutonAction::actionStatus::END; } + return COREAutonAction::actionStatus::END; } void DriveForwardAction::ActionEnd() { diff --git a/src/auto/IntakePowerCellsAction.cpp b/src/auto/IntakePowerCellsAction.cpp index e89d429..3d0b8c4 100644 --- a/src/auto/IntakePowerCellsAction.cpp +++ b/src/auto/IntakePowerCellsAction.cpp @@ -20,8 +20,8 @@ CORE::COREAutonAction::actionStatus IntakePowerCellsAction::Action() { case STOP: Robot::GetInstance()->intakeSubsystem.SetIntake(0); break; - return COREAutonAction::actionStatus::END; } + return COREAutonAction::actionStatus::END; } void IntakePowerCellsAction::ActionEnd() { diff --git a/src/auto/LaunchBallsAction.cpp b/src/auto/LaunchBallsAction.cpp index 150ae9e..614a804 100644 --- a/src/auto/LaunchBallsAction.cpp +++ b/src/auto/LaunchBallsAction.cpp @@ -21,8 +21,8 @@ CORE::COREAutonAction::actionStatus LaunchBallsAction::Action() { case LAUNCHER_OFF: Robot::GetInstance()->launcherSubsystem.launcherOn(false); break; - return COREAutonAction::actionStatus::END; } + return COREAutonAction::actionStatus::END; } void LaunchBallsAction::ActionEnd() { From 756362ee33b3686d8c167143135e54e32a677485 Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sat, 15 Feb 2020 15:17:06 -0600 Subject: [PATCH 06/22] worked on auton --- src/Robot.h | 2 +- src/auto/Auton.cpp | 10 ------- src/auto/Auton.h | 17 ----------- src/auto/ConveyorAction.cpp | 26 +++++++++++++++++ src/auto/ConveyorAction.h | 22 ++++++++++++++ src/auto/DriveAction.cpp | 26 +++++++++++++++++ .../{DriveForwardAction.h => DriveAction.h} | 11 ++++--- src/auto/DriveForwardAction.cpp | 29 ------------------- src/auto/DriveRoutine.cpp | 8 +++++ src/auto/DriveRoutine.h | 17 +++++++++++ src/auto/ThreeBallRoutine.cpp | 10 +++++++ src/auto/ThreeBallRoutine.h | 17 +++++++++++ 12 files changed, 132 insertions(+), 63 deletions(-) delete mode 100644 src/auto/Auton.cpp delete mode 100644 src/auto/Auton.h create mode 100644 src/auto/ConveyorAction.cpp create mode 100644 src/auto/ConveyorAction.h create mode 100644 src/auto/DriveAction.cpp rename src/auto/{DriveForwardAction.h => DriveAction.h} (55%) delete mode 100644 src/auto/DriveForwardAction.cpp create mode 100644 src/auto/DriveRoutine.cpp create mode 100644 src/auto/DriveRoutine.h create mode 100644 src/auto/ThreeBallRoutine.cpp create mode 100644 src/auto/ThreeBallRoutine.h diff --git a/src/Robot.h b/src/Robot.h index 63ad39f..4841c6c 100644 --- a/src/Robot.h +++ b/src/Robot.h @@ -6,7 +6,6 @@ #include #include #include -#include "Auton.h" #include "ClimberSubsystem.h" #include "ControlPanelSubsystem.h" #include "ConveyorSubsystem.h" @@ -32,6 +31,7 @@ class Robot : public CORERobot { LauncherSubsystem launcherSubsystem; IntakeSubsystem intakeSubsystem; TurretSubsystem turretSubsystem; + ConveyorSubsystem conveyorSubsystem; // Autonomous controlledAutonomous; private: diff --git a/src/auto/Auton.cpp b/src/auto/Auton.cpp deleted file mode 100644 index 77f4679..0000000 --- a/src/auto/Auton.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// #include "Auton.h" - -// Autonomous::Autonomous() : COREAuton("Test Auto") {} - -// void Autonomous::AddNodes() { -// autonNode1 = new Node(5, new AutonomousAction1()); -// autonNode2 = new Node(5, new AutonomousAction2()); -// AddFirstNode(autonNode1); -// autonNode1->AddNext(autonNode2); -// } diff --git a/src/auto/Auton.h b/src/auto/Auton.h deleted file mode 100644 index badb38d..0000000 --- a/src/auto/Auton.h +++ /dev/null @@ -1,17 +0,0 @@ -// #pragma once - -// #include -// #include -// // #include "AutonActionTest.h" - -// using namespace CORE; -// using namespace std; - -// class Autonomous: public COREAuton { -// public: -// Autonomous(); -// void AddNodes() override; -// private: -// Node * autonNode1; -// Node * autonNode2; -// }; diff --git a/src/auto/ConveyorAction.cpp b/src/auto/ConveyorAction.cpp new file mode 100644 index 0000000..54d8203 --- /dev/null +++ b/src/auto/ConveyorAction.cpp @@ -0,0 +1,26 @@ +#include "ConveyorAction.h" + +ConveyorAction::ConveyorAction(conveyorAction requestedConveyorAction) { + m_conveyorAction = requestedConveyorAction; + +} + +void ConveyorAction::ActionInit() { + +} + +CORE::COREAutonAction::actionStatus ConveyorAction::Action() { + switch(m_conveyorAction) { + case CONVEYOR_ON: + Robot::GetInstance()->conveyorSubsystem.setMotor(0.25); + break; + case CONVEYOR_OFF: + Robot::GetInstance()->conveyorSubsystem.setMotor(0); + break; + } + return COREAutonAction::actionStatus::END; +} + +void ConveyorAction::ActionEnd() { + +} \ No newline at end of file diff --git a/src/auto/ConveyorAction.h b/src/auto/ConveyorAction.h new file mode 100644 index 0000000..4056591 --- /dev/null +++ b/src/auto/ConveyorAction.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include "ConveyorSubsystem.h" +#include "Robot.h" + +using namespace CORE; + +enum conveyorAction { + CONVEYOR_ON, + CONVEYOR_OFF +}; + +class ConveyorAction : public COREAutonAction { +public: + ConveyorAction(conveyorAction requestedConveyorAction); + void ActionInit() override; + CORE::COREAutonAction::actionStatus Action() override; + void ActionEnd() override; +private: + conveyorAction m_conveyorAction; +}; diff --git a/src/auto/DriveAction.cpp b/src/auto/DriveAction.cpp new file mode 100644 index 0000000..030c72e --- /dev/null +++ b/src/auto/DriveAction.cpp @@ -0,0 +1,26 @@ +#include "DriveAction.h" + +DriveAction::DriveAction(driveAction requestedDriveAction) { + m_driveAction = requestedDriveAction; + +} + +void DriveAction::ActionInit() { + +} + +CORE::COREAutonAction::actionStatus DriveAction::Action() { + switch(m_driveAction) { + case FORWARD: + Robot::GetInstance()->driveSubsystem.setMotorSpeed(0.5, DriveSide::BOTH); + break; + case BACKWARD: + Robot::GetInstance()->driveSubsystem.setMotorSpeed(-0.5, DriveSide::BOTH); + break; + } + return COREAutonAction::actionStatus::END; +} + +void DriveAction::ActionEnd() { + +} \ No newline at end of file diff --git a/src/auto/DriveForwardAction.h b/src/auto/DriveAction.h similarity index 55% rename from src/auto/DriveForwardAction.h rename to src/auto/DriveAction.h index a9f7339..0f5e594 100644 --- a/src/auto/DriveForwardAction.h +++ b/src/auto/DriveAction.h @@ -6,18 +6,17 @@ using namespace CORE; -enum driveForwardAction { +enum driveAction { FORWARD, - BACKWARD, - STOP + BACKWARD }; -class DriveForwardAction : public COREAutonAction { +class DriveAction : public COREAutonAction { public: - DriveForwardAction(driveForwardAction requestedDriveForwardAction); + DriveAction(driveAction requestedDriveAction); void ActionInit() override; CORE::COREAutonAction::actionStatus Action() override; void ActionEnd() override; private: - driveForwardAction m_driveForwardAction; + driveAction m_driveAction; }; diff --git a/src/auto/DriveForwardAction.cpp b/src/auto/DriveForwardAction.cpp deleted file mode 100644 index 6d4f47d..0000000 --- a/src/auto/DriveForwardAction.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "DriveForwardAction.h" - -DriveForwardAction::DriveForwardAction(driveForwardAction requestedDriveForwardAction) { - m_driveForwardAction = requestedDriveForwardAction; - -} - -void DriveForwardAction::ActionInit() { - -} - -CORE::COREAutonAction::actionStatus DriveForwardAction::Action() { - switch(m_driveForwardAction) { - case FORWARD: - Robot::GetInstance()->driveSubsystem.setMotorSpeed(0.5, DriveSide::BOTH); - break; - case BACKWARD: - Robot::GetInstance()->driveSubsystem.setMotorSpeed(-0.5, DriveSide::BOTH); - break; - case STOP: - Robot::GetInstance()->driveSubsystem.setMotorSpeed(0, DriveSide::BOTH); - break; - } - return COREAutonAction::actionStatus::END; -} - -void DriveForwardAction::ActionEnd() { - -} \ No newline at end of file diff --git a/src/auto/DriveRoutine.cpp b/src/auto/DriveRoutine.cpp new file mode 100644 index 0000000..176c9b7 --- /dev/null +++ b/src/auto/DriveRoutine.cpp @@ -0,0 +1,8 @@ +#include "DriveRoutine.h" + +DriveRoutine::DriveRoutine() : COREAuton("Drive Routine") {} + +void DriveRoutine::AddNodes() { + driveNode = new Node(5, new DriveAction()); + AddFirstNode(driveNode); +} diff --git a/src/auto/DriveRoutine.h b/src/auto/DriveRoutine.h new file mode 100644 index 0000000..e9f2caf --- /dev/null +++ b/src/auto/DriveRoutine.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include +#include "DriveAction.h" +// #include "AutonActionTest.h" + +using namespace CORE; +using namespace std; + +class DriveRoutine: public COREAuton { +public: + DriveRoutine(); + void AddNodes() override; +private: + Node * driveNode; +}; diff --git a/src/auto/ThreeBallRoutine.cpp b/src/auto/ThreeBallRoutine.cpp new file mode 100644 index 0000000..4c45961 --- /dev/null +++ b/src/auto/ThreeBallRoutine.cpp @@ -0,0 +1,10 @@ +#include "ThreeBallRoutine.h" + +ThreeBallRoutine::ThreeBallRoutine() : COREAuton("Three Ball Routine") {} + +void ThreeBallRoutine::AddNodes() { + conveyorOnNode = new Node(5, new ()); + autonNode2 = new Node(5, new AutonomousAction2()); + AddFirstNode(autonNode1); + autonNode1->AddNext(autonNode2); +} diff --git a/src/auto/ThreeBallRoutine.h b/src/auto/ThreeBallRoutine.h new file mode 100644 index 0000000..bf2c2e1 --- /dev/null +++ b/src/auto/ThreeBallRoutine.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include +#include "LaunchBallsAction.h" +// #include "AutonActionTest.h" + +using namespace CORE; +using namespace std; + +class ThreeBallRoutine: public COREAuton { +public: + ThreeBallRoutine(); + void AddNodes() override; +private: + Node * threeBallNode; +}; From bb81c80baa75cd49029114cd7d631ea9b1d8d432 Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Thu, 27 Feb 2020 19:15:38 -0600 Subject: [PATCH 07/22] made auton actions and routines --- build.gradle | 2 +- src/auto/AutonActionTest.cpp | 8 ++++++++ src/auto/AutonActionTest.h | 20 +++++++++++++++++++ src/auto/DelayAction.cpp | 17 ++++++++++++++++ src/auto/DelayAction.h | 17 ++++++++++++++++ src/auto/DriveRoutine.cpp | 2 +- src/auto/LaunchBallsAction.cpp | 8 +------- src/auto/LaunchBallsAction.h | 4 +--- src/auto/ThreeBallRoutine.cpp | 12 ++++++++---- src/auto/ThreeBallRoutine.h | 8 +++++++- src/auto/ThreeBallRoutinePickup.cpp | 16 +++++++++++++++ src/auto/ThreeBallRoutinePickup.h | 25 ++++++++++++++++++++++++ vendordeps/Phoenix.json | 30 ++++++++++++++--------------- vendordeps/REVColorSensorV3.json | 6 +++--- vendordeps/navx_frc.json | 9 +++++---- 15 files changed, 145 insertions(+), 39 deletions(-) create mode 100644 src/auto/AutonActionTest.cpp create mode 100644 src/auto/AutonActionTest.h create mode 100644 src/auto/DelayAction.cpp create mode 100644 src/auto/DelayAction.h create mode 100644 src/auto/ThreeBallRoutinePickup.cpp create mode 100644 src/auto/ThreeBallRoutinePickup.h diff --git a/build.gradle b/build.gradle index 45668bb..2808a61 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { id "cpp" id "google-test-test-suite" - id "edu.wpi.first.GradleRIO" version "2020.1.2" + id "edu.wpi.first.GradleRIO" version "2020.3.2" } // Define my targets (RoboRIO) and artifacts (deployable files) diff --git a/src/auto/AutonActionTest.cpp b/src/auto/AutonActionTest.cpp new file mode 100644 index 0000000..aa67fec --- /dev/null +++ b/src/auto/AutonActionTest.cpp @@ -0,0 +1,8 @@ +#include "AutonActionTest.h" + +TestRoutine::TestRoutine() : COREAuton("Drive Routine") {} + +void TestRoutine::AddNodes() { + testNode = new Node(5, new DriveAction(FORWARD)); + AddFirstNode(testNode); +} diff --git a/src/auto/AutonActionTest.h b/src/auto/AutonActionTest.h new file mode 100644 index 0000000..0410153 --- /dev/null +++ b/src/auto/AutonActionTest.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include +#include "DriveAction.h" +#include "IntakePowerCellsAction.h" +#include "LaunchBallsAction.h" +#include "ConveyorAction.h" +// #include "AutonActionTest.h" + +using namespace CORE; +using namespace std; + +class TestRoutine: public COREAuton { +public: + TestRoutine(); + void AddNodes() override; +private: + Node * testNode; +}; diff --git a/src/auto/DelayAction.cpp b/src/auto/DelayAction.cpp new file mode 100644 index 0000000..b596d7d --- /dev/null +++ b/src/auto/DelayAction.cpp @@ -0,0 +1,17 @@ +#include "DelayAction.h" + +DelayAction::DelayAction() { + +} + +void DelayAction::ActionInit() { +} + +CORE::COREAutonAction::actionStatus DelayAction::Action() { + + return COREAutonAction::actionStatus::CONTINUE; +} + +void DelayAction::ActionEnd() { + +} diff --git a/src/auto/DelayAction.h b/src/auto/DelayAction.h new file mode 100644 index 0000000..11d8354 --- /dev/null +++ b/src/auto/DelayAction.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include "LauncherSubsystem.h" +#include "Robot.h" + +using namespace CORE; + +class DelayAction : public COREAutonAction { +public: + DelayAction(); + void ActionInit() override; + CORE::COREAutonAction::actionStatus Action() override; + void ActionEnd() override; +private: + +}; \ No newline at end of file diff --git a/src/auto/DriveRoutine.cpp b/src/auto/DriveRoutine.cpp index 176c9b7..5f37b6d 100644 --- a/src/auto/DriveRoutine.cpp +++ b/src/auto/DriveRoutine.cpp @@ -3,6 +3,6 @@ DriveRoutine::DriveRoutine() : COREAuton("Drive Routine") {} void DriveRoutine::AddNodes() { - driveNode = new Node(5, new DriveAction()); + driveNode = new Node(5, new DriveAction(FORWARD)); AddFirstNode(driveNode); } diff --git a/src/auto/LaunchBallsAction.cpp b/src/auto/LaunchBallsAction.cpp index 614a804..eae3707 100644 --- a/src/auto/LaunchBallsAction.cpp +++ b/src/auto/LaunchBallsAction.cpp @@ -9,13 +9,7 @@ void LaunchBallsAction::ActionInit() { CORE::COREAutonAction::actionStatus LaunchBallsAction::Action() { switch(m_launchBallsAction) { - case LAUNCH_LOCATION_ONE: - Robot::GetInstance()->launcherSubsystem.launcherOn(true); - break; - case LAUNCH_LOCATION_TWO: - Robot::GetInstance()->launcherSubsystem.launcherOn(true); - break; - case LAUNCH_LOCATION_THREE: + case LAUNCHER_ON: Robot::GetInstance()->launcherSubsystem.launcherOn(true); break; case LAUNCHER_OFF: diff --git a/src/auto/LaunchBallsAction.h b/src/auto/LaunchBallsAction.h index 5eb4416..0273922 100644 --- a/src/auto/LaunchBallsAction.h +++ b/src/auto/LaunchBallsAction.h @@ -7,9 +7,7 @@ using namespace CORE; enum launchBallsAction { - LAUNCH_LOCATION_ONE, - LAUNCH_LOCATION_TWO, - LAUNCH_LOCATION_THREE, + LAUNCHER_ON, LAUNCHER_OFF }; diff --git a/src/auto/ThreeBallRoutine.cpp b/src/auto/ThreeBallRoutine.cpp index 4c45961..fd298ba 100644 --- a/src/auto/ThreeBallRoutine.cpp +++ b/src/auto/ThreeBallRoutine.cpp @@ -3,8 +3,12 @@ ThreeBallRoutine::ThreeBallRoutine() : COREAuton("Three Ball Routine") {} void ThreeBallRoutine::AddNodes() { - conveyorOnNode = new Node(5, new ()); - autonNode2 = new Node(5, new AutonomousAction2()); - AddFirstNode(autonNode1); - autonNode1->AddNext(autonNode2); + delayNode = new Node(5, new DelayAction()); + launcherOnNode = new Node(5, new LaunchBallsAction(LAUNCHER_ON)); + conveyorOnNode = new Node(5, new ConveyorAction(CONVEYOR_ON)); + driveNode = new Node(5, new DriveAction(FORWARD)); + AddFirstNode(delayNode); + delayNode->AddNext(launcherOnNode); + launcherOnNode->AddNext(conveyorOnNode); + conveyorOnNode->AddNext(driveNode); } diff --git a/src/auto/ThreeBallRoutine.h b/src/auto/ThreeBallRoutine.h index bf2c2e1..dea4355 100644 --- a/src/auto/ThreeBallRoutine.h +++ b/src/auto/ThreeBallRoutine.h @@ -3,6 +3,9 @@ #include #include #include "LaunchBallsAction.h" +#include "ConveyorAction.h" +#include "DriveAction.h" +#include "DelayAction.h" // #include "AutonActionTest.h" using namespace CORE; @@ -13,5 +16,8 @@ class ThreeBallRoutine: public COREAuton { ThreeBallRoutine(); void AddNodes() override; private: - Node * threeBallNode; + Node * delayNode; + Node * launcherOnNode; + Node * conveyorOnNode; + Node * driveNode; }; diff --git a/src/auto/ThreeBallRoutinePickup.cpp b/src/auto/ThreeBallRoutinePickup.cpp new file mode 100644 index 0000000..501ae08 --- /dev/null +++ b/src/auto/ThreeBallRoutinePickup.cpp @@ -0,0 +1,16 @@ +#include "ThreeBallRoutinePickup.h" + +ThreeBallRoutinePickup::ThreeBallRoutinePickup() : COREAuton("Three Ball Routine") {} + +void ThreeBallRoutinePickup::AddNodes() { + delayNode = new Node(5, new DelayAction()); + launcherOnNode = new Node(5, new LaunchBallsAction(LAUNCHER_ON)); + conveyorOnNode = new Node(5, new ConveyorAction(CONVEYOR_ON)); + intakeOnNode = new Node(5, new IntakePowerCellsAction(INTAKE)); + driveNode = new Node(5, new DriveAction(FORWARD)); //replace with pathfinder + AddFirstNode(delayNode); + delayNode->AddNext(launcherOnNode); + launcherOnNode->AddNext(conveyorOnNode); + conveyorOnNode->AddNext(intakeOnNode); + intakeOnNode->AddNext(driveNode); +} diff --git a/src/auto/ThreeBallRoutinePickup.h b/src/auto/ThreeBallRoutinePickup.h new file mode 100644 index 0000000..2ff5b62 --- /dev/null +++ b/src/auto/ThreeBallRoutinePickup.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include +#include "LaunchBallsAction.h" +#include "ConveyorAction.h" +#include "DriveAction.h" +#include "DelayAction.h" +#include "IntakePowerCellsAction.h" +// #include "AutonActionTest.h" + +using namespace CORE; +using namespace std; + +class ThreeBallRoutinePickup: public COREAuton { +public: + ThreeBallRoutinePickup(); + void AddNodes() override; +private: + Node * delayNode; + Node * launcherOnNode; + Node * conveyorOnNode; + Node * intakeOnNode; + Node * driveNode; +}; diff --git a/vendordeps/Phoenix.json b/vendordeps/Phoenix.json index f8d42a4..aa5554e 100644 --- a/vendordeps/Phoenix.json +++ b/vendordeps/Phoenix.json @@ -1,7 +1,7 @@ { "fileName": "Phoenix.json", "name": "CTRE-Phoenix", - "version": "5.17.3", + "version": "5.18.2", "uuid": "ab676553-b602-441f-a38d-f1296eff6537", "mavenUrls": [ "http://devsite.ctr-electronics.com/maven/release/" @@ -11,19 +11,19 @@ { "groupId": "com.ctre.phoenix", "artifactId": "api-java", - "version": "5.17.3" + "version": "5.18.2" }, { "groupId": "com.ctre.phoenix", "artifactId": "wpiapi-java", - "version": "5.17.3" + "version": "5.18.2" } ], "jniDependencies": [ { "groupId": "com.ctre.phoenix", "artifactId": "cci", - "version": "5.17.3", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -35,7 +35,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "diagnostics", - "version": "5.17.3", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -47,7 +47,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "canutils", - "version": "5.17.3", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -58,7 +58,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "platform-stub", - "version": "5.17.3", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -69,7 +69,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "core", - "version": "5.17.3", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -83,7 +83,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "wpiapi-cpp", - "version": "5.17.3", + "version": "5.18.2", "libName": "CTRE_Phoenix_WPI", "headerClassifier": "headers", "sharedLibrary": false, @@ -97,7 +97,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "api-cpp", - "version": "5.17.3", + "version": "5.18.2", "libName": "CTRE_Phoenix", "headerClassifier": "headers", "sharedLibrary": false, @@ -111,7 +111,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "cci", - "version": "5.17.3", + "version": "5.18.2", "libName": "CTRE_PhoenixCCI", "headerClassifier": "headers", "sharedLibrary": false, @@ -125,7 +125,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "diagnostics", - "version": "5.17.3", + "version": "5.18.2", "libName": "CTRE_PhoenixDiagnostics", "headerClassifier": "headers", "sharedLibrary": false, @@ -139,7 +139,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "canutils", - "version": "5.17.3", + "version": "5.18.2", "libName": "CTRE_PhoenixCanutils", "headerClassifier": "headers", "sharedLibrary": false, @@ -152,7 +152,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "platform-stub", - "version": "5.17.3", + "version": "5.18.2", "libName": "CTRE_PhoenixPlatform", "headerClassifier": "headers", "sharedLibrary": false, @@ -165,7 +165,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "core", - "version": "5.17.3", + "version": "5.18.2", "libName": "CTRE_PhoenixCore", "headerClassifier": "headers", "sharedLibrary": false, diff --git a/vendordeps/REVColorSensorV3.json b/vendordeps/REVColorSensorV3.json index 3940c21..9601ef8 100644 --- a/vendordeps/REVColorSensorV3.json +++ b/vendordeps/REVColorSensorV3.json @@ -1,7 +1,7 @@ { "fileName": "REVColorSensorV3.json", "name": "REVColorSensorV3", - "version": "1.0.1", + "version": "1.2.0", "uuid": "cda7b4b1-d003-44ac-a1ef-485c1347059a", "mavenUrls": [ "http://www.revrobotics.com/content/sw/color-sensor-v3/sdk/maven/" @@ -11,7 +11,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "ColorSensorV3-java", - "version": "1.0.1" + "version": "1.2.0" } ], "jniDependencies": [], @@ -19,7 +19,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "ColorSensorV3-cpp", - "version": "1.0.1", + "version": "1.2.0", "libName": "ColorSensorV3", "headerClassifier": "headers", "sourcesClassifier": "source", diff --git a/vendordeps/navx_frc.json b/vendordeps/navx_frc.json index 82810d3..b3119a9 100644 --- a/vendordeps/navx_frc.json +++ b/vendordeps/navx_frc.json @@ -1,7 +1,7 @@ { "fileName": "navx_frc.json", "name": "KauaiLabs_navX_FRC", - "version": "3.1.400", + "version": "3.1.409", "uuid": "cb311d09-36e9-4143-a032-55bb2b94443b", "mavenUrls": [ "https://repo1.maven.org/maven2/" @@ -11,7 +11,7 @@ { "groupId": "com.kauailabs.navx.frc", "artifactId": "navx-java", - "version": "3.1.400" + "version": "3.1.409" } ], "jniDependencies": [], @@ -19,7 +19,7 @@ { "groupId": "com.kauailabs.navx.frc", "artifactId": "navx-cpp", - "version": "3.1.400", + "version": "3.1.409", "headerClassifier": "headers", "sourcesClassifier": "sources", "sharedLibrary": false, @@ -27,7 +27,8 @@ "skipInvalidPlatforms": true, "binaryPlatforms": [ "linuxathena", - "linuxraspbian" + "linuxraspbian", + "windowsx86-64" ] } ] From d59ed0a15bb8893b71801757eff0ba11e8147c27 Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Thu, 27 Feb 2020 20:42:08 -0600 Subject: [PATCH 08/22] fix error in conveyor and got ready for testing --- src/auto/AutonActionTest.cpp | 4 +++- src/auto/AutonActionTest.h | 1 + src/auto/ConveyorAction.cpp | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/auto/AutonActionTest.cpp b/src/auto/AutonActionTest.cpp index aa67fec..eab81c6 100644 --- a/src/auto/AutonActionTest.cpp +++ b/src/auto/AutonActionTest.cpp @@ -3,6 +3,8 @@ TestRoutine::TestRoutine() : COREAuton("Drive Routine") {} void TestRoutine::AddNodes() { - testNode = new Node(5, new DriveAction(FORWARD)); + testNode = new Node(5, new IntakePowerCellsAction(INTAKE)); + testNode2 = new Node(5, new IntakePowerCellsAction(STOP)); AddFirstNode(testNode); + testNode->AddNext(testNode2); } diff --git a/src/auto/AutonActionTest.h b/src/auto/AutonActionTest.h index 0410153..9f792b0 100644 --- a/src/auto/AutonActionTest.h +++ b/src/auto/AutonActionTest.h @@ -17,4 +17,5 @@ class TestRoutine: public COREAuton { void AddNodes() override; private: Node * testNode; + Node * testNode2; }; diff --git a/src/auto/ConveyorAction.cpp b/src/auto/ConveyorAction.cpp index 54d8203..efa4170 100644 --- a/src/auto/ConveyorAction.cpp +++ b/src/auto/ConveyorAction.cpp @@ -12,10 +12,10 @@ void ConveyorAction::ActionInit() { CORE::COREAutonAction::actionStatus ConveyorAction::Action() { switch(m_conveyorAction) { case CONVEYOR_ON: - Robot::GetInstance()->conveyorSubsystem.setMotor(0.25); + Robot::GetInstance()->conveyorSubsystem.setMotor(0.25, 0.25); break; case CONVEYOR_OFF: - Robot::GetInstance()->conveyorSubsystem.setMotor(0); + Robot::GetInstance()->conveyorSubsystem.setMotor(0, 0); break; } return COREAutonAction::actionStatus::END; From 077a844162dd869396a65b559c71a7e955ff6c19 Mon Sep 17 00:00:00 2001 From: James M Bizub III Date: Fri, 28 Feb 2020 11:54:05 -0600 Subject: [PATCH 09/22] modified auton test to have a delay between toggle --- src/auto/AutonActionTest.cpp | 6 ++++-- src/auto/AutonActionTest.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/auto/AutonActionTest.cpp b/src/auto/AutonActionTest.cpp index eab81c6..2db9f39 100644 --- a/src/auto/AutonActionTest.cpp +++ b/src/auto/AutonActionTest.cpp @@ -4,7 +4,9 @@ TestRoutine::TestRoutine() : COREAuton("Drive Routine") {} void TestRoutine::AddNodes() { testNode = new Node(5, new IntakePowerCellsAction(INTAKE)); + delayNode = new Node(3, new DelayAction()); testNode2 = new Node(5, new IntakePowerCellsAction(STOP)); AddFirstNode(testNode); - testNode->AddNext(testNode2); -} + testNode->AddNext(delayNode); + delayNode->AddNext(testNode2); +} \ No newline at end of file diff --git a/src/auto/AutonActionTest.h b/src/auto/AutonActionTest.h index 9f792b0..03f3fe3 100644 --- a/src/auto/AutonActionTest.h +++ b/src/auto/AutonActionTest.h @@ -6,6 +6,7 @@ #include "IntakePowerCellsAction.h" #include "LaunchBallsAction.h" #include "ConveyorAction.h" +#include "DelayAction.h" // #include "AutonActionTest.h" using namespace CORE; @@ -17,5 +18,6 @@ class TestRoutine: public COREAuton { void AddNodes() override; private: Node * testNode; + node * delaynode; Node * testNode2; }; From 89d644b5e7558527d4702545e523ee3541e74033 Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sat, 29 Feb 2020 09:44:52 -0600 Subject: [PATCH 10/22] setup movement in drive action --- src/DriveSubsystem.cpp | 4 ++++ src/DriveSubsystem.h | 3 ++- src/auto/AutonActionTest.h | 2 +- src/auto/DriveAction.cpp | 17 +++++++++++++---- src/auto/DriveAction.h | 2 ++ 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/DriveSubsystem.cpp b/src/DriveSubsystem.cpp index 6f235ac..9c719f4 100644 --- a/src/DriveSubsystem.cpp +++ b/src/DriveSubsystem.cpp @@ -66,6 +66,10 @@ void DriveSubsystem::setMotorSpeed(double leftPercent, double rightPercent) { setMotorSpeed(rightPercent, DriveSide::RIGHT); } +double DriveSubsystem::getRobotPosition(){ + return m_leftMaster.GetSelectedSensorPosition(); +} + void DriveSubsystem::initTalons() { // Sets up talons m_leftMaster.Set(ControlMode::PercentOutput, 0); diff --git a/src/DriveSubsystem.h b/src/DriveSubsystem.h index 53d9d39..b2f8ff1 100644 --- a/src/DriveSubsystem.h +++ b/src/DriveSubsystem.h @@ -21,7 +21,8 @@ class DriveSubsystem : public CORESubsystem { void teleopInit() override; void teleop() override; void teleopEnd() override; - + + double getRobotPosition(); void initTalons(); void setMotorSpeed(double speedInFraction, DriveSide whichSide); void setMotorSpeed(double leftPercent, double rightPercent); diff --git a/src/auto/AutonActionTest.h b/src/auto/AutonActionTest.h index 03f3fe3..e8e7d4f 100644 --- a/src/auto/AutonActionTest.h +++ b/src/auto/AutonActionTest.h @@ -18,6 +18,6 @@ class TestRoutine: public COREAuton { void AddNodes() override; private: Node * testNode; - node * delaynode; + Node * delayNode; Node * testNode2; }; diff --git a/src/auto/DriveAction.cpp b/src/auto/DriveAction.cpp index 030c72e..746a9f7 100644 --- a/src/auto/DriveAction.cpp +++ b/src/auto/DriveAction.cpp @@ -1,21 +1,30 @@ #include "DriveAction.h" -DriveAction::DriveAction(driveAction requestedDriveAction) { +DriveAction::DriveAction(driveAction requestedDriveAction): + m_distAutonMoveEncoderTicks("Auton Movement", 6000) { m_driveAction = requestedDriveAction; } void DriveAction::ActionInit() { - + DriveSubsystem* driveSubsystem = &Robot::GetInstance()->driveSubsystem; + m_encoderStartUpPosition = driveSubsystem->getRobotPosition(); } CORE::COREAutonAction::actionStatus DriveAction::Action() { + DriveSubsystem* driveSubsystem = &Robot::GetInstance()->driveSubsystem; + double encoderValue = driveSubsystem->getRobotPosition(); switch(m_driveAction) { case FORWARD: - Robot::GetInstance()->driveSubsystem.setMotorSpeed(0.5, DriveSide::BOTH); + // Robot::GetInstance()->driveSubsystem.setMotorSpeed(0.5, DriveSide::BOTH); + if(encoderValue < m_distAutonMoveEncoderTicks.Get() + m_encoderStartUpPosition){ + driveSubsystem->setMotorSpeed(0.5, DriveSide::BOTH); + } break; case BACKWARD: - Robot::GetInstance()->driveSubsystem.setMotorSpeed(-0.5, DriveSide::BOTH); + if(encoderValue < m_distAutonMoveEncoderTicks.Get() + m_encoderStartUpPosition){ + driveSubsystem->setMotorSpeed(-0.5, DriveSide::BOTH); + } break; } return COREAutonAction::actionStatus::END; diff --git a/src/auto/DriveAction.h b/src/auto/DriveAction.h index 0f5e594..d0f7721 100644 --- a/src/auto/DriveAction.h +++ b/src/auto/DriveAction.h @@ -19,4 +19,6 @@ class DriveAction : public COREAutonAction { void ActionEnd() override; private: driveAction m_driveAction; + double m_encoderStartUpPosition; + COREConstant m_distAutonMoveEncoderTicks; }; From a70947d231383dddcd6612236d7f7ac02b354cb6 Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sat, 29 Feb 2020 09:54:35 -0600 Subject: [PATCH 11/22] fixed drive action to be able to stop --- src/auto/DriveAction.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/auto/DriveAction.cpp b/src/auto/DriveAction.cpp index 746a9f7..3263086 100644 --- a/src/auto/DriveAction.cpp +++ b/src/auto/DriveAction.cpp @@ -19,11 +19,17 @@ CORE::COREAutonAction::actionStatus DriveAction::Action() { // Robot::GetInstance()->driveSubsystem.setMotorSpeed(0.5, DriveSide::BOTH); if(encoderValue < m_distAutonMoveEncoderTicks.Get() + m_encoderStartUpPosition){ driveSubsystem->setMotorSpeed(0.5, DriveSide::BOTH); + return COREAutonAction::actionStatus::CONTINUE; + } else{ + driveSubsystem->setMotorSpeed(0.0, DriveSide::BOTH); } break; case BACKWARD: - if(encoderValue < m_distAutonMoveEncoderTicks.Get() + m_encoderStartUpPosition){ + if(encoderValue > m_encoderStartUpPosition - m_distAutonMoveEncoderTicks.Get()){ driveSubsystem->setMotorSpeed(-0.5, DriveSide::BOTH); + return COREAutonAction::actionStatus::CONTINUE; + } else{ + driveSubsystem->setMotorSpeed(0.0, DriveSide::BOTH); } break; } From 6bfe7cf163ecc34d0a57bb7c2581fa8a184fb19d Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sat, 29 Feb 2020 11:44:48 -0600 Subject: [PATCH 12/22] made a five ball auton --- src/auto/FiveBallRoutine.cpp | 20 ++++++++++++++++++++ src/auto/FiveBallRoutine.h | 26 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/auto/FiveBallRoutine.cpp create mode 100644 src/auto/FiveBallRoutine.h diff --git a/src/auto/FiveBallRoutine.cpp b/src/auto/FiveBallRoutine.cpp new file mode 100644 index 0000000..5d698e4 --- /dev/null +++ b/src/auto/FiveBallRoutine.cpp @@ -0,0 +1,20 @@ +#include "FiveBallRoutine.h" + +FiveBallRoutinePickup::FiveBallRoutine() : COREAuton("Three Ball Routine") {} + +void FiveBallRoutinePickup::AddNodes() { + delayNode = new Node(5, new DelayAction()); + launcherOnNode = new Node(5, new LaunchBallsAction(LAUNCHER_ON)); + intakeOnNode = new Node(5, new IntakePowerCellsAction(INTAKE)); + driveNode1 = new Node(5, new DriveAction(BACKWARD)); //replace with pathfinder + driveNode2 = new Node(5, new DriveAction(FORWARD)); //replace with pathfinder + conveyorOnNode = new Node(5, new ConveyorAction(CONVEYOR_ON)); + AddFirstNode(delayNode); + delayNode->AddNext(launcherOnNode); + launcherOnNode->AddNext(intakeOnNode); + intakeOnNode->AddNext(driveNode1); + driveNode1->AddNext(driveNode2); + driveNode2->AddNext(conveyorOnNode); + conveyorOnNode->AddNext(intakeOnNode); + intakeOnNode->AddNext(driveNode1); +} diff --git a/src/auto/FiveBallRoutine.h b/src/auto/FiveBallRoutine.h new file mode 100644 index 0000000..d37d828 --- /dev/null +++ b/src/auto/FiveBallRoutine.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include +#include "LaunchBallsAction.h" +#include "ConveyorAction.h" +#include "DriveAction.h" +#include "DelayAction.h" +#include "IntakePowerCellsAction.h" +// #include "AutonActionTest.h" + +using namespace CORE; +using namespace std; + +class FiveBallRoutinePickup: public COREAuton { +public: + FiveBallRoutinePickup(); + void AddNodes() override; +private: + Node * delayNode; + Node * launcherOnNode; + Node * conveyorOnNode; + Node * intakeOnNode; + Node * driveNode1; + Node * driveNode2; +}; From a71b8773f16a20ef9f8ab0cd26cb329922a9ae8c Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sun, 1 Mar 2020 13:22:47 -0600 Subject: [PATCH 13/22] finished test routine config --- src/Robot.h | 2 ++ src/auto/ConveyorAction.cpp | 1 + src/auto/ConveyorAction.h | 1 - src/auto/DelayAction.cpp | 1 + src/auto/DelayAction.h | 1 - src/auto/DriveAction.cpp | 1 + src/auto/DriveAction.h | 1 - src/auto/FiveBallRoutine.cpp | 2 +- src/auto/IntakePowerCellsAction.cpp | 1 + src/auto/IntakePowerCellsAction.h | 2 +- src/auto/LaunchBallsAction.cpp | 1 + src/auto/LaunchBallsAction.h | 1 - src/auto/{AutonActionTest.cpp => TestRoutine.cpp} | 2 +- src/auto/{AutonActionTest.h => TestRoutine.h} | 1 - 14 files changed, 10 insertions(+), 8 deletions(-) rename src/auto/{AutonActionTest.cpp => TestRoutine.cpp} (92%) rename src/auto/{AutonActionTest.h => TestRoutine.h} (92%) diff --git a/src/Robot.h b/src/Robot.h index e91e8f3..5f6600a 100644 --- a/src/Robot.h +++ b/src/Robot.h @@ -14,6 +14,7 @@ #include "LauncherSubsystem.h" #include "TurretSubsystem.h" #include "Config.h" +#include "TestRoutine.h" using namespace CORE; using namespace std; @@ -32,6 +33,7 @@ class Robot : public CORERobot { IntakeSubsystem intakeSubsystem; TurretSubsystem turretSubsystem; ConveyorSubsystem conveyorSubsystem; + TestRoutine testRoutine; private: static Robot * m_instance; diff --git a/src/auto/ConveyorAction.cpp b/src/auto/ConveyorAction.cpp index efa4170..53b0bf4 100644 --- a/src/auto/ConveyorAction.cpp +++ b/src/auto/ConveyorAction.cpp @@ -1,4 +1,5 @@ #include "ConveyorAction.h" +#include "Robot.h" ConveyorAction::ConveyorAction(conveyorAction requestedConveyorAction) { m_conveyorAction = requestedConveyorAction; diff --git a/src/auto/ConveyorAction.h b/src/auto/ConveyorAction.h index 4056591..b25e8b0 100644 --- a/src/auto/ConveyorAction.h +++ b/src/auto/ConveyorAction.h @@ -2,7 +2,6 @@ #include #include "ConveyorSubsystem.h" -#include "Robot.h" using namespace CORE; diff --git a/src/auto/DelayAction.cpp b/src/auto/DelayAction.cpp index b596d7d..247381a 100644 --- a/src/auto/DelayAction.cpp +++ b/src/auto/DelayAction.cpp @@ -1,4 +1,5 @@ #include "DelayAction.h" +#include "Robot.h" DelayAction::DelayAction() { diff --git a/src/auto/DelayAction.h b/src/auto/DelayAction.h index 11d8354..1ad6d37 100644 --- a/src/auto/DelayAction.h +++ b/src/auto/DelayAction.h @@ -2,7 +2,6 @@ #include #include "LauncherSubsystem.h" -#include "Robot.h" using namespace CORE; diff --git a/src/auto/DriveAction.cpp b/src/auto/DriveAction.cpp index 3263086..3b43a06 100644 --- a/src/auto/DriveAction.cpp +++ b/src/auto/DriveAction.cpp @@ -1,4 +1,5 @@ #include "DriveAction.h" +#include "Robot.h" DriveAction::DriveAction(driveAction requestedDriveAction): m_distAutonMoveEncoderTicks("Auton Movement", 6000) { diff --git a/src/auto/DriveAction.h b/src/auto/DriveAction.h index d0f7721..f01963c 100644 --- a/src/auto/DriveAction.h +++ b/src/auto/DriveAction.h @@ -2,7 +2,6 @@ #include #include "DriveSubsystem.h" -#include "Robot.h" using namespace CORE; diff --git a/src/auto/FiveBallRoutine.cpp b/src/auto/FiveBallRoutine.cpp index 5d698e4..dd6301f 100644 --- a/src/auto/FiveBallRoutine.cpp +++ b/src/auto/FiveBallRoutine.cpp @@ -1,6 +1,6 @@ #include "FiveBallRoutine.h" -FiveBallRoutinePickup::FiveBallRoutine() : COREAuton("Three Ball Routine") {} +FiveBallRoutinePickup::FiveBallRoutinePickup() : COREAuton("Three Ball Routine") {} void FiveBallRoutinePickup::AddNodes() { delayNode = new Node(5, new DelayAction()); diff --git a/src/auto/IntakePowerCellsAction.cpp b/src/auto/IntakePowerCellsAction.cpp index 3d0b8c4..d3553c6 100644 --- a/src/auto/IntakePowerCellsAction.cpp +++ b/src/auto/IntakePowerCellsAction.cpp @@ -1,4 +1,5 @@ #include "IntakePowerCellsAction.h" +#include "Robot.h" IntakePowerCellsAction::IntakePowerCellsAction(intakePowerCellsAction requestedIntakePowerCellAction) { m_intakePowerCellsAction = requestedIntakePowerCellAction; diff --git a/src/auto/IntakePowerCellsAction.h b/src/auto/IntakePowerCellsAction.h index 5ed1548..abf91d9 100644 --- a/src/auto/IntakePowerCellsAction.h +++ b/src/auto/IntakePowerCellsAction.h @@ -2,7 +2,7 @@ #include #include "IntakeSubsystem.h" -#include "Robot.h" + using namespace CORE; diff --git a/src/auto/LaunchBallsAction.cpp b/src/auto/LaunchBallsAction.cpp index eae3707..14f5c2a 100644 --- a/src/auto/LaunchBallsAction.cpp +++ b/src/auto/LaunchBallsAction.cpp @@ -1,4 +1,5 @@ #include "LaunchBallsAction.h" +#include "Robot.h" LaunchBallsAction::LaunchBallsAction(launchBallsAction requestedLaunchBallsAction) { m_launchBallsAction = requestedLaunchBallsAction; diff --git a/src/auto/LaunchBallsAction.h b/src/auto/LaunchBallsAction.h index 0273922..05db684 100644 --- a/src/auto/LaunchBallsAction.h +++ b/src/auto/LaunchBallsAction.h @@ -2,7 +2,6 @@ #include #include "LauncherSubsystem.h" -#include "Robot.h" using namespace CORE; diff --git a/src/auto/AutonActionTest.cpp b/src/auto/TestRoutine.cpp similarity index 92% rename from src/auto/AutonActionTest.cpp rename to src/auto/TestRoutine.cpp index 2db9f39..a19f28b 100644 --- a/src/auto/AutonActionTest.cpp +++ b/src/auto/TestRoutine.cpp @@ -1,4 +1,4 @@ -#include "AutonActionTest.h" +#include "TestRoutine.h" TestRoutine::TestRoutine() : COREAuton("Drive Routine") {} diff --git a/src/auto/AutonActionTest.h b/src/auto/TestRoutine.h similarity index 92% rename from src/auto/AutonActionTest.h rename to src/auto/TestRoutine.h index e8e7d4f..772b134 100644 --- a/src/auto/AutonActionTest.h +++ b/src/auto/TestRoutine.h @@ -7,7 +7,6 @@ #include "LaunchBallsAction.h" #include "ConveyorAction.h" #include "DelayAction.h" -// #include "AutonActionTest.h" using namespace CORE; using namespace std; From 922996ca2169192f8da330e09d3f50e46836e309 Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sun, 1 Mar 2020 13:34:08 -0600 Subject: [PATCH 14/22] Conveyor testing and changes --- src/auto/ConveyorAction.cpp | 2 +- src/auto/TestRoutine.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/auto/ConveyorAction.cpp b/src/auto/ConveyorAction.cpp index 53b0bf4..c870175 100644 --- a/src/auto/ConveyorAction.cpp +++ b/src/auto/ConveyorAction.cpp @@ -13,7 +13,7 @@ void ConveyorAction::ActionInit() { CORE::COREAutonAction::actionStatus ConveyorAction::Action() { switch(m_conveyorAction) { case CONVEYOR_ON: - Robot::GetInstance()->conveyorSubsystem.setMotor(0.25, 0.25); + Robot::GetInstance()->conveyorSubsystem.setMotor(-0.25, -0.25); break; case CONVEYOR_OFF: Robot::GetInstance()->conveyorSubsystem.setMotor(0, 0); diff --git a/src/auto/TestRoutine.cpp b/src/auto/TestRoutine.cpp index a19f28b..e3830db 100644 --- a/src/auto/TestRoutine.cpp +++ b/src/auto/TestRoutine.cpp @@ -1,11 +1,11 @@ #include "TestRoutine.h" -TestRoutine::TestRoutine() : COREAuton("Drive Routine") {} +TestRoutine::TestRoutine() : COREAuton("Test Routine") {} void TestRoutine::AddNodes() { - testNode = new Node(5, new IntakePowerCellsAction(INTAKE)); + testNode = new Node(5, new ConveyorAction(CONVEYOR_ON)); delayNode = new Node(3, new DelayAction()); - testNode2 = new Node(5, new IntakePowerCellsAction(STOP)); + testNode2 = new Node(5, new ConveyorAction(CONVEYOR_OFF)); AddFirstNode(testNode); testNode->AddNext(delayNode); delayNode->AddNext(testNode2); From d5aafe2c5f86f6e8d666ddcd7508a1dd1b5b5a6f Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sun, 1 Mar 2020 13:40:39 -0600 Subject: [PATCH 15/22] Made intake speed set to the core constant --- src/IntakeSubsystem.cpp | 6 +++--- src/IntakeSubsystem.h | 4 +++- src/auto/IntakePowerCellsAction.cpp | 5 +++-- src/auto/IntakePowerCellsAction.h | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/IntakeSubsystem.cpp b/src/IntakeSubsystem.cpp index 9a4d70b..ba9c594 100644 --- a/src/IntakeSubsystem.cpp +++ b/src/IntakeSubsystem.cpp @@ -2,7 +2,7 @@ IntakeSubsystem::IntakeSubsystem() : m_intakeMotor(INTAKE_PORT), m_intakeSolenoid(LEFT_DRIVE_SHIFTER_PCM, INTAKE_DOWN_PORT, INTAKE_UP_PORT), - m_intakeSpeed("Intake Speed", 0){ + intakeSpeed("Intake Speed", 0){ } void IntakeSubsystem::robotInit(){ @@ -16,13 +16,13 @@ void IntakeSubsystem::teleopInit() {} void IntakeSubsystem::teleop(){ if(operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::RIGHT_TRIGGER)){ - SetIntake(-m_intakeSpeed.Get()); + SetIntake(-intakeSpeed.Get()); } else{ SetIntake(0.0); } if (operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::RIGHT_BUTTON)) { - SetIntake(m_intakeSpeed.Get()); + SetIntake(intakeSpeed.Get()); } } diff --git a/src/IntakeSubsystem.h b/src/IntakeSubsystem.h index 3ee4a9c..417cbbb 100644 --- a/src/IntakeSubsystem.h +++ b/src/IntakeSubsystem.h @@ -15,9 +15,11 @@ class IntakeSubsystem : public CORESubsystem { void teleop() override; void SetIntake(double intakeSpeed); void ToggleIntake(); + + COREConstant intakeSpeed; + private: TalonSRX m_intakeMotor; frc::DoubleSolenoid m_intakeSolenoid; - COREConstant m_intakeSpeed; bool m_isIntakeDown; }; \ No newline at end of file diff --git a/src/auto/IntakePowerCellsAction.cpp b/src/auto/IntakePowerCellsAction.cpp index 3d0b8c4..22170fa 100644 --- a/src/auto/IntakePowerCellsAction.cpp +++ b/src/auto/IntakePowerCellsAction.cpp @@ -6,16 +6,17 @@ IntakePowerCellsAction::IntakePowerCellsAction(intakePowerCellsAction requestedI } void IntakePowerCellsAction::ActionInit() { + m_intakeSpeed = Robot::GetInstance()->intakeSubsystem.intakeSpeed.Get(); } CORE::COREAutonAction::actionStatus IntakePowerCellsAction::Action() { switch(m_intakePowerCellsAction) { case INTAKE: - Robot::GetInstance()->intakeSubsystem.SetIntake(0.2); + Robot::GetInstance()->intakeSubsystem.SetIntake(m_intakeSpeed); break; case OUTTAKE: - Robot::GetInstance()->intakeSubsystem.SetIntake(-0.2); + Robot::GetInstance()->intakeSubsystem.SetIntake(-m_intakeSpeed); break; case STOP: Robot::GetInstance()->intakeSubsystem.SetIntake(0); diff --git a/src/auto/IntakePowerCellsAction.h b/src/auto/IntakePowerCellsAction.h index 5ed1548..7ad86ef 100644 --- a/src/auto/IntakePowerCellsAction.h +++ b/src/auto/IntakePowerCellsAction.h @@ -20,4 +20,5 @@ class IntakePowerCellsAction : public COREAutonAction { void ActionEnd() override; private: intakePowerCellsAction m_intakePowerCellsAction; + double m_intakeSpeed }; From 8609f16677963977a6cde6a47bde83b50cf43a6f Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sun, 1 Mar 2020 14:05:21 -0600 Subject: [PATCH 16/22] Made conveyor auton speed set to a core constant --- src/ConveyorSubsystem.cpp | 8 ++++---- src/ConveyorSubsystem.h | 2 +- src/auto/ConveyorAction.cpp | 5 +++-- src/auto/ConveyorAction.h | 1 + src/auto/IntakePowerCellsAction.h | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ConveyorSubsystem.cpp b/src/ConveyorSubsystem.cpp index 1883637..48936b2 100644 --- a/src/ConveyorSubsystem.cpp +++ b/src/ConveyorSubsystem.cpp @@ -5,8 +5,8 @@ using namespace CORE; ConveyorSubsystem::ConveyorSubsystem() : m_lowerConveyorMotor(CONVEYOR_1_PORT), m_frontConveyorMotor(CONVEYOR_2_PORT), m_backConveyorMotor(CONVEYOR_3_PORT), - m_lowerConveyorSpeed("Lower Conveyor Speed", 0), - m_upperConveyorSpeed("Upper Conveyor Speed", 0) { + lowerConveyorSpeed("Lower Conveyor Speed", 0), + upperConveyorSpeed("Upper Conveyor Speed", 0) { } void ConveyorSubsystem::robotInit(){ @@ -23,9 +23,9 @@ void ConveyorSubsystem::teleopInit() {} void ConveyorSubsystem::teleop(){ if(operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::RIGHT_TRIGGER)) { - setMotor(m_lowerConveyorSpeed.Get(), m_upperConveyorSpeed.Get()); + setMotor(lowerConveyorSpeed.Get(), upperConveyorSpeed.Get()); } else if(operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::RIGHT_BUTTON)) { - setMotor(-m_lowerConveyorSpeed.Get(), -m_upperConveyorSpeed.Get()); + setMotor(-lowerConveyorSpeed.Get(), -upperConveyorSpeed.Get()); } else { setMotor(0.0, 0.0); } diff --git a/src/ConveyorSubsystem.h b/src/ConveyorSubsystem.h index b366893..9fbe229 100644 --- a/src/ConveyorSubsystem.h +++ b/src/ConveyorSubsystem.h @@ -12,8 +12,8 @@ class ConveyorSubsystem : public CORESubsystem { void teleop() override; void setMotor(double lowerConveyorSpeed, double upperConveyorSpeed); + COREConstant lowerConveyorSpeed, upperConveyorSpeed; private: TalonSRX m_lowerConveyorMotor, m_frontConveyorMotor, m_backConveyorMotor; - COREConstant m_lowerConveyorSpeed, m_upperConveyorSpeed; }; diff --git a/src/auto/ConveyorAction.cpp b/src/auto/ConveyorAction.cpp index c870175..39bf011 100644 --- a/src/auto/ConveyorAction.cpp +++ b/src/auto/ConveyorAction.cpp @@ -7,13 +7,14 @@ ConveyorAction::ConveyorAction(conveyorAction requestedConveyorAction) { } void ConveyorAction::ActionInit() { - + m_lowerConveyorSpeed = Robot::GetInstance()->conveyorSubsystem.lowerConveyorSpeed.Get(); + m_upperConveyorSpeed = Robot::GetInstance()->conveyorSubsystem.upperConveyorSpeed.Get(); } CORE::COREAutonAction::actionStatus ConveyorAction::Action() { switch(m_conveyorAction) { case CONVEYOR_ON: - Robot::GetInstance()->conveyorSubsystem.setMotor(-0.25, -0.25); + Robot::GetInstance()->conveyorSubsystem.setMotor(-m_lowerConveyorSpeed, -m_upperConveyorSpeed); break; case CONVEYOR_OFF: Robot::GetInstance()->conveyorSubsystem.setMotor(0, 0); diff --git a/src/auto/ConveyorAction.h b/src/auto/ConveyorAction.h index b25e8b0..524dcc1 100644 --- a/src/auto/ConveyorAction.h +++ b/src/auto/ConveyorAction.h @@ -18,4 +18,5 @@ class ConveyorAction : public COREAutonAction { void ActionEnd() override; private: conveyorAction m_conveyorAction; + double m_lowerConveyorSpeed, m_upperConveyorSpeed; }; diff --git a/src/auto/IntakePowerCellsAction.h b/src/auto/IntakePowerCellsAction.h index 8f657c2..9c86913 100644 --- a/src/auto/IntakePowerCellsAction.h +++ b/src/auto/IntakePowerCellsAction.h @@ -20,5 +20,5 @@ class IntakePowerCellsAction : public COREAutonAction { void ActionEnd() override; private: intakePowerCellsAction m_intakePowerCellsAction; - double m_intakeSpeed + double m_intakeSpeed; }; From 42386fb7eed034287dfee22cd0c4ed81141cd02e Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sun, 1 Mar 2020 14:06:21 -0600 Subject: [PATCH 17/22] tested actions and set up 3 ball auton --- src/Robot.h | 4 ++++ src/auto/TestRoutine.cpp | 4 ++-- src/auto/ThreeBallRoutine.cpp | 12 +++++++----- src/auto/ThreeBallRoutine.h | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Robot.h b/src/Robot.h index 5f6600a..8e10954 100644 --- a/src/Robot.h +++ b/src/Robot.h @@ -15,6 +15,8 @@ #include "TurretSubsystem.h" #include "Config.h" #include "TestRoutine.h" +#include "DriveRoutine.h" +#include "ThreeBallRoutine.h" using namespace CORE; using namespace std; @@ -34,6 +36,8 @@ class Robot : public CORERobot { TurretSubsystem turretSubsystem; ConveyorSubsystem conveyorSubsystem; TestRoutine testRoutine; + DriveRoutine driveRoutine; + ThreeBallRoutine threeBallRoutine; private: static Robot * m_instance; diff --git a/src/auto/TestRoutine.cpp b/src/auto/TestRoutine.cpp index e3830db..bcd217d 100644 --- a/src/auto/TestRoutine.cpp +++ b/src/auto/TestRoutine.cpp @@ -3,9 +3,9 @@ TestRoutine::TestRoutine() : COREAuton("Test Routine") {} void TestRoutine::AddNodes() { - testNode = new Node(5, new ConveyorAction(CONVEYOR_ON)); + testNode = new Node(5, new LaunchBallsAction(LAUNCHER_ON)); delayNode = new Node(3, new DelayAction()); - testNode2 = new Node(5, new ConveyorAction(CONVEYOR_OFF)); + testNode2 = new Node(5, new LaunchBallsAction(LAUNCHER_OFF)); AddFirstNode(testNode); testNode->AddNext(delayNode); delayNode->AddNext(testNode2); diff --git a/src/auto/ThreeBallRoutine.cpp b/src/auto/ThreeBallRoutine.cpp index fd298ba..92e7df7 100644 --- a/src/auto/ThreeBallRoutine.cpp +++ b/src/auto/ThreeBallRoutine.cpp @@ -3,12 +3,14 @@ ThreeBallRoutine::ThreeBallRoutine() : COREAuton("Three Ball Routine") {} void ThreeBallRoutine::AddNodes() { - delayNode = new Node(5, new DelayAction()); launcherOnNode = new Node(5, new LaunchBallsAction(LAUNCHER_ON)); + delayNode1 = new Node(10, new DelayAction()); conveyorOnNode = new Node(5, new ConveyorAction(CONVEYOR_ON)); + delayNode2 = new Node(2, new DelayAction()); driveNode = new Node(5, new DriveAction(FORWARD)); - AddFirstNode(delayNode); - delayNode->AddNext(launcherOnNode); - launcherOnNode->AddNext(conveyorOnNode); - conveyorOnNode->AddNext(driveNode); + AddFirstNode(launcherOnNode); + launcherOnNode->AddNext(delayNode1); + delayNode1->AddNext(conveyorOnNode); + conveyorOnNode->AddNext(delayNode2); + delayNode2->AddNext(driveNode); } diff --git a/src/auto/ThreeBallRoutine.h b/src/auto/ThreeBallRoutine.h index dea4355..8b7ddb0 100644 --- a/src/auto/ThreeBallRoutine.h +++ b/src/auto/ThreeBallRoutine.h @@ -16,7 +16,8 @@ class ThreeBallRoutine: public COREAuton { ThreeBallRoutine(); void AddNodes() override; private: - Node * delayNode; + Node * delayNode1; + Node * delayNode2; Node * launcherOnNode; Node * conveyorOnNode; Node * driveNode; From ef9877b97a8017683d7f55c008f977573e9ccb5e Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sun, 1 Mar 2020 14:33:07 -0600 Subject: [PATCH 18/22] modified delay on auton --- src/auto/ThreeBallRoutine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auto/ThreeBallRoutine.cpp b/src/auto/ThreeBallRoutine.cpp index 92e7df7..c0dfb53 100644 --- a/src/auto/ThreeBallRoutine.cpp +++ b/src/auto/ThreeBallRoutine.cpp @@ -4,7 +4,7 @@ ThreeBallRoutine::ThreeBallRoutine() : COREAuton("Three Ball Routine") {} void ThreeBallRoutine::AddNodes() { launcherOnNode = new Node(5, new LaunchBallsAction(LAUNCHER_ON)); - delayNode1 = new Node(10, new DelayAction()); + delayNode1 = new Node(5, new DelayAction()); conveyorOnNode = new Node(5, new ConveyorAction(CONVEYOR_ON)); delayNode2 = new Node(2, new DelayAction()); driveNode = new Node(5, new DriveAction(FORWARD)); From 77aca92850e4a45b8b13109b68a9fdd3d044e740 Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sun, 1 Mar 2020 14:49:44 -0600 Subject: [PATCH 19/22] fixed errors --- src/ConveyorSubsystem.cpp | 8 ++++---- src/auto/ConveyorAction.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ConveyorSubsystem.cpp b/src/ConveyorSubsystem.cpp index 02e5704..22179d3 100644 --- a/src/ConveyorSubsystem.cpp +++ b/src/ConveyorSubsystem.cpp @@ -29,17 +29,17 @@ void ConveyorSubsystem::teleopInit() {} void ConveyorSubsystem::teleop(){ if(operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::RIGHT_TRIGGER)) { - setLowerMotor(m_lowerConveyorSpeed.Get()); + setLowerMotor(lowerConveyorSpeed.Get()); } else if(operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::RIGHT_BUTTON)) { - setLowerMotor(-m_lowerConveyorSpeed.Get()); + setLowerMotor(-lowerConveyorSpeed.Get()); } else { setLowerMotor(0.0); } if(operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::LEFT_TRIGGER)) { - setUpperMotor(m_upperConveyorSpeed.Get()); + setUpperMotor(upperConveyorSpeed.Get()); } else if(operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::LEFT_BUTTON)) { - setUpperMotor(-m_upperConveyorSpeed.Get()); + setUpperMotor(-upperConveyorSpeed.Get()); } else { setUpperMotor(0.0); } diff --git a/src/auto/ConveyorAction.cpp b/src/auto/ConveyorAction.cpp index 39bf011..6690f10 100644 --- a/src/auto/ConveyorAction.cpp +++ b/src/auto/ConveyorAction.cpp @@ -14,10 +14,12 @@ void ConveyorAction::ActionInit() { CORE::COREAutonAction::actionStatus ConveyorAction::Action() { switch(m_conveyorAction) { case CONVEYOR_ON: - Robot::GetInstance()->conveyorSubsystem.setMotor(-m_lowerConveyorSpeed, -m_upperConveyorSpeed); + Robot::GetInstance()->conveyorSubsystem.setLowerMotor(-m_lowerConveyorSpeed); + Robot::GetInstance()->conveyorSubsystem.setUpperMotor(-m_upperConveyorSpeed); break; case CONVEYOR_OFF: - Robot::GetInstance()->conveyorSubsystem.setMotor(0, 0); + Robot::GetInstance()->conveyorSubsystem.setLowerMotor(0); + Robot::GetInstance()->conveyorSubsystem.setUpperMotor(0); break; } return COREAutonAction::actionStatus::END; From 00c2e60bde387312a4da43659347cf9d6098e999 Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Sun, 1 Mar 2020 15:19:59 -0600 Subject: [PATCH 20/22] Worked on making turret auton action --- src/TurretSubsystem.cpp | 16 ++++++++++------ src/TurretSubsystem.h | 4 +++- src/auto/TurretTrackingAction.cpp | 25 +++++++++++++++++++++++++ src/auto/TurretTrackingAction.h | 21 +++++++++++++++++++++ 4 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 src/auto/TurretTrackingAction.cpp create mode 100644 src/auto/TurretTrackingAction.h diff --git a/src/TurretSubsystem.cpp b/src/TurretSubsystem.cpp index e0398b7..651969e 100644 --- a/src/TurretSubsystem.cpp +++ b/src/TurretSubsystem.cpp @@ -30,22 +30,20 @@ void TurretSubsystem::teleopInit() { void TurretSubsystem::teleop() { double manualInput = -operatorJoystick->GetAxis(CORE::COREJoystick::JoystickAxis::LEFT_STICK_X); bool aButtonPressed = operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::A_BUTTON); - double motorPercent = 0; + m_motorPercent = 0; bool atLeftStop = m_turret.GetSelectedSensorPosition(0) < (m_startupTurretPosition - 7000.0); bool atRightStop = m_turret.GetSelectedSensorPosition(0) > (m_startupTurretPosition + 7000.0); if (aButtonPressed) { - nt::NetworkTableInstance::GetDefault().GetTable("limelight")->PutNumber("ledMode",3); - nt::NetworkTableInstance::GetDefault().GetTable("limelight")->PutNumber("camMode",0); - motorPercent = CalculateMotorFromVision(atLeftStop, atRightStop); + m_motorPercent = VisionMove(atLeftStop, atRightStop); } else if ((!atRightStop && manualInput < 0) || (!atLeftStop && manualInput > 0)) { nt::NetworkTableInstance::GetDefault().GetTable("limelight")->PutNumber("ledMode",1); nt::NetworkTableInstance::GetDefault().GetTable("limelight")->PutNumber("camMode",1); // manual turret position double turretSpeed = m_turretSpeed.Get(); - motorPercent = turretSpeed * manualInput; + m_motorPercent = turretSpeed * manualInput; } - SetTurret(motorPercent); + SetTurret(m_motorPercent); SmartDashboard::PutNumber("Distance from target", GetDistance()); SmartDashboard::PutNumber("Turret position", m_turret.GetSelectedSensorPosition(0)); @@ -54,6 +52,12 @@ void TurretSubsystem::teleop() { SmartDashboard::PutBoolean("A Button Pressed", operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::A_BUTTON)); } +double TurretSubsystem::VisionMove(bool atLeftStop, bool atRightStop) { + nt::NetworkTableInstance::GetDefault().GetTable("limelight")->PutNumber("ledMode",3); + nt::NetworkTableInstance::GetDefault().GetTable("limelight")->PutNumber("camMode",0); + return m_motorPercent = CalculateMotorFromVision(atLeftStop, atRightStop); +} + double TurretSubsystem::CalculateMotorFromVision(bool atLeftStop, bool atRightStop) { // auto turret position corePID.SetDerivativeConstant(m_KD.Get()); diff --git a/src/TurretSubsystem.h b/src/TurretSubsystem.h index 7c51ecb..dc87327 100644 --- a/src/TurretSubsystem.h +++ b/src/TurretSubsystem.h @@ -14,7 +14,7 @@ using namespace frc; class TurretSubsystem : public CORESubsystem { private: TalonSRX m_turret; - double m_startupTurretPosition; + double m_startupTurretPosition, m_motorPercent; nt::NetworkTableInstance ntinst; //Distance Coefficent A,B,C,D COREConstant m_KP, m_KI, m_KD, m_KF, m_turretSpeed, m_DistCoefA, m_DistCoefB /*, m_DistCoefC, m_DistCoefD, m_DistCoffee*/; @@ -25,6 +25,8 @@ class TurretSubsystem : public CORESubsystem { void robotInit() override; void teleopInit() override; void teleop() override; + + double VisionMove(bool atLeftStop, bool atRightStop); double CalculateMotorFromVision(bool atLeftStop, bool atRightStop); double GetDistance(); void InitTalons(); diff --git a/src/auto/TurretTrackingAction.cpp b/src/auto/TurretTrackingAction.cpp new file mode 100644 index 0000000..99541c8 --- /dev/null +++ b/src/auto/TurretTrackingAction.cpp @@ -0,0 +1,25 @@ +// #include "TurretTrackingAction.h" +// #include "Robot.h" + +// LaunchBallsAction::LaunchBallsAction(launchBallsAction requestedLaunchBallsAction) { +// m_launchBallsAction = requestedLaunchBallsAction; +// } + +// void LaunchBallsAction::ActionInit() { +// } + +// CORE::COREAutonAction::actionStatus LaunchBallsAction::Action() { +// switch(m_launchBallsAction) { +// case TRACKING_ON: +// Robot::GetInstance()->launcherSubsystem.launcherOn(true); +// break; +// case TRACKING_OFF: +// Robot::GetInstance()->launcherSubsystem.launcherOn(false); +// break; +// } +// return COREAutonAction::actionStatus::END; +// } + +// void LaunchBallsAction::ActionEnd() { + +// } diff --git a/src/auto/TurretTrackingAction.h b/src/auto/TurretTrackingAction.h new file mode 100644 index 0000000..f011666 --- /dev/null +++ b/src/auto/TurretTrackingAction.h @@ -0,0 +1,21 @@ +// #pragma once + +// #include +// #include "TurretSubsystem.h" + +// using namespace CORE; + +// enum launchBallsAction { +// TRACKING_ON, +// TRACKING_OFF +// }; + +// class TurretTrackingAction : public COREAutonAction { +// public: +// TurretTrackingAction(turretTrackingAction requestedLaunchBallsAction); +// void ActionInit() override; +// CORE::COREAutonAction::actionStatus Action() override; +// void ActionEnd() override; +// private: +// launchBallsAction m_launchBallsAction; +// }; \ No newline at end of file From 8526227a507694c6d45f19e21c015312325ade2f Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Thu, 5 Mar 2020 17:26:56 -0600 Subject: [PATCH 21/22] Made Turret tracking auton action --- src/IntakeSubsystem.cpp | 4 ++- src/TurretSubsystem.cpp | 7 +++-- src/TurretSubsystem.h | 1 + src/auto/DriveAction.cpp | 2 +- src/auto/TurretTrackingAction.cpp | 50 ++++++++++++++++++------------- src/auto/TurretTrackingAction.h | 36 +++++++++++----------- 6 files changed, 59 insertions(+), 41 deletions(-) diff --git a/src/IntakeSubsystem.cpp b/src/IntakeSubsystem.cpp index d69f706..3461f36 100644 --- a/src/IntakeSubsystem.cpp +++ b/src/IntakeSubsystem.cpp @@ -1,6 +1,7 @@ #include "IntakeSubsystem.h" -IntakeSubsystem::IntakeSubsystem() : m_intakeMotor(INTAKE_PORT), +IntakeSubsystem::IntakeSubsystem() : + m_intakeMotor(INTAKE_PORT), m_intakeSolenoid(LEFT_DRIVE_SHIFTER_PCM, INTAKE_DOWN_PORT, INTAKE_UP_PORT), intakeSpeed("Intake Speed", 0.45){ } @@ -10,6 +11,7 @@ void IntakeSubsystem::robotInit(){ operatorJoystick->RegisterButton(CORE::COREJoystick::JoystickButton::RIGHT_TRIGGER); operatorJoystick->RegisterButton(CORE::COREJoystick::JoystickButton::RIGHT_BUTTON); m_isIntakeDown = false; + m_intakeMotor.SetInverted(true); } void IntakeSubsystem::teleopInit() {} diff --git a/src/TurretSubsystem.cpp b/src/TurretSubsystem.cpp index 651969e..dbc0227 100644 --- a/src/TurretSubsystem.cpp +++ b/src/TurretSubsystem.cpp @@ -9,10 +9,10 @@ TurretSubsystem::TurretSubsystem(): m_turret(TURRET_PORT), m_DistCoefA("DistCoefA", 0), m_DistCoefB("DistCoefB", 0), corePID(0, 0, 0, 0) { - std::cout << "Turret Subsystem constructer called" << std::endl; } void TurretSubsystem::robotInit() { + m_startupTurretPosition = m_turret.GetSelectedSensorPosition(0); operatorJoystick->RegisterButton(CORE::COREJoystick::JoystickButton::A_BUTTON); operatorJoystick->RegisterAxis(CORE::COREJoystick::LEFT_STICK_X); InitTalons(); @@ -24,7 +24,6 @@ void TurretSubsystem::robotInit() { } void TurretSubsystem::teleopInit() { - m_startupTurretPosition = m_turret.GetSelectedSensorPosition(0); } void TurretSubsystem::teleop() { @@ -52,6 +51,10 @@ void TurretSubsystem::teleop() { SmartDashboard::PutBoolean("A Button Pressed", operatorJoystick->GetButton(CORE::COREJoystick::JoystickButton::A_BUTTON)); } +double TurretSubsystem::turretPosition() { + return m_turret.GetSelectedSensorPosition(0); +} + double TurretSubsystem::VisionMove(bool atLeftStop, bool atRightStop) { nt::NetworkTableInstance::GetDefault().GetTable("limelight")->PutNumber("ledMode",3); nt::NetworkTableInstance::GetDefault().GetTable("limelight")->PutNumber("camMode",0); diff --git a/src/TurretSubsystem.h b/src/TurretSubsystem.h index dc87327..25aa850 100644 --- a/src/TurretSubsystem.h +++ b/src/TurretSubsystem.h @@ -26,6 +26,7 @@ class TurretSubsystem : public CORESubsystem { void teleopInit() override; void teleop() override; + double turretPosition(); double VisionMove(bool atLeftStop, bool atRightStop); double CalculateMotorFromVision(bool atLeftStop, bool atRightStop); double GetDistance(); diff --git a/src/auto/DriveAction.cpp b/src/auto/DriveAction.cpp index 3b43a06..fa0ec55 100644 --- a/src/auto/DriveAction.cpp +++ b/src/auto/DriveAction.cpp @@ -3,7 +3,7 @@ DriveAction::DriveAction(driveAction requestedDriveAction): m_distAutonMoveEncoderTicks("Auton Movement", 6000) { - m_driveAction = requestedDriveAction; + m_driveAction = requestedDriveAction; } diff --git a/src/auto/TurretTrackingAction.cpp b/src/auto/TurretTrackingAction.cpp index 99541c8..a48bf0d 100644 --- a/src/auto/TurretTrackingAction.cpp +++ b/src/auto/TurretTrackingAction.cpp @@ -1,25 +1,35 @@ -// #include "TurretTrackingAction.h" -// #include "Robot.h" +#include "TurretTrackingAction.h" +#include "Robot.h" -// LaunchBallsAction::LaunchBallsAction(launchBallsAction requestedLaunchBallsAction) { -// m_launchBallsAction = requestedLaunchBallsAction; -// } +TurretTrackingAction::TurretTrackingAction(turretTrackingAction requestedTurretTrackingAction) { + m_turretTrackingAction = requestedTurretTrackingAction; +} -// void LaunchBallsAction::ActionInit() { -// } +void TurretTrackingAction::ActionInit() { + TurretSubsystem* turretSubsystem = &Robot::GetInstance()->turretSubsystem; + m_turretStartupPosition = turretSubsystem->turretPosition(); +} -// CORE::COREAutonAction::actionStatus LaunchBallsAction::Action() { -// switch(m_launchBallsAction) { -// case TRACKING_ON: -// Robot::GetInstance()->launcherSubsystem.launcherOn(true); -// break; -// case TRACKING_OFF: -// Robot::GetInstance()->launcherSubsystem.launcherOn(false); -// break; -// } -// return COREAutonAction::actionStatus::END; -// } +CORE::COREAutonAction::actionStatus TurretTrackingAction::Action() { + TurretSubsystem* turretSubsystem = &Robot::GetInstance()->turretSubsystem; + m_turretPosition = turretSubsystem->turretPosition(); + bool atLeftStop = m_turretPosition < (m_turretStartupPosition - 7000.0); + bool atRightStop = m_turretPosition > (m_turretStartupPosition + 7000.0); + switch(m_turretTrackingAction) { + case TRACKING_ON: { + double motorPercent = turretSubsystem->VisionMove(atLeftStop, atRightStop); + Robot::GetInstance()->turretSubsystem.SetTurret(motorPercent); + break; + } + case TRACKING_OFF: { + Robot::GetInstance()->turretSubsystem.SetTurret(0.0); + break; + } + default: break; + } + return COREAutonAction::actionStatus::END; +} -// void LaunchBallsAction::ActionEnd() { +void TurretTrackingAction::ActionEnd() { -// } +} diff --git a/src/auto/TurretTrackingAction.h b/src/auto/TurretTrackingAction.h index f011666..ea00c9f 100644 --- a/src/auto/TurretTrackingAction.h +++ b/src/auto/TurretTrackingAction.h @@ -1,21 +1,23 @@ -// #pragma once +#pragma once -// #include -// #include "TurretSubsystem.h" +#include +#include "TurretSubsystem.h" -// using namespace CORE; +using namespace CORE; -// enum launchBallsAction { -// TRACKING_ON, -// TRACKING_OFF -// }; +enum turretTrackingAction { + TRACKING_ON, + TRACKING_OFF +}; -// class TurretTrackingAction : public COREAutonAction { -// public: -// TurretTrackingAction(turretTrackingAction requestedLaunchBallsAction); -// void ActionInit() override; -// CORE::COREAutonAction::actionStatus Action() override; -// void ActionEnd() override; -// private: -// launchBallsAction m_launchBallsAction; -// }; \ No newline at end of file +class TurretTrackingAction : public COREAutonAction { +public: + TurretTrackingAction(turretTrackingAction requestedTurretTrackingAction); + void ActionInit() override; + CORE::COREAutonAction::actionStatus Action() override; + void ActionEnd() override; +private: + turretTrackingAction m_turretTrackingAction; + double m_turretStartupPosition, m_turretPosition; + +}; \ No newline at end of file From efd93cdb4ec48528fd73ca9f426b95304d8b0ed4 Mon Sep 17 00:00:00 2001 From: CORE Programmers Date: Fri, 6 Mar 2020 20:28:21 -0600 Subject: [PATCH 22/22] implented turret auton --- src/TurretSubsystem.cpp | 7 +++---- src/TurretSubsystem.h | 3 ++- src/auto/TestRoutine.cpp | 8 ++++---- src/auto/TestRoutine.h | 1 + src/auto/ThreeBallRoutine.cpp | 4 +++- src/auto/ThreeBallRoutine.h | 2 ++ src/auto/TurretTrackingAction.cpp | 21 +++++++++++++++------ 7 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/TurretSubsystem.cpp b/src/TurretSubsystem.cpp index dbc0227..2e4d5d1 100644 --- a/src/TurretSubsystem.cpp +++ b/src/TurretSubsystem.cpp @@ -19,8 +19,7 @@ void TurretSubsystem::robotInit() { // start NetworkTables ntinst = nt::NetworkTableInstance::GetDefault(); ntinst.StartClientTeam(2062); - - + m_turret.SetNeutralMode(motorcontrol::NeutralMode::Brake); } void TurretSubsystem::teleopInit() { @@ -68,10 +67,10 @@ double TurretSubsystem::CalculateMotorFromVision(bool atLeftStop, bool atRightSt corePID.SetIntegralConstant(m_KI.Get()); corePID.SetProportionalConstant(m_KP.Get()); auto table = ntinst.GetTable("limelight"); - bool hasCenterX = table->GetNumber("tv", 0.0) == 1; + hasCenterX = table->GetNumber("tv", 0.0) == 1; double conversion = 4096 / -360; // convert degrees to ticks // calculate center error as a percent output for the motor - double centerError = table->GetNumber("tx", 0.0) * conversion; + centerError = table->GetNumber("tx", 0.0) * conversion; SmartDashboard::PutNumber("Center Error", centerError); SmartDashboard::PutBoolean("HasTable", hasCenterX); diff --git a/src/TurretSubsystem.h b/src/TurretSubsystem.h index 25aa850..dd8aa5f 100644 --- a/src/TurretSubsystem.h +++ b/src/TurretSubsystem.h @@ -32,5 +32,6 @@ class TurretSubsystem : public CORESubsystem { double GetDistance(); void InitTalons(); void SetTurret(double turretPercent); - + double centerError; + bool hasCenterX; }; diff --git a/src/auto/TestRoutine.cpp b/src/auto/TestRoutine.cpp index bcd217d..a433e59 100644 --- a/src/auto/TestRoutine.cpp +++ b/src/auto/TestRoutine.cpp @@ -3,10 +3,10 @@ TestRoutine::TestRoutine() : COREAuton("Test Routine") {} void TestRoutine::AddNodes() { - testNode = new Node(5, new LaunchBallsAction(LAUNCHER_ON)); + testNode = new Node(5, new TurretTrackingAction(TRACKING_ON)); delayNode = new Node(3, new DelayAction()); - testNode2 = new Node(5, new LaunchBallsAction(LAUNCHER_OFF)); + testNode2 = new Node(5, new TurretTrackingAction(TRACKING_OFF)); AddFirstNode(testNode); - testNode->AddNext(delayNode); - delayNode->AddNext(testNode2); + testNode->AddNext(testNode2); + //delayNode->AddNext(testNode2); } \ No newline at end of file diff --git a/src/auto/TestRoutine.h b/src/auto/TestRoutine.h index 772b134..7d0a07c 100644 --- a/src/auto/TestRoutine.h +++ b/src/auto/TestRoutine.h @@ -7,6 +7,7 @@ #include "LaunchBallsAction.h" #include "ConveyorAction.h" #include "DelayAction.h" +#include "TurretTrackingAction.h" using namespace CORE; using namespace std; diff --git a/src/auto/ThreeBallRoutine.cpp b/src/auto/ThreeBallRoutine.cpp index c0dfb53..bbe2685 100644 --- a/src/auto/ThreeBallRoutine.cpp +++ b/src/auto/ThreeBallRoutine.cpp @@ -4,12 +4,14 @@ ThreeBallRoutine::ThreeBallRoutine() : COREAuton("Three Ball Routine") {} void ThreeBallRoutine::AddNodes() { launcherOnNode = new Node(5, new LaunchBallsAction(LAUNCHER_ON)); + turretNode = new Node(5, new TurretTrackingAction(TRACKING_ON)); delayNode1 = new Node(5, new DelayAction()); conveyorOnNode = new Node(5, new ConveyorAction(CONVEYOR_ON)); delayNode2 = new Node(2, new DelayAction()); driveNode = new Node(5, new DriveAction(FORWARD)); AddFirstNode(launcherOnNode); - launcherOnNode->AddNext(delayNode1); + launcherOnNode->AddNext(turretNode); + turretNode->AddNext(delayNode1); delayNode1->AddNext(conveyorOnNode); conveyorOnNode->AddNext(delayNode2); delayNode2->AddNext(driveNode); diff --git a/src/auto/ThreeBallRoutine.h b/src/auto/ThreeBallRoutine.h index 8b7ddb0..fe49520 100644 --- a/src/auto/ThreeBallRoutine.h +++ b/src/auto/ThreeBallRoutine.h @@ -6,6 +6,7 @@ #include "ConveyorAction.h" #include "DriveAction.h" #include "DelayAction.h" +#include "TurretTrackingAction.h" // #include "AutonActionTest.h" using namespace CORE; @@ -18,6 +19,7 @@ class ThreeBallRoutine: public COREAuton { private: Node * delayNode1; Node * delayNode2; + Node * turretNode; Node * launcherOnNode; Node * conveyorOnNode; Node * driveNode; diff --git a/src/auto/TurretTrackingAction.cpp b/src/auto/TurretTrackingAction.cpp index a48bf0d..3ed86fe 100644 --- a/src/auto/TurretTrackingAction.cpp +++ b/src/auto/TurretTrackingAction.cpp @@ -13,21 +13,30 @@ void TurretTrackingAction::ActionInit() { CORE::COREAutonAction::actionStatus TurretTrackingAction::Action() { TurretSubsystem* turretSubsystem = &Robot::GetInstance()->turretSubsystem; m_turretPosition = turretSubsystem->turretPosition(); - bool atLeftStop = m_turretPosition < (m_turretStartupPosition - 7000.0); - bool atRightStop = m_turretPosition > (m_turretStartupPosition + 7000.0); + bool atLeftStop = false; //m_turretPosition < (m_turretStartupPosition - 7000.0); + bool atRightStop = false; //m_turretPosition > (m_turretStartupPosition + 7000.0); switch(m_turretTrackingAction) { case TRACKING_ON: { double motorPercent = turretSubsystem->VisionMove(atLeftStop, atRightStop); - Robot::GetInstance()->turretSubsystem.SetTurret(motorPercent); + cout << "Center Error" << turretSubsystem->centerError << endl; + if (turretSubsystem->hasCenterX) { + if (abs(turretSubsystem->centerError) > 10) { + turretSubsystem->SetTurret(motorPercent); + break; + } else { + turretSubsystem->SetTurret(0.0); + return COREAutonAction::actionStatus::END; + } + } break; } case TRACKING_OFF: { - Robot::GetInstance()->turretSubsystem.SetTurret(0.0); - break; + turretSubsystem->SetTurret(0.0); + return COREAutonAction::actionStatus::END; } default: break; } - return COREAutonAction::actionStatus::END; + return COREAutonAction::actionStatus::CONTINUE; } void TurretTrackingAction::ActionEnd() {