Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
130 changes: 65 additions & 65 deletions .github/workflows/addTestsLabels.yml
Original file line number Diff line number Diff line change
@@ -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}"
#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}"
126 changes: 63 additions & 63 deletions .github/workflows/checkLabels.yml
Original file line number Diff line number Diff line change
@@ -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
#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
18 changes: 18 additions & 0 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -20,18 +22,34 @@ 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,
DoubleJointedArm.FIRST_JOINT_LENGTH_METERS,
DoubleJointedArm.SECOND_JOINT_LENGTH_METERS
);

public Robot() {
BatteryUtil.scheduleLimiter();
}

public void periodic() {
BatteryUtil.logStatus();
BusChain.logChainsStatuses();

armVisualizer.setAngles(arm.getFirstJointAngle(), arm.getSecondJointAngle());

CommandScheduler.getInstance().run(); // Should be last
}

public Command getAutonomousCommand() {
return new InstantCommand();
}

public DoubleJointedArm getArm() {
return arm;
}

}
54 changes: 54 additions & 0 deletions src/main/java/frc/robot/subsystems/DoubleJointedArm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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 {

public static final double FIRST_JOINT_LENGTH_METERS = 0.8;
public static final double SECOND_JOINT_LENGTH_METERS = 0.5;

private Rotation2d firstJointAngle = new Rotation2d();
private Rotation2d secondJointAngle = new Rotation2d();

public DoubleJointedArm(String logPath) {
super(logPath);
}

@Override
protected void subsystemPeriodic() {
Logger.recordOutput(getLogPath() + "/FirstJointAngleDeg", firstJointAngle.getDegrees());
Logger.recordOutput(getLogPath() + "/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);
}

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))));
}

}
Loading