Пример #1
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);
 }
Пример #2
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);
        }
Пример #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);
        }
Пример #4
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);
 }