Class RobotVisualizer
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
FieldsModifier and TypeFieldDescriptionprivate final edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2dDrawn representation of red bumpers to show the silhouette of the robotprivate final edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2dRoot of theredbumpers to show the silhouette of the robotprivate final edu.wpi.first.wpilibj.smartdashboard.Mechanism2dSendable main canvas object for every drawn mechanismprivate static final doubleprivate static final doubleprivate final edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2dRoot 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 feederstatic RobotVisualizerprivate final edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2dPivoting arm of the intake.private final edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2dRoot for the drawn representation of the intakeprivate final edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d[]Intake rollers, made into flattened array of every set of rollers for easy iterationprivate static final intNumber of spokes for wheelsprivate final edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2dRoot for the drawn representation of the shooterprivate final edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d[]Shooter rollersprivate static edu.wpi.first.wpilibj.util.Color8BitColor of spokes for wheels -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d[]createSpokes(edu.wpi.first.wpilibj.smartdashboard.MechanismObject2d target, String name, double length, double width) Helper to create wheelsprivate 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 wheelsstatic RobotVisualizervoidupdate()Publish the canvas toSmartDashboardvoidupdateFeeder(edu.wpi.first.units.measure.AngularVelocity angularVelocity) Update method for the feedervoidupdateIntake(edu.wpi.first.units.measure.Angle pivotAngle, edu.wpi.first.units.measure.AngularVelocity angularVelocity) Update method for the intakevoidupdateShooter(edu.wpi.first.units.measure.AngularVelocity angularVelocity) Update method for the shooter
-
Field Details
-
instance
-
CANVAS_WIDTH
- See Also:
-
CANVAS_HEIGHT
- See Also:
-
NUM_SPOKES
Number of spokes for wheels -
SPOKE_COLOR
Color of spokes for wheels -
canvas
Sendable main canvas object for every drawn mechanism -
bumperRoot
Root of theredbumpers to show the silhouette of the robot -
bumper
Drawn representation of red bumpers to show the silhouette of the robot- See Also:
-
feederRoot
Root for the drawn representation of the feeder The actual feeder is a belt, but spokes are easier. Additionally, thespokesare placed where the handoff should be... -
feederSpokes
Spokes of the feeder- See Also:
-
intakeRoot
Root for the drawn representation of the intake- See Also:
-
intakePivot
Pivoting arm of the intake. Parent of theintake rollers -
intakeSpokes
Intake rollers, made into flattened array of every set of rollers for easy iteration- See Also:
-
shooterRoot
Root for the drawn representation of the shooter -
shooterSpokes
Shooter rollers- See Also:
-
-
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
-
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 toname- name of each spoke, with name mangling applied internallylength- length of the spokeswidth- width of the spokescolor- 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 toname- name of each spoke, with name mangling applied internallylength- length of the spokeswidth- width of the spokes- Returns:
- An array of the generated spokes
-
updateFeeder
Update method for the feeder
To be called by subsystems using motor measurements
- Parameters:
angularVelocity- measured angular velocity of the feeder rollers
-
updateShooter
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 pivotangularVelocity- measured angular velocity of the intake rollers
-
update
Publish the canvas to
SmartDashboard
-