Class LoggedMechanismRoot2d

java.lang.Object
org.littletonrobotics.junction.mechanism.LoggedMechanismRoot2d
All Implemented Interfaces:
AutoCloseable

public final class LoggedMechanismRoot2d extends Object implements AutoCloseable
Root Mechanism2d node.

A root is the anchor point of other nodes (such as ligaments).

Do not create objects of this class directly! Obtain instances from the Mechanism2d.getRoot(String, double, double) factory method.

Append other nodes by using append(LoggedMechanismObject2d).

  • Method Details

    • close

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

      public <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.
    • setPosition

      public void setPosition(double x, double y)
      Set the root's position.
      Parameters:
      x - new x coordinate
      y - new y coordinate
    • getName

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

      public ArrayList<Pose3d> generate3dMechanism()
      Converts the Mechanism2d into a series of Pose3d objects. Poses are generated with standard coordinate frame (+x forward, +y left, +z up) and each pivot point is assumed to be at the origin of the model.

      The order of the poses returned is based on the order of insertion. The first root inserted into the Mechanism2d goes first, and processed in a depth-first manner.

      Returns:
      list of poses for starting from the root point