From 9790a543705737f71a6598e25e838dc87a7b1b49 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Mon, 12 Aug 2024 12:57:56 -0700 Subject: [PATCH 01/12] initial revisions to readme --- simulation/SyntheSimJava/README.md | 59 +++++++++++++++++------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/simulation/SyntheSimJava/README.md b/simulation/SyntheSimJava/README.md index 3e10a613a3..1c525fd6e8 100644 --- a/simulation/SyntheSimJava/README.md +++ b/simulation/SyntheSimJava/README.md @@ -4,18 +4,21 @@ This is the SyntheSim Java utility library. FRC users can add this to their proj ## Current 3rd-Party Support -This is a list of the following 3rd-Party libraries that SyntheSim - Java improves, as well as the level of capability currently offered. +A list of the 3rd-Party libraries SyntheSimJava supports, including the features currently offered. ### REVRobotics -- [ ] CANSparkMax + +- [x] CANSparkMax - [x] Basic motor control - [x] Basic internal encoder data - - [ ] Motor following - - [ ] Full encoder support + - [x] Motor following + - [x] Full encoder support + +### CTRE Phoenix v6 -### CTRE Phoenix -- [ ] TalonFX - - [ ] Basic motor control +- [x] TalonFX + - [x] Basic motor control + - [x] Full configuration support (via a [TalonFXConfigurator](src/main/com/autodesk/synthesis/ctre/TalonFXConfigurator.java) wrapper) - [ ] Basic internal encoder data - [ ] Motor following - [ ] Full encoder support @@ -27,15 +30,18 @@ To build the project, run the `build` task:
Example - Windows: - ```sh - $ gradlew.bat build - ``` +Windows: + +```sh +gradlew.bat build +``` + +MacOS/Linux: + +```sh +./gradlew build +``` - MacOS/Linux: - ```sh - $ ./gradlew build - ```
## Usage @@ -49,20 +55,23 @@ To publish the project locally, run the `publishToMavenLocal` task:
Example - Windows: - ```sh - $ gradlew.bat publishToMavenLocal - ``` +Windows: + +```sh +gradlew.bat publishToMavenLocal +``` + +MacOS/Linux: + +```sh +./gradlew publishToMavenLocal +``` - MacOS/Linux: - ```sh - $ ./gradlew publishToMavenLocal - ```
### Adding to project locally -In order to add the project locally, you must include the the `mavenLocal()` repository to your projects: +In order to add the project locally, you must include the `mavenLocal()` repository to your projects: ```groovy repositories { @@ -83,4 +92,4 @@ dependencies { ### Swapping Imports -SyntheSimJava creates alternative classes that wrap the original ones. Everything that we intercept is passed on to the original class, making it so these classes can (although not recommended) be used when running your robot code on original hardware. Be sure to switch over any and all CAN devices that this project supports in order to effectively simulate your code inside of Synthesis, or with any HALSim, WebSocket supported simulation/device. \ No newline at end of file +SyntheSimJava creates alternative classes that wrap the original ones. Everything that we intercept is passed on to the original class, making it so these classes can (although not recommended) be used when running your robot code on original hardware. Be sure to switch over any and all CAN devices that this project supports in order to effectively simulate your code inside of Synthesis, or with any HALSim, WebSocket supported simulation/device. From a89a0fa0597fab27967676f3751dca972b214a8f Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Mon, 12 Aug 2024 17:11:20 -0700 Subject: [PATCH 02/12] wrote exception to API swap in readme --- simulation/SyntheSimJava/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/simulation/SyntheSimJava/README.md b/simulation/SyntheSimJava/README.md index 1c525fd6e8..fff3e72efd 100644 --- a/simulation/SyntheSimJava/README.md +++ b/simulation/SyntheSimJava/README.md @@ -19,9 +19,9 @@ A list of the 3rd-Party libraries SyntheSimJava supports, including the features - [x] TalonFX - [x] Basic motor control - [x] Full configuration support (via a [TalonFXConfigurator](src/main/com/autodesk/synthesis/ctre/TalonFXConfigurator.java) wrapper) - - [ ] Basic internal encoder data - - [ ] Motor following - - [ ] Full encoder support + - [x] Basic internal encoder data + - [x] Motor following + - [x] Full encoder support ## Building @@ -93,3 +93,5 @@ dependencies { ### Swapping Imports SyntheSimJava creates alternative classes that wrap the original ones. Everything that we intercept is passed on to the original class, making it so these classes can (although not recommended) be used when running your robot code on original hardware. Be sure to switch over any and all CAN devices that this project supports in order to effectively simulate your code inside of Synthesis, or with any HALSim, WebSocket supported simulation/device. + +The one exception to this is the `CANSparkMax.getAbsoluteEncoder()` method, which you must substitute for the `CANSparkMax.getAbsoluteEncoderSim()` method, because we were unable to override the original, because we are unable to wrap the return type `SparkAbsoluteEncoder`, because it's constructor is private. We instead created a class that implements all the same interfaces and has all the same methods, and thus works exactly the same, except it isn't an explicit subclass of `SparkAbsoluteEncoder`. The only difference to the API is the method name, everything else operates identically. From 3b80456a2c1041c7e1d86b0b44ab9fbf6ae35b66 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Tue, 13 Aug 2024 15:35:23 -0700 Subject: [PATCH 03/12] basic method docs --- .../synthesis/ctre/TalonFXConfigurator.java | 5 +- .../synthesis/revrobotics/CANSparkMax.java | 25 +++++++-- .../revrobotics/SparkAbsoluteEncoder.java | 55 +++++++++++++++++-- 3 files changed, 73 insertions(+), 12 deletions(-) diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java index e934719df8..06354626ef 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java @@ -15,7 +15,10 @@ public TalonFXConfigurator(DeviceIdentifier id, TalonFX device) { // if you know how to get a device from an id, let me know this.devicePtr = device; } - + + /* + * Applies a torque configuration to a TalonFX motor and passes the new neutral deadband to the simulated motor in fission if applicable + */ @Override public StatusCode apply(TorqueCurrentConfigs newTorqueCurrent) { StatusCode code = super.apply(newTorqueCurrent); 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 index f61f91e0f0..76960435e1 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/CANSparkMax.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/CANSparkMax.java @@ -23,6 +23,8 @@ public class CANSparkMax extends com.revrobotics.CANSparkMax { * @param deviceId CAN Device ID. * @param motorType Motortype. 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); @@ -32,7 +34,12 @@ public CANSparkMax(int deviceId, MotorType motorType) { this.followers = new ArrayList(); } - // setting a follower doesn't break the simulated follower - leader relationship + /* + * Sets the percent output of the motor + * Setting a follower doesn't break the simulated follower - leader relationship, which it does for exclusively non-simulated motors + * + * See the original documentation for more information + */ @Override public void set(double percent) { super.set(percent); @@ -42,7 +49,7 @@ public void set(double percent) { } } - public void setNeutralDeadband(double n) { + void setNeutralDeadband(double n) { this.m_motor.setNeutralDeadband(n); } @@ -55,16 +62,24 @@ public REVLibError setIdleMode(com.revrobotics.CANSparkBase.IdleMode mode) { return super.setIdleMode(mode); } - /// Use instead on getAbsoluteEncoder(), everything else works exactly the same in every way but name + /* + * Returns 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 on getAbsoluteEncoder(), everything except for the name of the method works exactly the same + */ public com.autodesk.synthesis.revrobotics.SparkAbsoluteEncoder getAbsoluteEncoderSim() { return new SparkAbsoluteEncoder(super.getAbsoluteEncoder(), this.m_encoder); } - public void newFollower(CANSparkMax f) { + void newFollower(CANSparkMax f) { this.followers.add(f); } - // Must pass in a simulation-supported leader to have the simulated portion of this motor follow + /* + * Causes a simulation-supported leader to follow another simulation-supported leader + * The real versions of these motors will also follow each other + * + */ @Override public REVLibError follow(CANSparkBase leader) { REVLibError err = super.follow(leader); 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 index e99a73a6d6..c7ab6f5705 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java @@ -9,59 +9,102 @@ public class SparkAbsoluteEncoder implements AbsoluteEncoder { private CANEncoder simEncoder; private com.revrobotics.SparkAbsoluteEncoder realEncoder; - // We're prettys sure that it's impossible to make a child class of this parent class with a constructor, because the parent's constructor is private - // Reflection didn't work since a child constructor __needs__ a super() call at the top of the body - // Passing in the constuctor wouldn't work either, since it's just a function pointer and the child constructor would have no idea that it points to its super + /* + * 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; } + /* + * Get the average sampling depth for an absolute encoder + * Returns: The average sampling depth + */ public int getAverageDepth() { return this.realEncoder.getAverageDepth(); } + /* + * Get the phase of the AbsoluteEncoder + * Returns: The phase of the encoder + */ public boolean getInverted() { return this.realEncoder.getInverted(); } + /* + * Get the position of the motor. This returns the native units of 'rotations' by default, and can be changed by a scale factor using setPositionConversionFactor(). + * Returns: Number of rotations of the motor + */ public double getPosition() { return this.simEncoder.getPosition() * this.realEncoder.getPositionConversionFactor(); } - // TODO: Remove conversion factors on the fission end + /* + * Set the conversion factor for position of the encoder. Multiplied by the native output units to give you position + * Returns: The conversion factor for position + */ public double getPositionConversionFactor() { return this.getPositionConversionFactor(); } - + + + /* + * Get the velocity of the motor. This returns the native units of 'rotations per second' by default, and can be changed by a scale factor using setVelocityConversionFactor(). + * Returns: Number of rotations per second of the motor + */ public double getVelocity() { return this.simEncoder.getVelocity() * this.realEncoder.getVelocityConversionFactor(); } + + /* + * Get the conversion factor for velocity of the encoder. + */ public double getVelocityConversionFactor() { return this.realEncoder.getVelocityConversionFactor(); } + /* + * Gets the zero offset for an absolute encoder (the position that is reported as zero). + */ public double getZeroOffset() { return this.realEncoder.getZeroOffset(); } - + + /* + * Set the average sampling depth for an absolute encoder. + */ public REVLibError setAverageDepth(int depth) { return this.realEncoder.setAverageDepth(depth); } + /* + * Set the phase of the AbsoluteEncoder so that it is set to be in phase with the motor itself + */ public REVLibError setInverted(boolean inverted) { return this.realEncoder.setInverted(inverted); } + /* + * Set the conversion factor for position of the encoder. + */ public REVLibError setPositionConversionFactor(double factor) { return this.realEncoder.setPositionConversionFactor(factor); } + /* + * Set the conversion factor for velocity of the encoder. + */ public REVLibError setVelocityConversionFactor(double factor) { return this.realEncoder.setVelocityConversionFactor(factor); } + /* + * Sets the zero offset of an absolute encoder (the position that is reported as zero). + */ public REVLibError setZeroOffset(double factor) { return this.realEncoder.setZeroOffset(factor); } From f0a971069241868cbcdab8120d8c71dc9e29f535 Mon Sep 17 00:00:00 2001 From: BrandonPacewic <92102436+BrandonPacewic@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:21:51 -0700 Subject: [PATCH 04/12] Added open Synthesis on export option --- .../src/Parser/ExporterOptions.py | 1 + .../SynthesisFusionAddin/src/UI/ConfigCommand.py | 9 ++++++++- .../src/UI/GeneralConfigTab.py | 15 +++++++++++++++ exporter/SynthesisFusionAddin/src/__init__.py | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py index 69e9bbef5d..8f4375a19c 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py +++ b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py @@ -57,6 +57,7 @@ class ExporterOptions: exportAsPart: bool = field(default=False) exportLocation: ExportLocation = field(default=ExportLocation.UPLOAD) + openSynthesisUponExport: bool = field(default=False) hierarchy: ModelHierarchy = field(default=ModelHierarchy.FusionAssembly) visualQuality: TriangleMeshQualityOptions = field(default=TriangleMeshQualityOptions.LowQualityTriangleMesh) diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index c50c7feed2..56115cd1a4 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -4,12 +4,13 @@ import os import pathlib +import webbrowser from enum import Enum import adsk.core import adsk.fusion -from src import gm +from src import APP_WEBSITE_URL, gm from src.APS.APS import getAuth, getUserInfo from src.Logging import getLogger, logFailure from src.Parser.ExporterOptions import ExporterOptions @@ -343,6 +344,7 @@ def notify(self, args): exportAsPart=generalConfigTab.exportAsPart, frictionOverride=generalConfigTab.overrideFriction, frictionOverrideCoeff=generalConfigTab.frictionOverrideCoeff, + openSynthesisUponExport=generalConfigTab.openSynthesisUponExport, ) Parser(exporterOptions).export() @@ -354,6 +356,11 @@ def notify(self, args): jointConfigTab.reset() gamepieceConfigTab.reset() + if generalConfigTab.openSynthesisUponExport: + res = webbrowser.open(APP_WEBSITE_URL) + if not res: + gm.ui.messageBox("Failed to open Synthesis in your default browser.") + class CommandExecutePreviewHandler(adsk.core.CommandEventHandler): """### Gets an event that is fired when the command has completed gathering the required input and now needs to perform a preview. diff --git a/exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py b/exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py index 40a602a406..a0da168958 100644 --- a/exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py +++ b/exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py @@ -154,6 +154,14 @@ def __init__(self, args: adsk.core.CommandCreatedEventArgs, exporterOptions: Exp frictionCoefficient.tooltip = "Friction coefficients range from 0 (ice) to 1 (rubber)." frictionCoefficient.isVisible = exporterOptions.frictionOverride + createBooleanInput( + "openSynthesisOnExportButton", + "Open Synthesis on Export", + generalTabInputs, + checked=exporterOptions.openSynthesisUponExport, + tooltip="Launch the Synthesis website upon export.", + ) + if exporterOptions.exportMode == ExportMode.FIELD: autoCalcWeightButton.isVisible = False exportAsPartButton.isVisible = False @@ -232,6 +240,13 @@ def frictionOverrideCoeff(self) -> float: ) return frictionSlider.valueOne + @property + def openSynthesisUponExport(self) -> bool: + openSynthesisButton: adsk.core.BoolValueCommandInput = self.generalOptionsTab.children.itemById( + "openSynthesisOnExportButton" + ) + return openSynthesisButton.value or False + @logFailure def handleInputChanged(self, args: adsk.core.InputChangedEventArgs) -> None: commandInput = args.input diff --git a/exporter/SynthesisFusionAddin/src/__init__.py b/exporter/SynthesisFusionAddin/src/__init__.py index 1e426279bb..6ba62d2144 100644 --- a/exporter/SynthesisFusionAddin/src/__init__.py +++ b/exporter/SynthesisFusionAddin/src/__init__.py @@ -5,6 +5,7 @@ APP_NAME = "Synthesis" APP_TITLE = "Synthesis Robot Exporter" +APP_WEBSITE_URL = "https://synthesis.autodesk.com/fission/" DESCRIPTION = "Exports files from Fusion into the Synthesis Format" INTERNAL_ID = "Synthesis" ADDIN_PATH = os.path.dirname(os.path.realpath(__file__)) From 455ff03566719de9399a31391c66d2df7636c9bb Mon Sep 17 00:00:00 2001 From: Azalea Colburn <62953415+azaleacolburn@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:15:20 -0700 Subject: [PATCH 05/12] Update simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/CANSparkMax.java Co-authored-by: PepperLola --- .../java/com/autodesk/synthesis/revrobotics/CANSparkMax.java | 1 - 1 file changed, 1 deletion(-) 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 index 76960435e1..7e157f6859 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/CANSparkMax.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/CANSparkMax.java @@ -78,7 +78,6 @@ void newFollower(CANSparkMax f) { /* * Causes a simulation-supported leader to follow another simulation-supported leader * The real versions of these motors will also follow each other - * */ @Override public REVLibError follow(CANSparkBase leader) { From 713d5f049e5321b14264bcf3dfedc267b94d5b1f Mon Sep 17 00:00:00 2001 From: Azalea Colburn <62953415+azaleacolburn@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:15:27 -0700 Subject: [PATCH 06/12] Update simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java Co-authored-by: PepperLola --- .../autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index c7ab6f5705..1923be5497 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java @@ -20,7 +20,7 @@ public SparkAbsoluteEncoder(com.revrobotics.SparkAbsoluteEncoder realEncoder, CA /* * Get the average sampling depth for an absolute encoder - * Returns: The average sampling depth + * @return The average sampling depth */ public int getAverageDepth() { return this.realEncoder.getAverageDepth(); From 0b436bd8dbc60f6ef8a553b58e2970517f1cb834 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Wed, 21 Aug 2024 09:34:41 -0700 Subject: [PATCH 07/12] javadoc support in most places i think --- .../com/autodesk/synthesis/ctre/TalonFX.java | 29 +++++++++++++-- .../synthesis/ctre/TalonFXConfigurator.java | 4 ++- .../synthesis/revrobotics/CANSparkMax.java | 36 ++++++++++++++----- 3 files changed, 58 insertions(+), 11 deletions(-) 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 5e671b86cd..286937c4e5 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 @@ -22,13 +22,24 @@ public TalonFX(int deviceNumber) { this.m_motor = new CANMotor("SYN TalonFX", deviceNumber, 0.0, false, 0.3); } - /// I think we're getting percentOutput and speed mixed up + /// I think we're getting percentOutput and torque mixed up + /** + * 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); @@ -36,6 +47,11 @@ public void setNeutralMode(NeutralModeValue mode) { this.m_motor.setBrakeMode(mode == NeutralModeValue.Brake); } + /** + * 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; @@ -47,6 +63,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(); @@ -54,7 +75,11 @@ public StatusSignal getPosition() { return super.getPosition(); } - /// I think this is a pointless method + /** + * 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(); diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java index 06354626ef..d3a14fffdb 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java @@ -16,8 +16,10 @@ public TalonFXConfigurator(DeviceIdentifier id, TalonFX device) { this.devicePtr = device; } - /* + /** * Applies a torque configuration to a TalonFX motor and passes the new neutral deadband to the simulated motor in fission if applicable + * + * @param The new torque configuration for this motor */ @Override public StatusCode apply(TorqueCurrentConfigs newTorqueCurrent) { 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 index 7e157f6859..5cc913d478 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/CANSparkMax.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/CANSparkMax.java @@ -34,10 +34,12 @@ public CANSparkMax(int deviceId, MotorType motorType) { this.followers = new ArrayList(); } - /* - * Sets the percent output of the motor + /** + * 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 percentOutput The new percent output of the motor + * * See the original documentation for more information */ @Override @@ -49,24 +51,38 @@ public void set(double percent) { } } + /** + * Sets the neutralDeadband of the real and simulated motors + * + * @param n The new neutralDeadband + */ 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) { + if (mode != null) this.m_motor.setBrakeMode(mode.equals(com.revrobotics.CANSparkBase.IdleMode.kBrake)); - } return super.setIdleMode(mode); } - /* - * Returns a simulation-supported SparkAbsoluteEncoder containing the position and velocity of the motor in fission. + /** + * 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 on getAbsoluteEncoder(), everything except for the name of the method works exactly the same - */ + + * @return thewsimulation-supported SparkAbsoluteEncoder. + * + * */ public com.autodesk.synthesis.revrobotics.SparkAbsoluteEncoder getAbsoluteEncoderSim() { return new SparkAbsoluteEncoder(super.getAbsoluteEncoder(), this.m_encoder); } @@ -75,9 +91,13 @@ 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) { From 65d0cb2fc2d4ee04fe928f9121843075e577021d Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Wed, 21 Aug 2024 09:54:07 -0700 Subject: [PATCH 08/12] javadocs for custom encoder class --- .../com/autodesk/synthesis/CANEncoder.java | 4 +- .../revrobotics/SparkAbsoluteEncoder.java | 94 ++++++++++++------- 2 files changed, 64 insertions(+), 34 deletions(-) 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 d00e5439b8..9b7220a1c2 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANEncoder.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANEncoder.java @@ -36,7 +36,7 @@ public CANEncoder(String name, int deviceId) { /** * Gets the current position of the encoder, simulated. * - * @return Current Position. + * @return Current position in revolutions. */ public double getPosition() { return m_position.get(); @@ -45,7 +45,7 @@ public double getPosition() { /** * Gets the current velocity of the encoder, simulated. * - * @return Current Velocity. + * @return Current velocity in revolutions per second. */ public double getVelocity() { return m_velocity.get(); 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 index 1923be5497..de1d952d60 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java @@ -18,94 +18,124 @@ public SparkAbsoluteEncoder(com.revrobotics.SparkAbsoluteEncoder realEncoder, CA this.simEncoder = simEncoder; } - /* - * Get the average sampling depth for an absolute encoder + /** + * Gets the average sampling depth for the real encoder + * * @return The average sampling depth */ public int getAverageDepth() { return this.realEncoder.getAverageDepth(); } - /* - * Get the phase of the AbsoluteEncoder - * Returns: The phase of the encoder + /** + * Gets the phase of the real encoder + * + * @return The phase of the real encoder */ public boolean getInverted() { return this.realEncoder.getInverted(); } - /* - * Get the position of the motor. This returns the native units of 'rotations' by default, and can be changed by a scale factor using setPositionConversionFactor(). - * Returns: Number of rotations of the motor + /** + * Gets the position lf 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() * this.realEncoder.getPositionConversionFactor(); + return this.simEncoder.getPosition(); } - /* - * Set the conversion factor for position of the encoder. Multiplied by the native output units to give you position - * Returns: The conversion factor for position + /** + * Sets the conversion factor for position of the real encoder. Multiplied by the native output units to give you position + * + * @return The conversion factor used by the encoder for position */ public double getPositionConversionFactor() { - return this.getPositionConversionFactor(); + return this.realEncoder.getPositionConversionFactor(); } - /* - * Get the velocity of the motor. This returns the native units of 'rotations per second' by default, and can be changed by a scale factor using setVelocityConversionFactor(). - * Returns: Number of rotations per second of the motor + /** + * 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(); } - /* - * Get the conversion factor for velocity of the encoder. + /** + * 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 for an absolute encoder (the position that is reported as zero). + /** + * 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(); } - /* - * Set the average sampling depth for an absolute encoder. + /** + * 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); } - /* - * Set the phase of the AbsoluteEncoder so that it is set to be in phase with the motor itself + /** + * 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); } - /* - * Set the conversion factor for position of the encoder. + /** + * Sets the conversion factor for position of the real encoder. + * + * @param The new position conversion factor + * + * @return a library error indicating failure or success */ public REVLibError setPositionConversionFactor(double factor) { return this.realEncoder.setPositionConversionFactor(factor); } - /* - * Set the conversion factor for velocity of the encoder. + /** + * 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 an absolute encoder (the position that is reported as zero). + /** + * 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 factor) { - return this.realEncoder.setZeroOffset(factor); + public REVLibError setZeroOffset(double offset) { + return this.realEncoder.setZeroOffset(offset); } } From edf956cc2f72f5885b8a1832685dbbc6ac3aae2a Mon Sep 17 00:00:00 2001 From: Azalea Colburn <62953415+azaleacolburn@users.noreply.github.com> Date: Wed, 21 Aug 2024 10:19:38 -0700 Subject: [PATCH 09/12] Update simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFX.java --- .../src/main/java/com/autodesk/synthesis/ctre/TalonFX.java | 1 - 1 file changed, 1 deletion(-) 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 286937c4e5..92863e701a 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 @@ -22,7 +22,6 @@ public TalonFX(int deviceNumber) { this.m_motor = new CANMotor("SYN TalonFX", deviceNumber, 0.0, false, 0.3); } - /// I think we're getting percentOutput and torque mixed up /** * Sets the torque of the real and simulated motors * From d5e57d42534f5ae41294d73ae263a44f8004a3fe Mon Sep 17 00:00:00 2001 From: PepperLola Date: Wed, 21 Aug 2024 17:57:50 -0700 Subject: [PATCH 10/12] standardized javadoc format a bit --- .../java/com/autodesk/synthesis/CANMotor.java | 6 +-- .../synthesis/ctre/TalonFXConfigurator.java | 11 +++- .../synthesis/revrobotics/CANSparkMax.java | 24 +++++---- .../revrobotics/SparkAbsoluteEncoder.java | 51 ++++++++++--------- 4 files changed, 54 insertions(+), 38 deletions(-) diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANMotor.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANMotor.java index e4df23ba66..6e5f0ccd0f 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANMotor.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/CANMotor.java @@ -96,7 +96,7 @@ public void setNeutralDeadband(double deadband) { /** * Get the supply current, simulated. * - * @return Supply Current. + * @return Supply current in amps. */ public double getSupplyCurrent() { return m_supplyCurrent.get(); @@ -105,7 +105,7 @@ public double getSupplyCurrent() { /** * Get the motor current, simulated. * - * @return Motor Current. + * @return Motor current in amps. */ public double getMotorCurrent() { return m_motorCurrent.get(); @@ -114,7 +114,7 @@ public double getMotorCurrent() { /** * Get the Bus Voltage, simulated. * - * @return Bus Voltage + * @return Bus voltage */ public double getBusVoltage() { return m_busVoltage.get(); diff --git a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java index d3a14fffdb..a5b372b221 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java @@ -6,9 +6,18 @@ //import com.ctre.phoenix6.configs.TalonFXConfigurator +/** + * TalonFXConfigurator wrapper to add proper WPILib HALSim support. + */ public class TalonFXConfigurator extends com.ctre.phoenix6.configs.TalonFXConfigurator { private TalonFX devicePtr; + /** + * Creates a new TalonFXConfigurator, wrapped with simulation support. + * + * @param id Device ID + * @param device The motor to configure + */ public TalonFXConfigurator(DeviceIdentifier id, TalonFX device) { super(id); // awful, jank solution, please help @@ -19,7 +28,7 @@ public TalonFXConfigurator(DeviceIdentifier id, TalonFX device) { /** * Applies a torque configuration to a TalonFX motor and passes the new neutral deadband to the simulated motor in fission if applicable * - * @param The new torque configuration for this motor + * @param newTorqueCurrent The new torque configuration for this motor */ @Override public StatusCode apply(TorqueCurrentConfigs newTorqueCurrent) { 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 index 5cc913d478..86a7cd917f 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/CANSparkMax.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/CANSparkMax.java @@ -21,7 +21,7 @@ public class CANSparkMax extends com.revrobotics.CANSparkMax { * Creates a new CANSparkMax, wrapped with simulation support. * * @param deviceId CAN Device ID. - * @param motorType Motortype. For Simulation purposes, this is discarded at the + * @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 @@ -54,7 +54,7 @@ public void set(double percent) { /** * Sets the neutralDeadband of the real and simulated motors * - * @param n The new neutralDeadband + * @param n The new neutral deadband */ void setNeutralDeadband(double n) { this.m_motor.setNeutralDeadband(n); @@ -77,27 +77,31 @@ public REVLibError setIdleMode(com.revrobotics.CANSparkBase.IdleMode 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 on getAbsoluteEncoder(), everything except for the name of the method works exactly the same + * 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 thewsimulation-supported SparkAbsoluteEncoder. - * - * */ + * @return The simulation-supported SparkAbsoluteEncoder. + */ public com.autodesk.synthesis.revrobotics.SparkAbsoluteEncoder getAbsoluteEncoderSim() { return new SparkAbsoluteEncoder(super.getAbsoluteEncoder(), 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 + * 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 + * @return A library error indicating failure or success */ @Override public REVLibError follow(CANSparkBase leader) { 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 index de1d952d60..402bdca0b9 100644 --- a/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java +++ b/simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/SparkAbsoluteEncoder.java @@ -5,13 +5,16 @@ 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 + * 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; @@ -31,26 +34,26 @@ public int 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 lf the simulated motor. + * 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. Multiplied by the native output units to give you position + * 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(); } @@ -60,7 +63,7 @@ public double 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(); } @@ -70,7 +73,7 @@ public double getVelocity() { * 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(); } @@ -79,7 +82,7 @@ public double 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(); } @@ -89,8 +92,8 @@ public double getZeroOffset() { * * @param depth The average sampling depth * - * @return a library error indicating failure or success - */ + * @return A library error indicating failure or success + */ public REVLibError setAverageDepth(int depth) { return this.realEncoder.setAverageDepth(depth); } @@ -100,19 +103,19 @@ public REVLibError setAverageDepth(int depth) { * * @param inverted Whether the real motor should be inverted * - * @return a library error indicating failure or success - */ + * @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 The new position conversion factor - * - * @return a library error indicating failure or success - */ + * 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); } @@ -122,8 +125,8 @@ public REVLibError setPositionConversionFactor(double factor) { * * @param factor The new velocity conversion factor * - * @return a library error indicating failure or success - */ + * @return A library error indicating failure or success + */ public REVLibError setVelocityConversionFactor(double factor) { return this.realEncoder.setVelocityConversionFactor(factor); } @@ -133,8 +136,8 @@ public REVLibError setVelocityConversionFactor(double factor) { * * @param offset The new zero offset * - * @return a library error indicating failure or success - */ + * @return A library error indicating failure or success + */ public REVLibError setZeroOffset(double offset) { return this.realEncoder.setZeroOffset(offset); } From 3b002ce9e2a15b535ecc989f04bf1afabd647ed9 Mon Sep 17 00:00:00 2001 From: LucaHaverty Date: Thu, 22 Aug 2024 11:04:53 -0700 Subject: [PATCH 11/12] Small modal spacing tweaks and control scheme deletion fix --- fission/src/ui/components/Modal.tsx | 4 +- .../src/ui/components/StyledComponents.tsx | 4 +- .../ui/modals/configuring/SettingsModal.tsx | 43 ++++++++++++------- .../theme-editor/NewInputSchemeModal.tsx | 2 +- .../configuring/ChooseInputSchemePanel.tsx | 1 - .../inputs/ConfigureInputsInterface.tsx | 13 +++++- 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/fission/src/ui/components/Modal.tsx b/fission/src/ui/components/Modal.tsx index 3dad42319d..ad7357bb12 100644 --- a/fission/src/ui/components/Modal.tsx +++ b/fission/src/ui/components/Modal.tsx @@ -56,7 +56,7 @@ const Modal: React.FC = ({
{name && ( diff --git a/fission/src/ui/components/StyledComponents.tsx b/fission/src/ui/components/StyledComponents.tsx index 66e404d71f..a42896b75d 100644 --- a/fission/src/ui/components/StyledComponents.tsx +++ b/fission/src/ui/components/StyledComponents.tsx @@ -3,7 +3,6 @@ import Label, { LabelSize } from "./Label" import Button, { ButtonProps, ButtonSize } from "./Button" import { IoCheckmark, IoPencil, IoPeople, IoTrashBin } from "react-icons/io5" import { HiDownload } from "react-icons/hi" -import { AiOutlinePlus } from "react-icons/ai" import { BiRefresh } from "react-icons/bi" import { AiFillWarning } from "react-icons/ai" import { BsCodeSquare } from "react-icons/bs" @@ -58,7 +57,8 @@ export class SynthesisIcons { /** Large icons: used for icon buttons */ public static DeleteLarge = () public static DownloadLarge = () - public static AddLarge = () + public static AddLarge = () + public static GearLarge = () public static RefreshLarge = () public static SelectLarge = () public static EditLarge = () diff --git a/fission/src/ui/modals/configuring/SettingsModal.tsx b/fission/src/ui/modals/configuring/SettingsModal.tsx index 006666d7bf..ce9f1b6a3d 100644 --- a/fission/src/ui/modals/configuring/SettingsModal.tsx +++ b/fission/src/ui/modals/configuring/SettingsModal.tsx @@ -1,22 +1,22 @@ import React, { useState } from "react" import Modal, { ModalPropsImpl } from "@/components/Modal" -import { FaGear } from "react-icons/fa6" import Label, { LabelSize } from "@/components/Label" import Dropdown from "@/components/Dropdown" -import Slider from "@/components/Slider" import Checkbox from "@/components/Checkbox" import PreferencesSystem from "@/systems/preferences/PreferencesSystem" import { SceneOverlayEvent, SceneOverlayEventKey } from "@/ui/components/SceneOverlayEvents" import { QualitySetting } from "@/systems/preferences/PreferenceTypes" import { Box } from "@mui/material" -import { Spacer } from "@/ui/components/StyledComponents" +import { Spacer, SynthesisIcons } from "@/ui/components/StyledComponents" import World from "@/systems/World" const SettingsModal: React.FC = ({ modalId }) => { const [qualitySettings, setQualitySettings] = useState( PreferencesSystem.getGlobalPreference("QualitySettings") ) - const [zoomSensitivity, setZoomSensitivity] = useState( + + // Disabled until camera settings are implemented + /* const [zoomSensitivity, setZoomSensitivity] = useState( PreferencesSystem.getGlobalPreference("ZoomSensitivity") ) const [pitchSensitivity, setPitchSensitivity] = useState( @@ -24,11 +24,15 @@ const SettingsModal: React.FC = ({ modalId }) => { ) const [yawSensitivity, setYawSensitivity] = useState( PreferencesSystem.getGlobalPreference("YawSensitivity") - ) + ) */ + const [reportAnalytics, setReportAnalytics] = useState( PreferencesSystem.getGlobalPreference("ReportAnalytics") ) - const [useMetric, setUseMetric] = useState(PreferencesSystem.getGlobalPreference("UseMetric")) + + // Disabled until use metric is implemented + // const [useMetric, setUseMetric] = useState(PreferencesSystem.getGlobalPreference("UseMetric")) + const [renderScoringZones, setRenderScoringZones] = useState( PreferencesSystem.getGlobalPreference("RenderScoringZones") ) @@ -44,29 +48,32 @@ const SettingsModal: React.FC = ({ modalId }) => { const saveSettings = () => { PreferencesSystem.setGlobalPreference("QualitySettings", qualitySettings) - PreferencesSystem.setGlobalPreference("ZoomSensitivity", zoomSensitivity) - PreferencesSystem.setGlobalPreference("PitchSensitivity", pitchSensitivity) - PreferencesSystem.setGlobalPreference("YawSensitivity", yawSensitivity) + PreferencesSystem.setGlobalPreference("ReportAnalytics", reportAnalytics) - PreferencesSystem.setGlobalPreference("UseMetric", useMetric) PreferencesSystem.setGlobalPreference("RenderScoringZones", renderScoringZones) PreferencesSystem.setGlobalPreference("RenderSceneTags", renderSceneTags) PreferencesSystem.setGlobalPreference("RenderScoreboard", renderScoreboard) PreferencesSystem.setGlobalPreference("SubsystemGravity", subsystemGravity) + // Disabled until these settings are implemented + /* PreferencesSystem.setGlobalPreference("ZoomSensitivity", zoomSensitivity) + PreferencesSystem.setGlobalPreference("PitchSensitivity", pitchSensitivity) + PreferencesSystem.setGlobalPreference("YawSensitivity", yawSensitivity) + PreferencesSystem.setGlobalPreference("UseMetric", useMetric) */ + PreferencesSystem.savePreferences() } return ( } + icon={SynthesisIcons.GearLarge} modalId={modalId} onAccept={() => { saveSettings() }} > -
+
= ({ modalId }) => { World.SceneRenderer.ChangeLighting(selected) }} /> - {Spacer(5)} + + {/* Disabled until these settings are implemented */} + {/* {Spacer(5)} = ({ modalId }) => { format={{ maximumFractionDigits: 2 }} onChange={(_, value) => setYawSensitivity(value as number)} tooltipText="Moving the camera left and right." - /> + />*/} {Spacer(20)} @@ -118,13 +127,15 @@ const SettingsModal: React.FC = ({ modalId }) => { }} tooltipText="Record user data such as what robots are spawned and how they are configured. No personal data will be collected." /> - ("UseMetric")} onClick={checked => { setUseMetric(checked) }} - /> + tooltipText="Metric measurements. (ex: meters instead of feet)" + /> */} ("SubsystemGravity")} diff --git a/fission/src/ui/modals/configuring/theme-editor/NewInputSchemeModal.tsx b/fission/src/ui/modals/configuring/theme-editor/NewInputSchemeModal.tsx index 81c59769aa..06b95d7a1f 100644 --- a/fission/src/ui/modals/configuring/theme-editor/NewInputSchemeModal.tsx +++ b/fission/src/ui/modals/configuring/theme-editor/NewInputSchemeModal.tsx @@ -16,7 +16,7 @@ const NewInputSchemeModal: React.FC = ({ modalId }) => { return ( { const scheme = DefaultInputs.newBlankScheme diff --git a/fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx b/fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx index 40a2ed7a86..0d5b549f36 100644 --- a/fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx +++ b/fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx @@ -73,7 +73,6 @@ const ChooseInputSchemePanel: React.FC = ({ panelId }) => { sidePadding={8} acceptEnabled={false} icon={SynthesisIcons.Gamepad} - cancelEnabled={selectedBrainIndexGlobal != undefined} cancelName="Close" > {/** A scroll view with buttons to select default and custom input schemes */} diff --git a/fission/src/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface.tsx b/fission/src/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface.tsx index 913ad32b4c..175bca83aa 100644 --- a/fission/src/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface.tsx +++ b/fission/src/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface.tsx @@ -77,10 +77,19 @@ const ConfigureInputsInterface = () => { // Fetch current custom schemes InputSchemeManager.saveSchemes() InputSchemeManager.resetDefaultSchemes() - const schemes = PreferencesSystem.getGlobalPreference("InputSchemes") - // Find and remove this input scheme + // Find the scheme to remove in preferences + const schemes = PreferencesSystem.getGlobalPreference("InputSchemes") const index = schemes.indexOf(val.scheme) + + // If currently bound to a robot, remove the binding + for (const [key, value] of InputSystem.brainIndexSchemeMap.entries()) { + if (value == schemes[index]) { + InputSystem.brainIndexSchemeMap.delete(key) + } + } + + // Find and remove this input scheme from preferences schemes.splice(index, 1) // Save to preferences From 0887cb891b16b8a6ad0bfd61b115f4b806763e30 Mon Sep 17 00:00:00 2001 From: LucaHaverty Date: Fri, 23 Aug 2024 12:14:17 -0700 Subject: [PATCH 12/12] settings modal fix --- fission/src/ui/modals/configuring/SettingsModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fission/src/ui/modals/configuring/SettingsModal.tsx b/fission/src/ui/modals/configuring/SettingsModal.tsx index ce9f1b6a3d..6f54dd1f0d 100644 --- a/fission/src/ui/modals/configuring/SettingsModal.tsx +++ b/fission/src/ui/modals/configuring/SettingsModal.tsx @@ -73,7 +73,7 @@ const SettingsModal: React.FC = ({ modalId }) => { saveSettings() }} > -
+