[sim] Fix ADXRS450_GyroSim and DutyCycleEncoderSim (#2963)

These were broken by #2952.

Also fix Java ADXRS450_Gyro angle/rate SimValue names.
This commit is contained in:
Peter Johnson
2020-12-24 12:23:38 -08:00
committed by GitHub
parent 240c629cda
commit a8bb2ef1c3
8 changed files with 23 additions and 14 deletions

View File

@@ -72,8 +72,8 @@ public class ADXRS450_Gyro extends GyroBase implements Gyro, PIDSource, Sendable
m_simDevice = SimDevice.create("Gyro:ADXRS450", port.value);
if (m_simDevice != null) {
m_simConnected = m_simDevice.createBoolean("connected", SimDevice.Direction.kInput, true);
m_simAngle = m_simDevice.createDouble("angle", SimDevice.Direction.kInput, 0.0);
m_simRate = m_simDevice.createDouble("rate", SimDevice.Direction.kInput, 0.0);
m_simAngle = m_simDevice.createDouble("angle_x", SimDevice.Direction.kInput, 0.0);
m_simRate = m_simDevice.createDouble("rate_x", SimDevice.Direction.kInput, 0.0);
}
m_spi.setClockRate(3000000);

View File

@@ -32,6 +32,7 @@ public class DutyCycleEncoder implements Sendable, AutoCloseable {
protected SimDevice m_simDevice;
protected SimDouble m_simPosition;
protected SimDouble m_simDistancePerRotation;
protected SimBoolean m_simIsConnected;
/**
@@ -72,6 +73,8 @@ public class DutyCycleEncoder implements Sendable, AutoCloseable {
if (m_simDevice != null) {
m_simPosition = m_simDevice.createDouble("position", SimDevice.Direction.kInput, 0.0);
m_simDistancePerRotation = m_simDevice.createDouble("distance_per_rot",
SimDevice.Direction.kOutput, 1.0);
m_simIsConnected = m_simDevice.createBoolean("connected", SimDevice.Direction.kInput, true);
} else {
m_counter = new Counter();

View File

@@ -24,9 +24,9 @@ public class ADXRS450_GyroSim {
* @param gyro ADXRS450_Gyro to simulate
*/
public ADXRS450_GyroSim(ADXRS450_Gyro gyro) {
SimDeviceSim wrappedSimDevice = new SimDeviceSim("ADXRS450_Gyro" + "[" + gyro.getPort() + "]");
m_simAngle = wrappedSimDevice.getDouble("Angle");
m_simRate = wrappedSimDevice.getDouble("Rate");
SimDeviceSim wrappedSimDevice = new SimDeviceSim("Gyro:ADXRS450" + "[" + gyro.getPort() + "]");
m_simAngle = wrappedSimDevice.getDouble("angle_x");
m_simRate = wrappedSimDevice.getDouble("rate_x");
}
/**

View File

@@ -23,9 +23,10 @@ public class DutyCycleEncoderSim {
* @param encoder DutyCycleEncoder to simulate
*/
public DutyCycleEncoderSim(DutyCycleEncoder encoder) {
SimDeviceSim wrappedSimDevice = new SimDeviceSim("DutyCycleEncoder" + "[" + encoder.getFPGAIndex() + "]");
m_simPosition = wrappedSimDevice.getDouble("Position");
m_simDistancePerRotation = wrappedSimDevice.getDouble("DistancePerRotation");
SimDeviceSim wrappedSimDevice = new SimDeviceSim("DutyCycle:DutyCycleEncoder" + "["
+ encoder.getSourceChannel() + "]");
m_simPosition = wrappedSimDevice.getDouble("position");
m_simDistancePerRotation = wrappedSimDevice.getDouble("distance_per_rot");
}
/**