Class VelocityState

  • All Implemented Interfaces:
    NetworkTablePopulator

    public class VelocityState
    extends java.lang.Object
    implements NetworkTablePopulator
    Represents a desired state of motion, including the translational velocity.
    • Constructor Summary

      Constructors 
      Constructor Description
      VelocityState​(double translationDirection, double translationSpeed, double rotationVelocity, boolean isFieldCentric)
      Constructs this velocity state assuming a center of rotation of [0, 0].
      VelocityState​(double translationDirection, double translationSpeed, double rotationVelocity, double centerOfRotationX, double centerOfRotationY, boolean isFieldCentric)
      Constructs this velocity state with all possible parameters.
    • Constructor Detail

      • VelocityState

        public VelocityState​(double translationDirection,
                             double translationSpeed,
                             double rotationVelocity,
                             double centerOfRotationX,
                             double centerOfRotationY,
                             boolean isFieldCentric)
        Constructs this velocity state with all possible parameters.
        Parameters:
        translationDirection - The direction to translate, in degrees counting counterclockise from forwards.
        translationSpeed - The speed to translate, in feet per second.
        rotationVelocity - The angular velocity to rotate, in degrees per second.
        centerOfRotationX - The x component of the point to rotate about relative to the robot's origin, in feet. The positive x-axis points forwards on the robot.
        centerOfRotationY - The y component of the point to rotate about relative to the robot's origin, in feet. The positive y-axis points left on the robot.
        isFieldCentric - True if this state is field-centric, false if it is robot-centric.
      • VelocityState

        public VelocityState​(double translationDirection,
                             double translationSpeed,
                             double rotationVelocity,
                             boolean isFieldCentric)
        Constructs this velocity state assuming a center of rotation of [0, 0].
        Parameters:
        translationDirection - The direction to translate, in degrees counting counterclockise from forwards.
        translationSpeed - The speed to translate, in feet per second.
        rotationVelocity - The angular velocity to rotate, in degrees per second.
        isFieldCentric - True if this state is field-centric, false if it is robot-centric.
    • Method Detail

      • getTranslationDirection

        public double getTranslationDirection()
        Gets the direction of translation.
        Returns:
        The translation direction, in degrees counterclockwise from forwards.
      • getTranslationSpeed

        public double getTranslationSpeed()
        Gets the speed of translation.
        Returns:
        The translation speed, in feet per second.
      • getTranslationVector

        public Vector2D getTranslationVector()
        Gets a vector representing translation.
        Returns:
        The translation velocity vector, in feet per second.
      • getRotationVelocity

        public double getRotationVelocity()
        Gets the rotational velocity.
        Returns:
        The angular velocity, in degrees per second.
      • getCenterOfRotationX

        public double getCenterOfRotationX()
        Gets the x component of the center of rotation. The positive x-axis points forwards on the robot.
        Returns:
        The x component of the center of rotation, in feet.
      • getCenterOfRotationY

        public double getCenterOfRotationY()
        Gets the y component of the center of rotation. The positive y-axis points left on the robot.
        Returns:
        The y component of the center of rotation, in feet.
      • getCenterOfRotationVector

        public Vector2D getCenterOfRotationVector()
        Gets the center of rotation as a vector. The positive x-axis points forwards on the robot, while the positive y-axis points left.
        Returns:
        The center of rotation, in feet.
      • isFieldCentric

        public boolean isFieldCentric()
        Gets if this velocity state is field-centric.
        Returns:
        True if this velocity state is field-centric, false otherwise.
      • changeTranslationDirection

        public VelocityState changeTranslationDirection​(double direction)
        Creates a new velocity state that is the same as this one, except with the given translation direction.
        Parameters:
        direction - The translation direction, in degrees counterclockwise from forwards.
        Returns:
        The new velocity state.
      • changeTranslationSpeed

        public VelocityState changeTranslationSpeed​(double speed)
        Creates a new velocity state that is the same as this one, except with the given translation speed.
        Parameters:
        speed - The translation speed, in feet per second.
        Returns:
        The new velocity state.
      • changeRotationVelocity

        public VelocityState changeRotationVelocity​(double velocity)
        Creates a new velocity state that is the same as this one, except with the given rotation velocity.
        Parameters:
        velocity - The rotation velocity, in degrees per second.
        Returns:
        The new velocity state.
      • changeCenterOfRotation

        public VelocityState changeCenterOfRotation​(double x,
                                                    double y)
        Creates a new velocity state that is the same as this one, except with the given center of rotation.
        Parameters:
        x - The x component of the center of rotation, in feet. The positive x-axis points forwards on the robot.
        y - The y component of the center of rotation, in feet. The positive y-axis points left on the robot.
        Returns:
        The new velocity state.
      • changeIsFieldCentric

        public VelocityState changeIsFieldCentric​(boolean isFieldCentric)
        Creates a new velocity state that is the same as this one, except with the given field-centric setting.
        Parameters:
        isFieldCentric - True if the velocity state should be field-centric, false if it should be robot-centric.
        Returns:
        The new velocity state.
      • populateNetworkTable

        public void populateNetworkTable​(edu.wpi.first.networktables.NetworkTable table)
        Description copied from interface: NetworkTablePopulator
        Populates the given network table with data from this class. May also read in values.
        Specified by:
        populateNetworkTable in interface NetworkTablePopulator
        Parameters:
        table - The table to populate, and possibly read from.