Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
feat: Add frame perimeter distances.
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenheroux committed Feb 13, 2024
1 parent 6787503 commit a7dc2ed
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/main/java/frc/robot/RobotConstants.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package frc.robot;

import edu.wpi.first.math.util.Units;
import java.util.EnumSet;
import java.util.Set;

Expand All @@ -21,6 +22,15 @@ public class RobotConstants {
*/
public static final double DISABLE_COAST_DELAY = 3.0;

/** Distance from the frame perimeter to the origin in meters. */
public static final double FRAME_PERIMETER_TO_ORIGIN_DISTANCE = Units.inchesToMeters(14);

/** Maximum horizontal extension distance in meters. */
public static final double MAX_HORIZONTAL_EXTENSION_DISTANCE = Units.feetToMeters(1);

/** Maximum vertical extension distance in meters. */
public static final double MAX_VERTICAL_EXTENSION_DISTANCE = Units.inchesToMeters(48);

/** Robot subsystems. */
public enum Subsystem {
ARM,
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/arm/ArmConstants.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package frc.robot.arm;

import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.trajectory.TrapezoidProfile;
import edu.wpi.first.math.util.Units;
import frc.lib.CAN;
Expand Down Expand Up @@ -29,6 +30,10 @@ public static class ShoulderMotorConstants {
/** Tolerance of the shoulder joint. */
public static final Rotation2d TOLERANCE = Rotation2d.fromDegrees(5.0);

/** Translation of the shoulder joint relative to the origin. */
public static final Translation2d SHOULDER_TRANSLATION =
new Translation2d(Units.inchesToMeters(11.361), Units.inchesToMeters(7.721));

/** Shoulder pivot to elbow pivot distance in meters. */
public static final double SHOULDER_TO_ELBOW_DISTANCE = Units.inchesToMeters(16.775);

Expand Down
20 changes: 16 additions & 4 deletions src/main/java/frc/robot/arm/ArmMechanism.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2d;
import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj.util.Color8Bit;
import frc.robot.RobotConstants;
import frc.robot.arm.ArmConstants.ElbowMotorConstants;
import frc.robot.arm.ArmConstants.ShoulderMotorConstants;

Expand All @@ -24,22 +25,33 @@ public class ArmMechanism {
private final double THICKNESS = Units.inchesToMeters(2) * 100;

private ArmMechanism() {
mechanism = new Mechanism2d(1, 1);
root = mechanism.getRoot("arm", 0.15, 0);
mechanism =
new Mechanism2d(
2
* (RobotConstants.FRAME_PERIMETER_TO_ORIGIN_DISTANCE
+ RobotConstants.MAX_HORIZONTAL_EXTENSION_DISTANCE),
RobotConstants.MAX_VERTICAL_EXTENSION_DISTANCE);
root =
mechanism.getRoot(
"arm",
RobotConstants.FRAME_PERIMETER_TO_ORIGIN_DISTANCE
+ RobotConstants.MAX_HORIZONTAL_EXTENSION_DISTANCE
- ShoulderMotorConstants.SHOULDER_TRANSLATION.getX(),
ShoulderMotorConstants.SHOULDER_TRANSLATION.getY());
shoulder =
root.append(
new MechanismLigament2d(
"shoulder",
ShoulderMotorConstants.SHOULDER_TO_ELBOW_DISTANCE,
90,
0,
THICKNESS,
new Color8Bit(Color.kOrange)));
elbow =
shoulder.append(
new MechanismLigament2d(
"elbow",
ElbowMotorConstants.ELBOW_TO_WRIST_DISTANCE,
90,
0,
THICKNESS,
new Color8Bit(Color.kGreen)));
}
Expand Down

0 comments on commit a7dc2ed

Please sign in to comment.