Class LoggedMechanismObject2d

java.lang.Object
org.littletonrobotics.junction.mechanism.LoggedMechanismObject2d
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
LoggedMechanismLigament2d

public abstract class LoggedMechanismObject2d extends Object implements AutoCloseable
Common base class for all Mechanism2d node types.

To append another node, call append(LoggedMechanismObject2d). Objects that aren't appended to a published Mechanism2d container are nonfunctional.

See Also:
  • Constructor Details

    • LoggedMechanismObject2d

      protected LoggedMechanismObject2d(String name)
      Create a new Mechanism node object.
      Parameters:
      name - the node's name, must be unique.
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • append

      public final <T extends LoggedMechanismObject2d> T append(T object)
      Append a Mechanism object that is based on this one.
      Type Parameters:
      T - The object type.
      Parameters:
      object - the object to add.
      Returns:
      the object given as a parameter, useful for variable assignments and call chaining.
      Throws:
      UnsupportedOperationException - if the object's name is already used - object names must be unique.
    • updateEntries

      protected abstract void updateEntries(NetworkTable table)
      Update all entries with new ones from a new table.
      Parameters:
      table - the new table.
    • getName

      public final String getName()
      Get the name of the object.
      Returns:
      The name of the object.
    • generate3dMechanism

      public ArrayList<Pose3d> generate3dMechanism(Pose3d seed)
      Propogates the mechanism2d down the tree structure.
      Parameters:
      seed - position to start the calculations at
      Returns:
      array list of all poses generated from this point in a depth-first pattern
    • getObject2dRange

      public abstract double getObject2dRange()
      Abstract helper function. A proxy for getLength() with Ligament2d, but would be something else like getRadius() for circular parts if they were to be implemented.
      Returns:
      distance in meters
    • getAngle

      public abstract double getAngle()
      Abstract helper function. Should be common to all 2d parts, and assumes a normal xy or xz positive direction of left or up, respectively.
      Returns:
      angle in degrees