Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
836690f
added orchestra stuff
ShmayaR Feb 14, 2025
51bd0c6
changed name from TrigonOrchestra to Orchestra
ShmayaR Feb 14, 2025
ae0cd14
Ugliness so @ShmayaR can clean :)
Strflightmight09 Feb 16, 2025
38060ab
Hard code 💪
Strflightmight09 Feb 16, 2025
4f06706
added java docs
ShmayaR Feb 16, 2025
c6169f9
rewrote java docs
ShmayaR Feb 16, 2025
8c7f53a
rewrote java docs again
ShmayaR Feb 16, 2025
567a210
Update Orchestra.java
ShmayaR Feb 18, 2025
9ae124b
fixed up java doc
ShmayaR Feb 25, 2025
52dd814
Update Orchestra.java
ShmayaR Feb 25, 2025
4488b3e
Update TalonFXMotor.java
ShmayaR Mar 2, 2025
b015457
Update Orchestra.java
ShmayaR Mar 4, 2025
ac91426
shortened a java doc into one @return
ShmayaR Mar 5, 2025
d6da940
Fix error message
Strflightmight09 Mar 6, 2025
f621f70
No more throwing
Strflightmight09 Jun 24, 2025
f44fc18
Merge branch 'main' into orchestra
Strflightmight09 Jul 3, 2025
3012beb
Quick fix
Strflightmight09 Jul 3, 2025
5289a52
WOW
Strflightmight09 Jul 3, 2025
32e3df0
Try this
Strflightmight09 Jul 3, 2025
9048ec2
ok sure
Strflightmight09 Jul 3, 2025
cc95c54
tets
Strflightmight09 Jul 3, 2025
33c5a01
NOw tis goinna work trust
Strflightmight09 Jul 3, 2025
52c9fe9
I thiikn we got it guys
Strflightmight09 Jul 3, 2025
4183fa2
A bit of an update
Strflightmight09 Jul 5, 2025
dba95ee
ID 0 😢
Strflightmight09 Jul 5, 2025
4b50c8a
Oops
Strflightmight09 Jul 5, 2025
cf18c47
Fix
Strflightmight09 Jul 5, 2025
b8b63f6
Test idk
Strflightmight09 Jul 5, 2025
9e42192
oops
Strflightmight09 Jul 5, 2025
e5669f2
Optimization
Strflightmight09 Jul 6, 2025
4dccd5b
test
Strflightmight09 Jul 7, 2025
ed478c8
more test
Strflightmight09 Jul 7, 2025
bee510a
Smth idek
Strflightmight09 Jul 16, 2025
4091b2c
For testing purposes
Strflightmight09 Jul 16, 2025
5ab2372
test
Strflightmight09 Jul 16, 2025
533042a
wowow
Strflightmight09 Jul 16, 2025
4a2c572
ArrayList is goated
Strflightmight09 Jul 16, 2025
5828631
?
Strflightmight09 Jul 16, 2025
06bd78d
Ughhhhh
Strflightmight09 Jul 16, 2025
8ce853f
O
Strflightmight09 Jul 16, 2025
f475382
WTHELLYYYYYYYYYYYYY
Strflightmight09 Jul 16, 2025
0da6572
whatttttttttttt
Strflightmight09 Jul 16, 2025
b0e0a2c
JIOHSEF"DS
Strflightmight09 Jul 16, 2025
ee67c54
test ig
Strflightmight09 Jul 16, 2025
c4a0c2f
Fine
Strflightmight09 Jul 16, 2025
cead20d
Simplify
Strflightmight09 Jul 16, 2025
609f645
Small improvement
Strflightmight09 Jul 17, 2025
f0f5c87
Replay protection and used IDs instead of skipped
Strflightmight09 Aug 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.trigon.hardware.phoenix6.talonfx.io.RealTalonFXIO;
import org.trigon.hardware.phoenix6.talonfx.io.SimulationTalonFXIO;
import org.trigon.hardware.simulation.MotorPhysicsSimulation;
import org.trigon.utilities.Orchestra;

/**
* A class that represents a TalonFX motor controller.
Expand All @@ -31,6 +32,7 @@ public class TalonFXMotor {
*/
public TalonFXMotor(int id, String motorName) {
this(id, motorName, "");
Orchestra.addMotor(motorIO.getTalonFX());
}

