Example #1
0
 /// <summary>
 /// Provides arcade style driving for the robot.
 /// </summary>
 /// <remarks>Given a single joystick, the class assumes the Y axis for the move value and the X
 /// axis for the rotate value.</remarks>
 /// <param name="stick">The joystick to use for drving. Y-axis will be forward/backwards, and X-axis
 /// will be rotation.</param>
 /// <param name="squaredInputs">If this setting is true, it decreases the sensitvity at lower speeds.</param>
 public void ArcadeDrive(GenericHID stick, bool squaredInputs = true)
 {
     if (stick == null)
     {
         throw new ArgumentNullException(nameof(stick), "Joystick provided was null");
     }
     ArcadeDrive(stick.GetY(), stick.GetX(), squaredInputs);
 }
Example #2
0
 /// <summary>
 /// Provide tank style driving for the robot.
 /// </summary>
 /// <remarks>Drives the robot using the 2 joystick inputs. The Y-axis will be selected
 /// from each joystick object.</remarks>
 /// <param name="leftStick">The joystick to control the left side of the robot.</param>
 /// <param name="rightStick">The joystick to control the right side of the robot.</param>
 /// <param name="squaredInputs">If this setting is true, it decreases the sensitvity at lower speeds.</param>
 public void TankDrive(GenericHID leftStick, GenericHID rightStick, bool squaredInputs = true)
 {
     if (leftStick == null)
     {
         throw new ArgumentNullException(nameof(leftStick), "Joystick provided was null");
     }
     if (rightStick == null)
     {
         throw new ArgumentNullException(nameof(rightStick), "Joystick provided was null");
     }
     TankDrive(leftStick.GetY(), rightStick.GetY(), squaredInputs);
 }
Example #3
0
        /// <summary>
        /// Provides arcade style driving for the robot.
        /// </summary>
        /// <remarks>Given 2 joysticks and 2 axis numbers, computes the values to send to the drive.</remarks>
        /// <param name="moveStick">The Joystick object that represents the forward/backward direction</param>
        /// <param name="moveAxis">The axis on the moveStick to use.</param>
        /// <param name="rotateStick">The Joystick object that represents the rotation value</param>
        /// <param name="rotateAxis">The axis on the rotationStick to use.</param>
        /// <param name="squaredInputs">If this setting is true, it decreases the sensitvity at lower speeds.</param>
        public void ArcadeDrive(GenericHID moveStick, int moveAxis, GenericHID rotateStick, int rotateAxis,
                                bool squaredInputs = true)
        {
            if (moveStick == null)
            {
                throw new ArgumentNullException(nameof(moveStick), "Joystick provided was null");
            }
            if (rotateStick == null)
            {
                throw new ArgumentNullException(nameof(rotateStick), "Joystick provided was null");
            }

            double moveValue   = moveStick.GetRawAxis(moveAxis);
            double rotateValue = rotateStick.GetRawAxis(rotateAxis);

            ArcadeDrive(moveValue, rotateValue, squaredInputs);
        }
Example #4
0
        /// <summary>
        /// Provides arcade style driving for the robot.
        /// </summary>
        /// <remarks>Given 2 joysticks and 2 axis numbers, computes the values to send to the drive.</remarks>
        /// <param name="moveStick">The Joystick object that represents the forward/backward direction</param>
        /// <param name="moveAxis">The axis on the moveStick to use.</param>
        /// <param name="rotateStick">The Joystick object that represents the rotation value</param>
        /// <param name="rotateAxis">The axis on the rotationStick to use.</param>
        /// <param name="squaredInputs">If this setting is true, it decreases the sensitvity at lower speeds.</param>
        public void ArcadeDrive(GenericHID moveStick, int moveAxis, GenericHID rotateStick, int rotateAxis,
            bool squaredInputs = true)
        {
            if (moveStick == null)
                throw new ArgumentNullException(nameof(moveStick), "Joystick provided was null");
            if (rotateStick == null)
                throw new ArgumentNullException(nameof(rotateStick), "Joystick provided was null");

            double moveValue = moveStick.GetRawAxis(moveAxis);
            double rotateValue = rotateStick.GetRawAxis(rotateAxis);

            ArcadeDrive(moveValue, rotateValue, squaredInputs);
        }
Example #5
0
 /// <summary>
 /// Provides arcade style driving for the robot.
 /// </summary>
 /// <remarks>Given a single joystick, the class assumes the Y axis for the move value and the X
 /// axis for the rotate value.</remarks>
 /// <param name="stick">The joystick to use for drving. Y-axis will be forward/backwards, and X-axis
 /// will be rotation.</param>
 /// <param name="squaredInputs">If this setting is true, it decreases the sensitvity at lower speeds.</param>
 public void ArcadeDrive(GenericHID stick, bool squaredInputs = true)
 {
     if (stick == null)
         throw new ArgumentNullException(nameof(stick), "Joystick provided was null");
     ArcadeDrive(stick.GetY(), stick.GetX(), squaredInputs);
 }
Example #6
0
 /// <summary>
 /// Provide tank style driving for the robot.
 /// </summary>
 /// <remarks>This function lets you pick the axis to be used on each joystick object for
 /// each side of the robot.</remarks>
 /// <param name="leftStick">The joystick to use for the left side.</param>
 /// <param name="leftAxis">The axis to select on the left joystick.</param>
 /// <param name="rightStick">The joystick to use for the right side.</param>
 /// <param name="rightAxis">The axis to select on the right joystick</param>
 /// <param name="squaredInputs">If this setting is true, it decreases the sensitvity at lower speeds.</param>
 public void TankDrive(GenericHID leftStick, int leftAxis,
                   GenericHID rightStick, int rightAxis, bool squaredInputs = true)
 {
     if (leftStick == null)
         throw new ArgumentNullException(nameof(leftStick), "Joystick provided was null");
     if (rightStick == null)
         throw new ArgumentNullException(nameof(rightStick), "Joystick provided was null");
     TankDrive(leftStick.GetRawAxis(leftAxis), rightStick.GetRawAxis(rightAxis), squaredInputs);
 }