diff --git a/simulation/SyntheSimJava/build.gradle b/simulation/SyntheSimJava/build.gradle index e8631a287e..c41ea04ffe 100644 --- a/simulation/SyntheSimJava/build.gradle +++ b/simulation/SyntheSimJava/build.gradle @@ -33,14 +33,14 @@ repositories { // KAUAI maven { - url "https://dev.studica.com/maven/release/2024/" + url "https://dev.studica.com/maven/release/2025/" } } -def WPI_Version = '2024.3.2' -def REV_Version = '2024.2.4' -def CTRE_Version = '24.3.0' -def KAUAI_Version = '2024.1.0' +def WPI_Version = '2025.1.1' +def REV_Version = '2025.0.0' +def CTRE_Version = '25.1.0' +def KAUAI_Version = '2025.1.1-beta-1' dependencies { // This dependency is exported to consumers, that is to say found on their compile classpath. @@ -52,6 +52,7 @@ dependencies { // WPILib implementation "edu.wpi.first.wpilibj:wpilibj-java:$WPI_Version" implementation "edu.wpi.first.wpiutil:wpiutil-java:$WPI_Version" + implementation "edu.wpi.first.wpiunits:wpiunits-java:$WPI_Version" implementation "edu.wpi.first.hal:hal-java:$WPI_Version" // REVRobotics @@ -61,7 +62,7 @@ dependencies { implementation "com.ctre.phoenix6:wpiapi-java:$CTRE_Version" // KAUAI - implementation "com.kauailabs.navx.frc:navx-frc-java:$KAUAI_Version" + implementation "com.kauailabs.navx.frc:navx_frc-java:$KAUAI_Version" } java { diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANEncoder.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANEncoder.java index 23b2a29bd2..f79e2dd7f4 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANEncoder.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANEncoder.java @@ -31,7 +31,6 @@ public CANEncoder(String name, int deviceId) { m_init = m_device.createBoolean("init", Direction.kOutput, true); m_position = m_device.createDouble("position", Direction.kInput, 0.0); m_velocity = m_device.createDouble("velocity", Direction.kInput, 0.0); - m_init.set(true); } diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFX.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFX.java index 3fdc46bf31..48f2555cca 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFX.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFX.java @@ -3,7 +3,7 @@ import com.autodesk.synthesis.CANEncoder; import com.autodesk.synthesis.CANMotor; import com.ctre.phoenix6.signals.NeutralModeValue; -import com.ctre.phoenix6.StatusSignal; +import com.ctre.phoenix6.StatusCode; import com.ctre.phoenix6.configs.TalonFXConfigurator; import com.ctre.phoenix6.hardware.DeviceIdentifier; @@ -23,35 +23,18 @@ public TalonFX(int deviceNumber) { this.m_encoder = new CANEncoder("SYN TalonFX", deviceNumber); } - /** - * Sets the torque of the real and simulated motors - * - * @param percentOutput The torque - */ @Override public void set(double percentOutput) { super.set(percentOutput); this.m_motor.setPercentOutput(percentOutput); } - /** - * Sets both the real and simulated motors to neutral mode - * - * @param mode The neutral mode value - * - */ @Override - public void setNeutralMode(NeutralModeValue mode) { - super.setNeutralMode(mode); - + public StatusCode setNeutralMode(NeutralModeValue mode) { this.m_motor.setBrakeMode(mode == NeutralModeValue.Brake); + return super.setNeutralMode(mode); } - /** - * Gets and internal configurator for both the simulated and real motors - * - * @return The internal configurator for this Talon motor - */ @Override public TalonFXConfigurator getConfigurator() { DeviceIdentifier id = this.deviceIdentifier; @@ -63,27 +46,11 @@ public void setNeutralDeadband(double deadband) { this.m_motor.setNeutralDeadband(deadband); } - /** - * Gets the position of the simulated encoder - * - * @return The motor position in revolutions - */ - @Override - public StatusSignal getPosition() { - Double pos = this.m_encoder.getPosition(); - super.setPosition(pos); - return super.getPosition(); + public double getPositionSim() { + return this.m_encoder.getPosition(); } - /** - * Gets the velocity of the simulated motor according to the simulated encoder - * - * @return The motor velocity in revolutions per second - */ - @Override - public StatusSignal getVelocity() { - Double velocity = this.m_encoder.getVelocity(); - super.set(velocity); - return super.getVelocity(); + public double getVelocitySim() { + return this.m_encoder.getVelocity(); } } diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/CANSparkMax.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/CANSparkMax.java deleted file mode 100644 index d696fabd26..0000000000 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/CANSparkMax.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.autodesk.synthesis.revrobotics; - -import java.util.ArrayList; - -import com.autodesk.synthesis.CANEncoder; -import com.autodesk.synthesis.CANMotor; -import com.revrobotics.CANSparkBase; -import com.revrobotics.REVLibError; - -/** - * CANSparkMax wrapper to add proper WPILib HALSim support. - */ -public class CANSparkMax extends com.revrobotics.CANSparkMax { - - private CANMotor m_motor; - public CANEncoder m_encoder; - private ArrayList followers; - - /** - * Creates a new CANSparkMax, wrapped with simulation support. - * - * @param deviceId CAN Device ID. - * @param motorType Motor type. For Simulation purposes, this is discarded at the - * moment. - * - * See original documentation for more information https://codedocs.revrobotics.com/java/com/revrobotics/cansparkmax - */ - public CANSparkMax(int deviceId, MotorType motorType) { - super(deviceId, motorType); - - this.m_motor = new CANMotor("SYN CANSparkMax", deviceId, 0.0, false, 0.3); - this.m_encoder = new CANEncoder("SYN CANSparkMax", deviceId); - this.followers = new ArrayList(); - } - - /** - * Sets the percent output of the real and simulated motors - * Setting a follower doesn't break the simulated follower - leader relationship, which it does for exclusively non-simulated motors - * - * @param percent The new percent output of the motor - * - * See the original documentation for more information - */ - @Override - public void set(double percent) { - super.set(percent); - this.m_motor.setPercentOutput(percent); - for (CANSparkMax follower : this.followers) { - follower.set(percent); - } - } - - /** - * Sets the neutralDeadband of the real and simulated motors - * - * @param n The new neutral deadband - */ - void setNeutralDeadband(double n) { - this.m_motor.setNeutralDeadband(n); - } - - /** - * Sets the real and simulated motors to an idle mode - * - * @param mode The specific idle mode (Brake, Coast) - * - * @return A library error indicating failure or success - */ - @Override - public REVLibError setIdleMode(com.revrobotics.CANSparkBase.IdleMode mode) { - if (mode != null) - this.m_motor.setBrakeMode(mode.equals(com.revrobotics.CANSparkBase.IdleMode.kBrake)); - - return super.setIdleMode(mode); - } - - /** - * Gets a simulation-supported SparkAbsoluteEncoder containing the position and velocity of the motor in fission. - * All information returned by this class besides position and velocity is from the real motor. - * Use instead of getAbsoluteEncoder(), everything except for the name of the method works exactly the same. - - * @return The simulation-supported SparkAbsoluteEncoder. - */ - public com.autodesk.synthesis.revrobotics.SparkAbsoluteEncoder getAbsoluteEncoderSim() { - return new SparkAbsoluteEncoder(super.getAbsoluteEncoder(), this.m_encoder); - } - - public com.autodesk.synthesis.revrobotics.RelativeEncoder getEncoderSim() { - return new RelativeEncoder(super.getEncoder(), this.m_encoder); - } - - /** - * Adds a follower to this motor controller. - * - * @param f The new follower - */ - void newFollower(CANSparkMax f) { - this.followers.add(f); - } - - /** - * Causes a simulation-supported leader to follow another simulation-supported leader. - * The real versions of these motors will also follow each other. - * - * @param leader The motor for this robot to follow - * - * @return A library error indicating failure or success - */ - @Override - public REVLibError follow(CANSparkBase leader) { - REVLibError err = super.follow(leader); - if (leader instanceof CANSparkMax) { - ((CANSparkMax) leader).newFollower(this); - } - return err; - } -} diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/RelativeEncoder.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/RelativeEncoder.java deleted file mode 100644 index a25dddaec3..0000000000 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/RelativeEncoder.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.autodesk.synthesis.revrobotics; - -import com.autodesk.synthesis.CANEncoder; -import com.revrobotics.REVLibError; - -public class RelativeEncoder implements com.revrobotics.RelativeEncoder { - - private com.revrobotics.RelativeEncoder m_original; - private CANEncoder m_encoder; - private double m_zero = 0.0; - private double m_positionConversionFactor = 1.0; - private double m_velocityConversionFactor = 1.0; - private double m_invertedFactor = 1.0; - - public RelativeEncoder(com.revrobotics.RelativeEncoder original, CANEncoder encoder) { - m_original = original; - m_encoder = encoder; - - m_positionConversionFactor = m_original.getPositionConversionFactor(); - m_velocityConversionFactor = m_original.getVelocityConversionFactor(); - m_invertedFactor = m_original.getInverted() ? -1.0 : 1.0; - } - - @Override - public double getPosition() { - return m_encoder.getPosition() * m_positionConversionFactor * m_invertedFactor - m_zero; - } - - @Override - public double getVelocity() { - return m_encoder.getVelocity() * m_velocityConversionFactor * m_invertedFactor; - } - - @Override - public REVLibError setPosition(double position) { - m_zero = m_encoder.getPosition() * m_positionConversionFactor * m_invertedFactor - position; - return REVLibError.kOk; - } - - @Override - public REVLibError setPositionConversionFactor(double factor) { - m_positionConversionFactor = factor; - return REVLibError.kOk; - } - - @Override - public REVLibError setVelocityConversionFactor(double factor) { - m_velocityConversionFactor = factor; - return REVLibError.kOk; - } - - @Override - public double getPositionConversionFactor() { - return m_positionConversionFactor; - } - - @Override - public double getVelocityConversionFactor() { - return m_velocityConversionFactor; - } - - @Override - public REVLibError setAverageDepth(int depth) { - return m_original.setAverageDepth(depth); - } - - @Override - public int getAverageDepth() { - return m_original.getAverageDepth(); - } - - @Override - public REVLibError setMeasurementPeriod(int period_ms) { - return m_original.setMeasurementPeriod(period_ms); - } - - @Override - public int getMeasurementPeriod() { - return m_original.getMeasurementPeriod(); - } - - @Override - public int getCountsPerRevolution() { - return 1; - } - - @Override - public REVLibError setInverted(boolean inverted) { - m_invertedFactor = inverted ? -1.0 : 1.0; - return REVLibError.kOk; - } - - @Override - public boolean getInverted() { - return m_invertedFactor < 0.0; - } - -} diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java deleted file mode 100644 index 402bdca0b9..0000000000 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.autodesk.synthesis.revrobotics; - -import com.autodesk.synthesis.CANEncoder; - -import com.revrobotics.AbsoluteEncoder; -import com.revrobotics.REVLibError; - -/** - * SparkAbsoluteEncoder wrapper to add proper WPILib HALSim support. - */ -public class SparkAbsoluteEncoder implements AbsoluteEncoder { - private CANEncoder simEncoder; - private com.revrobotics.SparkAbsoluteEncoder realEncoder; - - /* - * A SparkAbsoluteEncoder class that returns the motors position and velocity from the simulated motor in fission, rather than the actual motor. - * All other parameters are returned from the real motor, which likely won't exist, not sure what it does then but we'll just call it UB. - */ - public SparkAbsoluteEncoder(com.revrobotics.SparkAbsoluteEncoder realEncoder, CANEncoder simEncoder) { - this.realEncoder = realEncoder; - this.simEncoder = simEncoder; - } - - /** - * Gets the average sampling depth for the real encoder - * - * @return The average sampling depth - */ - public int getAverageDepth() { - return this.realEncoder.getAverageDepth(); - } - - /** - * Gets the phase of the real encoder - * - * @return The phase of the real encoder - */ - public boolean getInverted() { - return this.realEncoder.getInverted(); - } - - /** - * Gets the position of the simulated motor. - * This returns the native units of 'rotations' by default, and can be changed by a scale factor using setPositionConversionFactor(). - * - * @return Number of rotations of the motor - */ - public double getPosition() { - return this.simEncoder.getPosition(); - } - - /** - * Sets the conversion factor for position of the real encoder. Multiplying by the native output units to give you position - * - * @return The conversion factor used by the encoder for position - */ - public double getPositionConversionFactor() { - return this.realEncoder.getPositionConversionFactor(); - } - - - /** - * Gets the velocity of the simulated motor. This returns the native units of 'rotations per second' by default, and can be changed by a scale factor using setVelocityConversionFactor(). - * - * @return Number of rotations per second of the motor - */ - public double getVelocity() { - return this.simEncoder.getVelocity() * this.realEncoder.getVelocityConversionFactor(); - } - - - /** - * Gets the conversion factor for velocity of the real encoder. - * - * @return The conversion factor used by the encoder for position - */ - public double getVelocityConversionFactor() { - return this.realEncoder.getVelocityConversionFactor(); - } - - /** - * Gets the zero offset in revolutions for the real encoder (the position that is reported as zero). - * - * @return The zero offset - */ - public double getZeroOffset() { - return this.realEncoder.getZeroOffset(); - } - - /** - * Sets the average sampling depth for the real encoder. - * - * @param depth The average sampling depth - * - * @return A library error indicating failure or success - */ - public REVLibError setAverageDepth(int depth) { - return this.realEncoder.setAverageDepth(depth); - } - - /** - * Sets the phase of the real encoder - * - * @param inverted Whether the real motor should be inverted - * - * @return A library error indicating failure or success - */ - public REVLibError setInverted(boolean inverted) { - return this.realEncoder.setInverted(inverted); - } - - /** - * Sets the conversion factor for position of the real encoder. - * - * @param factor The new position conversion factor - * - * @return A library error indicating failure or success - */ - public REVLibError setPositionConversionFactor(double factor) { - return this.realEncoder.setPositionConversionFactor(factor); - } - - /** - * Sets the conversion factor for velocity of the real encoder. - * - * @param factor The new velocity conversion factor - * - * @return A library error indicating failure or success - */ - public REVLibError setVelocityConversionFactor(double factor) { - return this.realEncoder.setVelocityConversionFactor(factor); - } - - /** - * Sets the zero offset of the real encoder (the position that is reported as zero). - * - * @param offset The new zero offset - * - * @return A library error indicating failure or success - */ - public REVLibError setZeroOffset(double offset) { - return this.realEncoder.setZeroOffset(offset); - } -} diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/spark/SparkAbsoluteEncoder.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/spark/SparkAbsoluteEncoder.java new file mode 100644 index 0000000000..1be401f75b --- /dev/null +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/spark/SparkAbsoluteEncoder.java @@ -0,0 +1,35 @@ +package com.autodesk.synthesis.revrobotics.spark; + +import com.autodesk.synthesis.CANEncoder; + +import com.revrobotics.AbsoluteEncoder; +import com.revrobotics.spark.config.AbsoluteEncoderConfigAccessor; + +/** + * SparkAbsoluteEncoder wrapper to add proper WPILib HALSim support. + */ +public class SparkAbsoluteEncoder implements AbsoluteEncoder { + private CANEncoder simEncoder; + private com.revrobotics.spark.SparkAbsoluteEncoder realEncoder; + private AbsoluteEncoderConfigAccessor m_accessor; + + /* + * A SparkAbsoluteEncoder class that returns the motors position and velocity from the simulated motor in fission, rather than the actual motor. + * All other parameters are returned from the real motor, which likely won't exist, not sure what it does then but we'll just call it UB. + */ + public SparkAbsoluteEncoder(com.revrobotics.spark.SparkAbsoluteEncoder realEncoder, CANEncoder simEncoder, AbsoluteEncoderConfigAccessor accessor) { + this.realEncoder = realEncoder; + this.simEncoder = simEncoder; + m_accessor = accessor; + } + + @Override + public double getPosition() { + return simEncoder.getPosition() * m_accessor.getPositionConversionFactor() * (m_accessor.getInverted() ? -1.0 : 1.0) - m_accessor.getZeroOffset(); + } + + @Override + public double getVelocity() { + return simEncoder.getVelocity() * m_accessor.getVelocityConversionFactor() * (m_accessor.getInverted() ? -1.0 : 1.0); + } +} diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/spark/SparkMax.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/spark/SparkMax.java new file mode 100644 index 0000000000..6ebc92f4d4 --- /dev/null +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/spark/SparkMax.java @@ -0,0 +1,137 @@ +package com.autodesk.synthesis.revrobotics.spark; + +import java.util.HashMap; +import java.util.HashSet; + +import com.autodesk.synthesis.CANEncoder; +import com.autodesk.synthesis.CANMotor; +import com.revrobotics.RelativeEncoder; +import com.revrobotics.REVLibError; +import com.revrobotics.spark.config.SparkBaseConfig; +import com.revrobotics.spark.config.SparkBaseConfig.IdleMode; + +/** + * CANSparkMax wrapper to add proper WPILib HALSim support. + */ +public class SparkMax extends com.revrobotics.spark.SparkMax { + + public CANMotor m_motor; + public CANEncoder m_encoder; + public boolean m_inverted = false; + public HashSet followers = new HashSet<>(); + + private static HashMap s_motors = new HashMap<>(); + + /** + * Creates a new CANSparkMax, wrapped with simulation support. + * + * @param deviceId CAN Device ID. + * @param motorType Motor type. For Simulation purposes, this is discarded at + * the + * moment. + * + * See original documentation for more information + * https://codedocs.revrobotics.com/java/com/revrobotics/cansparkmax + */ + public SparkMax(int deviceId, com.revrobotics.spark.SparkLowLevel.MotorType motorType) { + super(deviceId, motorType); + + this.m_motor = new CANMotor("SYN CANSparkMax", deviceId, 0.0, false, 0.3); + this.m_encoder = new CANEncoder("SYN CANSparkMax", deviceId); + + s_motors.put(this.getDeviceId(), this); + } + + /** + * Sets the percent output of the real and simulated motors + * Setting a follower doesn't break the simulated follower - leader + * relationship, which it does for exclusively non-simulated motors + * + * @param percent The new percent output of the motor + * + * See the original documentation for more information + */ + @Override + public void set(double percent) { + super.set(m_inverted ? -percent : percent); + this.m_motor.setPercentOutput(percent); + for (FollowerInfo info : this.followers) { + SparkMax.s_motors.get(info.canId).set(info.inverted ? -percent : percent); + } + } + + @Override + public REVLibError configure(SparkBaseConfig config, ResetMode resetMode, PersistMode persistMode) { + REVLibError res = super.configure(config, resetMode, persistMode); + if (res != REVLibError.kOk) { + return res; + } + + SparkMax.s_motors.entrySet() + .forEach((e) -> e.getValue().followers.remove(new FollowerInfo(this.getDeviceId(), false))); + int leaderId = this.configAccessor.getFollowerModeLeaderId(); + SparkMax leader = SparkMax.s_motors.get(leaderId); + if (leader != null) { + leader.followers.add( + new FollowerInfo(this.getDeviceId(), this.configAccessor.getFollowerModeInverted())); + } + + this.m_inverted = this.configAccessor.getInverted(); + + this.m_motor.setBrakeMode(this.configAccessor.getIdleMode() == IdleMode.kBrake); + + return res; + } + + /** + * Sets the neutralDeadband of the real and simulated motors + * + * @param n The new neutral deadband + */ + void setNeutralDeadband(double n) { + this.m_motor.setNeutralDeadband(n); + } + + /** + * Gets a simulation-supported SparkAbsoluteEncoder containing the position and + * velocity of the motor in fission. + * All information returned by this class besides position and velocity is from + * the real motor. + * Use instead of getAbsoluteEncoder(), everything except for the name of the + * method works exactly the same. + * + * @return The simulation-supported SparkAbsoluteEncoder. + */ + public com.autodesk.synthesis.revrobotics.spark.SparkAbsoluteEncoder getAbsoluteEncoderSim() { + return new com.autodesk.synthesis.revrobotics.spark.SparkAbsoluteEncoder(super.getAbsoluteEncoder(), this.m_encoder, this.configAccessor.absoluteEncoder); + } + + public com.autodesk.synthesis.revrobotics.spark.SparkRelativeEncoder getEncoderSim() { + return new com.autodesk.synthesis.revrobotics.spark.SparkRelativeEncoder(super.getEncoder(), this.m_encoder, this.configAccessor.encoder); + } + + public class FollowerInfo { + public int canId; + public boolean inverted; + + public FollowerInfo(int canId, boolean inverted) { + this.canId = canId; + + this.inverted = inverted; + } + + @Override + public int hashCode() { + return canId; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof FollowerInfo)) { + return false; + } + + return ((FollowerInfo) obj).canId == this.canId; + } + } +} diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/spark/SparkRelativeEncoder.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/spark/SparkRelativeEncoder.java new file mode 100644 index 0000000000..fa209a519f --- /dev/null +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/spark/SparkRelativeEncoder.java @@ -0,0 +1,37 @@ +package com.autodesk.synthesis.revrobotics.spark; + +import com.autodesk.synthesis.CANEncoder; +import com.revrobotics.RelativeEncoder; +import com.revrobotics.spark.config.EncoderConfigAccessor; +import com.revrobotics.REVLibError; + +public class SparkRelativeEncoder implements RelativeEncoder { + + private com.revrobotics.RelativeEncoder m_original; + private double m_zero = 0.0; + private CANEncoder m_encoder; + private EncoderConfigAccessor m_accessor; + + public SparkRelativeEncoder(com.revrobotics.RelativeEncoder original, CANEncoder encoder, EncoderConfigAccessor accessor) { + m_original = original; + m_encoder = encoder; + m_accessor = accessor; + } + + @Override + public double getPosition() { + return m_encoder.getPosition() * m_accessor.getPositionConversionFactor() * (m_accessor.getInverted() ? -1.0 : 1.0) - m_zero; + } + + @Override + public double getVelocity() { + return m_encoder.getVelocity() * m_accessor.getVelocityConversionFactor() * (m_accessor.getInverted() ? -1.0 : 1.0); + } + + @Override + public REVLibError setPosition(double position) { + m_zero = this.getPosition() - position; + return REVLibError.kOk; + } + +} diff --git a/simulation/SyntheSimJava/vendordeps/NavX.json b/simulation/SyntheSimJava/vendordeps/NavX.json index e978a5f745..c86a80df29 100644 --- a/simulation/SyntheSimJava/vendordeps/NavX.json +++ b/simulation/SyntheSimJava/vendordeps/NavX.json @@ -1,26 +1,26 @@ { "fileName": "NavX.json", "name": "NavX", - "version": "2024.1.0", + "version": "2025.1.1-beta-1", "uuid": "cb311d09-36e9-4143-a032-55bb2b94443b", - "frcYear": "2024", + "frcYear": "2025", "mavenUrls": [ - "https://dev.studica.com/maven/release/2024/" + "https://dev.studica.com/maven/release/2025/" ], - "jsonUrl": "https://dev.studica.com/releases/2024/NavX.json", + "jsonUrl": "https://dev.studica.com/releases/2025/NavX.json", "javaDependencies": [ { "groupId": "com.kauailabs.navx.frc", - "artifactId": "navx-frc-java", - "version": "2024.1.0" + "artifactId": "navx_frc-java", + "version": "2025.1.1-beta-1" } ], "jniDependencies": [], "cppDependencies": [ { "groupId": "com.kauailabs.navx.frc", - "artifactId": "navx-frc-cpp", - "version": "2024.1.0", + "artifactId": "navx_frc-cpp", + "version": "2025.1.1-beta-1", "headerClassifier": "headers", "sourcesClassifier": "sources", "sharedLibrary": false, @@ -28,7 +28,6 @@ "skipInvalidPlatforms": true, "binaryPlatforms": [ "linuxathena", - "linuxraspbian", "linuxarm32", "linuxarm64", "linuxx86-64", diff --git a/simulation/SyntheSimJava/vendordeps/Phoenix6.json b/simulation/SyntheSimJava/vendordeps/Phoenix6.json index 032238505f..21e0637317 100644 --- a/simulation/SyntheSimJava/vendordeps/Phoenix6.json +++ b/simulation/SyntheSimJava/vendordeps/Phoenix6.json @@ -1,76 +1,94 @@ { "fileName": "Phoenix6.json", "name": "CTRE-Phoenix (v6)", - "version": "24.3.0", - "frcYear": 2024, + "version": "25.1.0", + "frcYear": "2025", "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", + "jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix6/latest/Phoenix6-frc2025-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" + "uuid": "e7900d8d-826f-4dca-a1ff-182f658e98af", + "errorMessage": "Users can not have both the replay and regular Phoenix 6 vendordeps in their robot program.", + "offlineFileName": "Phoenix6-replay-frc2025-latest.json" } ], "javaDependencies": [ { "groupId": "com.ctre.phoenix6", "artifactId": "wpiapi-java", - "version": "24.3.0" + "version": "25.1.0" } ], "jniDependencies": [ + { + "groupId": "com.ctre.phoenix6", + "artifactId": "api-cpp", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "linuxathena" + ], + "simMode": "hwsim" + }, { "groupId": "com.ctre.phoenix6", "artifactId": "tools", - "version": "24.3.0", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "linuxathena" ], "simMode": "hwsim" }, { "groupId": "com.ctre.phoenix6.sim", - "artifactId": "tools-sim", - "version": "24.3.0", + "artifactId": "api-cpp-sim", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" }, { "groupId": "com.ctre.phoenix6.sim", - "artifactId": "simTalonSRX", - "version": "24.3.0", + "artifactId": "tools-sim", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" }, { "groupId": "com.ctre.phoenix6.sim", - "artifactId": "simTalonFX", - "version": "24.3.0", + "artifactId": "simTalonSRX", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -78,12 +96,13 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simVictorSPX", - "version": "24.3.0", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -91,12 +110,13 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simPigeonIMU", - "version": "24.3.0", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -104,12 +124,13 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simCANCoder", - "version": "24.3.0", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -117,12 +138,13 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProTalonFX", - "version": "24.3.0", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -130,12 +152,13 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANcoder", - "version": "24.3.0", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -143,12 +166,27 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProPigeon2", - "version": "24.3.0", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simProCANrange", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -158,7 +196,7 @@ { "groupId": "com.ctre.phoenix6", "artifactId": "wpiapi-cpp", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_Phoenix6_WPI", "headerClassifier": "headers", "sharedLibrary": true, @@ -166,6 +204,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "linuxathena" ], "simMode": "hwsim" @@ -173,7 +212,7 @@ { "groupId": "com.ctre.phoenix6", "artifactId": "tools", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_PhoenixTools", "headerClassifier": "headers", "sharedLibrary": true, @@ -181,6 +220,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "linuxathena" ], "simMode": "hwsim" @@ -188,7 +228,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "wpiapi-cpp-sim", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_Phoenix6_WPISim", "headerClassifier": "headers", "sharedLibrary": true, @@ -196,6 +236,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -203,7 +244,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "tools-sim", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_PhoenixTools_Sim", "headerClassifier": "headers", "sharedLibrary": true, @@ -211,6 +252,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -218,7 +260,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simTalonSRX", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimTalonSRX", "headerClassifier": "headers", "sharedLibrary": true, @@ -226,21 +268,7 @@ "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", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -248,7 +276,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simVictorSPX", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimVictorSPX", "headerClassifier": "headers", "sharedLibrary": true, @@ -256,6 +284,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -263,7 +292,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simPigeonIMU", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimPigeonIMU", "headerClassifier": "headers", "sharedLibrary": true, @@ -271,6 +300,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -278,7 +308,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simCANCoder", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimCANCoder", "headerClassifier": "headers", "sharedLibrary": true, @@ -286,6 +316,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -293,7 +324,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProTalonFX", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimProTalonFX", "headerClassifier": "headers", "sharedLibrary": true, @@ -301,6 +332,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -308,7 +340,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANcoder", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimProCANcoder", "headerClassifier": "headers", "sharedLibrary": true, @@ -316,6 +348,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -323,7 +356,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProPigeon2", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimProPigeon2", "headerClassifier": "headers", "sharedLibrary": true, @@ -331,6 +364,23 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simProCANrange", + "version": "25.1.0", + "libName": "CTRE_SimProCANrange", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" diff --git a/simulation/SyntheSimJava/vendordeps/REVLib.json b/simulation/SyntheSimJava/vendordeps/REVLib.json index f85acd4054..2c3962840b 100644 --- a/simulation/SyntheSimJava/vendordeps/REVLib.json +++ b/simulation/SyntheSimJava/vendordeps/REVLib.json @@ -1,25 +1,25 @@ { "fileName": "REVLib.json", "name": "REVLib", - "version": "2024.2.4", - "frcYear": "2024", + "version": "2025.0.0", + "frcYear": "2025", "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", "mavenUrls": [ "https://maven.revrobotics.com/" ], - "jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2024.json", + "jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2025.json", "javaDependencies": [ { "groupId": "com.revrobotics.frc", "artifactId": "REVLib-java", - "version": "2024.2.4" + "version": "2025.0.0" } ], "jniDependencies": [ { "groupId": "com.revrobotics.frc", "artifactId": "REVLib-driver", - "version": "2024.2.4", + "version": "2025.0.0", "skipInvalidPlatforms": true, "isJar": false, "validPlatforms": [ @@ -37,7 +37,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "REVLib-cpp", - "version": "2024.2.4", + "version": "2025.0.0", "libName": "REVLib", "headerClassifier": "headers", "sharedLibrary": false, @@ -55,7 +55,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "REVLib-driver", - "version": "2024.2.4", + "version": "2025.0.0", "libName": "REVLibDriver", "headerClassifier": "headers", "sharedLibrary": false, diff --git a/simulation/samples/Java2025Sample/.gitignore b/simulation/samples/Java2025Sample/.gitignore new file mode 100644 index 0000000000..34cbaac119 --- /dev/null +++ b/simulation/samples/Java2025Sample/.gitignore @@ -0,0 +1,187 @@ +# This gitignore has been specially created by the WPILib team. +# If you remove items from this file, intellisense might break. + +### C++ ### +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### Gradle ### +.gradle +/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +# # VS Code Specific Java Settings +# DO NOT REMOVE .classpath and .project +.classpath +.project +.settings/ +bin/ + +# IntelliJ +*.iml +*.ipr +*.iws +.idea/ +out/ + +# Fleet +.fleet + +# Simulation GUI and other tools window save file +networktables.json +simgui.json +*-window.json + +# Simulation data log directory +logs/ + +# Folder that has CTRE Phoenix Sim device config storage +ctre_sim/ + +# clangd +/.cache +compile_commands.json + +# Eclipse generated file for annotation processors +.factorypath diff --git a/simulation/samples/Java2025Sample/.wpilib/wpilib_preferences.json b/simulation/samples/Java2025Sample/.wpilib/wpilib_preferences.json new file mode 100644 index 0000000000..ea18b6a111 --- /dev/null +++ b/simulation/samples/Java2025Sample/.wpilib/wpilib_preferences.json @@ -0,0 +1,6 @@ +{ + "enableCppIntellisense": false, + "currentLanguage": "java", + "projectYear": "2025", + "teamNumber": 997 +} \ No newline at end of file diff --git a/simulation/samples/Java2025Sample/WPILib-License.md b/simulation/samples/Java2025Sample/WPILib-License.md new file mode 100644 index 0000000000..645e54253a --- /dev/null +++ b/simulation/samples/Java2025Sample/WPILib-License.md @@ -0,0 +1,24 @@ +Copyright (c) 2009-2024 FIRST and other WPILib contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of FIRST, WPILib, nor the names of other WPILib + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY FIRST AND OTHER WPILIB CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/simulation/samples/Java2025Sample/build.gradle b/simulation/samples/Java2025Sample/build.gradle new file mode 100644 index 0000000000..74aa17e794 --- /dev/null +++ b/simulation/samples/Java2025Sample/build.gradle @@ -0,0 +1,112 @@ +plugins { + id "java" + id "edu.wpi.first.GradleRIO" version "2025.1.1" +} + +repositories { + mavenLocal() +} + +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +def ROBOT_MAIN_CLASS = "frc.robot.Main" + +// Define my targets (RoboRIO) and artifacts (deployable files) +// This is added by GradleRIO's backing project DeployUtils. +deploy { + targets { + roborio(getTargetTypeClass('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 = project.frc.getTeamNumber() + debug = project.frc.getDebugOrDefault(false) + + artifacts { + // First part is artifact name, 2nd is artifact type + // getTargetTypeClass is a shortcut to get the class type using a string + + frcJava(getArtifactTypeClass('FRCJavaArtifact')) { + } + + // Static files artifact + frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) { + files = project.fileTree('src/main/deploy') + directory = '/home/lvuser/deploy' + deleteOldFiles = false // Change to true to delete files on roboRIO that no + // longer exist in deploy directory of this project + } + } + } + } +} + +def deployArtifact = deploy.targets.roborio.artifacts.frcJava + +// Set to true to use debug for JNI. +wpi.java.debugJni = false + +// 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 5. +dependencies { + annotationProcessor wpi.java.deps.wpilibAnnotations() + implementation wpi.java.deps.wpilib() + implementation wpi.java.vendor.java() + + roborioDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.roborio) + roborioDebug wpi.java.vendor.jniDebug(wpi.platforms.roborio) + + roborioRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.roborio) + roborioRelease wpi.java.vendor.jniRelease(wpi.platforms.roborio) + + nativeDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.desktop) + nativeDebug wpi.java.vendor.jniDebug(wpi.platforms.desktop) + simulationDebug wpi.sim.enableDebug() + + nativeRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.desktop) + nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop) + simulationRelease wpi.sim.enableRelease() + + testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + implementation "com.autodesk.synthesis:SyntheSimJava:1.0.0" +} + +test { + useJUnitPlatform() + systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true' +} + +// Simulation configuration (e.g. environment variables). +wpi.sim.addGui().defaultEnabled = true +wpi.sim.addDriverstation() + +wpi.sim.addWebsocketsServer().defaultEnabled = true + +// 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) } } + from sourceSets.main.allSource + manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS) + duplicatesStrategy = DuplicatesStrategy.INCLUDE +} + +// Configure jar and deploy tasks +deployArtifact.jarTask = jar +wpi.java.configureExecutableTasks(jar) +wpi.java.configureTestTasks(test) + +// Configure string concat to always inline compile +tasks.withType(JavaCompile) { + options.compilerArgs.add '-XDstringConcat=inline' +} diff --git a/simulation/samples/Java2025Sample/gradle/wrapper/gradle-wrapper.jar b/simulation/samples/Java2025Sample/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000..a4b76b9530 Binary files /dev/null and b/simulation/samples/Java2025Sample/gradle/wrapper/gradle-wrapper.jar differ diff --git a/simulation/samples/Java2025Sample/gradle/wrapper/gradle-wrapper.properties b/simulation/samples/Java2025Sample/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..34bd9ce95f --- /dev/null +++ b/simulation/samples/Java2025Sample/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=permwrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=permwrapper/dists diff --git a/simulation/samples/Java2025Sample/gradlew b/simulation/samples/Java2025Sample/gradlew new file mode 100644 index 0000000000..f5feea6d6b --- /dev/null +++ b/simulation/samples/Java2025Sample/gradlew @@ -0,0 +1,252 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original 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. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# 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" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/simulation/samples/Java2025Sample/gradlew.bat b/simulation/samples/Java2025Sample/gradlew.bat new file mode 100644 index 0000000000..9d21a21834 --- /dev/null +++ b/simulation/samples/Java2025Sample/gradlew.bat @@ -0,0 +1,94 @@ +@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 +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/simulation/samples/Java2025Sample/settings.gradle b/simulation/samples/Java2025Sample/settings.gradle new file mode 100644 index 0000000000..969c7b09ca --- /dev/null +++ b/simulation/samples/Java2025Sample/settings.gradle @@ -0,0 +1,30 @@ +import org.gradle.internal.os.OperatingSystem + +pluginManagement { + repositories { + mavenLocal() + gradlePluginPortal() + String frcYear = '2025' + File frcHome + if (OperatingSystem.current().isWindows()) { + String publicFolder = System.getenv('PUBLIC') + if (publicFolder == null) { + publicFolder = "C:\\Users\\Public" + } + def homeRoot = new File(publicFolder, "wpilib") + frcHome = new File(homeRoot, frcYear) + } else { + def userFolder = System.getProperty("user.home") + def homeRoot = new File(userFolder, "wpilib") + frcHome = new File(homeRoot, frcYear) + } + def frcHomeMaven = new File(frcHome, 'maven') + maven { + name 'frcHome' + url frcHomeMaven + } + } +} + +Properties props = System.getProperties(); +props.setProperty("org.gradle.internal.native.headers.unresolved.dependencies.ignore", "true"); diff --git a/simulation/samples/Java2025Sample/simgui-ds.json b/simulation/samples/Java2025Sample/simgui-ds.json new file mode 100644 index 0000000000..c4b7efd3d8 --- /dev/null +++ b/simulation/samples/Java2025Sample/simgui-ds.json @@ -0,0 +1,98 @@ +{ + "keyboardJoysticks": [ + { + "axisConfig": [ + { + "decKey": 65, + "incKey": 68 + }, + { + "decKey": 87, + "incKey": 83 + }, + { + "decKey": 69, + "decayRate": 0.0, + "incKey": 82, + "keyRate": 0.009999999776482582 + } + ], + "axisCount": 3, + "buttonCount": 4, + "buttonKeys": [ + 90, + 88, + 67, + 86 + ], + "povConfig": [ + { + "key0": 328, + "key135": 323, + "key180": 322, + "key225": 321, + "key270": 324, + "key315": 327, + "key45": 329, + "key90": 326 + } + ], + "povCount": 1 + }, + { + "axisConfig": [ + { + "decKey": 74, + "incKey": 76 + }, + { + "decKey": 73, + "incKey": 75 + } + ], + "axisCount": 2, + "buttonCount": 4, + "buttonKeys": [ + 77, + 44, + 46, + 47 + ], + "povCount": 0 + }, + { + "axisConfig": [ + { + "decKey": 263, + "incKey": 262 + }, + { + "decKey": 265, + "incKey": 264 + } + ], + "axisCount": 2, + "buttonCount": 6, + "buttonKeys": [ + 260, + 268, + 266, + 261, + 269, + 267 + ], + "povCount": 0 + }, + { + "axisCount": 0, + "buttonCount": 0, + "povCount": 0 + } + ], + "robotJoysticks": [ + { + "guid": "78696e70757401000000000000000000", + "useGamepad": true + } + ] +} diff --git a/simulation/samples/Java2025Sample/src/main/deploy/example.txt b/simulation/samples/Java2025Sample/src/main/deploy/example.txt new file mode 100644 index 0000000000..bb82515dad --- /dev/null +++ b/simulation/samples/Java2025Sample/src/main/deploy/example.txt @@ -0,0 +1,3 @@ +Files placed in this directory will be deployed to the RoboRIO into the +'deploy' directory in the home folder. Use the 'Filesystem.getDeployDirectory' wpilib function +to get a proper path relative to the deploy directory. \ No newline at end of file diff --git a/simulation/samples/Java2025Sample/src/main/java/frc/robot/Main.java b/simulation/samples/Java2025Sample/src/main/java/frc/robot/Main.java new file mode 100644 index 0000000000..8776e5dda7 --- /dev/null +++ b/simulation/samples/Java2025Sample/src/main/java/frc/robot/Main.java @@ -0,0 +1,25 @@ +// 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 edu.wpi.first.wpilibj.RobotBase; + +/** + * Do NOT add any static variables to this class, or any initialization at all. Unless you know what + * you are doing, do not modify this file except to change the parameter class to the startRobot + * call. + */ +public final class Main { + private Main() {} + + /** + * Main initialization function. Do not perform any initialization here. + * + *

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/Java2025Sample/src/main/java/frc/robot/Robot.java b/simulation/samples/Java2025Sample/src/main/java/frc/robot/Robot.java new file mode 100644 index 0000000000..34eee24368 --- /dev/null +++ b/simulation/samples/Java2025Sample/src/main/java/frc/robot/Robot.java @@ -0,0 +1,240 @@ +// 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.spark.SparkBase.PersistMode; +import com.revrobotics.spark.SparkBase.ResetMode; +import com.revrobotics.spark.SparkLowLevel.MotorType; +import com.revrobotics.spark.config.SparkMaxConfig; +import com.autodesk.synthesis.io.*; +import com.autodesk.synthesis.revrobotics.spark.SparkMax; + +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.kauailabs.navx.frc.AHRS; + +/** + * 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 m_chooser = new SendableChooser<>(); + + private Spark m_Spark1 = new Spark(0); + private Spark m_Spark2 = new Spark(1); + // private TalonFX m_Talon = new TalonFX(7); + private XboxController m_Controller = new XboxController(0); + + private ADXL362 m_Accelerometer = new ADXL362(SPI.Port.kMXP, ADXL362.Range.k8G); + private AHRS m_Gyro = new AHRS(); + + private DigitalInput m_DI = new DigitalInput(0); + private DigitalOutput m_DO = new DigitalOutput(1); + private AnalogInput m_AI = new AnalogInput(0); + private AnalogOutput m_AO = new AnalogOutput(1); + + private SparkMax m_SparkMax1 = new SparkMax(1, MotorType.kBrushless); + private SparkMax m_SparkMax2 = new SparkMax(2, MotorType.kBrushless); + private SparkMax m_SparkMax3 = new SparkMax(3, MotorType.kBrushless); + private SparkMax m_SparkMax4 = new SparkMax(4, MotorType.kBrushless); + private SparkMax m_SparkMax5 = new SparkMax(5, MotorType.kBrushless); + private SparkMax m_SparkMax6 = new SparkMax(6, MotorType.kBrushless); + + /** + * This function is run when the robot is first started up and should be used + * for any + * initialization code. + */ + @Override + public void robotInit() { + m_chooser.setDefaultOption("Default Auto", kDefaultAuto); + m_chooser.addOption("My Auto", kCustomAuto); + SmartDashboard.putData("Auto choices", m_chooser); + + SparkMaxConfig configPrimary = new SparkMaxConfig(); + configPrimary.encoder.positionConversionFactor(0.01); + SparkMaxConfig configSecondary = new SparkMaxConfig(); + configSecondary.follow(1); + + m_SparkMax1.configure(configPrimary, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters); + m_SparkMax2.configure(configSecondary, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters); + } + + /** + * This function is called every 20 ms, no matter the mode. Use this for items + * like diagnostics + * that you want ran during disabled, autonomous, teleoperated and test. + * + *

+ * This runs after the mode specific periodic functions, but before LiveWindow + * and + * SmartDashboard integrated updating. + */ + @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_DO.set(true); + m_AO.setVoltage(0.0); + } + + /** This function is called periodically during autonomous. */ + @Override + public void autonomousPeriodic() { + + 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: + // Put custom auto code here + break; + case kDefaultAuto: + default: + // Put default auto code here + break; + } + } + + /** This function is called once when teleop is enabled. */ + @Override + public void teleopInit() { + m_DO.set(false); + 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() { + 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(forward); + // 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()); + // System.out.println("AI: " + m_AI.getVoltage()); + // m_Talon.set(-0.5); + // m_SparkMax1.set(-0.75); + // m_SparkMax2.set(-0.75); + m_SparkMax3.set(-0.75); + m_SparkMax4.set(-0.75); + m_SparkMax5.set(-0.75); + m_SparkMax6.set(-0.75); + + System.out.println("Encoder: " + m_SparkMax1.getEncoderSim().getPosition()); + + // m_SparkMax1.getEncoder().setPosition(0.0); + } + + /** This function is called once when the robot is disabled. */ + @Override + public void disabledInit() { + 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); + m_AO.setVoltage(12.0); + } + + /** 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/Java2025Sample/vendordeps/NavX.json b/simulation/samples/Java2025Sample/vendordeps/NavX.json new file mode 100644 index 0000000000..c86a80df29 --- /dev/null +++ b/simulation/samples/Java2025Sample/vendordeps/NavX.json @@ -0,0 +1,39 @@ +{ + "fileName": "NavX.json", + "name": "NavX", + "version": "2025.1.1-beta-1", + "uuid": "cb311d09-36e9-4143-a032-55bb2b94443b", + "frcYear": "2025", + "mavenUrls": [ + "https://dev.studica.com/maven/release/2025/" + ], + "jsonUrl": "https://dev.studica.com/releases/2025/NavX.json", + "javaDependencies": [ + { + "groupId": "com.kauailabs.navx.frc", + "artifactId": "navx_frc-java", + "version": "2025.1.1-beta-1" + } + ], + "jniDependencies": [], + "cppDependencies": [ + { + "groupId": "com.kauailabs.navx.frc", + "artifactId": "navx_frc-cpp", + "version": "2025.1.1-beta-1", + "headerClassifier": "headers", + "sourcesClassifier": "sources", + "sharedLibrary": false, + "libName": "navx_frc", + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "linuxathena", + "linuxarm32", + "linuxarm64", + "linuxx86-64", + "osxuniversal", + "windowsx86-64" + ] + } + ] +} \ No newline at end of file diff --git a/simulation/samples/Java2025Sample/vendordeps/Phoenix6.json b/simulation/samples/Java2025Sample/vendordeps/Phoenix6.json new file mode 100644 index 0000000000..21e0637317 --- /dev/null +++ b/simulation/samples/Java2025Sample/vendordeps/Phoenix6.json @@ -0,0 +1,389 @@ +{ + "fileName": "Phoenix6.json", + "name": "CTRE-Phoenix (v6)", + "version": "25.1.0", + "frcYear": "2025", + "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-frc2025-latest.json", + "conflictsWith": [ + { + "uuid": "e7900d8d-826f-4dca-a1ff-182f658e98af", + "errorMessage": "Users can not have both the replay and regular Phoenix 6 vendordeps in their robot program.", + "offlineFileName": "Phoenix6-replay-frc2025-latest.json" + } + ], + "javaDependencies": [ + { + "groupId": "com.ctre.phoenix6", + "artifactId": "wpiapi-java", + "version": "25.1.0" + } + ], + "jniDependencies": [ + { + "groupId": "com.ctre.phoenix6", + "artifactId": "api-cpp", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "linuxathena" + ], + "simMode": "hwsim" + }, + { + "groupId": "com.ctre.phoenix6", + "artifactId": "tools", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "linuxathena" + ], + "simMode": "hwsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "api-cpp-sim", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "tools-sim", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simTalonSRX", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simVictorSPX", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simPigeonIMU", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simCANCoder", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simProTalonFX", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simProCANcoder", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simProPigeon2", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simProCANrange", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + } + ], + "cppDependencies": [ + { + "groupId": "com.ctre.phoenix6", + "artifactId": "wpiapi-cpp", + "version": "25.1.0", + "libName": "CTRE_Phoenix6_WPI", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "linuxathena" + ], + "simMode": "hwsim" + }, + { + "groupId": "com.ctre.phoenix6", + "artifactId": "tools", + "version": "25.1.0", + "libName": "CTRE_PhoenixTools", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "linuxathena" + ], + "simMode": "hwsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "wpiapi-cpp-sim", + "version": "25.1.0", + "libName": "CTRE_Phoenix6_WPISim", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "tools-sim", + "version": "25.1.0", + "libName": "CTRE_PhoenixTools_Sim", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simTalonSRX", + "version": "25.1.0", + "libName": "CTRE_SimTalonSRX", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simVictorSPX", + "version": "25.1.0", + "libName": "CTRE_SimVictorSPX", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simPigeonIMU", + "version": "25.1.0", + "libName": "CTRE_SimPigeonIMU", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simCANCoder", + "version": "25.1.0", + "libName": "CTRE_SimCANCoder", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simProTalonFX", + "version": "25.1.0", + "libName": "CTRE_SimProTalonFX", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simProCANcoder", + "version": "25.1.0", + "libName": "CTRE_SimProCANcoder", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simProPigeon2", + "version": "25.1.0", + "libName": "CTRE_SimProPigeon2", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simProCANrange", + "version": "25.1.0", + "libName": "CTRE_SimProCANrange", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + } + ] +} \ No newline at end of file diff --git a/simulation/samples/Java2025Sample/vendordeps/REVLib.json b/simulation/samples/Java2025Sample/vendordeps/REVLib.json new file mode 100644 index 0000000000..2c3962840b --- /dev/null +++ b/simulation/samples/Java2025Sample/vendordeps/REVLib.json @@ -0,0 +1,74 @@ +{ + "fileName": "REVLib.json", + "name": "REVLib", + "version": "2025.0.0", + "frcYear": "2025", + "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", + "mavenUrls": [ + "https://maven.revrobotics.com/" + ], + "jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2025.json", + "javaDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-java", + "version": "2025.0.0" + } + ], + "jniDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-driver", + "version": "2025.0.0", + "skipInvalidPlatforms": true, + "isJar": false, + "validPlatforms": [ + "windowsx86-64", + "windowsx86", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + } + ], + "cppDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-cpp", + "version": "2025.0.0", + "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": "2025.0.0", + "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/Java2025Sample/vendordeps/WPILibNewCommands.json b/simulation/samples/Java2025Sample/vendordeps/WPILibNewCommands.json new file mode 100644 index 0000000000..3718e0acd7 --- /dev/null +++ b/simulation/samples/Java2025Sample/vendordeps/WPILibNewCommands.json @@ -0,0 +1,38 @@ +{ + "fileName": "WPILibNewCommands.json", + "name": "WPILib-New-Commands", + "version": "1.0.0", + "uuid": "111e20f7-815e-48f8-9dd6-e675ce75b266", + "frcYear": "2025", + "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", + "linuxarm32", + "linuxarm64", + "windowsx86-64", + "windowsx86", + "linuxx86-64", + "osxuniversal" + ] + } + ] +} diff --git a/simulation/samples/JavaSample/.classpath b/simulation/samples/JavaSample/.classpath index ea7f567adf..1e023977da 100644 --- a/simulation/samples/JavaSample/.classpath +++ b/simulation/samples/JavaSample/.classpath @@ -6,6 +6,7 @@ + diff --git a/simulation/samples/JavaSample/build.gradle b/simulation/samples/JavaSample/build.gradle index 5acbea004b..9427fa6837 100644 --- a/simulation/samples/JavaSample/build.gradle +++ b/simulation/samples/JavaSample/build.gradle @@ -1,6 +1,6 @@ plugins { id "java" - id "edu.wpi.first.GradleRIO" version "2024.3.2" + id "edu.wpi.first.GradleRIO" version "2025.1.1" } repositories { 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 f1b05386fc..dc705fbcf1 100644 --- a/simulation/samples/JavaSample/src/main/java/frc/robot/Robot.java +++ b/simulation/samples/JavaSample/src/main/java/frc/robot/Robot.java @@ -4,9 +4,13 @@ package frc.robot; -import com.revrobotics.CANSparkLowLevel.MotorType; +import com.revrobotics.spark.SparkBase.PersistMode; +import com.revrobotics.spark.SparkBase.ResetMode; +import com.revrobotics.spark.SparkLowLevel.MotorType; import com.autodesk.synthesis.io.*; +import com.autodesk.synthesis.revrobotics.spark.SparkMax; +import com.autodesk.synthesis.revrobotics.spark.config.SparkMaxConfig; import edu.wpi.first.wpilibj.SPI; @@ -17,9 +21,7 @@ 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 @@ -31,187 +33,211 @@ * 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 m_chooser = new SendableChooser<>(); - - private Spark m_Spark1 = new Spark(0); - private Spark m_Spark2 = new Spark(1); - private TalonFX m_Talon = new TalonFX(7); - private XboxController m_Controller = new XboxController(0); - - private ADXL362 m_Accelerometer = new ADXL362(SPI.Port.kMXP, ADXL362.Range.k8G); - private AHRS m_Gyro = new AHRS(); - - private DigitalInput m_DI = new DigitalInput(0); - private DigitalOutput m_DO = new DigitalOutput(1); - private AnalogInput m_AI = new AnalogInput(0); - private AnalogOutput m_AO = new AnalogOutput(1); - - private CANSparkMax m_SparkMax1 = new CANSparkMax(1, MotorType.kBrushless); - private CANSparkMax m_SparkMax2 = new CANSparkMax(2, MotorType.kBrushless); - private CANSparkMax m_SparkMax3 = new CANSparkMax(3, MotorType.kBrushless); - private CANSparkMax m_SparkMax4 = new CANSparkMax(4, MotorType.kBrushless); - private CANSparkMax m_SparkMax5 = new CANSparkMax(5, MotorType.kBrushless); - private CANSparkMax m_SparkMax6 = new CANSparkMax(6, MotorType.kBrushless); - - /** - * This function is run when the robot is first started up and should be used for any - * initialization code. - */ - @Override - public void robotInit() { - m_chooser.setDefaultOption("Default Auto", kDefaultAuto); - m_chooser.addOption("My Auto", kCustomAuto); - SmartDashboard.putData("Auto choices", m_chooser); - } - - /** - * This function is called every 20 ms, no matter the mode. Use this for items like diagnostics - * that you want ran during disabled, autonomous, teleoperated and test. - * - *

This runs after the mode specific periodic functions, but before LiveWindow and - * SmartDashboard integrated updating. - */ - @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_DO.set(true); - m_AO.setVoltage(0.0); - } - - /** This function is called periodically during autonomous. */ - @Override - public void autonomousPeriodic() { - - 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: - // Put custom auto code here - break; - case kDefaultAuto: - default: - // Put default auto code here - break; + private static final String kDefaultAuto = "Default"; + private static final String kCustomAuto = "My Auto"; + private String m_autoSelected; + private final SendableChooser m_chooser = new SendableChooser<>(); + + private Spark m_Spark1 = new Spark(0); + private Spark m_Spark2 = new Spark(1); + // private TalonFX m_Talon = new TalonFX(7); + private XboxController m_Controller = new XboxController(0); + + private ADXL362 m_Accelerometer = new ADXL362(SPI.Port.kMXP, ADXL362.Range.k8G); + private AHRS m_Gyro = new AHRS(); + + private DigitalInput m_DI = new DigitalInput(0); + private DigitalOutput m_DO = new DigitalOutput(1); + private AnalogInput m_AI = new AnalogInput(0); + private AnalogOutput m_AO = new AnalogOutput(1); + + private SparkMax m_SparkMax1 = new SparkMax(1, MotorType.kBrushless); + private SparkMax m_SparkMax2 = new SparkMax(2, MotorType.kBrushless); + private SparkMax m_SparkMax3 = new SparkMax(3, MotorType.kBrushless); + private SparkMax m_SparkMax4 = new SparkMax(4, MotorType.kBrushless); + private SparkMax m_SparkMax5 = new SparkMax(5, MotorType.kBrushless); + private SparkMax m_SparkMax6 = new SparkMax(6, MotorType.kBrushless); + + /** + * This function is run when the robot is first started up and should be used + * for any + * initialization code. + */ + @Override + public void robotInit() { + m_chooser.setDefaultOption("Default Auto", kDefaultAuto); + m_chooser.addOption("My Auto", kCustomAuto); + SmartDashboard.putData("Auto choices", m_chooser); + + SparkMaxConfig configPrimary = new SparkMaxConfig(); + configPrimary.encoder.positionConversionFactor(0.01); + SparkMaxConfig configSecondary = new SparkMaxConfig(); + configSecondary.follow(1); + + // configPrimary.encoder + + m_SparkMax1.configure(configPrimary, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters); + m_SparkMax2.configure(configSecondary, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters); } - } - - /** This function is called once when teleop is enabled. */ - @Override - public void teleopInit() { - m_DO.set(false); - 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() { - double forward = -m_Controller.getLeftY(); - double turn = m_Controller.getRightX(); - if (Math.abs(forward) < 0.2) { - forward = 0.0; + + /** + * This function is called every 20 ms, no matter the mode. Use this for items + * like diagnostics + * that you want ran during disabled, autonomous, teleoperated and test. + * + *

+ * This runs after the mode specific periodic functions, but before LiveWindow + * and + * SmartDashboard integrated updating. + */ + @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_DO.set(true); + m_AO.setVoltage(0.0); } - if (Math.abs(turn) < 0.2) { - turn = 0.0; + + /** This function is called periodically during autonomous. */ + @Override + public void autonomousPeriodic() { + + 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: + // Put custom auto code here + break; + case kDefaultAuto: + default: + // Put default auto code here + break; + } + } + + /** This function is called once when teleop is enabled. */ + @Override + public void teleopInit() { + m_DO.set(false); + m_AO.setVoltage(6.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()); - // System.out.println("AI: " + m_AI.getVoltage()); - // m_Talon.set(-0.5); - // m_SparkMax1.set(-0.75); - // m_SparkMax2.set(-0.75); - m_SparkMax3.set(-0.75); - m_SparkMax4.set(-0.75); - m_SparkMax5.set(-0.75); - m_SparkMax6.set(-0.75); - - m_SparkMax1.getEncoder().setPosition(0.0); - } - - - /** This function is called once when the robot is disabled. */ - @Override - public void disabledInit() { - 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); - m_AO.setVoltage(12.0); - } - - /** 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() { - } + 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() { + 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(forward); + // 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()); + // System.out.println("AI: " + m_AI.getVoltage()); + // m_Talon.set(-0.5); + // m_SparkMax1.set(-0.75); + // m_SparkMax2.set(-0.75); + m_SparkMax3.set(-0.75); + m_SparkMax4.set(-0.75); + m_SparkMax5.set(-0.75); + m_SparkMax6.set(-0.75); + + System.out.println("Encoder: " + m_SparkMax1.getEncoderSim().getPosition()); + + // m_SparkMax1.getEncoder().setPosition(0.0); + } + + /** This function is called once when the robot is disabled. */ + @Override + public void disabledInit() { + 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); + m_AO.setVoltage(12.0); + } + + /** 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/JavaSample/vendordeps/NavX.json b/simulation/samples/JavaSample/vendordeps/NavX.json index e978a5f745..c86a80df29 100644 --- a/simulation/samples/JavaSample/vendordeps/NavX.json +++ b/simulation/samples/JavaSample/vendordeps/NavX.json @@ -1,26 +1,26 @@ { "fileName": "NavX.json", "name": "NavX", - "version": "2024.1.0", + "version": "2025.1.1-beta-1", "uuid": "cb311d09-36e9-4143-a032-55bb2b94443b", - "frcYear": "2024", + "frcYear": "2025", "mavenUrls": [ - "https://dev.studica.com/maven/release/2024/" + "https://dev.studica.com/maven/release/2025/" ], - "jsonUrl": "https://dev.studica.com/releases/2024/NavX.json", + "jsonUrl": "https://dev.studica.com/releases/2025/NavX.json", "javaDependencies": [ { "groupId": "com.kauailabs.navx.frc", - "artifactId": "navx-frc-java", - "version": "2024.1.0" + "artifactId": "navx_frc-java", + "version": "2025.1.1-beta-1" } ], "jniDependencies": [], "cppDependencies": [ { "groupId": "com.kauailabs.navx.frc", - "artifactId": "navx-frc-cpp", - "version": "2024.1.0", + "artifactId": "navx_frc-cpp", + "version": "2025.1.1-beta-1", "headerClassifier": "headers", "sourcesClassifier": "sources", "sharedLibrary": false, @@ -28,7 +28,6 @@ "skipInvalidPlatforms": true, "binaryPlatforms": [ "linuxathena", - "linuxraspbian", "linuxarm32", "linuxarm64", "linuxx86-64", diff --git a/simulation/samples/JavaSample/vendordeps/Phoenix6.json b/simulation/samples/JavaSample/vendordeps/Phoenix6.json index 032238505f..21e0637317 100644 --- a/simulation/samples/JavaSample/vendordeps/Phoenix6.json +++ b/simulation/samples/JavaSample/vendordeps/Phoenix6.json @@ -1,76 +1,94 @@ { "fileName": "Phoenix6.json", "name": "CTRE-Phoenix (v6)", - "version": "24.3.0", - "frcYear": 2024, + "version": "25.1.0", + "frcYear": "2025", "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", + "jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix6/latest/Phoenix6-frc2025-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" + "uuid": "e7900d8d-826f-4dca-a1ff-182f658e98af", + "errorMessage": "Users can not have both the replay and regular Phoenix 6 vendordeps in their robot program.", + "offlineFileName": "Phoenix6-replay-frc2025-latest.json" } ], "javaDependencies": [ { "groupId": "com.ctre.phoenix6", "artifactId": "wpiapi-java", - "version": "24.3.0" + "version": "25.1.0" } ], "jniDependencies": [ + { + "groupId": "com.ctre.phoenix6", + "artifactId": "api-cpp", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "linuxathena" + ], + "simMode": "hwsim" + }, { "groupId": "com.ctre.phoenix6", "artifactId": "tools", - "version": "24.3.0", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "linuxathena" ], "simMode": "hwsim" }, { "groupId": "com.ctre.phoenix6.sim", - "artifactId": "tools-sim", - "version": "24.3.0", + "artifactId": "api-cpp-sim", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" }, { "groupId": "com.ctre.phoenix6.sim", - "artifactId": "simTalonSRX", - "version": "24.3.0", + "artifactId": "tools-sim", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" }, { "groupId": "com.ctre.phoenix6.sim", - "artifactId": "simTalonFX", - "version": "24.3.0", + "artifactId": "simTalonSRX", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -78,12 +96,13 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simVictorSPX", - "version": "24.3.0", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -91,12 +110,13 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simPigeonIMU", - "version": "24.3.0", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -104,12 +124,13 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simCANCoder", - "version": "24.3.0", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -117,12 +138,13 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProTalonFX", - "version": "24.3.0", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -130,12 +152,13 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANcoder", - "version": "24.3.0", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -143,12 +166,27 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProPigeon2", - "version": "24.3.0", + "version": "25.1.0", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simProCANrange", + "version": "25.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -158,7 +196,7 @@ { "groupId": "com.ctre.phoenix6", "artifactId": "wpiapi-cpp", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_Phoenix6_WPI", "headerClassifier": "headers", "sharedLibrary": true, @@ -166,6 +204,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "linuxathena" ], "simMode": "hwsim" @@ -173,7 +212,7 @@ { "groupId": "com.ctre.phoenix6", "artifactId": "tools", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_PhoenixTools", "headerClassifier": "headers", "sharedLibrary": true, @@ -181,6 +220,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "linuxathena" ], "simMode": "hwsim" @@ -188,7 +228,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "wpiapi-cpp-sim", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_Phoenix6_WPISim", "headerClassifier": "headers", "sharedLibrary": true, @@ -196,6 +236,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -203,7 +244,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "tools-sim", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_PhoenixTools_Sim", "headerClassifier": "headers", "sharedLibrary": true, @@ -211,6 +252,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -218,7 +260,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simTalonSRX", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimTalonSRX", "headerClassifier": "headers", "sharedLibrary": true, @@ -226,21 +268,7 @@ "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", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -248,7 +276,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simVictorSPX", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimVictorSPX", "headerClassifier": "headers", "sharedLibrary": true, @@ -256,6 +284,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -263,7 +292,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simPigeonIMU", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimPigeonIMU", "headerClassifier": "headers", "sharedLibrary": true, @@ -271,6 +300,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -278,7 +308,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simCANCoder", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimCANCoder", "headerClassifier": "headers", "sharedLibrary": true, @@ -286,6 +316,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -293,7 +324,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProTalonFX", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimProTalonFX", "headerClassifier": "headers", "sharedLibrary": true, @@ -301,6 +332,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -308,7 +340,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANcoder", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimProCANcoder", "headerClassifier": "headers", "sharedLibrary": true, @@ -316,6 +348,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -323,7 +356,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProPigeon2", - "version": "24.3.0", + "version": "25.1.0", "libName": "CTRE_SimProPigeon2", "headerClassifier": "headers", "sharedLibrary": true, @@ -331,6 +364,23 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix6.sim", + "artifactId": "simProCANrange", + "version": "25.1.0", + "libName": "CTRE_SimProCANrange", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" diff --git a/simulation/samples/JavaSample/vendordeps/REVLib.json b/simulation/samples/JavaSample/vendordeps/REVLib.json index f85acd4054..2c3962840b 100644 --- a/simulation/samples/JavaSample/vendordeps/REVLib.json +++ b/simulation/samples/JavaSample/vendordeps/REVLib.json @@ -1,25 +1,25 @@ { "fileName": "REVLib.json", "name": "REVLib", - "version": "2024.2.4", - "frcYear": "2024", + "version": "2025.0.0", + "frcYear": "2025", "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", "mavenUrls": [ "https://maven.revrobotics.com/" ], - "jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2024.json", + "jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2025.json", "javaDependencies": [ { "groupId": "com.revrobotics.frc", "artifactId": "REVLib-java", - "version": "2024.2.4" + "version": "2025.0.0" } ], "jniDependencies": [ { "groupId": "com.revrobotics.frc", "artifactId": "REVLib-driver", - "version": "2024.2.4", + "version": "2025.0.0", "skipInvalidPlatforms": true, "isJar": false, "validPlatforms": [ @@ -37,7 +37,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "REVLib-cpp", - "version": "2024.2.4", + "version": "2025.0.0", "libName": "REVLib", "headerClassifier": "headers", "sharedLibrary": false, @@ -55,7 +55,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "REVLib-driver", - "version": "2024.2.4", + "version": "2025.0.0", "libName": "REVLibDriver", "headerClassifier": "headers", "sharedLibrary": false,