Esempio n. 1
0
        /// <summary>
        /// Sets the motor's tilt angle.
        /// </summary>
        /// <param name="angle">
        /// Value between [-1.0, 1.0]
        /// </param>
        private void SetMotorTilt(double angle)
        {
            // Check if value is in valid ranges
            if (angle < -1.0 || angle > 1.0)
            {
                throw new ArgumentOutOfRangeException("Motor tilt has to be in the range [-1.0, 1.0]");
            }

            // Figure out raw angle between -31 and 31
            double rawAngle = Math.Round(angle * 31);

            // Call native func.
            int result = KinectNative.freenect_set_tilt_degs(this.parentDevice.devicePointer, rawAngle);

            if (result != 0)
            {
                throw new Exception("Coult not set raw motor tilt angle to " + angle + ". Error Code: " + result);
            }

            // Save commanded tilt
            this.commandedTilt = angle;
        }