/// <summary> /// Creates a new arm which is driven by an encoder /// </summary> /// <param name="input">The motor driving the system</param> /// <param name="output">The encoder giving feedback to the system</param> /// <param name="encoderCPR">The CPR of the encoder. If not a 1:1 ratio on the axle, scale this beforehand</param> /// <param name="model">The transmission model to use</param> /// <param name="startRotations">The location in rotations you want the system to start at.</param> /// <param name="invertInput">Inverts the motor input</param> public AngularEncoderMechanism(ISimSpeedController input, SimEncoder output, double encoderCPR, DCMotor model, double startRotations, bool invertInput) { m_input = input; //m_output = output; m_model = model; m_invert = invertInput; m_scaler = encoderCPR / (Math.PI * 2); CurrentRadians = 0; m_offset = startRotations * (Math.PI * 2); AdjustedRadians = m_offset; m_maxRadians = double.MaxValue; m_minRadians = double.MinValue; }
/// <summary> /// Initializes a new instance of the <see cref="LinearEncoderMechanism"/> class. /// </summary> /// <param name="input">The motor driving the system.</param> /// <param name="output">The encoder giving feedback to the system.</param> /// <param name="encoderCpr">The CPR of the encoder. If not a 1:1 ratio on the axle, scale this beforehand.</param> /// <param name="model">The transmission model to use.</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="startHeight">The start height of your elevator relative to the reset sensor in meters. If no reset sensor then use 0.</param> /// <param name="invertInput">if set to <c>true</c> [invert input].</param> public LinearEncoderMechanism(ISimSpeedController input, SimEncoder output, double encoderCpr, DCMotor model, double spoolRadius, double startHeight, bool invertInput) { m_input = input; m_output = output; m_model = model; m_invert = invertInput; RadiansPerMeter = 1 / spoolRadius; m_scaler = encoderCpr / (Math.PI * 2); m_offset = startHeight; CurrentMeters = m_offset; m_maxRadians = double.MaxValue; m_minRadians = double.MinValue; }