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 RTransformBACKWARDSBackwards transformation - (0, -1)static RTransformFORWARDSForwards transformation - (0, 1)static RTransformLEFTLeftwards transformation - (0, -1)static RTransformRIGHTRightwards transformation - (1, 0)private PointstartThe transformation's start point.private PointstopThe transformation's stop point.private AngleturnThe transformation's facing.private doublexX distance between start and stop points.private doubleyY distance between start and stop points.static RTransformZEROZero 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 Anglefd(double d)Internally-used method to get an angle from a degrees measurement.static RTransformfromGyro(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 RTransformfromGyro(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.PointgetStart()Get the transformation's start point.PointgetStop()Get the transformation's stop point.AnglegetTurn()Get the robot's desired heading.doublegetX()Get the transformation's X value.doublegetY()Get the transformation's Y value.voidinvertX()Invert the transformation's X value.voidinvertY()Invert the transformation's Y value.java.lang.StringtoString()Convert the transformation to a string.private voidupdateTransformDistances()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
Zero transformation - no movement whatsoever. -
FORWARDS
Forwards transformation - (0, 1) -
RIGHT
Rightwards transformation - (1, 0) -
BACKWARDS
Backwards transformation - (0, -1) -
LEFT
Leftwards transformation - (0, -1) -
start
The transformation's start point. -
stop
The transformation's stop point. -
turn
The transformation's facing. This facing should represent the angle that the robot as a whole should be facing. -
x
private double xX distance between start and stop points. -
y
private double yY distance between start and stop points.
-
-
Constructor Details
-
RTransform
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
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
Internally-used method to get an angle from a degrees measurement.- Parameters:
d- degrees of angle.- Returns:
- angle from degrees.
-
fromGyro
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
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
Get the transformation's start point.- Returns:
- the transformation's start point.
-
getStop
Get the transformation's stop point.- Returns:
- the transformation's stop point.
-
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:
toStringin classjava.lang.Object- Returns:
- a String representation of the transformation.
-