public void TestPidGetRate() { using (AnalogGyro c = GetAnalogGyro(0)) { SimAnalogGyro gyro = new SimAnalogGyro(0); c.PIDSourceType = PIDSourceType.Rate; gyro.SetRate(1.025); Assert.That(c.PidGet(), Is.EqualTo(1.025).Within(0.001)); gyro.SetRate(-1.0835); Assert.That(c.PidGet(), Is.EqualTo(-1.0835).Within(0.001)); } }
public void TestAnalogGyroGetAngle([Range(0, NumAccumulatorChannels - 1)]int channel) { using (AnalogGyro input = GetAnalogGyro(channel)) { SimAnalogGyro gyro = new SimAnalogGyro(channel); gyro.SetPosition(1.025); Assert.AreEqual(1.025, input.GetAngle(), 0.0001); gyro.SetPosition(-1.0835); Assert.AreEqual(-1.0835, input.GetAngle(), 0.0001); } }
public void TestPidGetDisplacement() { using (AnalogGyro c = GetAnalogGyro(0)) { SimAnalogGyro gyro = new SimAnalogGyro(0); c.PIDSourceType = PIDSourceType.Displacement; gyro.SetPosition(1.025); Assert.That(c.PidGet(), Is.EqualTo(1.025).Within(0.001)); gyro.SetPosition(-1.0835); Assert.That(c.PidGet(), Is.EqualTo(-1.0835).Within(0.001)); } }
public void TestReset() { using (AnalogGyro input = GetAnalogGyro(0)) { SimAnalogGyro gyro = new SimAnalogGyro(0); gyro.SetRate(1.025); gyro.SetPosition(1.124); Assert.AreEqual(1.025, input.GetRate(), 0.0001); Assert.AreEqual(1.124, input.GetAngle(), 0.0001); Assert.That(GetGyroData(0).AccumulatorCount, Is.Not.EqualTo(0)); Assert.That(GetGyroData(0).AccumulatorValue, Is.Not.EqualTo(0)); input.Reset(); Assert.That(GetGyroData(0).AccumulatorCount, Is.EqualTo(0)); Assert.That(GetGyroData(0).AccumulatorValue, Is.EqualTo(0)); } }