mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Fixed FRCSim artf2609 - double ports handled wrong.
Change-Id: I2dc59c8d3113f3024d237763eb4e2f94bb85ff1a
This commit is contained in:
@@ -45,6 +45,7 @@ public class DoubleSolenoid implements LiveWindowSendable {
|
||||
private int m_forwardChannel; ///< The forward channel on the module to control.
|
||||
private int m_reverseChannel; ///< The reverse channel on the module to control.
|
||||
private int m_moduleNumber;
|
||||
private boolean m_reverseDirection;
|
||||
private SimSpeedController m_impl;
|
||||
private Value m_value;
|
||||
|
||||
@@ -61,6 +62,7 @@ public class DoubleSolenoid implements LiveWindowSendable {
|
||||
int channel = forwardChannel;
|
||||
forwardChannel = reverseChannel;
|
||||
reverseChannel = channel;
|
||||
m_reverseDirection = true;
|
||||
}
|
||||
m_impl = new SimSpeedController("simulator/pneumatic/"+moduleNumber+"/"+forwardChannel+"/"+moduleNumber+"/"+reverseChannel);
|
||||
}
|
||||
@@ -103,10 +105,10 @@ public class DoubleSolenoid implements LiveWindowSendable {
|
||||
m_impl.set(0);
|
||||
break;
|
||||
case Value.kForward_val:
|
||||
m_impl.set(1);
|
||||
m_impl.set(m_reverseDirection ? -1 : 1);
|
||||
break;
|
||||
case Value.kReverse_val:
|
||||
m_impl.set(-1);
|
||||
m_impl.set(m_reverseDirection ? 1 : -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource,
|
||||
private boolean m_allocatedA;
|
||||
private boolean m_allocatedB;
|
||||
private boolean m_allocatedI;
|
||||
private boolean m_reverseDirection;
|
||||
private PIDSourceParameter m_pidSource;
|
||||
private SimEncoder impl;
|
||||
|
||||
@@ -59,6 +60,9 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource,
|
||||
int channel = bChannel;
|
||||
bChannel = aChannel;
|
||||
aChannel = channel;
|
||||
m_reverseDirection = !reverseDirection;
|
||||
} else {
|
||||
m_reverseDirection = reverseDirection;
|
||||
}
|
||||
impl = new SimEncoder("simulator/dio/1/"+aChannel+"/1/"+bChannel);
|
||||
setDistancePerPulse(1);
|
||||
@@ -243,7 +247,11 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource,
|
||||
*/
|
||||
public void setDistancePerPulse(double distancePerPulse) {
|
||||
System.err.println("NOTE|WPILibJSim: Encoder.setDistancePerPulse() assumes 360 pulses per revolution in simulation.");
|
||||
m_distancePerPulse = distancePerPulse;
|
||||
if (m_reverseDirection) {
|
||||
m_distancePerPulse = -distancePerPulse;
|
||||
} else {
|
||||
m_distancePerPulse = distancePerPulse;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,7 +317,7 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource,
|
||||
if (m_table != null) {
|
||||
m_table.putNumber("Speed", getRate());
|
||||
m_table.putNumber("Distance", getDistance());
|
||||
m_table.putNumber("Distance per Tick", m_distancePerPulse);
|
||||
m_table.putNumber("Distance per Tick", m_reverseDirection ? -m_distancePerPulse : m_distancePerPulse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user