mirror of
https://github.com/Team4388/Robot-Essentials.git
synced 2026-06-09 08:48:02 -06:00
Merge pull request #6 from Team4388/2020-framework-update
2020 Framework Update
This commit is contained in:
@@ -155,6 +155,7 @@ gradle-app.setting
|
|||||||
.project
|
.project
|
||||||
.settings/
|
.settings/
|
||||||
bin/
|
bin/
|
||||||
|
imgui.ini
|
||||||
|
|
||||||
|
|
||||||
# End of https://www.gitignore.io/api/c++,java,linux,macos,gradle,windows,visualstudiocode
|
# End of https://www.gitignore.io/api/c++,java,linux,macos,gradle,windows,visualstudiocode
|
||||||
|
|||||||
Vendored
+5
-4
@@ -7,8 +7,9 @@
|
|||||||
"**/CVS": true,
|
"**/CVS": true,
|
||||||
"**/.DS_Store": true,
|
"**/.DS_Store": true,
|
||||||
"bin/": true,
|
"bin/": true,
|
||||||
".classpath": true,
|
"**/.classpath": true,
|
||||||
".project": true
|
"**/.project": true,
|
||||||
},
|
"**/.settings": true,
|
||||||
"wpilib.online": true
|
"**/.factorypath": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"enableCppIntellisense": false,
|
"enableCppIntellisense": false,
|
||||||
"currentLanguage": "java",
|
"currentLanguage": "java",
|
||||||
"projectYear": "2019",
|
"projectYear": "2020",
|
||||||
"teamNumber": 4388
|
"teamNumber": 4388
|
||||||
}
|
}
|
||||||
+18
-11
@@ -1,8 +1,11 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "java"
|
id "java"
|
||||||
id "edu.wpi.first.GradleRIO" version "2019.1.1"
|
id "edu.wpi.first.GradleRIO" version "2020.1.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
|
||||||
def ROBOT_MAIN_CLASS = "frc4388.robot.Main"
|
def ROBOT_MAIN_CLASS = "frc4388.robot.Main"
|
||||||
|
|
||||||
// Define my targets (RoboRIO) and artifacts (deployable files)
|
// Define my targets (RoboRIO) and artifacts (deployable files)
|
||||||
@@ -35,27 +38,31 @@ deploy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set this to true to enable desktop support.
|
// Set this to true to enable desktop support.
|
||||||
def includeDesktopSupport = false
|
def includeDesktopSupport = true
|
||||||
|
|
||||||
// Maven central needed for JUnit
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
|
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
|
||||||
// Also defines JUnit 4.
|
// Also defines JUnit 4.
|
||||||
dependencies {
|
dependencies {
|
||||||
compile wpi.deps.wpilib()
|
implementation wpi.deps.wpilib()
|
||||||
compile wpi.deps.vendor.java()
|
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)
|
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
|
||||||
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
|
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
|
||||||
testCompile 'junit:junit:4.12'
|
|
||||||
|
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')
|
// 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
|
// in order to make them all available at runtime. Also adding the manifest so WPILib
|
||||||
// knows where to look for our Robot Class.
|
// knows where to look for our Robot Class.
|
||||||
jar {
|
jar {
|
||||||
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
|
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||||
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
|
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=permwrapper/dists
|
distributionPath=permwrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=permwrapper/dists
|
zipStorePath=permwrapper/dists
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
##
|
||||||
## Gradle start up script for UN*X
|
## Gradle start up script for UN*X
|
||||||
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
|
|||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD="maximum"
|
||||||
@@ -109,8 +125,8 @@ if $darwin; then
|
|||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if $cygwin ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
@@ -138,19 +154,19 @@ if $cygwin ; then
|
|||||||
else
|
else
|
||||||
eval `echo args$i`="\"$arg\""
|
eval `echo args$i`="\"$arg\""
|
||||||
fi
|
fi
|
||||||
i=$((i+1))
|
i=`expr $i + 1`
|
||||||
done
|
done
|
||||||
case $i in
|
case $i in
|
||||||
(0) set -- ;;
|
0) set -- ;;
|
||||||
(1) set -- "$args0" ;;
|
1) set -- "$args0" ;;
|
||||||
(2) set -- "$args0" "$args1" ;;
|
2) set -- "$args0" "$args1" ;;
|
||||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -159,14 +175,9 @@ save () {
|
|||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
echo " "
|
echo " "
|
||||||
}
|
}
|
||||||
APP_ARGS=$(save "$@")
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
|
||||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
Vendored
+17
-1
@@ -1,3 +1,19 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
|
|||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|||||||
+5
-3
@@ -4,17 +4,19 @@ pluginManagement {
|
|||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
String frcYear = '2019'
|
String frcYear = '2020'
|
||||||
File frcHome
|
File frcHome
|
||||||
if (OperatingSystem.current().isWindows()) {
|
if (OperatingSystem.current().isWindows()) {
|
||||||
String publicFolder = System.getenv('PUBLIC')
|
String publicFolder = System.getenv('PUBLIC')
|
||||||
if (publicFolder == null) {
|
if (publicFolder == null) {
|
||||||
publicFolder = "C:\\Users\\Public"
|
publicFolder = "C:\\Users\\Public"
|
||||||
}
|
}
|
||||||
frcHome = new File(publicFolder, "frc${frcYear}")
|
def homeRoot = new File(publicFolder, "wpilib")
|
||||||
|
frcHome = new File(homeRoot, frcYear)
|
||||||
} else {
|
} else {
|
||||||
def userFolder = System.getProperty("user.home")
|
def userFolder = System.getProperty("user.home")
|
||||||
frcHome = new File(userFolder, "frc${frcYear}")
|
def homeRoot = new File(userFolder, "wpilib")
|
||||||
|
frcHome = new File(homeRoot, frcYear)
|
||||||
}
|
}
|
||||||
def frcHomeMaven = new File(frcHome, 'maven')
|
def frcHomeMaven = new File(frcHome, 'maven')
|
||||||
maven {
|
maven {
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||||
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||||
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||||
|
/* the project. */
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
package frc4388.robot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean
|
||||||
|
* constants. This class should not be used for any other purpose. All constants should be
|
||||||
|
* declared globally (i.e. public static). Do not put anything functional in this class.
|
||||||
|
*
|
||||||
|
* <p>It is advised to statically import this class (or one of its inner classes) wherever the
|
||||||
|
* constants are needed, to reduce verbosity.
|
||||||
|
*/
|
||||||
|
public final class Constants {
|
||||||
|
public static final class DriveConstants {
|
||||||
|
public static final int DRIVE_LEFT_FRONT_CAN_ID = 2;
|
||||||
|
public static final int DRIVE_RIGHT_FRONT_CAN_ID = 4;
|
||||||
|
public static final int DRIVE_LEFT_BACK_CAN_ID = 3;
|
||||||
|
public static final int DRIVE_RIGHT_BACK_CAN_ID = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class LEDConstants {
|
||||||
|
public static final int LED_SPARK_ID = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class OIConstants {
|
||||||
|
public static final int XBOX_DRIVER_ID = 0;
|
||||||
|
public static final int XBOX_OPERATOR_ID = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
|
||||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
||||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
||||||
/* the project. */
|
|
||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
package frc4388.robot;
|
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.Joystick;
|
|
||||||
import edu.wpi.first.wpilibj.buttons.JoystickButton;
|
|
||||||
import frc4388.robot.commands.Drive.DriveWithJoystick;
|
|
||||||
import frc4388.robot.commands.Drive.GamerMove;
|
|
||||||
import frc4388.utility.controller.IHandController;
|
|
||||||
import frc4388.utility.controller.XboxController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is the glue that binds the controls on the physical operator
|
|
||||||
* interface to the commands and command groups that allow control of the robot.
|
|
||||||
*/
|
|
||||||
public class OI {
|
|
||||||
//// CREATING BUTTONS
|
|
||||||
// One type of button is a joystick button which is any button on a
|
|
||||||
//// joystick.
|
|
||||||
// You create one by telling it which joystick it's on and which button
|
|
||||||
// number it is.
|
|
||||||
// Joystick stick = new Joystick(port);
|
|
||||||
// Button button = new JoystickButton(stick, buttonNumber);
|
|
||||||
|
|
||||||
// There are a few additional built in buttons you can use. Additionally,
|
|
||||||
// by subclassing Button you can create custom triggers and bind those to
|
|
||||||
// commands the same as any other Button.
|
|
||||||
|
|
||||||
//// TRIGGERING COMMANDS WITH BUTTONS
|
|
||||||
// Once you have a button, it's trivial to bind it to a button in one of
|
|
||||||
// three ways:
|
|
||||||
|
|
||||||
// Start the command when the button is pressed and let it run the command
|
|
||||||
// until it is finished as determined by it's isFinished method.
|
|
||||||
// button.whenPressed(new ExampleCommand());
|
|
||||||
|
|
||||||
// Run the command while the button is being held down and interrupt it once
|
|
||||||
// the button is released.
|
|
||||||
// button.whileHeld(new ExampleCommand());
|
|
||||||
|
|
||||||
// Start the command when the button is released and let it run the command
|
|
||||||
// until it is finished as determined by it's isFinished method.
|
|
||||||
// button.whenReleased(new ExampleCommand());
|
|
||||||
|
|
||||||
private static OI instance;
|
|
||||||
|
|
||||||
public static XboxController m_driverXbox;
|
|
||||||
private static XboxController m_operatorXbox;
|
|
||||||
|
|
||||||
public OI() {
|
|
||||||
m_driverXbox = new XboxController(RobotMap.XBOX_DRIVER_ID);
|
|
||||||
m_operatorXbox = new XboxController(RobotMap.XBOX_OPERATOR_ID);
|
|
||||||
|
|
||||||
JoystickButton GamerMove = new JoystickButton(getDriverJoystick(), XboxController.A_BUTTON);
|
|
||||||
GamerMove.whenPressed(new GamerMove());
|
|
||||||
GamerMove.whenReleased(new DriveWithJoystick());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OI getInstance() {
|
|
||||||
if(instance == null) {
|
|
||||||
instance = new OI();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IHandController getDriverController() {
|
|
||||||
return m_driverXbox;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IHandController getOperatorController()
|
|
||||||
{
|
|
||||||
return m_operatorXbox;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Joystick getOperatorJoystick()
|
|
||||||
{
|
|
||||||
return m_operatorXbox.getJoyStick();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Joystick getDriverJoystick()
|
|
||||||
{
|
|
||||||
return m_driverXbox.getJoyStick();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||||
/* the project. */
|
/* the project. */
|
||||||
@@ -8,15 +8,8 @@
|
|||||||
package frc4388.robot;
|
package frc4388.robot;
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.TimedRobot;
|
import edu.wpi.first.wpilibj.TimedRobot;
|
||||||
import edu.wpi.first.wpilibj.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
import edu.wpi.first.wpilibj.command.Scheduler;
|
import edu.wpi.first.wpilibj2.command.CommandScheduler;
|
||||||
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
|
|
||||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
|
||||||
import frc4388.robot.commands.ExampleCommand;
|
|
||||||
import frc4388.robot.subsystems.Drive;
|
|
||||||
import frc4388.robot.subsystems.ExampleSubsystem;
|
|
||||||
import frc4388.robot.subsystems.LED;
|
|
||||||
import frc4388.utility.controller.XboxController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The VM is configured to automatically run this class, and to call the
|
* The VM is configured to automatically run this class, and to call the
|
||||||
@@ -26,13 +19,9 @@ import frc4388.utility.controller.XboxController;
|
|||||||
* project.
|
* project.
|
||||||
*/
|
*/
|
||||||
public class Robot extends TimedRobot {
|
public class Robot extends TimedRobot {
|
||||||
public static ExampleSubsystem m_subsystem = new ExampleSubsystem();
|
|
||||||
public static LED m_led = new LED();
|
|
||||||
public static Drive m_Drive = new Drive();
|
|
||||||
public static OI m_oi;
|
|
||||||
|
|
||||||
Command m_autonomousCommand;
|
Command m_autonomousCommand;
|
||||||
SendableChooser<Command> m_chooser = new SendableChooser<>();
|
|
||||||
|
private RobotContainer m_robotContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is run when the robot is first started up and should be
|
* This function is run when the robot is first started up and should be
|
||||||
@@ -40,10 +29,9 @@ public class Robot extends TimedRobot {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void robotInit() {
|
public void robotInit() {
|
||||||
m_oi = new OI();
|
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
|
||||||
m_chooser.setDefaultOption("Default Auto", new ExampleCommand());
|
// autonomous chooser on the dashboard.
|
||||||
// chooser.addOption("My Auto", new MyAutoCommand());
|
m_robotContainer = new RobotContainer();
|
||||||
SmartDashboard.putData("Auto mode", m_chooser);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,6 +44,11 @@ public class Robot extends TimedRobot {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void robotPeriodic() {
|
public void robotPeriodic() {
|
||||||
|
// Runs the Scheduler. This is responsible for polling buttons, adding newly-scheduled
|
||||||
|
// commands, running already-scheduled commands, removing finished or interrupted commands,
|
||||||
|
// and running subsystem periodic() methods. This must be called from the robot's periodic
|
||||||
|
// block in order for anything in the Command-based framework to work.
|
||||||
|
CommandScheduler.getInstance().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,23 +62,14 @@ public class Robot extends TimedRobot {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disabledPeriodic() {
|
public void disabledPeriodic() {
|
||||||
Scheduler.getInstance().run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This autonomous (along with the chooser code above) shows how to select
|
* This autonomous runs the autonomous command selected by your {@link RobotContainer} class.
|
||||||
* between different autonomous modes using the dashboard. The sendable
|
|
||||||
* chooser code works with the Java SmartDashboard. If you prefer the
|
|
||||||
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
|
|
||||||
* getString code to get the auto name from the text box below the Gyro
|
|
||||||
*
|
|
||||||
* <p>You can add additional auto modes by adding additional commands to the
|
|
||||||
* chooser code above (like the commented example) or additional comparisons
|
|
||||||
* to the switch structure below with additional strings & commands.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void autonomousInit() {
|
public void autonomousInit() {
|
||||||
m_autonomousCommand = m_chooser.getSelected();
|
m_autonomousCommand = m_robotContainer.getAutonomousCommand();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* String autoSelected = SmartDashboard.getString("Auto Selector",
|
* String autoSelected = SmartDashboard.getString("Auto Selector",
|
||||||
@@ -96,7 +80,7 @@ public class Robot extends TimedRobot {
|
|||||||
|
|
||||||
// schedule the autonomous command (example)
|
// schedule the autonomous command (example)
|
||||||
if (m_autonomousCommand != null) {
|
if (m_autonomousCommand != null) {
|
||||||
m_autonomousCommand.start();
|
m_autonomousCommand.schedule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +89,6 @@ public class Robot extends TimedRobot {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void autonomousPeriodic() {
|
public void autonomousPeriodic() {
|
||||||
Scheduler.getInstance().run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -124,7 +107,7 @@ public class Robot extends TimedRobot {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void teleopPeriodic() {
|
public void teleopPeriodic() {
|
||||||
Scheduler.getInstance().run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||||
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||||
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||||
|
/* the project. */
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
package frc4388.robot;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj.Joystick;
|
||||||
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
import edu.wpi.first.wpilibj2.command.InstantCommand;
|
||||||
|
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
|
||||||
|
import frc4388.robot.Constants.*;
|
||||||
|
import frc4388.robot.commands.Drive.DriveWithJoystick;
|
||||||
|
import frc4388.robot.commands.Drive.GamerMove;
|
||||||
|
import frc4388.robot.commands.LED.UpdateLED;
|
||||||
|
import frc4388.robot.subsystems.Drive;
|
||||||
|
import frc4388.robot.subsystems.LED;
|
||||||
|
import frc4388.utility.controller.IHandController;
|
||||||
|
import frc4388.utility.controller.XboxController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is where the bulk of the robot should be declared. Since
|
||||||
|
* Command-based is a "declarative" paradigm, very little robot logic should
|
||||||
|
* actually be handled in the {@link Robot} periodic methods (other than the
|
||||||
|
* scheduler calls). Instead, the structure of the robot (including subsystems,
|
||||||
|
* commands, and button mappings) should be declared here.
|
||||||
|
*/
|
||||||
|
public class RobotContainer {
|
||||||
|
/* Subsystems */
|
||||||
|
private final Drive m_robotDrive = new Drive();
|
||||||
|
private final LED m_robotLED = new LED();
|
||||||
|
|
||||||
|
/* Controllers */
|
||||||
|
private final XboxController m_driverXbox = new XboxController(OIConstants.XBOX_DRIVER_ID);
|
||||||
|
private final XboxController m_operatorXbox = new XboxController(OIConstants.XBOX_OPERATOR_ID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The container for the robot. Contains subsystems, OI devices, and commands.
|
||||||
|
*/
|
||||||
|
public RobotContainer() {
|
||||||
|
configureButtonBindings();
|
||||||
|
|
||||||
|
/* Default Commands */
|
||||||
|
m_robotDrive.setDefaultCommand(new DriveWithJoystick(m_robotDrive, getDriverController()));
|
||||||
|
m_robotLED.setDefaultCommand(new UpdateLED(m_robotLED));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to define your button->command mappings. Buttons can be created by
|
||||||
|
* instantiating a {@link GenericHID} or one of its subclasses ({@link
|
||||||
|
* edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then passing it to a
|
||||||
|
* {@link edu.wpi.first.wpilibj2.command.button.JoystickButton}.
|
||||||
|
*/
|
||||||
|
private void configureButtonBindings() {
|
||||||
|
new JoystickButton(getDriverJoystick(), XboxController.A_BUTTON)
|
||||||
|
.whenPressed(new GamerMove(m_robotDrive))
|
||||||
|
.whenReleased(new DriveWithJoystick(m_robotDrive, getDriverController()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this to pass the autonomous command to the main {@link Robot} class.
|
||||||
|
*
|
||||||
|
* @return the command to run in autonomous
|
||||||
|
*/
|
||||||
|
public Command getAutonomousCommand() {
|
||||||
|
// no auto
|
||||||
|
return new InstantCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public IHandController getDriverController() {
|
||||||
|
return m_driverXbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IHandController getOperatorController()
|
||||||
|
{
|
||||||
|
return m_operatorXbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Joystick getOperatorJoystick()
|
||||||
|
{
|
||||||
|
return m_operatorXbox.getJoyStick();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Joystick getDriverJoystick()
|
||||||
|
{
|
||||||
|
return m_driverXbox.getJoyStick();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
|
||||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
||||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
||||||
/* the project. */
|
|
||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
package frc4388.robot;
|
|
||||||
|
|
||||||
import frc4388.utility.controller.XboxController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The RobotMap is a mapping from the ports sensors and actuators are wired into
|
|
||||||
* to a variable name. This provides flexibility changing wiring, makes checking
|
|
||||||
* the wiring easier and significantly reduces the number of magic numbers
|
|
||||||
* floating around.
|
|
||||||
*/
|
|
||||||
public class RobotMap {
|
|
||||||
// For example to map the left and right motors, you could define the
|
|
||||||
// following variables to use with your drivetrain subsystem.
|
|
||||||
// public static int leftMotor = 1;
|
|
||||||
// public static int rightMotor = 2;
|
|
||||||
|
|
||||||
// If you are using multiple modules, make sure to define both the port
|
|
||||||
// number and the module. For example you with a rangefinder:
|
|
||||||
// public static int rangefinderPort = 1;
|
|
||||||
// public static int rangefinderModule = 1;
|
|
||||||
|
|
||||||
/* Xbox Controllers */
|
|
||||||
public static final int XBOX_DRIVER_ID = 0;
|
|
||||||
public static final int XBOX_OPERATOR_ID = 1;
|
|
||||||
|
|
||||||
/* Blinkin LED Strip */
|
|
||||||
public static final int LED_SPARK_ID = 0;
|
|
||||||
|
|
||||||
/* Drive Train */
|
|
||||||
public static final int DRIVE_LEFT_FRONT_CAN_ID = 2;
|
|
||||||
public static final int DRIVE_RIGHT_FRONT_CAN_ID = 4;
|
|
||||||
public static final int DRIVE_LEFT_BACK_CAN_ID = 3;
|
|
||||||
public static final int DRIVE_RIGHT_BACK_CAN_ID = 5;
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||||
/* the project. */
|
/* the project. */
|
||||||
@@ -7,47 +7,46 @@
|
|||||||
|
|
||||||
package frc4388.robot.commands.Drive;
|
package frc4388.robot.commands.Drive;
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.command.Command;
|
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||||
import frc4388.robot.OI;
|
import frc4388.robot.subsystems.Drive;
|
||||||
import frc4388.robot.Robot;
|
import frc4388.utility.controller.IHandController;
|
||||||
|
|
||||||
public class DriveWithJoystick extends Command {
|
public class DriveWithJoystick extends CommandBase {
|
||||||
|
|
||||||
|
private final Drive m_drive;
|
||||||
|
private final IHandController m_driverXbox;
|
||||||
public double m_inputMove, m_inputSteer;
|
public double m_inputMove, m_inputSteer;
|
||||||
|
|
||||||
public DriveWithJoystick() {
|
/**
|
||||||
// Use requires() here to declare subsystem dependencies
|
* Creates a new DriveWithJoystick, driving the robot with the given controller
|
||||||
// eg. requires(chassis);
|
*/
|
||||||
requires(Robot.m_Drive);
|
public DriveWithJoystick(Drive subsystem, IHandController controller) {
|
||||||
|
m_drive = subsystem;
|
||||||
|
m_driverXbox = controller;
|
||||||
|
addRequirements(m_drive);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called just before this Command runs the first time
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
protected void initialize() {
|
public void initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called repeatedly when this Command is scheduled to run
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
protected void execute() {
|
public void execute() {
|
||||||
m_inputMove = OI.getInstance().getDriverController().getLeftYAxis();
|
m_inputMove = m_driverXbox.getLeftYAxis();
|
||||||
m_inputSteer = -(OI.getInstance().getDriverController().getRightXAxis());
|
m_inputSteer = m_driverXbox.getRightXAxis();
|
||||||
Robot.m_Drive.driveWithInput(m_inputMove, m_inputSteer);
|
m_drive.driveWithInput(m_inputMove, m_inputSteer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make this return true when this Command no longer needs to run execute()
|
// Called once the command ends or is interrupted.
|
||||||
@Override
|
@Override
|
||||||
protected boolean isFinished() {
|
public void end(boolean interrupted) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once after isFinished returns true
|
|
||||||
@Override
|
|
||||||
protected void end() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when another command which requires one or more of the same
|
|
||||||
// subsystems is scheduled to run
|
|
||||||
@Override
|
|
||||||
protected void interrupted() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||||
/* the project. */
|
/* the project. */
|
||||||
@@ -7,41 +7,41 @@
|
|||||||
|
|
||||||
package frc4388.robot.commands.Drive;
|
package frc4388.robot.commands.Drive;
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.command.Command;
|
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||||
import frc4388.robot.Robot;
|
|
||||||
|
|
||||||
public class GamerMove extends Command {
|
import frc4388.robot.subsystems.Drive;
|
||||||
public GamerMove() {
|
|
||||||
// Use requires() here to declare subsystem dependencies
|
public class GamerMove extends CommandBase {
|
||||||
// eg. requires(chassis);
|
|
||||||
requires(Robot.m_Drive);
|
private final Drive m_drive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new GamerMove.
|
||||||
|
*/
|
||||||
|
public GamerMove(Drive subsystem) {
|
||||||
|
m_drive = subsystem;
|
||||||
|
addRequirements(m_drive);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called just before this Command runs the first time
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
protected void initialize() {
|
public void initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called repeatedly when this Command is scheduled to run
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
protected void execute() {
|
public void execute() {
|
||||||
Robot.m_Drive.driveWithInput(0, 1);
|
m_drive.driveWithInput(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make this return true when this Command no longer needs to run execute()
|
// Called once the command ends or is interrupted.
|
||||||
@Override
|
@Override
|
||||||
protected boolean isFinished() {
|
public void end(boolean interrupted) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once after isFinished returns true
|
|
||||||
@Override
|
|
||||||
protected void end() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when another command which requires one or more of the same
|
|
||||||
// subsystems is scheduled to run
|
|
||||||
@Override
|
|
||||||
protected void interrupted() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
|
||||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
||||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
||||||
/* the project. */
|
|
||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
package frc4388.robot.commands;
|
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.command.Command;
|
|
||||||
import frc4388.robot.Robot;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An example command. You can replace me with your own command.
|
|
||||||
*/
|
|
||||||
public class ExampleCommand extends Command {
|
|
||||||
public ExampleCommand() {
|
|
||||||
// Use requires() here to declare subsystem dependencies
|
|
||||||
requires(Robot.m_subsystem);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called just before this Command runs the first time
|
|
||||||
@Override
|
|
||||||
protected void initialize() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called repeatedly when this Command is scheduled to run
|
|
||||||
@Override
|
|
||||||
protected void execute() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make this return true when this Command no longer needs to run execute()
|
|
||||||
@Override
|
|
||||||
protected boolean isFinished() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called once after isFinished returns true
|
|
||||||
@Override
|
|
||||||
protected void end() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when another command which requires one or more of the same
|
|
||||||
// subsystems is scheduled to run
|
|
||||||
@Override
|
|
||||||
protected void interrupted() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||||
/* the project. */
|
/* the project. */
|
||||||
@@ -7,45 +7,28 @@
|
|||||||
|
|
||||||
package frc4388.robot.commands.LED;
|
package frc4388.robot.commands.LED;
|
||||||
|
|
||||||
import frc4388.robot.Robot;
|
import edu.wpi.first.wpilibj2.command.InstantCommand;
|
||||||
|
|
||||||
import frc4388.robot.constants.LEDPatterns;
|
import frc4388.robot.constants.LEDPatterns;
|
||||||
|
import frc4388.robot.subsystems.LED;
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.command.Command;
|
// NOTE: Consider using this command inline, rather than writing a subclass. For more
|
||||||
|
// information, see:
|
||||||
public class SetLEDPattern extends Command {
|
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
|
||||||
|
public class SetLEDPattern extends InstantCommand {
|
||||||
|
|
||||||
|
private final LED m_led;
|
||||||
public static LEDPatterns m_pattern;
|
public static LEDPatterns m_pattern;
|
||||||
|
|
||||||
public SetLEDPattern(LEDPatterns pattern) {
|
public SetLEDPattern(LED subsystem, LEDPatterns pattern) {
|
||||||
requires(Robot.m_led);
|
m_led = subsystem;
|
||||||
m_pattern = pattern;
|
m_pattern = pattern;
|
||||||
|
addRequirements(m_led);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called just before this Command runs the first time
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
protected void initialize() {
|
public void initialize() {
|
||||||
}
|
m_led.setPattern(m_pattern);
|
||||||
|
|
||||||
// Called repeatedly when this Command is scheduled to run
|
|
||||||
@Override
|
|
||||||
protected void execute() {
|
|
||||||
Robot.m_led.setPattern(m_pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make this return true when this Command no longer needs to run execute()
|
|
||||||
@Override
|
|
||||||
protected boolean isFinished() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called once after isFinished returns true
|
|
||||||
@Override
|
|
||||||
protected void end() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when another command which requires one or more of the same
|
|
||||||
// subsystems is scheduled to run
|
|
||||||
@Override
|
|
||||||
protected void interrupted() {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||||
/* the project. */
|
/* the project. */
|
||||||
@@ -7,40 +7,41 @@
|
|||||||
|
|
||||||
package frc4388.robot.commands.LED;
|
package frc4388.robot.commands.LED;
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.command.Command;
|
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||||
import frc4388.robot.Robot;
|
|
||||||
|
|
||||||
public class UpdateLED extends Command {
|
import frc4388.robot.subsystems.LED;
|
||||||
public UpdateLED() {
|
|
||||||
// Use requires() here to declare subsystem dependencies
|
public class UpdateLED extends CommandBase {
|
||||||
requires(Robot.m_led);
|
|
||||||
|
private final LED m_LED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new UpdateLED that continually runs updateLED in the LED subsystem.
|
||||||
|
*/
|
||||||
|
public UpdateLED(LED subsystem) {
|
||||||
|
m_LED = subsystem;
|
||||||
|
addRequirements(m_LED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called just before this Command runs the first time
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
protected void initialize() {
|
public void initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called repeatedly when this Command is scheduled to run
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
protected void execute() {
|
public void execute() {
|
||||||
Robot.m_led.updateLED();
|
m_LED.updateLED();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make this return true when this Command no longer needs to run execute()
|
// Called once the command ends or is interrupted.
|
||||||
@Override
|
@Override
|
||||||
protected boolean isFinished() {
|
public void end(boolean interrupted) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once after isFinished returns true
|
|
||||||
@Override
|
|
||||||
protected void end() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when another command which requires one or more of the same
|
|
||||||
// subsystems is scheduled to run
|
|
||||||
@Override
|
|
||||||
protected void interrupted() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,38 +7,29 @@
|
|||||||
|
|
||||||
package frc4388.robot.subsystems;
|
package frc4388.robot.subsystems;
|
||||||
|
|
||||||
import com.ctre.phoenix.motorcontrol.Faults;
|
|
||||||
import com.ctre.phoenix.motorcontrol.InvertType;
|
import com.ctre.phoenix.motorcontrol.InvertType;
|
||||||
import com.ctre.phoenix.motorcontrol.NeutralMode;
|
import com.ctre.phoenix.motorcontrol.NeutralMode;
|
||||||
import com.ctre.phoenix.motorcontrol.can.TalonSRX;
|
|
||||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.Talon;
|
|
||||||
import edu.wpi.first.wpilibj.command.Subsystem;
|
|
||||||
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||||
import frc4388.robot.RobotMap;
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||||
import frc4388.robot.commands.Drive.DriveWithJoystick;
|
|
||||||
import frc4388.robot.commands.Drive.GamerMove;
|
import frc4388.robot.Constants.DriveConstants;
|
||||||
import frc4388.robot.OI;
|
|
||||||
import frc4388.robot.Robot;
|
|
||||||
import frc4388.utility.controller.XboxController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add your docs here.
|
* Add your docs here.
|
||||||
*/
|
*/
|
||||||
public class Drive extends Subsystem {
|
public class Drive extends SubsystemBase {
|
||||||
// Put methods for controlling this subsystem
|
// Put methods for controlling this subsystem
|
||||||
// here. Call these from Commands.
|
// here. Call these from Commands.
|
||||||
|
|
||||||
public static WPI_TalonSRX m_leftFrontMotor = new WPI_TalonSRX(RobotMap.DRIVE_LEFT_FRONT_CAN_ID);
|
public static WPI_TalonSRX m_leftFrontMotor = new WPI_TalonSRX(DriveConstants.DRIVE_LEFT_FRONT_CAN_ID);
|
||||||
public static WPI_TalonSRX m_rightFrontMotor = new WPI_TalonSRX(RobotMap.DRIVE_RIGHT_FRONT_CAN_ID);
|
public static WPI_TalonSRX m_rightFrontMotor = new WPI_TalonSRX(DriveConstants.DRIVE_RIGHT_FRONT_CAN_ID);
|
||||||
public static WPI_TalonSRX m_leftBackMotor = new WPI_TalonSRX(RobotMap.DRIVE_LEFT_BACK_CAN_ID);
|
public static WPI_TalonSRX m_leftBackMotor = new WPI_TalonSRX(DriveConstants.DRIVE_LEFT_BACK_CAN_ID);
|
||||||
public static WPI_TalonSRX m_rightBackMotor = new WPI_TalonSRX(RobotMap.DRIVE_RIGHT_BACK_CAN_ID);
|
public static WPI_TalonSRX m_rightBackMotor = new WPI_TalonSRX(DriveConstants.DRIVE_RIGHT_BACK_CAN_ID);
|
||||||
|
|
||||||
public static DifferentialDrive m_driveTrain = new DifferentialDrive(m_leftFrontMotor, m_rightFrontMotor);
|
public static DifferentialDrive m_driveTrain = new DifferentialDrive(m_leftFrontMotor, m_rightFrontMotor);
|
||||||
|
|
||||||
private static double m_inputMove, m_inputSteer;
|
|
||||||
|
|
||||||
public Drive(){
|
public Drive(){
|
||||||
/* factory default values */
|
/* factory default values */
|
||||||
m_leftFrontMotor.configFactoryDefault();
|
m_leftFrontMotor.configFactoryDefault();
|
||||||
@@ -67,10 +58,10 @@ public class Drive extends Subsystem {
|
|||||||
m_driveTrain.arcadeDrive(move, steer);
|
m_driveTrain.arcadeDrive(move, steer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/* @Override
|
||||||
public void initDefaultCommand(){
|
public void initDefaultCommand(){
|
||||||
// Set the default command for a subsystem here.
|
// Set the default command for a subsystem here.
|
||||||
// setDefaultCommand(new MySpecialCommand());
|
// setDefaultCommand(new MySpecialCommand());
|
||||||
setDefaultCommand(new DriveWithJoystick());
|
setDefaultCommand(new DriveWithJoystick());
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
|
||||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
||||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
||||||
/* the project. */
|
|
||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
package frc4388.robot.subsystems;
|
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.command.Subsystem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An example subsystem. You can replace me with your own Subsystem.
|
|
||||||
*/
|
|
||||||
public class ExampleSubsystem extends Subsystem {
|
|
||||||
// Put methods for controlling this subsystem
|
|
||||||
// here. Call these from Commands.
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initDefaultCommand() {
|
|
||||||
// Set the default command for a subsystem here.
|
|
||||||
// setDefaultCommand(new MySpecialCommand());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,23 +7,24 @@
|
|||||||
|
|
||||||
package frc4388.robot.subsystems;
|
package frc4388.robot.subsystems;
|
||||||
|
|
||||||
import frc4388.robot.RobotMap;
|
|
||||||
import frc4388.robot.commands.LED.UpdateLED;
|
|
||||||
import frc4388.robot.constants.LEDPatterns;
|
|
||||||
import edu.wpi.first.wpilibj.Spark;
|
import edu.wpi.first.wpilibj.Spark;
|
||||||
import edu.wpi.first.wpilibj.command.Subsystem;
|
|
||||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||||
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||||
|
|
||||||
|
import frc4388.robot.Constants.LEDConstants;
|
||||||
|
import frc4388.robot.constants.LEDPatterns;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows for the control of a 5v LED Strip using a Rev Robotics Blinkin LED Driver
|
* Allows for the control of a 5v LED Strip using a Rev Robotics Blinkin LED
|
||||||
|
* Driver
|
||||||
*/
|
*/
|
||||||
public class LED extends Subsystem {
|
public class LED extends SubsystemBase {
|
||||||
|
|
||||||
public static float currentLED;
|
public static float currentLED;
|
||||||
public static Spark LEDController;
|
public static Spark LEDController;
|
||||||
|
|
||||||
public LED(){
|
public LED(){
|
||||||
LEDController = new Spark(RobotMap.LED_SPARK_ID);
|
LEDController = new Spark(LEDConstants.LED_SPARK_ID);
|
||||||
setPattern(LEDPatterns.FOREST_WAVES);
|
setPattern(LEDPatterns.FOREST_WAVES);
|
||||||
LEDController.set(currentLED);
|
LEDController.set(currentLED);
|
||||||
System.err.println("In the Beginning, there was Joe.\nAnd he said, 'Let there be LEDs.'\nAnd it was good.");
|
System.err.println("In the Beginning, there was Joe.\nAnd he said, 'Let there be LEDs.'\nAnd it was good.");
|
||||||
@@ -43,10 +44,10 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
|||||||
SmartDashboard.putNumber("LED", currentLED);
|
SmartDashboard.putNumber("LED", currentLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/* @Override
|
||||||
public void initDefaultCommand() {
|
public void initDefaultCommand() {
|
||||||
// Set the default command for a subsystem here.
|
// Set the default command for a subsystem here.
|
||||||
// setDefaultCommand(new MySpecialCommand());
|
// setDefaultCommand(new MySpecialCommand());
|
||||||
setDefaultCommand(new UpdateLED());
|
setDefaultCommand(new UpdateLED());
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package frc4388.utility.controller;
|
package frc4388.utility.controller;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj2.command.button.Button;
|
||||||
import frc4388.utility.controller.XboxController;
|
import frc4388.utility.controller.XboxController;
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj.buttons.Button;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapping for the Xbox controller triggers to allow triggers to be defined as
|
* Mapping for the Xbox controller triggers to allow triggers to be defined as
|
||||||
* buttons in {@link frc4388.robot.OI}. Checks to see if the given trigger
|
* buttons in {@link frc4388.robot.OI}. Checks to see if the given trigger
|
||||||
|
|||||||
+102
-9
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"fileName": "Phoenix.json",
|
"fileName": "Phoenix.json",
|
||||||
"name": "CTRE-Phoenix",
|
"name": "CTRE-Phoenix",
|
||||||
"version": "5.12.0",
|
"version": "5.17.3",
|
||||||
"uuid": "ab676553-b602-441f-a38d-f1296eff6537",
|
"uuid": "ab676553-b602-441f-a38d-f1296eff6537",
|
||||||
"mavenUrls": [
|
"mavenUrls": [
|
||||||
"http://devsite.ctr-electronics.com/maven/release/"
|
"http://devsite.ctr-electronics.com/maven/release/"
|
||||||
@@ -11,19 +11,65 @@
|
|||||||
{
|
{
|
||||||
"groupId": "com.ctre.phoenix",
|
"groupId": "com.ctre.phoenix",
|
||||||
"artifactId": "api-java",
|
"artifactId": "api-java",
|
||||||
"version": "5.12.0"
|
"version": "5.17.3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"groupId": "com.ctre.phoenix",
|
"groupId": "com.ctre.phoenix",
|
||||||
"artifactId": "wpiapi-java",
|
"artifactId": "wpiapi-java",
|
||||||
"version": "5.12.0"
|
"version": "5.17.3"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"jniDependencies": [
|
"jniDependencies": [
|
||||||
{
|
{
|
||||||
"groupId": "com.ctre.phoenix",
|
"groupId": "com.ctre.phoenix",
|
||||||
"artifactId": "cci",
|
"artifactId": "cci",
|
||||||
"version": "5.12.0",
|
"version": "5.17.3",
|
||||||
|
"isJar": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"validPlatforms": [
|
||||||
|
"linuxathena",
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "diagnostics",
|
||||||
|
"version": "5.17.3",
|
||||||
|
"isJar": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"validPlatforms": [
|
||||||
|
"linuxathena",
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "canutils",
|
||||||
|
"version": "5.17.3",
|
||||||
|
"isJar": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"validPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "platform-stub",
|
||||||
|
"version": "5.17.3",
|
||||||
|
"isJar": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"validPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "core",
|
||||||
|
"version": "5.17.3",
|
||||||
"isJar": false,
|
"isJar": false,
|
||||||
"skipInvalidPlatforms": true,
|
"skipInvalidPlatforms": true,
|
||||||
"validPlatforms": [
|
"validPlatforms": [
|
||||||
@@ -37,7 +83,7 @@
|
|||||||
{
|
{
|
||||||
"groupId": "com.ctre.phoenix",
|
"groupId": "com.ctre.phoenix",
|
||||||
"artifactId": "wpiapi-cpp",
|
"artifactId": "wpiapi-cpp",
|
||||||
"version": "5.12.0",
|
"version": "5.17.3",
|
||||||
"libName": "CTRE_Phoenix_WPI",
|
"libName": "CTRE_Phoenix_WPI",
|
||||||
"headerClassifier": "headers",
|
"headerClassifier": "headers",
|
||||||
"sharedLibrary": false,
|
"sharedLibrary": false,
|
||||||
@@ -51,7 +97,7 @@
|
|||||||
{
|
{
|
||||||
"groupId": "com.ctre.phoenix",
|
"groupId": "com.ctre.phoenix",
|
||||||
"artifactId": "api-cpp",
|
"artifactId": "api-cpp",
|
||||||
"version": "5.12.0",
|
"version": "5.17.3",
|
||||||
"libName": "CTRE_Phoenix",
|
"libName": "CTRE_Phoenix",
|
||||||
"headerClassifier": "headers",
|
"headerClassifier": "headers",
|
||||||
"sharedLibrary": false,
|
"sharedLibrary": false,
|
||||||
@@ -65,7 +111,7 @@
|
|||||||
{
|
{
|
||||||
"groupId": "com.ctre.phoenix",
|
"groupId": "com.ctre.phoenix",
|
||||||
"artifactId": "cci",
|
"artifactId": "cci",
|
||||||
"version": "5.12.0",
|
"version": "5.17.3",
|
||||||
"libName": "CTRE_PhoenixCCI",
|
"libName": "CTRE_PhoenixCCI",
|
||||||
"headerClassifier": "headers",
|
"headerClassifier": "headers",
|
||||||
"sharedLibrary": false,
|
"sharedLibrary": false,
|
||||||
@@ -76,12 +122,59 @@
|
|||||||
"linuxx86-64"
|
"linuxx86-64"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "diagnostics",
|
||||||
|
"version": "5.17.3",
|
||||||
|
"libName": "CTRE_PhoenixDiagnostics",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"linuxathena",
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "canutils",
|
||||||
|
"version": "5.17.3",
|
||||||
|
"libName": "CTRE_PhoenixCanutils",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groupId": "com.ctre.phoenix",
|
||||||
|
"artifactId": "platform-stub",
|
||||||
|
"version": "5.17.3",
|
||||||
|
"libName": "CTRE_PhoenixPlatform",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"groupId": "com.ctre.phoenix",
|
"groupId": "com.ctre.phoenix",
|
||||||
"artifactId": "core",
|
"artifactId": "core",
|
||||||
"version": "5.12.0",
|
"version": "5.17.3",
|
||||||
"libName": "CTRE_PhoenixCore",
|
"libName": "CTRE_PhoenixCore",
|
||||||
"headerClassifier": "headers"
|
"headerClassifier": "headers",
|
||||||
|
"sharedLibrary": false,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"linuxathena",
|
||||||
|
"windowsx86-64",
|
||||||
|
"linuxx86-64"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"fileName": "WPILibNewCommands.json",
|
||||||
|
"name": "WPILib-New-Commands",
|
||||||
|
"version": "2020.0.0",
|
||||||
|
"uuid": "111e20f7-815e-48f8-9dd6-e675ce75b266",
|
||||||
|
"mavenUrls": [],
|
||||||
|
"jsonUrl": "",
|
||||||
|
"javaDependencies": [
|
||||||
|
{
|
||||||
|
"groupId": "edu.wpi.first.wpilibNewCommands",
|
||||||
|
"artifactId": "wpilibNewCommands-java",
|
||||||
|
"version": "wpilib"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"jniDependencies": [],
|
||||||
|
"cppDependencies": [
|
||||||
|
{
|
||||||
|
"groupId": "edu.wpi.first.wpilibNewCommands",
|
||||||
|
"artifactId": "wpilibNewCommands-cpp",
|
||||||
|
"version": "wpilib",
|
||||||
|
"libName": "wpilibNewCommands",
|
||||||
|
"headerClassifier": "headers",
|
||||||
|
"sourcesClassifier": "sources",
|
||||||
|
"sharedLibrary": true,
|
||||||
|
"skipInvalidPlatforms": true,
|
||||||
|
"binaryPlatforms": [
|
||||||
|
"linuxathena",
|
||||||
|
"linuxraspbian",
|
||||||
|
"linuxaarch64bionic",
|
||||||
|
"windowsx86-64",
|
||||||
|
"windowsx86",
|
||||||
|
"linuxx86-64",
|
||||||
|
"osxx86-64"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user