Class Mechanism2d
java.lang.Object
edu.wpi.first.wpilibj.smartdashboard.Mechanism2d
- All Implemented Interfaces:
NTSendable,Sendable,AutoCloseable
Visual 2D representation of arms, elevators, and general mechanisms through a node-based API.
A Mechanism2d object is published and contains at least one root node. A root is the anchor point of other nodes (such as ligaments). Other nodes are recursively appended based on other nodes.
-
Constructor Summary
ConstructorsConstructorDescriptionMechanism2d(double width, double height) Create a new Mechanism2d with the given dimensions and default color (dark blue).Mechanism2d(double width, double height, Color8Bit backgroundColor) Create a new Mechanism2d with the given dimensions. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Get or create a root in this Mechanism2d with the given name and position.voidinitSendable(NTSendableBuilder builder) Initializes thisSendableobject.voidsetBackgroundColor(Color8Bit color) Set the Mechanism2d background color.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.wpi.first.networktables.NTSendable
initSendable
-
Constructor Details
-
Mechanism2d
Create a new Mechanism2d with the given dimensions and default color (dark blue).The dimensions represent the canvas that all the nodes are drawn on.
- Parameters:
width- the widthheight- the height
-
Mechanism2d
Create a new Mechanism2d with the given dimensions.The dimensions represent the canvas that all the nodes are drawn on.
- Parameters:
width- the widthheight- the heightbackgroundColor- the background color. Defaults to dark blue.
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable
-
getRoot
Get or create a root in this Mechanism2d with the given name and position.If a root with the given name already exists, the given x and y coordinates are not used.
- Parameters:
name- the root namex- the root x coordinatey- the root y coordinate- Returns:
- a new root joint object, or the existing one with the given name.
-
setBackgroundColor
Set the Mechanism2d background color.- Parameters:
color- the new color
-
initSendable
Description copied from interface:NTSendableInitializes thisSendableobject.- Specified by:
initSendablein interfaceNTSendable- Parameters:
builder- sendable builder
-