From 265d2575babc89185d83d7e98ba7c011fd0ed8d0 Mon Sep 17 00:00:00 2001 From: Patrick Frampton Date: Sat, 18 Jan 2020 15:45:32 -0500 Subject: [PATCH 1/8] Fix line endings, grr --- build.gradle | 136 +++++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/build.gradle b/build.gradle index b20386d..e3de057 100644 --- a/build.gradle +++ b/build.gradle @@ -1,68 +1,68 @@ -plugins { - id "java" - id "edu.wpi.first.GradleRIO" version "2020.1.2" -} - -sourceCompatibility = JavaVersion.VERSION_11 -targetCompatibility = JavaVersion.VERSION_11 - -def ROBOT_MAIN_CLASS = "frc.robot.Main" - -// Define my targets (RoboRIO) and artifacts (deployable files) -// This is added by GradleRIO's backing project EmbeddedTools. -deploy { - targets { - roboRIO("roborio") { - // Team number is loaded either from the .wpilib/wpilib_preferences.json - // or from command line. If not found an exception will be thrown. - // You can use getTeamOrDefault(team) instead of getTeamNumber if you - // want to store a team number in this file. - team = frc.getTeamNumber() - } - } - artifacts { - frcJavaArtifact('frcJava') { - targets << "roborio" - // Debug can be overridden by command line, for use with VSCode - debug = frc.getDebugOrDefault(false) - } - // Built in artifact to deploy arbitrary files to the roboRIO. - fileTreeArtifact('frcStaticFileDeploy') { - // The directory below is the local directory to deploy - files = fileTree(dir: 'src/main/deploy') - // Deploy to RoboRIO target, into /home/lvuser/deploy - targets << "roborio" - directory = '/home/lvuser/deploy' - } - } -} - -// Set this to true to enable desktop support. -def includeDesktopSupport = true - -// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries. -// Also defines JUnit 4. -dependencies { - implementation wpi.deps.wpilib() - nativeZip wpi.deps.wpilibJni(wpi.platforms.roborio) - nativeDesktopZip wpi.deps.wpilibJni(wpi.platforms.desktop) - - - implementation wpi.deps.vendor.java() - nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio) - nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop) - - testImplementation 'junit:junit:4.12' - - // Enable simulation gui support. Must check the box in vscode to enable support - // upon debugging - simulation wpi.deps.sim.gui(wpi.platforms.desktop, false) -} - -// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar') -// in order to make them all available at runtime. Also adding the manifest so WPILib -// knows where to look for our Robot Class. -jar { - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } - manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS) -} +plugins { + id "java" + id "edu.wpi.first.GradleRIO" version "2020.1.2" +} + +sourceCompatibility = JavaVersion.VERSION_11 +targetCompatibility = JavaVersion.VERSION_11 + +def ROBOT_MAIN_CLASS = "frc.robot.Main" + +// Define my targets (RoboRIO) and artifacts (deployable files) +// This is added by GradleRIO's backing project EmbeddedTools. +deploy { + targets { + roboRIO("roborio") { + // Team number is loaded either from the .wpilib/wpilib_preferences.json + // or from command line. If not found an exception will be thrown. + // You can use getTeamOrDefault(team) instead of getTeamNumber if you + // want to store a team number in this file. + team = frc.getTeamNumber() + } + } + artifacts { + frcJavaArtifact('frcJava') { + targets << "roborio" + // Debug can be overridden by command line, for use with VSCode + debug = frc.getDebugOrDefault(false) + } + // Built in artifact to deploy arbitrary files to the roboRIO. + fileTreeArtifact('frcStaticFileDeploy') { + // The directory below is the local directory to deploy + files = fileTree(dir: 'src/main/deploy') + // Deploy to RoboRIO target, into /home/lvuser/deploy + targets << "roborio" + directory = '/home/lvuser/deploy' + } + } +} + +// Set this to true to enable desktop support. +def includeDesktopSupport = true + +// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries. +// Also defines JUnit 4. +dependencies { + implementation wpi.deps.wpilib() + nativeZip wpi.deps.wpilibJni(wpi.platforms.roborio) + nativeDesktopZip wpi.deps.wpilibJni(wpi.platforms.desktop) + + + implementation wpi.deps.vendor.java() + nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio) + nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop) + + testImplementation 'junit:junit:4.12' + + // Enable simulation gui support. Must check the box in vscode to enable support + // upon debugging + simulation wpi.deps.sim.gui(wpi.platforms.desktop, false) +} + +// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar') +// in order to make them all available at runtime. Also adding the manifest so WPILib +// knows where to look for our Robot Class. +jar { + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS) +} From 18b7c1400506b119818195e6e64c0ec2e95c5234 Mon Sep 17 00:00:00 2001 From: Patrick Frampton Date: Sat, 18 Jan 2020 15:46:25 -0500 Subject: [PATCH 2/8] Attempt to set up snobot --- build.gradle | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build.gradle b/build.gradle index e3de057..4af2893 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ plugins { id "java" id "edu.wpi.first.GradleRIO" version "2020.1.2" + id "com.snobot.simulator.plugin.SnobotSimulatorPlugin" version "2020-0.0.0" apply false } sourceCompatibility = JavaVersion.VERSION_11 @@ -40,6 +41,13 @@ deploy { // Set this to true to enable desktop support. def includeDesktopSupport = true +////////////////////////////////// +// SnobotSim +////////////////////////////////// +apply plugin: com.snobot.simulator.plugin.SnobotSimulatorPlugin +apply from: "snobotsim/snobot_sim.gradle" +////////////////////////////////// + // Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries. // Also defines JUnit 4. dependencies { From 45fc6c5a6f78e1d26b4b6f273b17e2ab6b858359 Mon Sep 17 00:00:00 2001 From: Patrick Frampton Date: Sat, 18 Jan 2020 15:46:32 -0500 Subject: [PATCH 3/8] Add missing files --- snobotsim/SnobotSim.json | 114 ++++++++++++++++++++++++++++++++++++ snobotsim/snobot_sim.gradle | 10 ++++ 2 files changed, 124 insertions(+) create mode 100644 snobotsim/SnobotSim.json create mode 100755 snobotsim/snobot_sim.gradle diff --git a/snobotsim/SnobotSim.json b/snobotsim/SnobotSim.json new file mode 100644 index 0000000..cfef5fd --- /dev/null +++ b/snobotsim/SnobotSim.json @@ -0,0 +1,114 @@ +{ + "maven_repos": { + "SnobotSim": "http://raw.githubusercontent.com/snobotsim/maven_repo/master/development", + "Wpi": "http://first.wpi.edu/FRC/roborio/maven/release/" + }, + "required_third_party": [ + "CTRE-Phoenix", + "REVRobotics", + "KauaiLabs_navX_FRC" + ], + "snobot_sim": { + "version_number": "2020-0.0.1", + "libraries": { + "java": [ + "com.snobot.simulator:snobot_sim_gui:${version_number}", + "com.snobot.simulator:snobot_sim_java:${version_number}", + "com.snobot.simulator:snobot_sim_joysticks:${version_number}", + "com.snobot.simulator:snobot_sim_utilities:${version_number}", + + "edu.wpi.first.ntcore:ntcore-jni:${wpilibVersion}:${nativeclassifier}" + ], + "jni": [ + "edu.wpi.first.wpiutil:wpiutil-cpp:${wpilibVersion}:${nativeclassifier}@zip", + "edu.wpi.first.hal:hal-cpp:${wpilibVersion}:${nativeclassifier}@zip", + + "edu.wpi.first.cscore:cscore-cpp:${wpilibVersion}:${nativeclassifier}@zip", + "edu.wpi.first.ntcore:ntcore-cpp:${wpilibVersion}:${nativeclassifier}@zip", + "edu.wpi.first.wpilibc:wpilibc-cpp:${wpilibVersion}:${nativeclassifier}@zip", + "edu.wpi.first.cameraserver:cameraserver-cpp:${wpilibVersion}:${nativeclassifier}@zip" + ], + "cpp": [ + "com.snobot.simulator:snobot_sim:${version_number}", + "com.snobot.simulator:adx_family:${version_number}", + "com.snobot.simulator:navx_simulator:${version_number}" + ], + "cpp_java": [ + "edu.wpi.first.wpilibj:wpilibj-java:${wpilibVersion}", + "edu.wpi.first.ntcore:ntcore-java:${wpilibVersion}", + "edu.wpi.first.cscore:cscore-java:${wpilibVersion}", + "edu.wpi.first.wpiutil:wpiutil-java:${wpilibVersion}", + "edu.wpi.first.hal:hal-java:${wpilibVersion}", + "edu.wpi.first.cameraserver:cameraserver-java:${wpilibVersion}" + ] + } + }, + "third_party": { + "libraries": { + "java": [ + "jfree:jfreechart:1.0.13", + "org.apache.logging.log4j:log4j-core:2.11.0", + "org.yaml:snakeyaml:1.18", + "com.miglayout:miglayout-swing:4.2", + "net.java.jinput:jinput:2.0.7" + ], + "jni": [ + "net.java.jinput:jinput:2.0.7" + ] + } + }, + "vendor_props": { + "vendors": { + "KauaiLabs_navX_FRC": { + "default_version": "3.1.400", + "versions": { + "3.1.400": { + "version_number": "3.1.400_V0_RC", + "libraries": { + "java": ["com.snobot.simulator:navx_simulator:${version_number}"], + "jni": ["com.snobot.simulator:navx_simulator:${version_number}:${nativeclassifier}"] + } + } + } + }, + "CTRE-Phoenix": { + "default_version": "5.17.2", + "versions": { + "5.17.2": { + "version_number": "5.17.2_V0_RC", + "libraries": { + "java": ["com.snobot.simulator:ctre_sim_override:${version_number}"], + "jni": ["com.snobot.simulator:ctre_sim_override:${version_number}:${nativeclassifier}"] + } + }, + "5.17.3": { + "version_number": "5.17.2_V0_RC", + "libraries": { + "java": ["com.snobot.simulator:ctre_sim_override:${version_number}"], + "jni": ["com.snobot.simulator:ctre_sim_override:${version_number}:${nativeclassifier}"] + } + } + } + }, + "REVRobotics": { + "default_version": "1.5.0", + "versions": { + "1.5.0": { + "version_number": "1.5.0_V0", + "libraries": { + "java": ["com.snobot.simulator:rev_simulator:${version_number}"], + "jni": ["com.snobot.simulator:rev_simulator:${version_number}:${nativeclassifier}"] + } + }, + "1.5.1": { + "version_number": "1.5.0_V0", + "libraries": { + "java": ["com.snobot.simulator:rev_simulator:${version_number}"], + "jni": ["com.snobot.simulator:rev_simulator:${version_number}:${nativeclassifier}"] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/snobotsim/snobot_sim.gradle b/snobotsim/snobot_sim.gradle new file mode 100755 index 0000000..e88318e --- /dev/null +++ b/snobotsim/snobot_sim.gradle @@ -0,0 +1,10 @@ + + +dependencies { + // SnobotSim + snobotSimCompile snobotSimJava() +} + +tasks.withType(Test) { + systemProperty "java.library.path", "$rootDir/build/tmp/snobotSimJava" +} From 6a45593437e8bcae7f6a5136f4742da1e82f54e9 Mon Sep 17 00:00:00 2001 From: Patrick Frampton Date: Mon, 20 Jan 2020 15:48:55 -0500 Subject: [PATCH 4/8] Add more files --- .gitignore | 3 +++ simulator_config/joystick_config.properties | 8 ++++++++ simulator_config/simulator_config.properties | 5 +++++ simulator_config/simulator_config.yml | 0 4 files changed, 16 insertions(+) create mode 100644 simulator_config/joystick_config.properties create mode 100644 simulator_config/simulator_config.properties create mode 100644 simulator_config/simulator_config.yml diff --git a/.gitignore b/.gitignore index 983678a..7da1399 100644 --- a/.gitignore +++ b/.gitignore @@ -159,3 +159,6 @@ imgui.ini # End of https://www.gitignore.io/api/c++,java,linux,macos,gradle,windows,visualstudiocode + +logs/* + diff --git a/simulator_config/joystick_config.properties b/simulator_config/joystick_config.properties new file mode 100644 index 0000000..1a9dc48 --- /dev/null +++ b/simulator_config/joystick_config.properties @@ -0,0 +1,8 @@ +# +#Mon Jan 20 15:47:23 EST 2020 +Joystick_1=Null Joystick---null +Joystick_2=Null Joystick---null +Joystick_0=Null Joystick---null +Joystick_5=Null Joystick---null +Joystick_3=Null Joystick---null +Joystick_4=Null Joystick---null diff --git a/simulator_config/simulator_config.properties b/simulator_config/simulator_config.properties new file mode 100644 index 0000000..0f99a01 --- /dev/null +++ b/simulator_config/simulator_config.properties @@ -0,0 +1,5 @@ +# +#Mon Jan 20 15:09:42 EST 2020 +robot_type=java +simulator_config=simulator_config/simulator_config.yml +robot_class=com.snobot.simulator.example_robot.ExampleRobot diff --git a/simulator_config/simulator_config.yml b/simulator_config/simulator_config.yml new file mode 100644 index 0000000..e69de29 From a1692db2515a7cf5371fbf81609460360f239768 Mon Sep 17 00:00:00 2001 From: ultragamer1010 <31806444+ultragamer1010@users.noreply.github.com> Date: Thu, 23 Jan 2020 19:16:22 -0500 Subject: [PATCH 5/8] Change shooter controls --- src/main/java/frc/robot/Robot.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 329cfa5..a23b1a4 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -30,6 +30,8 @@ public class Robot extends TimedRobot { Shooter shooter = null; XboxController driver = null; + double speed = 0; + /** * This function is run when the robot is first started up and should be used * for any initialization code. @@ -62,18 +64,26 @@ public void teleopInit() { @Override public void teleopPeriodic() { limelight.update(); - double speed = 0; if (driver.getTriggerAxis(Hand.kRight) > 0.5) { speed = -1 * driver.getY(Hand.kRight); } else if (driver.getAButton()) { - speed = 1; + speed -= 0.05; + } else if (driver.getYButton()) { + speed += 0.05; } + /* if (Math.abs(speed) < 0.1) { speed = 0; } + */ - shooter.manualControl(speed); + if (driver.getBButton()) { + shooter.manualControl(speed); + } else { + shooter.manualControl(0); + } + SmartDashboard.putNumber("ShooterPower", speed); SmartDashboard.putNumber("ShooterRPM", shooter.getLauncherRPM()); From 64ecd37697bc3f5a958dacc3727c050c4b63c1e3 Mon Sep 17 00:00:00 2001 From: ultragamer1010 <31806444+ultragamer1010@users.noreply.github.com> Date: Thu, 20 Feb 2020 19:07:48 -0500 Subject: [PATCH 6/8] Fix merge error --- src/main/java/frc/robot/Robot.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index f00d1af..c054b7b 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -59,8 +59,6 @@ public class Robot extends TimedRobot { double speed = 0; - double speed = 0; - /** * This function is run when the robot is first started up and should be used * for any initialization code. From e20034e87d1c04f9859c68744c9bf378f6dbb487 Mon Sep 17 00:00:00 2001 From: ultragamer1010 <31806444+ultragamer1010@users.noreply.github.com> Date: Sat, 29 Feb 2020 13:27:24 -0500 Subject: [PATCH 7/8] Add reverse controls on index loader --- src/main/java/frc/robot/Manipulation.java | 6 +++--- src/main/java/frc/robot/Robot.java | 17 +++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/frc/robot/Manipulation.java b/src/main/java/frc/robot/Manipulation.java index 8ed765e..ed1ea86 100644 --- a/src/main/java/frc/robot/Manipulation.java +++ b/src/main/java/frc/robot/Manipulation.java @@ -70,10 +70,10 @@ public void setIndexLoad(boolean load) { /** * Feeds power cells into the scoring system. * - * @param feed if it should feed the shooter power cells. + * @param power the power the motor should move at. */ - public void setIndexFeed(boolean feed) { - indexFeed.set(feed ? 1: 0); + public void setIndexFeed(double power) { + indexFeed.set(power); } /** diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index e9ba756..5be35f1 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -191,11 +191,10 @@ public void teleopPeriodic() { limelight.update(); } - if (driver.getXButtonPressed()) - limelight.setLightEnabled(true); - else if (driver.getYButtonPressed()) - limelight.setLightEnabled(false); - } + if (driver.getXButtonPressed()) + limelight.setLightEnabled(true); + else if (driver.getYButtonPressed()) + limelight.setLightEnabled(false); if (this.powercellDetectorToggle) { detector.update(); @@ -237,7 +236,13 @@ else if (driver.getYButtonPressed()) manipulation.setIntakeSpin(driver.getYButton()); - manipulation.setIndexFeed(driver.getBButton()); + if(operator.getBButton()) { + manipulation.setIndexFeed(1); + } else if (operator.getXButton()) { + manipulation.setIndexFeed(-1); + } else { + manipulation.setIndexFeed(0); + } manipulation.setIndexLoad(driver.getXButton()); } From 80b642173d57459da33d02ba51ddcfeab725e87c Mon Sep 17 00:00:00 2001 From: Jordan Miller Date: Mon, 2 Mar 2020 20:14:11 -0500 Subject: [PATCH 8/8] Claned up robot classes from manipulation --- src/main/java/frc/robot/Manipulation.java | 18 ++++++------ src/main/java/frc/robot/Robot.java | 35 ++++++++++++----------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/main/java/frc/robot/Manipulation.java b/src/main/java/frc/robot/Manipulation.java index ccf718c..b3f537e 100644 --- a/src/main/java/frc/robot/Manipulation.java +++ b/src/main/java/frc/robot/Manipulation.java @@ -1,8 +1,8 @@ package frc.robot; -import com.revrobotics.CANSparkMax; - import edu.wpi.first.wpilibj.DoubleSolenoid; +import edu.wpi.first.wpilibj.DoubleSolenoid.Value; +import com.revrobotics.CANSparkMax; public class Manipulation { @@ -20,7 +20,7 @@ public class Manipulation { /** * Constructor - * + * * @param intakeWheel The CAN id of the spark for the intake system * @param intakePneumatics The intake solenoid * @param indexLoad The CAN id of the spark for the index loader @@ -45,7 +45,7 @@ public class Manipulation { /** * Rotates the intake motor. - * + * * @param spin true if it should spin, false if not. */ public void setIntakeSpin(boolean spin) { @@ -55,7 +55,7 @@ public void setIntakeSpin(boolean spin) { /** * Moves the intake system. - * + * * @param extend true if it should extend, false if not. */ public void setIntakeExtend(boolean extend) { @@ -64,7 +64,7 @@ public void setIntakeExtend(boolean extend) { /** * Moves power cells down indexing system. - * + * * @param load true if it should load */ public void setIndexLoad(boolean load) { @@ -74,7 +74,7 @@ public void setIndexLoad(boolean load) { /** * Feeds power cells into the scoring system. - * + * * @param power the power thr motor pull turn at. */ public void setIndexFeed(double power) { @@ -104,10 +104,10 @@ public void updateIndex() { /** * Gets current amount of balls in the index system. - * + * * @return current amount of balls in the index system. */ public int getBalls() { return balls; } -} +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 769b12e..16ac557 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -7,22 +7,29 @@ package frc.robot; +import frc.robot.Limelight; +import frc.robot.Shooter; +import frc.robot.Manipulation; + import java.io.File; import java.nio.file.Paths; -import com.ctre.phoenix.motorcontrol.can.TalonFX; import com.kauailabs.navx.frc.AHRS; +import edu.wpi.first.wpilibj.SPI; + +import com.ctre.phoenix.motorcontrol.can.TalonFX; import com.moandjiezana.toml.Toml; import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkMaxLowLevel.MotorType; +import edu.wpi.first.wpilibj.DoubleSolenoid; +import edu.wpi.first.wpilibj.Talon; import edu.wpi.first.wpilibj.Compressor; -import edu.wpi.first.wpilibj.DigitalInput; -import edu.wpi.first.wpilibj.GenericHID.Hand; -import edu.wpi.first.wpilibj.SPI; import edu.wpi.first.wpilibj.Solenoid; +import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.XboxController; +import edu.wpi.first.wpilibj.GenericHID.Hand; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; /** @@ -60,16 +67,16 @@ public class Robot extends TimedRobot { /** * CAN ID's: - * + * * PDP -> 1 PCM -> 2 Climber -> 4 Drive -> 5-10 Shooter -> 11 Shooter Hood -> 12 * Intake -> 13 Helix Index -> 14 Feeder Index -> 15 Pull Index -> 16 - * - * - * - * - * + * + * + * + * + * * PCM Channels: - * + * * Drivetrain PTO's -> 0 Manipulation Forward -> 1 Manipulation Reverse -> 2 */ @@ -187,11 +194,6 @@ else if (driver.getYButtonPressed()) limelight.setLightEnabled(false); } - if (driver.getXButtonPressed()) - limelight.setLightEnabled(true); - else if (driver.getYButtonPressed()) - limelight.setLightEnabled(false); - if (this.powercellDetectorToggle) { detector.update(); } @@ -204,6 +206,7 @@ else if (driver.getYButtonPressed()) speed = -1 * operator.getY(Hand.kRight); shooterAngleSpeed = operator.getY(Hand.kLeft); } + if (Math.abs(speed) < 0.1) { speed = 0; }