Class RobotVisualizer

java.lang.Object
com.stuypulse.robot.util.simulation.RobotVisualizer

public class RobotVisualizer extends Object

Combined robot visualizer for all of the subsystems in one canvas.

This class employs the singleton pattern to ensure that only one visualizer exists, since only one robot instance should exist.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d
    Drawn representation of red bumpers to show the silhouette of the robot
    private final edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2d
    Root of the red bumpers to show the silhouette of the robot
    private final edu.wpi.first.wpilibj.smartdashboard.Mechanism2d
    Sendable main canvas object for every drawn mechanism
    private static final double
     
    private static final double
     
    private final edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2d
    Root for the drawn representation of the feeder The actual feeder is a belt, but spokes are easier.
    private final edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d[]
    Spokes of the feeder
     
    private final edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d
    Pivoting arm of the intake.
    private final edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2d
    Root for the drawn representation of the intake
    private final edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d[]
    Intake rollers, made into flattened array of every set of rollers for easy iteration
    private static final int
    Number of spokes for wheels
    private final edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2d
    Root for the drawn representation of the shooter
    private final edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d[]
    Shooter rollers
    private static edu.wpi.first.wpilibj.util.Color8Bit
    Color of spokes for wheels
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Constructs the visualizer instance
  • Method Summary

    Modifier and Type
    Method
    Description
    private edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d[]
    createSpokes(edu.wpi.first.wpilibj.smartdashboard.MechanismObject2d target, String name, double length, double width)
    Helper to create wheels
    private edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d[]
    createSpokes(edu.wpi.first.wpilibj.smartdashboard.MechanismObject2d target, String name, double length, double width, edu.wpi.first.wpilibj.util.Color8Bit color)
    Helper to create wheels
     
    void
    Publish the canvas to SmartDashboard
    void
    updateFeeder(edu.wpi.first.units.measure.AngularVelocity angularVelocity)
    Update method for the feeder
    void
    updateIntake(edu.wpi.first.units.measure.Angle pivotAngle, edu.wpi.first.units.measure.AngularVelocity angularVelocity)
    Update method for the intake
    void
    updateShooter(edu.wpi.first.units.measure.AngularVelocity angularVelocity)
    Update method for the shooter

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • RobotVisualizer

      private RobotVisualizer()

      Constructs the visualizer instance

      Uses specific internal logic, viewing the source code is recommended to better understand how everything is setup.

  • Method Details

    • getInstance

      public static RobotVisualizer getInstance()
    • createSpokes

      private edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d[] createSpokes(edu.wpi.first.wpilibj.smartdashboard.MechanismObject2d target, String name, double length, double width, edu.wpi.first.wpilibj.util.Color8Bit color)

      Helper to create wheels

      Creates a simulacrum of a wheel or side view of a roller by making a bunch of equally-spaced, outwards-radiating lines that like are spokes of a wheel

      Parameters:
      target - the object to append the spokes to
      name - name of each spoke, with name mangling applied internally
      length - length of the spokes
      width - width of the spokes
      color - color of the spokes
      Returns:
      An array of the generated spokes
    • createSpokes

      private edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d[] createSpokes(edu.wpi.first.wpilibj.smartdashboard.MechanismObject2d target, String name, double length, double width)

      Helper to create wheels

      Creates a simulacrum of a wheel or side view of a roller by making a bunch of equally-spaced, outwards-radiating lines that like are spokes of a wheel. Defaults to the statically specified color SPOKE_COLOR

      Parameters:
      target - the object to append the spokes to
      name - name of each spoke, with name mangling applied internally
      length - length of the spokes
      width - width of the spokes
      Returns:
      An array of the generated spokes
    • updateFeeder

      public void updateFeeder(edu.wpi.first.units.measure.AngularVelocity angularVelocity)

      Update method for the feeder

      To be called by subsystems using motor measurements

      Parameters:
      angularVelocity - measured angular velocity of the feeder rollers
    • updateShooter

      public void updateShooter(edu.wpi.first.units.measure.AngularVelocity angularVelocity)

      Update method for the shooter

      To be called by subsystems using motor measurements

      Parameters:
      angularVelocity - measured angular velocity of the shooter rollers
    • updateIntake

      public void updateIntake(edu.wpi.first.units.measure.Angle pivotAngle, edu.wpi.first.units.measure.AngularVelocity angularVelocity)

      Update method for the intake

      To be called by subsystems using motor measurements

      Parameters:
      pivotAngle - measured position of the intake pivot
      angularVelocity - measured angular velocity of the intake rollers
    • update

      public void update()

      Publish the canvas to SmartDashboard