Class RTransform

java.lang.Object
me.wobblyyyy.pathfinder.kinematics.RTransform

public class RTransform
extends java.lang.Object
A representation of a robot's transformation. This representation doesn't include units or rates - rather, everything is measured as a generic unit that can be customized to your likings. As another note, this transformation doesn't include a rotation rate - rather, it includes a desired angle. The robot's movement direction is determined by the two points that represent the robot's transformation. The robot's angle is defined by whatever angle is inputted. The robot should attempt to turn to this angle whenever it can.
Since:
0.3.0
Author:
Colin Robertson
  • Field Summary

    Fields
    Modifier and Type Field Description
    static RTransform BACKWARDS
    Backwards transformation - (0, -1)
    static RTransform FORWARDS
    Forwards transformation - (0, 1)
    static RTransform LEFT
    Leftwards transformation - (0, -1)
    static RTransform RIGHT
    Rightwards transformation - (1, 0)
    private Point start
    The transformation's start point.
    private Point stop
    The transformation's stop point.
    private Angle turn
    The transformation's facing.
    private double x
    X distance between start and stop points.
    private double y
    Y distance between start and stop points.
    static RTransform ZERO
    Zero transformation - no movement whatsoever.
  • Constructor Summary

    Constructors
    Constructor Description
    RTransform​(double x, double y, Angle turn)
    Create a new robot transformation instance by using an X and a Y component translation rather than a pair of points.
    RTransform​(Point start, Point stop, Angle turn)
    Create a new robot transformation instance by using two points and an angle.
  • Method Summary

    Modifier and Type Method Description
    private static Angle fd​(double d)
    Internally-used method to get an angle from a degrees measurement.
    static RTransform fromGyro​(double vX, double vY, Angle turn, Angle gyro)
    Create a new robot transformation based on a given component X and Y translation as well as a gyroscope angle.
    static RTransform fromGyro​(Point start, Point stop, Angle turn, Angle gyro)
    Create a new robot transformation based on a given component X and Y translation as well as a gyroscope angle.
    Point getStart()
    Get the transformation's start point.
    Point getStop()
    Get the transformation's stop point.
    Angle getTurn()
    Get the robot's desired heading.
    double getX()
    Get the transformation's X value.
    double getY()
    Get the transformation's Y value.
    void invertX()
    Invert the transformation's X value.
    void invertY()
    Invert the transformation's Y value.
    java.lang.String toString()
    Convert the transformation to a string.
    private void updateTransformDistances()
    Internal method to update the transformation's distance values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ZERO

      public static RTransform ZERO
      Zero transformation - no movement whatsoever.
    • FORWARDS

      public static RTransform FORWARDS
      Forwards transformation - (0, 1)
    • BACKWARDS

      public static RTransform BACKWARDS
      Backwards transformation - (0, -1)
    • LEFT

      public static RTransform LEFT
      Leftwards transformation - (0, -1)
    • start

      private final Point start
      The transformation's start point.
    • stop

      private Point stop
      The transformation's stop point.
    • turn

      private final Angle turn
      The transformation's facing. This facing should represent the angle that the robot as a whole should be facing.
    • x

      private double x
      X distance between start and stop points.
    • y

      private double y
      Y distance between start and stop points.
  • Constructor Details

    • RTransform

      public RTransform​(Point start, Point stop, Angle turn)
      Create a new robot transformation instance by using two points and an angle. This angle represents the angle that the chassis should be facing. It DOES NOT represent the rate at which the robot should turn.
      Parameters:
      start - the transformation's start point.
      stop - the transformation's stop point.
      turn - the angle that the robot should be facing.
    • RTransform

      public RTransform​(double x, double y, Angle turn)
      Create a new robot transformation instance by using an X and a Y component translation rather than a pair of points. The angle required by this constructor should represent the angle that the robot is facing, not the angle that the robot should be moving in.
      Parameters:
      x - the translation's X component.
      y - the translation's Y component.
      turn - the translation's angle.
  • Method Details

    • fd

      private static Angle fd​(double d)
      Internally-used method to get an angle from a degrees measurement.
      Parameters:
      d - degrees of angle.
      Returns:
      angle from degrees.
    • fromGyro

      public static RTransform fromGyro​(Point start, Point stop, Angle turn, Angle gyro)
      Create a new robot transformation based on a given component X and Y translation as well as a gyroscope angle. This allows you to use field relative control instead of the default control system (which is relative to the robot, not the field).
      Parameters:
      start - the translation's start point.
      stop - the translation's stop point.
      turn - the angle the robot should be facing.
      gyro - the gyroscope's angle.
      Returns:
      a newly-created robot transformation that makes use of the gyro angle provided to transform the robot as specified.
    • fromGyro

      public static RTransform fromGyro​(double vX, double vY, Angle turn, Angle gyro)
      Create a new robot transformation based on a given component X and Y translation as well as a gyroscope angle. This allows you to use field relative control instead of the default control system (which is relative to the robot, not the field).
      Parameters:
      vX - the translation's component X value.
      vY - the translation's component Y value.
      turn - the angle the robot should be facing.
      gyro - the gyroscope's angle.
      Returns:
      a newly-created robot transformation that makes use of the gyro angle provided to transform the robot as specified.
    • getStart

      public Point getStart()
      Get the transformation's start point.
      Returns:
      the transformation's start point.
    • getStop

      public Point getStop()
      Get the transformation's stop point.
      Returns:
      the transformation's stop point.
    • getTurn

      public Angle getTurn()
      Get the robot's desired heading. This is not a measurement of desired rotation, this is a measurement of desired facing.
      Returns:
      the robot's desired heading turn value.
    • getX

      public double getX()
      Get the transformation's X value.
      Returns:
      the transformation's X value.
    • getY

      public double getY()
      Get the transformation's Y value.
      Returns:
      the transformation's Y value.
    • updateTransformDistances

      private void updateTransformDistances()
      Internal method to update the transformation's distance values.
    • invertX

      public void invertX()
      Invert the transformation's X value.

      This change is reflected in both the X distance and the stop point. The stop point has its X value literally flipped over the start point's X value, thus giving you an inverted value.

    • invertY

      public void invertY()
      Invert the transformation's Y value.

      This change is reflected in both the Y distance and the stop point. The stop point has its Y value literally flipped over the start point's Y value, thus giving you an inverted value.

    • toString

      public java.lang.String toString()
      Convert the transformation to a string.
      Overrides:
      toString in class java.lang.Object
      Returns:
      a String representation of the transformation.