001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.wpilibj.simulation;
006
007import edu.wpi.first.hal.SimDouble;
008import edu.wpi.first.wpilibj.ADXRS450_Gyro;
009
010/** Class to control a simulated ADXRS450 gyroscope. */
011@SuppressWarnings("TypeName")
012public class ADXRS450_GyroSim {
013  private final SimDouble m_simAngle;
014  private final SimDouble m_simRate;
015
016  /**
017   * Constructs from an ADXRS450_Gyro object.
018   *
019   * @param gyro ADXRS450_Gyro to simulate
020   */
021  public ADXRS450_GyroSim(ADXRS450_Gyro gyro) {
022    SimDeviceSim wrappedSimDevice = new SimDeviceSim("Gyro:ADXRS450" + "[" + gyro.getPort() + "]");
023    m_simAngle = wrappedSimDevice.getDouble("angle_x");
024    m_simRate = wrappedSimDevice.getDouble("rate_x");
025  }
026
027  /**
028   * Sets the angle in degrees (clockwise positive).
029   *
030   * @param angleDegrees The angle.
031   */
032  public void setAngle(double angleDegrees) {
033    m_simAngle.set(angleDegrees);
034  }
035
036  /**
037   * Sets the angular rate in degrees per second (clockwise positive).
038   *
039   * @param rateDegreesPerSecond The angular rate.
040   */
041  public void setRate(double rateDegreesPerSecond) {
042    m_simRate.set(rateDegreesPerSecond);
043  }
044}