If you change your main robot class, change the parameter type.
+ */
+ public static void main(String... args) {
+ RobotBase.startRobot(Robot::new);
+ }
+}
diff --git a/simulation/samples/JavaAutoSample/src/main/java/frc/robot/Robot.java b/simulation/samples/JavaAutoSample/src/main/java/frc/robot/Robot.java
new file mode 100644
index 0000000000..e8e8733c19
--- /dev/null
+++ b/simulation/samples/JavaAutoSample/src/main/java/frc/robot/Robot.java
@@ -0,0 +1,161 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+package frc.robot;
+
+import com.revrobotics.CANSparkLowLevel.MotorType;
+
+import com.autodesk.synthesis.io.*;
+
+import edu.wpi.first.wpilibj.SPI;
+
+import edu.wpi.first.wpilibj.ADXL362;
+import edu.wpi.first.wpilibj.TimedRobot;
+import edu.wpi.first.wpilibj.motorcontrol.Spark;
+import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
+import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
+import edu.wpi.first.wpilibj.XboxController;
+
+import com.autodesk.synthesis.revrobotics.CANSparkMax;
+import com.kauailabs.navx.frc.AHRS;
+import com.autodesk.synthesis.ctre.TalonFX;
+
+/**
+ * The VM is configured to automatically run this class, and to call the
+ * functions corresponding to
+ * each mode, as described in the TimedRobot documentation. If you change the
+ * name of this class or
+ * the package after creating this project, you must also update the
+ * build.gradle file in the
+ * project.
+ */
+public class Robot extends TimedRobot {
+ private static final String kDefaultAuto = "Default";
+ private static final String kCustomAuto = "My Auto";
+ private String m_autoSelected;
+ private final SendableChooser
+ * This runs after the mode specific periodic functions, but before LiveWindow
+ * and
+ * SmartDashboard integrated updating.
+ */
+ @Override
+ public void robotPeriodic() {
+ }
+
+ /**
+ * This autonomous (along with the chooser code above) shows how to select
+ * between different
+ * autonomous modes using the dashboard. The sendable chooser code works with
+ * the Java
+ * SmartDashboard. If you prefer the LabVIEW Dashboard, remove all of the
+ * chooser code and
+ * uncomment the getString line to get the auto name from the text box below the
+ * Gyro
+ *
+ *
+ * You can add additional auto modes by adding additional comparisons to the
+ * switch structure
+ * below with additional strings. If using the SendableChooser make sure to add
+ * them to the
+ * chooser code above as well.
+ */
+ @Override
+ public void autonomousInit() {
+ m_autoSelected = m_chooser.getSelected();
+ // m_autoSelected = SmartDashboard.getString("Auto Selector", kDefaultAuto);
+ System.out.println("Auto selected: " + m_autoSelected);
+ m_sparkLeft.getAbsoluteEncoderSim()
+ }
+
+ enum AutoState {
+ Stage1, Stage2
+ }
+
+ private AutoState m_autoState = AutoState.Stage1;
+
+ /** This function is called periodically during autonomous. */
+ @Override
+ public void autonomousPeriodic() {
+ switch (m_autoState) {
+ case Stage1: {
+ m_sparkLeft.set(0.5);
+ m_sparkRight.set(0.5);
+ if (m_sparkLeft.getEncoder())
+ break;
+ } case Stage2: {
+ break;
+ } default: {
+ break;
+ }
+ }
+ m_SparkMax1.set(0.2);
+ m_SparkMax2.set(-0.2);
+ }
+
+ /** This function is called once when teleop is enabled. */
+ @Override
+ public void teleopInit() {
+ }
+
+ /** This function is called periodically during operator control. */
+ @Override
+ public void teleopPeriodic() {
+ }
+
+ /** This function is called once when the robot is disabled. */
+ @Override
+ public void disabledInit() {
+ }
+
+ /** This function is called periodically when disabled. */
+ @Override
+ public void disabledPeriodic() {
+ }
+
+ /** This function is called once when test mode is enabled. */
+ @Override
+ public void testInit() {
+ }
+
+ /** This function is called periodically during test mode. */
+ @Override
+ public void testPeriodic() {
+ }
+
+ /** This function is called once when the robot is first started up. */
+ @Override
+ public void simulationInit() {
+ }
+
+ /** This function is called periodically whilst in simulation. */
+ @Override
+ public void simulationPeriodic() {
+ }
+}
diff --git a/simulation/samples/JavaAutoSample/vendordeps/NavX.json b/simulation/samples/JavaAutoSample/vendordeps/NavX.json
new file mode 100644
index 0000000000..e978a5f745
--- /dev/null
+++ b/simulation/samples/JavaAutoSample/vendordeps/NavX.json
@@ -0,0 +1,40 @@
+{
+ "fileName": "NavX.json",
+ "name": "NavX",
+ "version": "2024.1.0",
+ "uuid": "cb311d09-36e9-4143-a032-55bb2b94443b",
+ "frcYear": "2024",
+ "mavenUrls": [
+ "https://dev.studica.com/maven/release/2024/"
+ ],
+ "jsonUrl": "https://dev.studica.com/releases/2024/NavX.json",
+ "javaDependencies": [
+ {
+ "groupId": "com.kauailabs.navx.frc",
+ "artifactId": "navx-frc-java",
+ "version": "2024.1.0"
+ }
+ ],
+ "jniDependencies": [],
+ "cppDependencies": [
+ {
+ "groupId": "com.kauailabs.navx.frc",
+ "artifactId": "navx-frc-cpp",
+ "version": "2024.1.0",
+ "headerClassifier": "headers",
+ "sourcesClassifier": "sources",
+ "sharedLibrary": false,
+ "libName": "navx_frc",
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "linuxathena",
+ "linuxraspbian",
+ "linuxarm32",
+ "linuxarm64",
+ "linuxx86-64",
+ "osxuniversal",
+ "windowsx86-64"
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/simulation/samples/JavaAutoSample/vendordeps/Phoenix6.json b/simulation/samples/JavaAutoSample/vendordeps/Phoenix6.json
new file mode 100644
index 0000000000..032238505f
--- /dev/null
+++ b/simulation/samples/JavaAutoSample/vendordeps/Phoenix6.json
@@ -0,0 +1,339 @@
+{
+ "fileName": "Phoenix6.json",
+ "name": "CTRE-Phoenix (v6)",
+ "version": "24.3.0",
+ "frcYear": 2024,
+ "uuid": "e995de00-2c64-4df5-8831-c1441420ff19",
+ "mavenUrls": [
+ "https://maven.ctr-electronics.com/release/"
+ ],
+ "jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix6/latest/Phoenix6-frc2024-latest.json",
+ "conflictsWith": [
+ {
+ "uuid": "3fcf3402-e646-4fa6-971e-18afe8173b1a",
+ "errorMessage": "The combined Phoenix-6-And-5 vendordep is no longer supported. Please remove the vendordep and instead add both the latest Phoenix 6 vendordep and Phoenix 5 vendordep.",
+ "offlineFileName": "Phoenix6And5.json"
+ }
+ ],
+ "javaDependencies": [
+ {
+ "groupId": "com.ctre.phoenix6",
+ "artifactId": "wpiapi-java",
+ "version": "24.3.0"
+ }
+ ],
+ "jniDependencies": [
+ {
+ "groupId": "com.ctre.phoenix6",
+ "artifactId": "tools",
+ "version": "24.3.0",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "linuxathena"
+ ],
+ "simMode": "hwsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "tools-sim",
+ "version": "24.3.0",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simTalonSRX",
+ "version": "24.3.0",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simTalonFX",
+ "version": "24.3.0",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simVictorSPX",
+ "version": "24.3.0",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simPigeonIMU",
+ "version": "24.3.0",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simCANCoder",
+ "version": "24.3.0",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simProTalonFX",
+ "version": "24.3.0",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simProCANcoder",
+ "version": "24.3.0",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simProPigeon2",
+ "version": "24.3.0",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ }
+ ],
+ "cppDependencies": [
+ {
+ "groupId": "com.ctre.phoenix6",
+ "artifactId": "wpiapi-cpp",
+ "version": "24.3.0",
+ "libName": "CTRE_Phoenix6_WPI",
+ "headerClassifier": "headers",
+ "sharedLibrary": true,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "linuxathena"
+ ],
+ "simMode": "hwsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6",
+ "artifactId": "tools",
+ "version": "24.3.0",
+ "libName": "CTRE_PhoenixTools",
+ "headerClassifier": "headers",
+ "sharedLibrary": true,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "linuxathena"
+ ],
+ "simMode": "hwsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "wpiapi-cpp-sim",
+ "version": "24.3.0",
+ "libName": "CTRE_Phoenix6_WPISim",
+ "headerClassifier": "headers",
+ "sharedLibrary": true,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "tools-sim",
+ "version": "24.3.0",
+ "libName": "CTRE_PhoenixTools_Sim",
+ "headerClassifier": "headers",
+ "sharedLibrary": true,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simTalonSRX",
+ "version": "24.3.0",
+ "libName": "CTRE_SimTalonSRX",
+ "headerClassifier": "headers",
+ "sharedLibrary": true,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simTalonFX",
+ "version": "24.3.0",
+ "libName": "CTRE_SimTalonFX",
+ "headerClassifier": "headers",
+ "sharedLibrary": true,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simVictorSPX",
+ "version": "24.3.0",
+ "libName": "CTRE_SimVictorSPX",
+ "headerClassifier": "headers",
+ "sharedLibrary": true,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simPigeonIMU",
+ "version": "24.3.0",
+ "libName": "CTRE_SimPigeonIMU",
+ "headerClassifier": "headers",
+ "sharedLibrary": true,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simCANCoder",
+ "version": "24.3.0",
+ "libName": "CTRE_SimCANCoder",
+ "headerClassifier": "headers",
+ "sharedLibrary": true,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simProTalonFX",
+ "version": "24.3.0",
+ "libName": "CTRE_SimProTalonFX",
+ "headerClassifier": "headers",
+ "sharedLibrary": true,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simProCANcoder",
+ "version": "24.3.0",
+ "libName": "CTRE_SimProCANcoder",
+ "headerClassifier": "headers",
+ "sharedLibrary": true,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ },
+ {
+ "groupId": "com.ctre.phoenix6.sim",
+ "artifactId": "simProPigeon2",
+ "version": "24.3.0",
+ "libName": "CTRE_SimProPigeon2",
+ "headerClassifier": "headers",
+ "sharedLibrary": true,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64",
+ "osxuniversal"
+ ],
+ "simMode": "swsim"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/simulation/samples/JavaAutoSample/vendordeps/REVLib.json b/simulation/samples/JavaAutoSample/vendordeps/REVLib.json
new file mode 100644
index 0000000000..f85acd4054
--- /dev/null
+++ b/simulation/samples/JavaAutoSample/vendordeps/REVLib.json
@@ -0,0 +1,74 @@
+{
+ "fileName": "REVLib.json",
+ "name": "REVLib",
+ "version": "2024.2.4",
+ "frcYear": "2024",
+ "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb",
+ "mavenUrls": [
+ "https://maven.revrobotics.com/"
+ ],
+ "jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2024.json",
+ "javaDependencies": [
+ {
+ "groupId": "com.revrobotics.frc",
+ "artifactId": "REVLib-java",
+ "version": "2024.2.4"
+ }
+ ],
+ "jniDependencies": [
+ {
+ "groupId": "com.revrobotics.frc",
+ "artifactId": "REVLib-driver",
+ "version": "2024.2.4",
+ "skipInvalidPlatforms": true,
+ "isJar": false,
+ "validPlatforms": [
+ "windowsx86-64",
+ "windowsx86",
+ "linuxarm64",
+ "linuxx86-64",
+ "linuxathena",
+ "linuxarm32",
+ "osxuniversal"
+ ]
+ }
+ ],
+ "cppDependencies": [
+ {
+ "groupId": "com.revrobotics.frc",
+ "artifactId": "REVLib-cpp",
+ "version": "2024.2.4",
+ "libName": "REVLib",
+ "headerClassifier": "headers",
+ "sharedLibrary": false,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "windowsx86",
+ "linuxarm64",
+ "linuxx86-64",
+ "linuxathena",
+ "linuxarm32",
+ "osxuniversal"
+ ]
+ },
+ {
+ "groupId": "com.revrobotics.frc",
+ "artifactId": "REVLib-driver",
+ "version": "2024.2.4",
+ "libName": "REVLibDriver",
+ "headerClassifier": "headers",
+ "sharedLibrary": false,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "windowsx86",
+ "linuxarm64",
+ "linuxx86-64",
+ "linuxathena",
+ "linuxarm32",
+ "osxuniversal"
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/simulation/samples/JavaSample/src/main/java/frc/robot/Robot.java b/simulation/samples/JavaSample/src/main/java/frc/robot/Robot.java
index 302f80f47c..f1b05386fc 100644
--- a/simulation/samples/JavaSample/src/main/java/frc/robot/Robot.java
+++ b/simulation/samples/JavaSample/src/main/java/frc/robot/Robot.java
@@ -100,27 +100,30 @@ public void autonomousInit() {
@Override
public void autonomousPeriodic() {
- m_Spark1.set(0.5);
- m_Spark2.set(-0.5);
- m_Talon.set(-1.0);
-
- double position = m_SparkMax1.getAbsoluteEncoderSim().getPosition();
-
- if (position >= 20) {
- m_SparkMax1.set(0.0);
- m_SparkMax2.set(0.0);
- m_SparkMax3.set(0.0);
- m_SparkMax4.set(0.0);
- m_SparkMax5.set(0.0);
- m_SparkMax6.set(0.0);
- } else {
- m_SparkMax1.set(1.0);
- m_SparkMax2.set(1.0);
- m_SparkMax3.set(1.0);
- m_SparkMax4.set(1.0);
- m_SparkMax5.set(1.0);
- m_SparkMax6.set(1.0);
- }
+ m_SparkMax1.set(0.2);
+ m_SparkMax2.set(-0.2);
+
+ // m_Spark1.set(0.5);
+ // m_Spark2.set(-0.5);
+ // m_Talon.set(-1.0);
+
+ // double position = m_SparkMax1.getAbsoluteEncoderSim().getPosition();
+
+ // if (position >= 20) {
+ // m_SparkMax1.set(0.0);
+ // m_SparkMax2.set(0.0);
+ // m_SparkMax3.set(0.0);
+ // m_SparkMax4.set(0.0);
+ // m_SparkMax5.set(0.0);
+ // m_SparkMax6.set(0.0);
+ // } else {
+ // m_SparkMax1.set(1.0);
+ // m_SparkMax2.set(1.0);
+ // m_SparkMax3.set(1.0);
+ // m_SparkMax4.set(1.0);
+ // m_SparkMax5.set(1.0);
+ // m_SparkMax6.set(1.0);
+ // }
switch (m_autoSelected) {
case kCustomAuto:
@@ -140,11 +143,25 @@ public void teleopInit() {
m_AO.setVoltage(6.0);
}
+ private double clamp(double a, double min, double max) {
+ return Math.min(Math.max(a, min), max);
+ }
+
/** This function is called periodically during operator control. */
@Override
public void teleopPeriodic() {
- m_SparkMax1.set(m_Controller.getLeftY());
- m_SparkMax2.set(-m_Controller.getRightY());
+ double forward = -m_Controller.getLeftY();
+ double turn = m_Controller.getRightX();
+ if (Math.abs(forward) < 0.2) {
+ forward = 0.0;
+ }
+ if (Math.abs(turn) < 0.2) {
+ turn = 0.0;
+ }
+
+ m_SparkMax1.set(clamp(forward + turn, -1, 1));
+ m_SparkMax2.set(clamp(forward - turn, -1, 1));
+
m_Talon.set(m_Controller.getLeftX());
System.out.println("LeftX: " + m_Controller.getLeftX());
// System.out.println("OUT: " + m_DO.get());