/**
Expand Down Expand Up @@ -190,7 +192,7 @@ public void setPosition(double positionRotations) {
public void setBrake(boolean brake) {
motorIO.setBrake(brake);
}

private BaseStatusSignal motorSignalToStatusSignal(TalonFXSignal signal) {
final TalonFX talonFX = motorIO.getTalonFX();
if (RobotHardwareStats.isReplay() || talonFX == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ protected void setPosition(double positionRotations) {

@Override
public void applyConfiguration(TalonFXConfiguration configuration) {
configuration.Audio.BeepOnBoot = false;
configuration.Audio.BeepOnConfig = false;
configuration.Audio.AllowMusicDurDisable = true;

talonFX.getConfigurator().apply(configuration);
}

Expand Down
109 changes: 109 additions & 0 deletions src/main/java/org/trigon/utilities/Orchestra.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package org.trigon.utilities;

import com.ctre.phoenix6.hardware.TalonFX;

import java.util.ArrayList;

/**
* A class that uses the {@link com.ctre.phoenix6.Orchestra} library in Phoenix 6 to play a .chrp file.
*/
public class Orchestra {
private static final com.ctre.phoenix6.Orchestra ORCHESTRA = new com.ctre.phoenix6.Orchestra();
private static final ArrayList<TalonFX> MOTORS = new ArrayList<>();

/**
* Adds a motor to the Orchestra.
* The Orchestra can then play the music from those motors.
*
* @param motor the motor to be added to the Orchestra
*/
public static void addMotor(TalonFX motor) {
MOTORS.add(motor);
}

/**
* Plays a .chrp file and assigns a track to each motor.
* A .chrp file stores music as tracks that can be played separately.
* The tracks are assigned linearly and loop back if there are extra motors.
*
* @param filePath the path of the .chrp file to be played by the Orchestra
* @param totalTracks the number of tracks in the .chrp file.
*/
public static void playFile(String filePath, int totalTracks) {
for (int i = 0; i < MOTORS.size(); i++)
ORCHESTRA.addInstrument(MOTORS.get(i), i % totalTracks + 1);

addAndPlayFile(filePath);
}

/**
* plays a .chrp file and assigns a track to each motor.
* A .chrp file stores music as tracks that can be played separately.
* The tracks are assigned by the {@code motorsPerTrack}.
* Each slot represents a track.
* Each value in the slot represents the number of motors that will be assigned that track.
*
* @param filePath the path of the .chrp file to be added to the Orchestra
* @param motorsPerTrack number of motors that should be assigned to each track
*/
public static void playFile(String filePath, int... motorsPerTrack) throws IllegalStateException {
int totalUsedMotors = 0;
int motorsAssignedTracks = 0;
for (int i = 0; i < motorsPerTrack.length; i++) {
totalUsedMotors += motorsPerTrack[i];
if (totalUsedMotors > MOTORS.size())
System.out.println("Not enough motors added to the Orchestra.");
for (int j = 0; j < motorsPerTrack[i]; i++)
ORCHESTRA.addInstrument(MOTORS.get(motorsAssignedTracks++), i + 1);
}
addAndPlayFile(filePath);
}

/**
* Stops the music and removes all tracks assigned to motors.
*/
public static void stop() {
ORCHESTRA.stop();
ORCHESTRA.clearInstruments();
}

/**
* Plays the stored .chrp file.
*/
public static void play() {
ORCHESTRA.play();
}

/**
* Pauses the music.
*/
public static void pause() {
ORCHESTRA.pause();
}

/**
* @return if music is playing
*/
public static boolean isOrchestraCurrentlyPlayingMusic() {
return ORCHESTRA.isPlaying();
}

/**
* Gets the play time of the .chrp file being played in seconds.
*
* @return the play time
*/
public static double getPlayTimeSeconds() {
return ORCHESTRA.getCurrentTime();
}

/**
* Adds a .chrp file to the Orchestra and plays it.
*
* @param filePath the path of the .chrp file to be added to the Orchestra
*/
private static void addAndPlayFile(String filePath) {
ORCHESTRA.loadMusic(filePath);
play();
}
}
Loading