/// <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); }
/// <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; }
/// <summary> /// Initializes a new instance of the <see cref="DriveWheelMechanism"/> class. /// </summary> /// <param name="motor">The motor.</param> /// <param name="input">The input.</param> /// <param name="wheelbaseXM">The wheelbase xm.</param> /// <param name="wheelDiameterM">The wheel diameter m.</param> /// <param name="output">The output.</param> /// <param name="wheelStaticCoef">The wheel static coef.</param> /// <param name="wheelDynamicCoef">The wheel dynamic coef.</param> /// <param name="staticFriction">The static friction.</param> /// <param name="dynamicFriction">The dynamic friction.</param> public DriveWheelMechanism(DCMotor motor, ISimSpeedController input, double wheelbaseXM, double wheelDiameterM, IServoFeedback output, double wheelStaticCoef = 1.07, double wheelDynamicCoef = 0.1, double staticFriction = 0.1, double dynamicFriction = 0.01) : this(motor, input, wheelbaseXM, wheelDiameterM, wheelStaticCoef, wheelDynamicCoef, staticFriction, dynamicFriction) { m_output = output; }
/// <summary> /// Initializes a new instance of the <see cref="DriveWheelMechanism"/> class. /// </summary> /// <param name="motor">The motor.</param> /// <param name="input">The input.</param> /// <param name="wheelbaseXM">The wheelbase xm.</param> /// <param name="wheelDiameterM">The wheel diameter m.</param> /// <param name="wheelStaticCoef">The wheel static coef.</param> /// <param name="wheelDynamicCoef">The wheel dynamic coef.</param> /// <param name="staticFriction">The static friction.</param> /// <param name="dynamicFriction">The dynamic friction.</param> public DriveWheelMechanism(DCMotor motor, ISimSpeedController input, double wheelbaseXM, double wheelDiameterM, double wheelStaticCoef = 1.07, double wheelDynamicCoef = 0.1, double staticFriction = 0.1, double dynamicFriction = 0.01) { m_model = motor; m_output = null; m_input = input; XPosition = -wheelbaseXM; StaticCoef = wheelStaticCoef; DynamicCoef = wheelDynamicCoef; WheelDiameter = wheelDiameterM; StaticFriction = staticFriction; DynamicFriction = dynamicFriction; }
/// <summary> /// Initializes a new instance of the <see cref="ShooterWheelMechanism"/> class. /// </summary> /// <param name="input">The speed controller being used.</param> /// <param name="output">The feedback output.</param> /// <param name="model">The motor model.</param> /// <param name="invertInput">True if the input is inverted.</param> /// <param name="minimumVelocity">The minimum velocity in Rotations Per Minute</param> /// <param name="deaccelConstant">The deaccel constant in Rotations Per Minute</param> /// <param name="systemInertia">The system inertia in kg*m^2.</param> /// <param name="cpr">The counts per rotation of the sensor.</param> /// <exception cref="ArgumentOutOfRangeException">Shooter Wheels do not support analog inputs</exception> public ShooterWheelMechanism(ISimSpeedController input, IServoFeedback output, DCMotor model, bool invertInput, double minimumVelocity, double deaccelConstant, double systemInertia, double cpr) { if (output is SimAnalogInput) { throw new ArgumentOutOfRangeException(nameof(output), "Shooter Wheels do not support analog inputs"); } m_input = input; m_output = output; m_model = model; m_invert = invertInput; m_minimumVelocity = minimumVelocity.RpmsToRadiansPerSecond(); DeaccelerationConstant = deaccelConstant.RpmsToRadiansPerSecond(); SystemInertia = systemInertia; m_cpr = cpr; }