Class SimulatedRobot


  • public class SimulatedRobot
    extends java.lang.Object
    Keeps information about the robot's configuration. ALL PARAMETERS FOR ALL METHODS SHOULD BE IN SI UNITS.
    • Constructor Summary

      Constructors 
      Constructor Description
      SimulatedRobot​(SimulatedMotor motor, double wheelRadius, double wheelBaseWidth, double gearRatio, double robotWeight, Units.FORCE weightUnit)
      Creates a new SimulatedRobot.
      SimulatedRobot​(SimulatedMotor motor, int motorsPerSide, double wheelRadius, double wheelBaseWidth, double gearRatio, double robotWeight, Units.FORCE weightUnit, double motorUnitsPerUnit)
      Creates a new SimulatedRobot.
    • Constructor Detail

      • SimulatedRobot

        public SimulatedRobot​(SimulatedMotor motor,
                              double wheelRadius,
                              double wheelBaseWidth,
                              double gearRatio,
                              double robotWeight,
                              Units.FORCE weightUnit)
        Creates a new SimulatedRobot. Uses the default motors per side value of 2 and the default motor units per unit value of 0.472.
        Parameters:
        motor - The type of motor being used.
        wheelRadius - The radius of the drive wheels.
        wheelBaseWidth - The length between the two sets of wheels on the simulated robot
        gearRatio - The gear ratio of the gearbox (wheel RPM / motor RPM)
        robotWeight - The weight of the robot.
        weightUnit - The units used to specify the weight.
      • SimulatedRobot

        public SimulatedRobot​(SimulatedMotor motor,
                              int motorsPerSide,
                              double wheelRadius,
                              double wheelBaseWidth,
                              double gearRatio,
                              double robotWeight,
                              Units.FORCE weightUnit,
                              double motorUnitsPerUnit)
        Creates a new SimulatedRobot.
        Parameters:
        motor - The type of motor being used.
        motorsPerSide - The number of motors per side.
        wheelRadius - The radius of the drive wheels.
        wheelBaseWidth - The width between the sets of wheels of the robot.
        gearRatio - The gear ratio of the gearbox (wheel RPM / motorRPM);
        robotWeight - The weight of the robot.
        weightUnit - The units used to specify the weight.
        motorUnitsPerUnit - The number of motor units (RPM, ticks, etc) per length value (inches, meters, etc)
    • Method Detail

      • getGyro

        public TankGyro getGyro()
        Returns the simulated robot's gyro.
        Returns:
        The gyro.
      • getCurrentPositionAndHeading

        public Point2D getCurrentPositionAndHeading()
        Returns the current position of the simulated robot.
        Returns:
        Current position and heading of the robot.
      • setCurrentPositionAndHeading

        public void setCurrentPositionAndHeading​(Point2D positionAndHeading)
        Sets the position and heading of the simulated robot.
        Parameters:
        positionAndHeading - The new position and heading of the simulated robot.
      • zeroPositionAndHeading

        public void zeroPositionAndHeading()
        Zeros the position and heading of the robot. Because the robot is simulated, it may appear as though it teleports back to position (0, 0) when this method is called. This is expected.
      • getLeftVelocity

        public double getLeftVelocity()
        Returns the current left velocity of the robot.
        Returns:
        Linear velocity of robot's left wheels
      • getRightVelocity

        public double getRightVelocity()
        Returns the current right velocity of the robot.
        Returns:
        Linear velocity of robot's right wheels
      • update

        public Point2D update​(double leftPercentOutput,
                              double rightPercentOutput,
                              double timeInterval)
        Calculates the new position of the robot if it was driven for a certain time interval.
        Parameters:
        leftPercentOutput - The percent output of the left motors.
        rightPercentOutput - The percent output of the right motors.
        timeInterval - The time interval for which the robot drives.
        Returns:
        The position of the robot after it drives for the specified time interval