-
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.
Added Examples of Arm2d, Elevator2d, and Flywheel2d from porting over 2024 code
- Loading branch information
1 parent
acb6dbf
commit 8539f59
Showing
37 changed files
with
748 additions
and
87 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
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
Binary file added
BIN
+165 KB
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8-javadoc.jar
Binary file not shown.
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8-javadoc.jar.md5
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
6d11fcc0c9505a91a71f8a423956d7e9 |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8-javadoc.jar.sha1
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
ff2d3bfe1d47200847b571f4d2eab003fe20e2d4 |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8-javadoc.jar.sha256
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
c85109c1d1603514fb072f511f4e83b44b524c07db3d8f741e4e7cd879160685 |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8-javadoc.jar.sha512
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
3c57c1232fc5a4a249fc0df65f7ee56998a0cf2570f9dc9ac4aa58e50681964b2c69f022295ec0c6666cbe897c73098c733b9cde4c4ef014e3fa6c1d58987fee |
Binary file added
BIN
+20.3 KB
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8-sources.jar
Binary file not shown.
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8-sources.jar.md5
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
15ebc82253229d71dac7d6dc099c4ca2 |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8-sources.jar.sha1
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
90547d72e1f532f3097e667650360981fe0fc76d |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8-sources.jar.sha256
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
4708e8e8a939530d04155b324133c63679e636514c9669d50f0f5f2da889e638 |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8-sources.jar.sha512
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
50b86ac6e18a5c055494a9dd866c1c6756e4ab3b6957f7b4668bfd54ecfd1f15ba5aab8747771c51bb27a7ab32a88e5f8e95c1cb7183620b6b76554e2f78136f |
Binary file added
BIN
+6.79 MB
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8.jar
Binary file not shown.
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8.jar.md5
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
dd0d5897faecea3067ff6502c6e41925 |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8.jar.sha1
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
40f79aa79e8272be5f46b598c73f214eb70d8804 |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8.jar.sha256
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
cc509e2dfb9a1b4949cf9b466d42eb636b609a3fde8473d53d1a21fa204cd337 |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8.jar.sha512
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
214fd63f2543793f06056d64b6b241328e60953f1011ec5804bf5aeb4ae099f155e7dc154dac6cf24549a589355c092c3a7ce345d03c57807cd6cff3f4f9cc3c |
8 changes: 8 additions & 0 deletions
8
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8.pom
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.team4201</groupId> | ||
<artifactId>Codex-java</artifactId> | ||
<version>2025.0.8</version> | ||
</project> |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8.pom.md5
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
8d259f1a73931d69e48ece2262a7c9eb |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8.pom.sha1
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
8a86d64eae0462c6af1ac5d9067b4c22b07b0a49 |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8.pom.sha256
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
83cb8df8dd0d0decdc30b77eabb71a65711ee365d18e59ae6940f06ca6090bec |
1 change: 1 addition & 0 deletions
1
releases/repos/org/team4201/Codex-java/2025.0.8/Codex-java-2025.0.8.pom.sha512
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
f79a12d1df3a0388d05fd5ced3c323619aa3bec1df67eed0bc286bf3401382cb2bcb58477bc69a4d9416ce2824e8751b921cc7d1e4a7a48d1a1b5afd96e23570 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
e74c5081964c4fd3f7d0c695f5a247bf | ||
97d28333094cf5f92d1695e32e54b3f1 |
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 +1 @@ | ||
3d8468d1991db982ca5b5d85267496988ceed2fe | ||
70ff7d72fe79203e6c36a2f45cde78ddb616caf0 |
2 changes: 1 addition & 1 deletion
2
releases/repos/org/team4201/Codex-java/maven-metadata.xml.sha256
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 +1 @@ | ||
3bcdd5ee374718967b46baf59668286799e137d16426d599f95ce3c377ff147f | ||
d44f4e8863e5bf8981a34ae7e365b870322c7a04ba3a373603e378e2668ed863 |
2 changes: 1 addition & 1 deletion
2
releases/repos/org/team4201/Codex-java/maven-metadata.xml.sha512
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 +1 @@ | ||
c06792ea57f2a6168d40df85a8ca7556b28cb53a3641b0c297b47c383caa7703f1dfcf068e427b1e865f779178f7e646ec0de0325859eace1a202ba6088d9c8d | ||
7d6a6a0939b007e119eaac3f420ea9539dda74ef3eff501108f8608a717885e17127593a7991dca9ed243e493867c9de76bbd1018140908183e19fac6e4abebf |
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
134 changes: 118 additions & 16 deletions
134
src/main/java/org/team4201/codex/simulation/visualization/Arm2d.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,63 +1,165 @@ | ||
package org.team4201.codex.simulation.visualization; | ||
|
||
import edu.wpi.first.units.measure.Angle; | ||
import edu.wpi.first.units.measure.AngularVelocity; | ||
import edu.wpi.first.units.measure.Distance; | ||
import edu.wpi.first.wpilibj.smartdashboard.Mechanism2d; | ||
import edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d; | ||
import edu.wpi.first.wpilibj.util.Color8Bit; | ||
import edu.wpi.first.wpilibj.smartdashboard.MechanismObject2d; | ||
import edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2d; | ||
import org.team4201.codex.simulation.visualization.configs.Arm2dConfig; | ||
|
||
import static edu.wpi.first.units.Units.*; | ||
|
||
/** | ||
* Class to represent an arm using {@link Mechanism2d} | ||
* */ | ||
public class Arm2d implements AutoCloseable { | ||
private final Arm2dConfig m_config; | ||
private final MechanismLigament2d m_arm2d; | ||
private final Color8Bit m_ligamentColor = new Color8Bit(235, 137, 52); | ||
private final String m_name; | ||
private MechanismObject2d m_parentObject; | ||
private Arm2d m_subArm2d; | ||
|
||
/** | ||
* Create a new {@link Arm2d} instance | ||
* | ||
* @param name The name of the object (Must be unique across all {@link Mechanism2d} objects) | ||
* @param config The {@link Arm2dConfig} that defines the Arm2d parameters | ||
*/ | ||
public Arm2d(String name) { | ||
m_name = name; | ||
public Arm2d(Arm2dConfig config) { | ||
this(config, null); | ||
} | ||
|
||
/** | ||
* Create a new {@link Arm2d} instance | ||
* | ||
* @param config The {@link Arm2dConfig} that defines the Arm2d parameters | ||
* @param parentObject The {@link MechanismObject2d} (Either a {@link MechanismRoot2d} or | ||
* {@link MechanismLigament2d})the Arm2d attaches to | ||
*/ | ||
public Arm2d(Arm2dConfig config, MechanismLigament2d parentObject) { | ||
m_config = config; | ||
|
||
// Create a "line" to represent the arm. | ||
// We will use this to show its current position | ||
m_arm2d = new MechanismLigament2d(m_name, 0, 0); | ||
m_arm2d = new MechanismLigament2d(m_config.m_name, | ||
m_config.m_initialLength.in(Inches), | ||
m_config.m_initialAngle.in(Degrees), | ||
m_config.m_initialWidth.in(Inches), | ||
m_config.m_color); | ||
|
||
if (parentObject != null) { | ||
m_parentObject = parentObject; | ||
|
||
Arm2dConfig armSubConfig = m_config.clone(); | ||
armSubConfig.m_name = armSubConfig.m_name + "_sub"; | ||
m_subArm2d = new Arm2d(armSubConfig); | ||
m_parentObject.append(m_arm2d); | ||
} | ||
} | ||
|
||
/** | ||
* Get the {@link Arm2d}'s {@link Arm2dConfig} | ||
* | ||
* @return {@link Arm2dConfig} | ||
*/ | ||
public Arm2dConfig getConfig() { | ||
return m_config; | ||
} | ||
|
||
/** | ||
* Get the {@link Arm2d}'s {@link MechanismLigament2d} | ||
* | ||
* @return {@link MechanismLigament2d} | ||
*/ | ||
public MechanismLigament2d getArmLigament() { | ||
public MechanismLigament2d getLigament() { | ||
return m_arm2d; | ||
} | ||
|
||
/** | ||
* Get the {@link Arm2d}'s parent {@link MechanismObject2d}. Returns null if it doesn't exist. | ||
* | ||
* @return {@link MechanismObject2d} | ||
*/ | ||
public MechanismObject2d getParentObject() { | ||
return m_parentObject; | ||
} | ||
|
||
/** | ||
* Get the {@link Arm2d}'s subMechanism. For displaying the mechanism by itself. | ||
* | ||
* @return {@link Arm2d} | ||
*/ | ||
public Arm2d getArmSubMechanism() { | ||
return m_subArm2d; | ||
} | ||
/** | ||
* Set the {@link Arm2d}'s {@link Angle}. | ||
* | ||
* @param angle Angle of the Arm2d | ||
*/ | ||
public void setAngle(Angle angle) { | ||
setAngle(angle, angle); | ||
} | ||
|
||
/** | ||
* Set the {@link Arm2d}'s {@link Angle}. This function is used if you want a separate orientation for | ||
* the standalone display of the Arm2d. | ||
* | ||
* @param angle Angle of the Arm2d | ||
* @param subAngle Angle of the Arm2d's subMechanism. | ||
*/ | ||
public void setAngle(Angle angle, Angle subAngle) { | ||
m_arm2d.setAngle(angle.in(Degrees)); | ||
|
||
if (m_subArm2d != null) { | ||
m_subArm2d.getLigament().setAngle(subAngle.in(Degrees)); | ||
} | ||
} | ||
|
||
/** | ||
* Update the {@link Arm2d}'s position relative to its attachment point | ||
* | ||
* @param angle The angle to set the Arm2d to. | ||
*/ | ||
public void update(Angle angle) { | ||
update(angle, RotationsPerSecond.of(0)); | ||
} | ||
|
||
/** | ||
* Update the {@link Arm2d}'s position relative to its attachment point | ||
* | ||
* @param angle The angle to set the {@link Arm2d} to. | ||
* @param angle The angle to set the Arm2d to. | ||
* @param velocity The velocity of the Arm2d. Used to change the color of the Arm2d for visualization. | ||
*/ | ||
public void update(double angle) { | ||
update(angle, 0); | ||
public void update(Angle angle, AngularVelocity velocity) { | ||
update(angle, RotationsPerSecond.of(0), m_config.m_initialLength); | ||
} | ||
|
||
/** | ||
* Update the {@link Arm2d}'s position relative to its attachment point | ||
* | ||
* @param angle The angle to set the {@link Arm2d} to. | ||
* @param velocity The velocity of the {@link Arm2d}. Used to change the color of the {@link Arm2d} for visualization. | ||
* @param angle The angle to set the Arm2d to. | ||
* @param velocity The velocity of the Arm2d. Used to change the color of the Arm2d for visualization. | ||
* @param length The length of the Arm2d. By default, it will use its initial length. | ||
*/ | ||
public void update(double angle, double velocity) { | ||
// m_arm2d.setAngle(307.5 - m_armJoint2d.getAngle() - angle); | ||
public void update(Angle angle, AngularVelocity velocity, Distance length) { | ||
m_arm2d.setLength(length.in(Inches)); | ||
m_arm2d.setAngle(m_config.m_angleOffset.minus(angle).in(Degrees)); | ||
|
||
// Update the ligament color based on the module's current speed for easier visualization | ||
VisualizationUtils.updateMotorColor(m_arm2d, velocity, m_ligamentColor); | ||
VisualizationUtils.updateMotorColor(m_arm2d, velocity.in(RotationsPerSecond), m_config.m_color); | ||
|
||
if(m_subArm2d != null) { | ||
m_subArm2d.update(angle, velocity, length); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() throws Exception { | ||
m_arm2d.close(); | ||
|
||
if(m_subArm2d != null) { | ||
m_subArm2d.close(); | ||
} | ||
} | ||
} |
Oops, something went wrong.