-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
digital and analog inputs work but can't be configured
show joint name in CAN config panel update robot code to use all the sim things
- Loading branch information
1 parent
9f9948d
commit 88c551b
Showing
9 changed files
with
212 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/io/AnalogInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.autodesk.synthesis.io; | ||
|
||
import edu.wpi.first.hal.SimBoolean; | ||
import edu.wpi.first.hal.SimDevice; | ||
import edu.wpi.first.hal.SimDouble; | ||
import edu.wpi.first.hal.SimInt; | ||
import edu.wpi.first.hal.SimDevice.Direction; | ||
|
||
public class AnalogInput extends edu.wpi.first.wpilibj.AnalogInput { | ||
private SimDevice m_device; | ||
|
||
private SimBoolean m_init; | ||
private SimInt m_avgBits; | ||
private SimInt m_oversampleBits; | ||
private SimDouble m_voltage; | ||
private SimBoolean m_accumInit; | ||
private SimInt m_accumValue; | ||
private SimInt m_accumCount; | ||
private SimInt m_accumCenter; | ||
private SimInt m_accumDeadband; | ||
|
||
public AnalogInput(int channel) { | ||
super(channel); | ||
|
||
m_device = SimDevice.create("AI:SYN AI", channel); | ||
|
||
m_init = m_device.createBoolean("init", Direction.kOutput, true); | ||
m_avgBits = m_device.createInt("avg_bits", Direction.kOutput, 0); | ||
m_oversampleBits = m_device.createInt("oversample_bits", Direction.kOutput, 0); | ||
m_voltage = m_device.createDouble("voltage", Direction.kInput, 0.0); | ||
m_accumInit = m_device.createBoolean("accum_init", Direction.kOutput, false); | ||
m_accumValue = m_device.createInt("accum_value", Direction.kInput, 0); | ||
m_accumCount = m_device.createInt("accum_count", Direction.kInput, 0); | ||
m_accumCenter = m_device.createInt("accum_center", Direction.kOutput, 0); | ||
m_accumDeadband = m_device.createInt("accum_deadband", Direction.kOutput, 0); | ||
|
||
this.setSimDevice(m_device); | ||
} | ||
|
||
@Override | ||
public double getVoltage() { | ||
return m_voltage.get(); | ||
} | ||
|
||
@Override | ||
public int getAverageBits() { | ||
return m_avgBits.get(); | ||
} | ||
|
||
@Override | ||
public void setAverageBits(int bits) { | ||
m_avgBits.set(bits); | ||
} | ||
|
||
@Override | ||
public int getOversampleBits() { | ||
return m_oversampleBits.get(); | ||
} | ||
|
||
@Override | ||
public void setOversampleBits(int bits) { | ||
m_oversampleBits.set(bits); | ||
} | ||
|
||
@Override | ||
public void initAccumulator() { | ||
super.initAccumulator(); | ||
m_accumInit.set(true); | ||
} | ||
|
||
@Override | ||
public long getAccumulatorValue() { | ||
return m_accumValue.get(); | ||
} | ||
|
||
@Override | ||
public long getAccumulatorCount() { | ||
return m_accumCount.get(); | ||
} | ||
|
||
@Override | ||
public void setAccumulatorCenter(int center) { | ||
m_accumCenter.set(center); | ||
} | ||
|
||
@Override | ||
public void setAccumulatorDeadband(int deadband) { | ||
m_accumDeadband.set(deadband); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/io/AnalogOutput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.autodesk.synthesis.io; | ||
|
||
import edu.wpi.first.hal.SimBoolean; | ||
import edu.wpi.first.hal.SimDevice; | ||
import edu.wpi.first.hal.SimDouble; | ||
import edu.wpi.first.hal.SimDevice.Direction; | ||
|
||
public class AnalogOutput extends edu.wpi.first.wpilibj.AnalogOutput { | ||
private SimDevice m_device; | ||
|
||
private SimBoolean m_init; | ||
private SimDouble m_voltage; | ||
|
||
public AnalogOutput(int channel) { | ||
super(channel); | ||
|
||
m_device = SimDevice.create("AI:SYN AO", channel); | ||
|
||
m_init = m_device.createBoolean("init", Direction.kOutput, true); | ||
m_voltage = m_device.createDouble("voltage", Direction.kOutput, 0.0); | ||
} | ||
|
||
@Override | ||
public void setVoltage(double voltage) { | ||
m_voltage.set(voltage); | ||
} | ||
|
||
@Override | ||
public double getVoltage() { | ||
return m_voltage.get(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/io/DigitalInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.autodesk.synthesis.io; | ||
|
||
import edu.wpi.first.hal.SimBoolean; | ||
import edu.wpi.first.hal.SimDevice; | ||
import edu.wpi.first.hal.SimDouble; | ||
import edu.wpi.first.hal.SimDevice.Direction; | ||
|
||
public class DigitalInput extends edu.wpi.first.wpilibj.DigitalInput { | ||
private SimDevice m_device; | ||
|
||
private SimBoolean m_init; | ||
private SimBoolean m_input; | ||
private SimBoolean m_value; | ||
private SimDouble m_pulseLength; // unused but in HALSim spec | ||
|
||
public DigitalInput(int channel) { | ||
super(channel); | ||
|
||
m_device = SimDevice.create("DIO:SYN DI", channel); | ||
|
||
m_init = m_device.createBoolean("init", Direction.kOutput, true); | ||
m_input = m_device.createBoolean("input", Direction.kOutput, true); | ||
m_value = m_device.createBoolean("value", Direction.kBidir, false); | ||
m_pulseLength = m_device.createDouble("pulse_length", Direction.kOutput, 0.0); | ||
|
||
this.setSimDevice(m_device); | ||
} | ||
|
||
@Override | ||
public boolean get() { | ||
return m_value.get(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
simulation/SyntheSimJava/src/main/java/com/autodesk/synthesis/io/DigitalOutput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.autodesk.synthesis.io; | ||
|
||
import edu.wpi.first.hal.SimBoolean; | ||
import edu.wpi.first.hal.SimDevice; | ||
import edu.wpi.first.hal.SimDouble; | ||
import edu.wpi.first.hal.SimDevice.Direction; | ||
|
||
public class DigitalOutput extends edu.wpi.first.wpilibj.DigitalOutput { | ||
private SimDevice m_device; | ||
|
||
private SimBoolean m_init; | ||
private SimBoolean m_input; | ||
private SimBoolean m_value; | ||
private SimDouble m_pulseLength; // unused but in HALSim spec | ||
|
||
public DigitalOutput(int channel) { | ||
super(channel); | ||
|
||
m_device = SimDevice.create("DIO:SYN DO", channel); | ||
|
||
m_init = m_device.createBoolean("init", Direction.kOutput, true); | ||
m_input = m_device.createBoolean("input", Direction.kOutput, true); | ||
m_value = m_device.createBoolean("value", Direction.kBidir, false); | ||
m_pulseLength = m_device.createDouble("pulse_length", Direction.kOutput, 0.0); | ||
|
||
this.setSimDevice(m_device); | ||
} | ||
|
||
@Override | ||
public boolean get() { | ||
return m_value.get(); | ||
} | ||
|
||
@Override | ||
public void set(boolean value) { | ||
m_value.set(value); | ||
} | ||
} |
Oops, something went wrong.