Class TrcPose2D

java.lang.Object
trclib.pathdrive.TrcPose2D

public class TrcPose2D extends Object
This class implements a 2D pose object that represents the positional state of an object.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    double
     
    double
     
    double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor: Create an instance of the object.
    TrcPose2D(double[] data)
    Constructor: Create an instance of the object.
    TrcPose2D(double x, double y)
    Constructor: Create an instance of the object.
    TrcPose2D(double x, double y, double angle)
    Constructor: Create an instance of the object.
  • Method Summary

    Modifier and Type
    Method
    Description
    addRelativePose(TrcPose2D relativePose)
    This method adds a relative pose to this pose and return the resulting pose.
    This method creates and returns a copy of this pose.
    double
    This method returns the distance of the specified pose to this pose.
    boolean
    This method compares this pose with the specified pose for equality.
    int
    This method returns the hash code of the values in this pose.
    static TrcPose2D[]
    loadPosesFromCsv(String path, boolean loadFromResources)
    This method loads pose data from a CSV file either on the external file system or attached resources.
    This method returns a transformed pose relative to the given pose.
    relativeTo(TrcPose2D pose, boolean transformAngle)
    This method returns a transformed pose relative to the given pose.
    rotatePose(double angle)
    This method rotates this pose with the specified angle.
    void
    This method sets this pose to be the same as the given pose.
    This method subtracts a relative pose from this pose and return the resulting pose.
    org.apache.commons.math3.linear.RealVector
    This method returns the vector form of this pose.
    This method returns the string representation of the pose.
    translatePose(double xOffset, double yOffset)
    This method translates this pose with the x and y offset in reference to the angle of the pose.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • x

      public double x
    • y

      public double y
    • angle

      public double angle
  • Constructor Details

    • TrcPose2D

      public TrcPose2D(double x, double y, double angle)
      Constructor: Create an instance of the object.
      Parameters:
      x - specifies the x component of the position.
      y - specifies the y component of the position.
      angle - specifies the angle.
    • TrcPose2D

      public TrcPose2D(double[] data)
      Constructor: Create an instance of the object.
      Parameters:
      data - specifies an array with 3 elements: x, y and angle.
      Throws:
      ArrayIndexOutOfBoundsException - if array size is less than 3.
    • TrcPose2D

      public TrcPose2D(double x, double y)
      Constructor: Create an instance of the object.
      Parameters:
      x - specifies the x coordinate of the position.
      y - specifies the y coordinate of the position.
    • TrcPose2D

      public TrcPose2D()
      Constructor: Create an instance of the object.
  • Method Details

    • toString

      public String toString()
      This method returns the string representation of the pose.
      Overrides:
      toString in class Object
      Returns:
      string representation of the pose.
    • loadPosesFromCsv

      public static TrcPose2D[] loadPosesFromCsv(String path, boolean loadFromResources)
      This method loads pose data from a CSV file either on the external file system or attached resources.
      Parameters:
      path - specifies the file system path or resource name.
      loadFromResources - specifies true if the data is from attached resources, false if from file system.
      Returns:
      an array of poses.
    • equals

      public boolean equals(Object o)
      This method compares this pose with the specified pose for equality.
      Overrides:
      equals in class Object
      Returns:
      true if equal, false otherwise.
    • hashCode

      public int hashCode()
      This method returns the hash code of the values in this pose.
      Overrides:
      hashCode in class Object
      Returns:
      pose hash code.
    • clone

      public TrcPose2D clone()
      This method creates and returns a copy of this pose.
      Overrides:
      clone in class Object
      Returns:
      a copy of this pose.
    • toPosVector

      public org.apache.commons.math3.linear.RealVector toPosVector()
      This method returns the vector form of this pose.
      Returns:
      vector form of this pose.
    • distanceTo

      public double distanceTo(TrcPose2D pose)
      This method returns the distance of the specified pose to this pose.
      Parameters:
      pose - specifies the pose to calculate the distance to.
      Returns:
      distance to specified pose.
    • setAs

      public void setAs(TrcPose2D pose)
      This method sets this pose to be the same as the given pose.
      Parameters:
      pose - specifies the pose to make this pose equal to.
    • relativeTo

      public TrcPose2D relativeTo(TrcPose2D pose, boolean transformAngle)
      This method returns a transformed pose relative to the given pose.
      Parameters:
      pose - specifies the reference pose.
      transformAngle - specifies true to also transform angle, false to leave it alone.
      Returns:
      pose relative to the given pose.
    • relativeTo

      public TrcPose2D relativeTo(TrcPose2D pose)
      This method returns a transformed pose relative to the given pose.
      Parameters:
      pose - specifies the reference pose.
      Returns:
      pose relative to the given pose.
    • translatePose

      public TrcPose2D translatePose(double xOffset, double yOffset)
      This method translates this pose with the x and y offset in reference to the angle of the pose.
      Parameters:
      xOffset - specifies the x offset in reference to the angle of the pose.
      yOffset - specifies the y offset in reference to the angle of the pose.
      Returns:
      translated pose.
    • rotatePose

      public TrcPose2D rotatePose(double angle)
      This method rotates this pose with the specified angle.
      Parameters:
      angle - specifies the angle to rotate the pose.
      Returns:
      rotated pose.
    • addRelativePose

      public TrcPose2D addRelativePose(TrcPose2D relativePose)
      This method adds a relative pose to this pose and return the resulting pose. The relative pose has a relative vector and relative angle from this pose.
      Parameters:
      relativePose - specifies the pose relative to the previous pose.
      Returns:
      resulting pose.
    • subtractRelativePose

      public TrcPose2D subtractRelativePose(TrcPose2D relativePose)
      This method subtracts a relative pose from this pose and return the resulting pose. The relative pose has a relative vector and relative angle from the resulting pose to this pose. In other words, adding the relative pose to the resulting pose would yield this pose.
      Parameters:
      relativePose - specifies the relative pose from the resulting pose.
      Returns:
      resulting pose.