From 5e9ba2afd19cec1491359b0be19407e2b951dd83 Mon Sep 17 00:00:00 2001 From: YHerm <0549405422.yh@gmail.com> Date: Tue, 1 Apr 2025 15:49:16 +0300 Subject: [PATCH 1/5] added visualizer & subsystem --- src/main/java/frc/JoysticksBindings.java | 11 +++++ src/main/java/frc/robot/Robot.java | 10 +++++ .../robot/subsystems/DoubleJointedArm.java | 42 +++++++++++++++++++ .../DoubleJointedArmVisualizer.java | 38 +++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 src/main/java/frc/robot/subsystems/DoubleJointedArm.java create mode 100644 src/main/java/frc/robot/visualizers/DoubleJointedArmVisualizer.java diff --git a/src/main/java/frc/JoysticksBindings.java b/src/main/java/frc/JoysticksBindings.java index 0fe5ec2b70..8dc8e33d10 100644 --- a/src/main/java/frc/JoysticksBindings.java +++ b/src/main/java/frc/JoysticksBindings.java @@ -1,5 +1,7 @@ package frc; +import edu.wpi.first.math.geometry.Rotation2d; +import edu.wpi.first.wpilibj2.command.InstantCommand; import frc.joysticks.JoystickPorts; import frc.joysticks.SmartJoystick; import frc.robot.Robot; @@ -25,6 +27,15 @@ public static void configureBindings(Robot robot) { private static void mainJoystickButtons(Robot robot) { SmartJoystick usedJoystick = MAIN_JOYSTICK; // bindings... + + usedJoystick.A.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(100), + Rotation2d.fromDegrees(210)))); + usedJoystick.B.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(60), + Rotation2d.fromDegrees(80)))); + usedJoystick.X.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(150), + Rotation2d.fromDegrees(75)))); + usedJoystick.Y.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(95), + Rotation2d.fromDegrees(85)))); } private static void secondJoystickButtons(Robot robot) { diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index be6fbbae84..d83aa280c8 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -9,6 +9,8 @@ import edu.wpi.first.wpilibj2.command.InstantCommand; import frc.RobotManager; import frc.robot.hardware.phoenix6.BusChain; +import frc.robot.subsystems.DoubleJointedArm; +import frc.robot.visualizers.DoubleJointedArmVisualizer; import frc.utils.battery.BatteryUtil; /** @@ -20,6 +22,9 @@ public class Robot { public static final RobotType ROBOT_TYPE = RobotType.determineRobotType(); + private final DoubleJointedArm arm = new DoubleJointedArm("Arm"); + private final DoubleJointedArmVisualizer armVisualizer = new DoubleJointedArmVisualizer(2.5, 2.5, 0.8, 0.5); + public Robot() { BatteryUtil.scheduleLimiter(); } @@ -27,6 +32,7 @@ public Robot() { public void periodic() { BatteryUtil.logStatus(); BusChain.logChainsStatuses(); + armVisualizer.setAngles(arm.getFirstJointAngle(), arm.getSecondJointAngle()); CommandScheduler.getInstance().run(); // Should be last } @@ -34,4 +40,8 @@ public Command getAutonomousCommand() { return new InstantCommand(); } + public DoubleJointedArm getArm() { + return arm; + } + } diff --git a/src/main/java/frc/robot/subsystems/DoubleJointedArm.java b/src/main/java/frc/robot/subsystems/DoubleJointedArm.java new file mode 100644 index 0000000000..c04174becd --- /dev/null +++ b/src/main/java/frc/robot/subsystems/DoubleJointedArm.java @@ -0,0 +1,42 @@ +package frc.robot.subsystems; + +import edu.wpi.first.math.geometry.Rotation2d; +import org.littletonrobotics.junction.Logger; + +public class DoubleJointedArm extends GBSubsystem{ + + private Rotation2d firstJointAngle = new Rotation2d(); + private Rotation2d secondJointAngle = new Rotation2d(); + + public DoubleJointedArm(String logPath) { + super(logPath); + } + + @Override + protected void subsystemPeriodic() { + Logger.recordOutput("Arm/FirstJointAngleDeg", firstJointAngle.getDegrees()); + Logger.recordOutput("Arm/SecondJointAngleDeg", secondJointAngle.getDegrees()); + } + + public Rotation2d getFirstJointAngle() { + return firstJointAngle; + } + + public Rotation2d getSecondJointAngle() { + return secondJointAngle; + } + + public void setFirstJointAngle(Rotation2d firstJointAngle) { + this.firstJointAngle = firstJointAngle; + } + + public void setSecondJointAngle(Rotation2d secondJointAngle) { + this.secondJointAngle = secondJointAngle; + } + + public void setAngles(Rotation2d a1, Rotation2d a2){ + setFirstJointAngle(a1); + setSecondJointAngle(a2); + } + +} diff --git a/src/main/java/frc/robot/visualizers/DoubleJointedArmVisualizer.java b/src/main/java/frc/robot/visualizers/DoubleJointedArmVisualizer.java new file mode 100644 index 0000000000..fed6921940 --- /dev/null +++ b/src/main/java/frc/robot/visualizers/DoubleJointedArmVisualizer.java @@ -0,0 +1,38 @@ +package frc.robot.visualizers; + +import edu.wpi.first.math.geometry.Rotation2d; +import edu.wpi.first.wpilibj.smartdashboard.Mechanism2d; +import edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d; +import edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2d; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj.util.Color; +import edu.wpi.first.wpilibj.util.Color8Bit; + +public class DoubleJointedArmVisualizer { + + private final Mechanism2d mechanism; + private final MechanismRoot2d root; + private final MechanismLigament2d firstJoint; + private final MechanismLigament2d secondJoint; + + public DoubleJointedArmVisualizer(double xMeters, double yMeters, double l1Meters, double l2Meters) { + this.mechanism = new Mechanism2d(xMeters, yMeters); + this.root = mechanism.getRoot("Arm", xMeters / 2.0, 0); + this.firstJoint = new MechanismLigament2d("first joint", l1Meters, 0); + this.secondJoint = new MechanismLigament2d("first joint", l2Meters, 0, 10.0F, new Color8Bit(Color.kPurple)); + + firstJoint.append(secondJoint); + root.append(firstJoint); + SmartDashboard.putData("Mech2d", mechanism); + } + + public void setAngles(Rotation2d a1, Rotation2d a2) { + firstJoint.setAngle(a1); + secondJoint.setAngle(toFloorRelative(a1, a2)); + } + + private static Rotation2d toFloorRelative(Rotation2d floorRelativeAngle, Rotation2d jointRelativeAngle) { + return jointRelativeAngle.minus(floorRelativeAngle); + } + +} From 7d99187f4fac08cf3fec51cc4a47cb4176b38cea Mon Sep 17 00:00:00 2001 From: YHerm <0549405422.yh@gmail.com> Date: Tue, 1 Apr 2025 16:00:26 +0300 Subject: [PATCH 2/5] clean --- src/main/java/frc/JoysticksBindings.java | 12 ++-- src/main/java/frc/robot/Robot.java | 9 ++- .../robot/subsystems/DoubleJointedArm.java | 57 ++++++++++--------- .../DoubleJointedArmVisualizer.java | 48 ++++++++-------- 4 files changed, 66 insertions(+), 60 deletions(-) diff --git a/src/main/java/frc/JoysticksBindings.java b/src/main/java/frc/JoysticksBindings.java index 8dc8e33d10..140d1243c2 100644 --- a/src/main/java/frc/JoysticksBindings.java +++ b/src/main/java/frc/JoysticksBindings.java @@ -28,14 +28,10 @@ private static void mainJoystickButtons(Robot robot) { SmartJoystick usedJoystick = MAIN_JOYSTICK; // bindings... - usedJoystick.A.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(100), - Rotation2d.fromDegrees(210)))); - usedJoystick.B.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(60), - Rotation2d.fromDegrees(80)))); - usedJoystick.X.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(150), - Rotation2d.fromDegrees(75)))); - usedJoystick.Y.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(95), - Rotation2d.fromDegrees(85)))); + usedJoystick.A.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(100), Rotation2d.fromDegrees(210)))); + usedJoystick.B.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(60), Rotation2d.fromDegrees(80)))); + usedJoystick.X.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(150), Rotation2d.fromDegrees(75)))); + usedJoystick.Y.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(95), Rotation2d.fromDegrees(85)))); } private static void secondJoystickButtons(Robot robot) { diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index d83aa280c8..5cf0757a73 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -23,7 +23,12 @@ public class Robot { public static final RobotType ROBOT_TYPE = RobotType.determineRobotType(); private final DoubleJointedArm arm = new DoubleJointedArm("Arm"); - private final DoubleJointedArmVisualizer armVisualizer = new DoubleJointedArmVisualizer(2.5, 2.5, 0.8, 0.5); + private final DoubleJointedArmVisualizer armVisualizer = new DoubleJointedArmVisualizer( + 2.5, + 2.5, + DoubleJointedArm.FIRST_JOINT_LENGTH_METERS, + DoubleJointedArm.SECOND_JOINT_LENGTH_METERS + ); public Robot() { BatteryUtil.scheduleLimiter(); @@ -32,7 +37,9 @@ public Robot() { public void periodic() { BatteryUtil.logStatus(); BusChain.logChainsStatuses(); + armVisualizer.setAngles(arm.getFirstJointAngle(), arm.getSecondJointAngle()); + CommandScheduler.getInstance().run(); // Should be last } diff --git a/src/main/java/frc/robot/subsystems/DoubleJointedArm.java b/src/main/java/frc/robot/subsystems/DoubleJointedArm.java index c04174becd..6a6a236782 100644 --- a/src/main/java/frc/robot/subsystems/DoubleJointedArm.java +++ b/src/main/java/frc/robot/subsystems/DoubleJointedArm.java @@ -3,40 +3,43 @@ import edu.wpi.first.math.geometry.Rotation2d; import org.littletonrobotics.junction.Logger; -public class DoubleJointedArm extends GBSubsystem{ +public class DoubleJointedArm extends GBSubsystem { - private Rotation2d firstJointAngle = new Rotation2d(); - private Rotation2d secondJointAngle = new Rotation2d(); + public static final double FIRST_JOINT_LENGTH_METERS = 0.8; + public static final double SECOND_JOINT_LENGTH_METERS = 0.5; - public DoubleJointedArm(String logPath) { - super(logPath); - } + private Rotation2d firstJointAngle = new Rotation2d(); + private Rotation2d secondJointAngle = new Rotation2d(); - @Override - protected void subsystemPeriodic() { - Logger.recordOutput("Arm/FirstJointAngleDeg", firstJointAngle.getDegrees()); - Logger.recordOutput("Arm/SecondJointAngleDeg", secondJointAngle.getDegrees()); - } + public DoubleJointedArm(String logPath) { + super(logPath); + } - public Rotation2d getFirstJointAngle() { - return firstJointAngle; - } + @Override + protected void subsystemPeriodic() { + Logger.recordOutput(getLogPath() + "/FirstJointAngleDeg", firstJointAngle.getDegrees()); + Logger.recordOutput(getLogPath() + "/SecondJointAngleDeg", secondJointAngle.getDegrees()); + } - public Rotation2d getSecondJointAngle() { - return secondJointAngle; - } + public Rotation2d getFirstJointAngle() { + return firstJointAngle; + } - public void setFirstJointAngle(Rotation2d firstJointAngle) { - this.firstJointAngle = firstJointAngle; - } + public Rotation2d getSecondJointAngle() { + return secondJointAngle; + } - public void setSecondJointAngle(Rotation2d secondJointAngle) { - this.secondJointAngle = secondJointAngle; - } + public void setFirstJointAngle(Rotation2d firstJointAngle) { + this.firstJointAngle = firstJointAngle; + } - public void setAngles(Rotation2d a1, Rotation2d a2){ - setFirstJointAngle(a1); - setSecondJointAngle(a2); - } + public void setSecondJointAngle(Rotation2d secondJointAngle) { + this.secondJointAngle = secondJointAngle; + } + + public void setAngles(Rotation2d a1, Rotation2d a2) { + setFirstJointAngle(a1); + setSecondJointAngle(a2); + } } diff --git a/src/main/java/frc/robot/visualizers/DoubleJointedArmVisualizer.java b/src/main/java/frc/robot/visualizers/DoubleJointedArmVisualizer.java index fed6921940..c96e9e9973 100644 --- a/src/main/java/frc/robot/visualizers/DoubleJointedArmVisualizer.java +++ b/src/main/java/frc/robot/visualizers/DoubleJointedArmVisualizer.java @@ -10,29 +10,29 @@ public class DoubleJointedArmVisualizer { - private final Mechanism2d mechanism; - private final MechanismRoot2d root; - private final MechanismLigament2d firstJoint; - private final MechanismLigament2d secondJoint; - - public DoubleJointedArmVisualizer(double xMeters, double yMeters, double l1Meters, double l2Meters) { - this.mechanism = new Mechanism2d(xMeters, yMeters); - this.root = mechanism.getRoot("Arm", xMeters / 2.0, 0); - this.firstJoint = new MechanismLigament2d("first joint", l1Meters, 0); - this.secondJoint = new MechanismLigament2d("first joint", l2Meters, 0, 10.0F, new Color8Bit(Color.kPurple)); - - firstJoint.append(secondJoint); - root.append(firstJoint); - SmartDashboard.putData("Mech2d", mechanism); - } - - public void setAngles(Rotation2d a1, Rotation2d a2) { - firstJoint.setAngle(a1); - secondJoint.setAngle(toFloorRelative(a1, a2)); - } - - private static Rotation2d toFloorRelative(Rotation2d floorRelativeAngle, Rotation2d jointRelativeAngle) { - return jointRelativeAngle.minus(floorRelativeAngle); - } + private final Mechanism2d mechanism; + private final MechanismRoot2d root; + private final MechanismLigament2d firstJoint; + private final MechanismLigament2d secondJoint; + + public DoubleJointedArmVisualizer(double xMeters, double yMeters, double l1Meters, double l2Meters) { + this.mechanism = new Mechanism2d(xMeters, yMeters); + this.root = mechanism.getRoot("Arm", xMeters / 2.0, 0); + this.firstJoint = new MechanismLigament2d("first joint", l1Meters, 0); + this.secondJoint = new MechanismLigament2d("second joint", l2Meters, 0, 10.0F, new Color8Bit(Color.kPurple)); + + firstJoint.append(secondJoint); + root.append(firstJoint); + SmartDashboard.putData("DoubleJointedArmMech2d", mechanism); + } + + public void setAngles(Rotation2d a1, Rotation2d a2) { + firstJoint.setAngle(a1); + secondJoint.setAngle(toFloorRelative(a1, a2)); + } + + private static Rotation2d toFloorRelative(Rotation2d floorRelativeAngle, Rotation2d jointRelativeAngle) { + return jointRelativeAngle.minus(floorRelativeAngle); + } } From e73b4612a1db2cfe06bb640048b7d356eeb9202e Mon Sep 17 00:00:00 2001 From: YHerm <0549405422.yh@gmail.com> Date: Tue, 1 Apr 2025 16:03:52 +0300 Subject: [PATCH 3/5] no lables --- .github/workflows/addTestsLabels.yml | 130 +++++++++++++-------------- .github/workflows/checkLabels.yml | 126 +++++++++++++------------- 2 files changed, 128 insertions(+), 128 deletions(-) diff --git a/.github/workflows/addTestsLabels.yml b/.github/workflows/addTestsLabels.yml index 7f0661fc45..df8863dd43 100644 --- a/.github/workflows/addTestsLabels.yml +++ b/.github/workflows/addTestsLabels.yml @@ -1,65 +1,65 @@ -name: Add Tests Labels - -on: - pull_request: - types: - - opened - - reopened - - synchronize - -jobs: - add-tests-labels: - runs-on: ubuntu-latest - env: - ROBOT_TESTING: "needs-robot-testing" - NO_ROBOT_TESTING: "no-need-of-robot-testing" - SIMULATION_TESTING: "needs-simulation-testing" - NO_SIMULATION_TESTING: "no-need-of-simulation-testing" - PASSED_ALL_TESTS: "passed-all-tests" - stop: 'false' - steps: - - - name: get existing labels - run: | - existingLabels=$(jq -r '.pull_request.labels[].name' $GITHUB_EVENT_PATH | tr '\n' ' ') - echo "existing-labels=${existingLabels}" >>$GITHUB_ENV - echo "Existing labels: $existingLabels" - - - - name: Open Behavior - if: ${{ github.event.action == 'opened' && contains(env.existing-labels, env.PASSED_ALL_TESTS)}} - run: | - echo "stop=true" >>$GITHUB_ENV - - - - name: add needs robot test - if: ${{ env.stop == 'false' - && !contains(env.existing-labels, env.ROBOT_TESTING) - && !contains(env.existing-labels, env.NO_ROBOT_TESTING)}} - run: | - curl -X POST \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels \ - -d "{\"labels\":[\"${ROBOT_TESTING}\"]}" - - - - name: add needs simulation test - if: ${{env.stop == 'false' - && !contains(env.existing-labels, env.SIMULATION_TESTING) - && !contains(env.existing-labels, env.NO_SIMULATION_TESTING)}} - run: | - curl -X POST \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels \ - -d "{\"labels\":[\"${SIMULATION_TESTING}\"]}" - - - - name: remove passed all tests - if: ${{env.stop == 'false' && contains(env.existing-labels, env.PASSED_ALL_TESTS)}} - run: | - curl -X DELETE \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels/${PASSED_ALL_TESTS}" \ No newline at end of file +#name: Add Tests Labels +# +#on: +# pull_request: +# types: +# - opened +# - reopened +# - synchronize +# +#jobs: +# add-tests-labels: +# runs-on: ubuntu-latest +# env: +# ROBOT_TESTING: "needs-robot-testing" +# NO_ROBOT_TESTING: "no-need-of-robot-testing" +# SIMULATION_TESTING: "needs-simulation-testing" +# NO_SIMULATION_TESTING: "no-need-of-simulation-testing" +# PASSED_ALL_TESTS: "passed-all-tests" +# stop: 'false' +# steps: +# +# - name: get existing labels +# run: | +# existingLabels=$(jq -r '.pull_request.labels[].name' $GITHUB_EVENT_PATH | tr '\n' ' ') +# echo "existing-labels=${existingLabels}" >>$GITHUB_ENV +# echo "Existing labels: $existingLabels" +# +# +# - name: Open Behavior +# if: ${{ github.event.action == 'opened' && contains(env.existing-labels, env.PASSED_ALL_TESTS)}} +# run: | +# echo "stop=true" >>$GITHUB_ENV +# +# +# - name: add needs robot test +# if: ${{ env.stop == 'false' +# && !contains(env.existing-labels, env.ROBOT_TESTING) +# && !contains(env.existing-labels, env.NO_ROBOT_TESTING)}} +# run: | +# curl -X POST \ +# -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ +# -H "Accept: application/vnd.github.v3+json" \ +# https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels \ +# -d "{\"labels\":[\"${ROBOT_TESTING}\"]}" +# +# +# - name: add needs simulation test +# if: ${{env.stop == 'false' +# && !contains(env.existing-labels, env.SIMULATION_TESTING) +# && !contains(env.existing-labels, env.NO_SIMULATION_TESTING)}} +# run: | +# curl -X POST \ +# -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ +# -H "Accept: application/vnd.github.v3+json" \ +# https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels \ +# -d "{\"labels\":[\"${SIMULATION_TESTING}\"]}" +# +# +# - name: remove passed all tests +# if: ${{env.stop == 'false' && contains(env.existing-labels, env.PASSED_ALL_TESTS)}} +# run: | +# curl -X DELETE \ +# -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ +# -H "Accept: application/vnd.github.v3+json" \ +# "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels/${PASSED_ALL_TESTS}" \ No newline at end of file diff --git a/.github/workflows/checkLabels.yml b/.github/workflows/checkLabels.yml index fb35403b99..a3f5a30be0 100644 --- a/.github/workflows/checkLabels.yml +++ b/.github/workflows/checkLabels.yml @@ -1,63 +1,63 @@ -name: Check Labels - -on: - pull_request: - types: - - opened - - labeled - - unlabeled - - synchronize - - -jobs: - check-labels: - runs-on: ubuntu-latest - env: - PASSED_ALL_TESTS: "passed-all-tests" - NO_NEED_ROBOT: "no-need-of-robot-testing" - NO_NEED_SIMULATION: "no-need-of-simulation-testing" - steps: - - name: Get PR Labels - id: pr-info - run: | - LABELS=$(curl -s "https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${{ github.event.pull_request.number }}/labels" | jq -r '.[].name' | tr '\n' ' ') - echo "Labels for PR: ${LABELS}" - echo "existing_labels=${LABELS}" >> $GITHUB_ENV - - - name: Check On Push if no need appear - if: ${{ github.event.action == 'synchronize' }} - run: | - EXISTING_LABELS="${{env.existing_labels}}" - - if [[ "${EXISTING_LABELS}" =~ "${NO_NEED_ROBOT}" && "${EXISTING_LABELS}" =~ "${NO_NEED_SIMULATION}" ]]; then - echo "Label '${NO_NEED_ROBOT}' and label '${NO_NEED_SIMULATION}' found." - exit 0 - fi - - echo "This is a push event and no no-need-testing was found" - exit 1 - - - name: Check Absent Labels - run: | - EXISTING_LABELS="${{env.existing_labels}}" - declare -a absent_labels=("waiting-for-another-pr" "needs-robot-testing" "needs-simulation-testing") - for label in "${absent_labels[@]}"; do - if [[ "${EXISTING_LABELS}" =~ "${label}" ]]; then - echo "Label '${label}' should not be present." - exit 1 - fi - done - - - name: Check Present Label - run: | - EXISTING_LABELS="${{env.existing_labels}}" - if [[ "${EXISTING_LABELS}" =~ "${PASSED_ALL_TESTS}" ]]; then - echo "Label '${PASSED_ALL_TESTS}' found." - exit 0 - fi - if [[ "${EXISTING_LABELS}" =~ "${NO_NEED_ROBOT}" && "${EXISTING_LABELS}" =~ "${NO_NEED_SIMULATION}" ]]; then - echo "Label "${NO_NEED_ROBOT}" and label "${NO_NEED_SIMULATION}" found." - exit 0 - fi - echo "no passed-all-tests Or no-need-of-robot-testing And no-need-of-simulation-testing was found." - exit 1 \ No newline at end of file +#name: Check Labels +# +#on: +# pull_request: +# types: +# - opened +# - labeled +# - unlabeled +# - synchronize +# +# +#jobs: +# check-labels: +# runs-on: ubuntu-latest +# env: +# PASSED_ALL_TESTS: "passed-all-tests" +# NO_NEED_ROBOT: "no-need-of-robot-testing" +# NO_NEED_SIMULATION: "no-need-of-simulation-testing" +# steps: +# - name: Get PR Labels +# id: pr-info +# run: | +# LABELS=$(curl -s "https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${{ github.event.pull_request.number }}/labels" | jq -r '.[].name' | tr '\n' ' ') +# echo "Labels for PR: ${LABELS}" +# echo "existing_labels=${LABELS}" >> $GITHUB_ENV +# +# - name: Check On Push if no need appear +# if: ${{ github.event.action == 'synchronize' }} +# run: | +# EXISTING_LABELS="${{env.existing_labels}}" +# +# if [[ "${EXISTING_LABELS}" =~ "${NO_NEED_ROBOT}" && "${EXISTING_LABELS}" =~ "${NO_NEED_SIMULATION}" ]]; then +# echo "Label '${NO_NEED_ROBOT}' and label '${NO_NEED_SIMULATION}' found." +# exit 0 +# fi +# +# echo "This is a push event and no no-need-testing was found" +# exit 1 +# +# - name: Check Absent Labels +# run: | +# EXISTING_LABELS="${{env.existing_labels}}" +# declare -a absent_labels=("waiting-for-another-pr" "needs-robot-testing" "needs-simulation-testing") +# for label in "${absent_labels[@]}"; do +# if [[ "${EXISTING_LABELS}" =~ "${label}" ]]; then +# echo "Label '${label}' should not be present." +# exit 1 +# fi +# done +# +# - name: Check Present Label +# run: | +# EXISTING_LABELS="${{env.existing_labels}}" +# if [[ "${EXISTING_LABELS}" =~ "${PASSED_ALL_TESTS}" ]]; then +# echo "Label '${PASSED_ALL_TESTS}' found." +# exit 0 +# fi +# if [[ "${EXISTING_LABELS}" =~ "${NO_NEED_ROBOT}" && "${EXISTING_LABELS}" =~ "${NO_NEED_SIMULATION}" ]]; then +# echo "Label "${NO_NEED_ROBOT}" and label "${NO_NEED_SIMULATION}" found." +# exit 0 +# fi +# echo "no passed-all-tests Or no-need-of-robot-testing And no-need-of-simulation-testing was found." +# exit 1 \ No newline at end of file From 1e90fd2041d133c5febdb15bbc4845f8cb3c6b05 Mon Sep 17 00:00:00 2001 From: YHerm <0549405422.yh@gmail.com> Date: Tue, 1 Apr 2025 16:14:14 +0300 Subject: [PATCH 4/5] clean --- src/main/java/frc/robot/Robot.java | 1 + .../DoubleJointedArmVisualizer.java | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 5cf0757a73..20dc0c7f11 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -24,6 +24,7 @@ public class Robot { private final DoubleJointedArm arm = new DoubleJointedArm("Arm"); private final DoubleJointedArmVisualizer armVisualizer = new DoubleJointedArmVisualizer( + "", 2.5, 2.5, DoubleJointedArm.FIRST_JOINT_LENGTH_METERS, diff --git a/src/main/java/frc/robot/visualizers/DoubleJointedArmVisualizer.java b/src/main/java/frc/robot/visualizers/DoubleJointedArmVisualizer.java index c96e9e9973..c73bf35a28 100644 --- a/src/main/java/frc/robot/visualizers/DoubleJointedArmVisualizer.java +++ b/src/main/java/frc/robot/visualizers/DoubleJointedArmVisualizer.java @@ -15,20 +15,26 @@ public class DoubleJointedArmVisualizer { private final MechanismLigament2d firstJoint; private final MechanismLigament2d secondJoint; - public DoubleJointedArmVisualizer(double xMeters, double yMeters, double l1Meters, double l2Meters) { - this.mechanism = new Mechanism2d(xMeters, yMeters); - this.root = mechanism.getRoot("Arm", xMeters / 2.0, 0); - this.firstJoint = new MechanismLigament2d("first joint", l1Meters, 0); - this.secondJoint = new MechanismLigament2d("second joint", l2Meters, 0, 10.0F, new Color8Bit(Color.kPurple)); + public DoubleJointedArmVisualizer( + String name, + double frameXMeters, + double frameYMeters, + double firstJointLengthMeters, + double secondJointLengthMeters + ) { + this.mechanism = new Mechanism2d(frameXMeters, frameYMeters); + this.root = mechanism.getRoot(name + " DoubleJointedArm", frameXMeters / 2.0, 0); + this.firstJoint = new MechanismLigament2d("first joint", firstJointLengthMeters, 0); + this.secondJoint = new MechanismLigament2d("second joint", secondJointLengthMeters, 0, 10.0F, new Color8Bit(Color.kPurple)); firstJoint.append(secondJoint); root.append(firstJoint); - SmartDashboard.putData("DoubleJointedArmMech2d", mechanism); + SmartDashboard.putData(name + " DoubleJointedArmMech2d", mechanism); } - public void setAngles(Rotation2d a1, Rotation2d a2) { - firstJoint.setAngle(a1); - secondJoint.setAngle(toFloorRelative(a1, a2)); + public void setAngles(Rotation2d firstJointAngle, Rotation2d secondJointAngle) { + firstJoint.setAngle(firstJointAngle); + secondJoint.setAngle(toFloorRelative(firstJointAngle, secondJointAngle)); } private static Rotation2d toFloorRelative(Rotation2d floorRelativeAngle, Rotation2d jointRelativeAngle) { From 82b57327f6fe631594e377714f168d15f6f241a8 Mon Sep 17 00:00:00 2001 From: YHerm <0549405422.yh@gmail.com> Date: Tue, 1 Apr 2025 16:15:35 +0300 Subject: [PATCH 5/5] test binds --- src/main/java/frc/JoysticksBindings.java | 7 ------- src/main/java/frc/robot/subsystems/DoubleJointedArm.java | 9 +++++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/JoysticksBindings.java b/src/main/java/frc/JoysticksBindings.java index 140d1243c2..0fe5ec2b70 100644 --- a/src/main/java/frc/JoysticksBindings.java +++ b/src/main/java/frc/JoysticksBindings.java @@ -1,7 +1,5 @@ package frc; -import edu.wpi.first.math.geometry.Rotation2d; -import edu.wpi.first.wpilibj2.command.InstantCommand; import frc.joysticks.JoystickPorts; import frc.joysticks.SmartJoystick; import frc.robot.Robot; @@ -27,11 +25,6 @@ public static void configureBindings(Robot robot) { private static void mainJoystickButtons(Robot robot) { SmartJoystick usedJoystick = MAIN_JOYSTICK; // bindings... - - usedJoystick.A.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(100), Rotation2d.fromDegrees(210)))); - usedJoystick.B.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(60), Rotation2d.fromDegrees(80)))); - usedJoystick.X.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(150), Rotation2d.fromDegrees(75)))); - usedJoystick.Y.onTrue(new InstantCommand(() -> robot.getArm().setAngles(Rotation2d.fromDegrees(95), Rotation2d.fromDegrees(85)))); } private static void secondJoystickButtons(Robot robot) { diff --git a/src/main/java/frc/robot/subsystems/DoubleJointedArm.java b/src/main/java/frc/robot/subsystems/DoubleJointedArm.java index 6a6a236782..2abd1bddd2 100644 --- a/src/main/java/frc/robot/subsystems/DoubleJointedArm.java +++ b/src/main/java/frc/robot/subsystems/DoubleJointedArm.java @@ -1,6 +1,8 @@ package frc.robot.subsystems; import edu.wpi.first.math.geometry.Rotation2d; +import edu.wpi.first.wpilibj2.command.InstantCommand; +import frc.joysticks.SmartJoystick; import org.littletonrobotics.junction.Logger; public class DoubleJointedArm extends GBSubsystem { @@ -42,4 +44,11 @@ public void setAngles(Rotation2d a1, Rotation2d a2) { setSecondJointAngle(a2); } + public void applyTestBinds(SmartJoystick joystick) { + joystick.A.onTrue(new InstantCommand(() -> setAngles(Rotation2d.fromDegrees(100), Rotation2d.fromDegrees(210)))); + joystick.B.onTrue(new InstantCommand(() -> setAngles(Rotation2d.fromDegrees(60), Rotation2d.fromDegrees(80)))); + joystick.X.onTrue(new InstantCommand(() -> setAngles(Rotation2d.fromDegrees(150), Rotation2d.fromDegrees(75)))); + joystick.Y.onTrue(new InstantCommand(() -> setAngles(Rotation2d.fromDegrees(95), Rotation2d.fromDegrees(85)))); + } + }