Package trclib.pathdrive
Class TrcPose2D
java.lang.Object
trclib.pathdrive.TrcPose2D
This class implements a 2D pose object that represents the positional state of an object.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor: 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 TypeMethodDescriptionaddRelativePose
(TrcPose2D relativePose) This method adds a relative pose to this pose and return the resulting pose.clone()
This method creates and returns a copy of this pose.double
distanceTo
(TrcPose2D pose) 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
hashCode()
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.relativeTo
(TrcPose2D pose) 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.subtractRelativePose
(TrcPose2D relativePose) 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.toString()
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.
-
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
This method returns the string representation of the pose. -
loadPosesFromCsv
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
This method compares this pose with the specified pose for equality. -
hashCode
public int hashCode()This method returns the hash code of the values in this pose. -
clone
This method creates and 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
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
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
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
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
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
This method rotates this pose with the specified angle.- Parameters:
angle
- specifies the angle to rotate the pose.- Returns:
- rotated pose.
-
addRelativePose
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
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.
-