Class BLineField
Field2d widget.
BLine paths are polylines, so a path can be displayed directly from
Path.getTranslations().
Field2d field = new Field2d();
SmartDashboard.putData("Field", field);
BLineField.drawPath(field, scoreTwoPath);
BLineField.drawPath(field, "Leave", leavePath);
How it renders (and why object names end in "Trajectory")
Each FieldObject2d is published as a list of poses. Elastic decides
whether to draw an object as a connected polyline or as individual
pose markers based on the object's name and size: an object is drawn as a
connected line when its NetworkTables name ends with "trajectory"
(case-insensitive) or when it contains more than 8 poses; otherwise it is drawn
as discrete arrow markers, one per pose.
These helpers ensure object names end in "Trajectory" so short
paths render as clean polylines in Elastic. Field2d requires poses, so these
helpers create display-only rotations from the polyline direction when
drawing.
-
Method Details
-
drawPath
Draws a path's planned polyline using a stable, generated object name.The generated name is unique per
Field2dandPathinstance, and repeated calls with the same field and path reuse the same object name.- Parameters:
field- The field widget to draw onpath- The path to draw- Returns:
- The final
Field2dobject name used
-
drawPath
public static String drawPath(edu.wpi.first.wpilibj.smartdashboard.Field2d field, String objectName, Path path) Draws a path's planned polyline using the given object name.The object name is trimmed, and
"Trajectory"is appended if the name does not already end with that suffix case-insensitively. Reusing the same explicit name updates the same display slot by design.- Parameters:
field- The field widget to draw onobjectName- TheField2dobject name or base name to publish underpath- The path to draw- Returns:
- The final
Field2dobject name used
-