Package frc.lib5k.spatial
Class LocalizationEngine
- java.lang.Object
-
- frc.lib5k.spatial.LocalizationEngine
-
public class LocalizationEngine extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
calculate(double leftMeters, double rightMeters, double heading)
Calculates the current robot location given some sensor readings.static LocalizationEngine
getInstance()
Get the currentLocalizationEngine
instanceFieldPosition
getLocationObject()
Get a reference to the currentFieldPosition
object.FieldPosition
getRobotPosition()
Get the robot's current field-relative positionError2D
getRotatedError(FieldPosition goalPosition)
Get the rotated 2D error from the robot's current location to a goal positionvoid
setRobotPosition(FieldPosition position)
Force-set the robot location
-
-
-
Method Detail
-
getInstance
public static LocalizationEngine getInstance()
Get the currentLocalizationEngine
instance- Returns:
-
calculate
public void calculate(double leftMeters, double rightMeters, double heading)
Calculates the current robot location given some sensor readings. This should be called at least once every 20ms- Parameters:
leftMeters
- Total distance in meters traveled by the left side of the robotrightMeters
- Total distance in meters traveled by the right side of the robotheading
- The robot's current heading/angle
-
getRotatedError
public Error2D getRotatedError(FieldPosition goalPosition)
Get the rotated 2D error from the robot's current location to a goal position- Parameters:
goalPosition
- Goal position (where the robot wants to be)- Returns:
- Error from current position to goal
-
setRobotPosition
public void setRobotPosition(FieldPosition position)
Force-set the robot location- Parameters:
position
- Robot position
-
getRobotPosition
public FieldPosition getRobotPosition()
Get the robot's current field-relative position- Returns:
- A COPY of the current position object
-
getLocationObject
public FieldPosition getLocationObject()
Get a reference to the currentFieldPosition
object. This should only be used if you know what you are doing.- Returns:
- Local object reference
-
-