Ejemplo n.º 1
0
        public static double MotorRawToValue(PWMData pwm)
        {
            if (pwm == null) return 0.0;

            ControllerType type = pwm.Type;
            double transVal = pwm.RawValue;
            //Make sure motor safety works
            if (transVal == 0) return 0.0;

            switch (type)
            {
                case ControllerType.None:
                    return 0.0;
                case ControllerType.Jaguar:
                    return ReverseJaguarPWM(transVal);
                case ControllerType.Talon:
                    return ReverseTalonPWM(transVal);
                case ControllerType.TalonSRX:
                    return ReverseTalonSRXPWM(transVal);
                case ControllerType.Victor:
                    return ReverseVictorPWM(transVal);
                case ControllerType.VictorSP:
                    return ReverseVictorSPPWM(transVal);
                case ControllerType.Spark:
                    return ReverseSparkPWM(transVal);
                case ControllerType.SD540:
                    return ReverseSD540PWM(transVal);
                case ControllerType.Servo:
                    return 0.0;
                default:
                    throw new InvalidOperationException($"The type {type} is not a usable motor controller type");
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new PWM Speed controller for the Sim to use.
 /// </summary>
 /// <param name="port">The PWM port the Speed controller is attached to.</param>
 public SimPWMController(int port)
 {
     PWMData = SimData.PWM[port];
 }