forked from Autodesk/synthesis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from HunterBarclay/ktvuwhs/2025-sim-ver
2025 Minor Simulation Tweaks
- Loading branch information
Showing
31 changed files
with
2,190 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 56 additions & 89 deletions
145
simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFX.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,56 @@ | ||
// package com.autodesk.synthesis.ctre; | ||
|
||
// 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.configs.TalonFXConfigurator; | ||
// import com.ctre.phoenix6.hardware.DeviceIdentifier; | ||
|
||
// public class TalonFX extends com.ctre.phoenix6.hardware.TalonFX { | ||
// private CANMotor m_motor; | ||
// private CANEncoder m_encoder; | ||
|
||
// /** | ||
// * Creates a new TalonFX, wrapped with simulation support. | ||
// * | ||
// * @param deviceNumber CAN Device ID. | ||
// */ | ||
// public TalonFX(int deviceNumber) { | ||
// super(deviceNumber); | ||
|
||
// this.m_motor = new CANMotor("SYN TalonFX", deviceNumber, 0.0, false, 0.3); | ||
// 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); | ||
|
||
// 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; | ||
// return new com.autodesk.synthesis.ctre.TalonFXConfigurator(id, this); | ||
// } | ||
|
||
// // called internally by the configurator to set the deadband, not for user use | ||
// 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<Double> getPosition() { | ||
// Double pos = this.m_encoder.getPosition(); | ||
// super.setPosition(pos); | ||
// return super.getPosition(); | ||
// } | ||
|
||
// /** | ||
// * Gets the velocity of the simulated motor according to the simulated encoder | ||
// * | ||
// * @return The motor velocity in revolutions per second | ||
// */ | ||
// @Override | ||
// public StatusSignal<Double> getVelocity() { | ||
// Double velocity = this.m_encoder.getVelocity(); | ||
// super.set(velocity); | ||
// return super.getVelocity(); | ||
// } | ||
// } | ||
package com.autodesk.synthesis.ctre; | ||
|
||
import com.autodesk.synthesis.CANEncoder; | ||
import com.autodesk.synthesis.CANMotor; | ||
import com.ctre.phoenix6.signals.NeutralModeValue; | ||
import com.ctre.phoenix6.StatusCode; | ||
import com.ctre.phoenix6.configs.TalonFXConfigurator; | ||
import com.ctre.phoenix6.hardware.DeviceIdentifier; | ||
|
||
public class TalonFX extends com.ctre.phoenix6.hardware.TalonFX { | ||
private CANMotor m_motor; | ||
private CANEncoder m_encoder; | ||
|
||
/** | ||
* Creates a new TalonFX, wrapped with simulation support. | ||
* | ||
* @param deviceNumber CAN Device ID. | ||
*/ | ||
public TalonFX(int deviceNumber) { | ||
super(deviceNumber); | ||
|
||
this.m_motor = new CANMotor("SYN TalonFX", deviceNumber, 0.0, false, 0.3); | ||
this.m_encoder = new CANEncoder("SYN TalonFX", deviceNumber); | ||
} | ||
|
||
@Override | ||
public void set(double percentOutput) { | ||
super.set(percentOutput); | ||
this.m_motor.setPercentOutput(percentOutput); | ||
} | ||
|
||
@Override | ||
public StatusCode setNeutralMode(NeutralModeValue mode) { | ||
this.m_motor.setBrakeMode(mode == NeutralModeValue.Brake); | ||
return super.setNeutralMode(mode); | ||
} | ||
|
||
@Override | ||
public TalonFXConfigurator getConfigurator() { | ||
DeviceIdentifier id = this.deviceIdentifier; | ||
return new com.autodesk.synthesis.ctre.TalonFXConfigurator(id, this); | ||
} | ||
|
||
// called internally by the configurator to set the deadband, not for user use | ||
public void setNeutralDeadband(double deadband) { | ||
this.m_motor.setNeutralDeadband(deadband); | ||
} | ||
|
||
public double getPositionSim() { | ||
return this.m_encoder.getPosition(); | ||
} | ||
|
||
public double getVelocitySim() { | ||
return this.m_encoder.getVelocity(); | ||
} | ||
} |
68 changes: 34 additions & 34 deletions
68
simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/ctre/TalonFXConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
// package com.autodesk.synthesis.ctre; | ||
package com.autodesk.synthesis.ctre; | ||
|
||
// import com.ctre.phoenix6.hardware.DeviceIdentifier; | ||
// import com.ctre.phoenix6.configs.TorqueCurrentConfigs; | ||
// import com.ctre.phoenix6.StatusCode; | ||
import com.ctre.phoenix6.hardware.DeviceIdentifier; | ||
import com.ctre.phoenix6.configs.TorqueCurrentConfigs; | ||
import com.ctre.phoenix6.StatusCode; | ||
|
||
// /** | ||
// * TalonFXConfigurator wrapper to add proper WPILib HALSim support. | ||
// */ | ||
// public class TalonFXConfigurator extends com.ctre.phoenix6.configs.TalonFXConfigurator { | ||
// private TalonFX devicePtr; | ||
/** | ||
* 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 | ||
// // if you know how to get a device from an id, let me know | ||
// this.devicePtr = device; | ||
// } | ||
/** | ||
* 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 | ||
// 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 | ||
// * | ||
// * @param newTorqueCurrent The new torque configuration for this motor | ||
// */ | ||
// @Override | ||
// public StatusCode apply(TorqueCurrentConfigs newTorqueCurrent) { | ||
// StatusCode code = super.apply(newTorqueCurrent); | ||
// double newDeadband = newTorqueCurrent.TorqueNeutralDeadband; | ||
// this.devicePtr.setNeutralDeadband(newDeadband); | ||
// return code; | ||
// } | ||
// } | ||
/** | ||
* Applies a torque configuration to a TalonFX motor and passes the new neutral deadband to the simulated motor in fission if applicable | ||
* | ||
* @param newTorqueCurrent The new torque configuration for this motor | ||
*/ | ||
@Override | ||
public StatusCode apply(TorqueCurrentConfigs newTorqueCurrent) { | ||
StatusCode code = super.apply(newTorqueCurrent); | ||
double newDeadband = newTorqueCurrent.TorqueNeutralDeadband; | ||
this.devicePtr.setNeutralDeadband(newDeadband); | ||
return code; | ||
} | ||
} |
18 changes: 11 additions & 7 deletions
18
...ation/SyntheSimJava/src/main/java/com/autodesk/synthesis/revrobotics/RelativeEncoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.