示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AngularPotentiometerMechanism"/> class.
 /// </summary>
 /// <param name="input">The motor driving the system</param>
 /// <param name="output">The Analog Input giving feedback to the system..</param>
 /// <param name="model">The motor model.</param>
 /// <param name="startPercentage">The starting percentage of the potentiometer from 0.</param>
 /// <param name="potentiometerRotations">The number of rotations the potentiometer has.</param>
 /// <param name="invertInput">if set to <c>true</c> [invert input].</param>
 public AngularPotentiometerMechanism(ISimSpeedController input, SimAnalogInput output, DCMotor model,
                                      double startPercentage, double potentiometerRotations, bool invertInput)
 {
     m_input        = input;
     m_output       = output;
     m_model        = model;
     m_maxRadians   = potentiometerRotations * (Math.PI * 2);
     m_minRadians   = 0;
     CurrentRadians = (m_maxRadians - m_minRadians) * startPercentage;
     m_invert       = invertInput;
     m_scaler       = 5 / (m_maxRadians - m_minRadians);
 }
        //String travel and Spool Radius in meters
        /// <summary>
        /// Initializes a new instance of the <see cref="LinearPotentiometerMechanism"/> class.
        /// </summary>
        /// <param name="input">The motor driving the system.</param>
        /// <param name="output">The potentiometer giving feedback to the system.</param>
        /// <param name="model">The motor model with transmission to use.</param>
        /// <param name="startPercentage">The starting percentages of the potentiometer from 0.</param>
        /// <param name="stringTravel">The potentiometer travel scaled to be linear (in meters).</param>
        /// <param name="spoolRadius">The radius of your spool in Meters. (Use the radius of the up spool if using a cascade elevator).</param>
        /// <param name="invertInput">if set to <c>true</c> [invert input].</param>
        public LinearPotentiometerMechanism(ISimSpeedController input, SimAnalogInput output, DCMotor model,
                                            double startPercentage, double stringTravel, double spoolRadius, bool invertInput)
        {
            m_input  = input;
            m_output = output;
            m_model  = model;

            double metersPerRotation = Math.PI * (spoolRadius * 2);
            double totalRotations    = stringTravel / metersPerRotation;
            double totalRadians      = totalRotations * Math.PI * 2;

            RadiansPerMeter = totalRadians / stringTravel;
            m_maxRadians    = totalRadians;
            m_minRadians    = 0;

            CurrentRadians = (m_maxRadians - m_minRadians) * startPercentage;
            CurrentMeters  = CurrentRadians / RadiansPerMeter;
            m_invert       = invertInput;
            m_scaler       = 5 / (m_maxRadians - m_minRadians);
        }