Skip to content
Permalink
Browse files

Merge origin/master

Conflicts:
	src/ch/unizh/ini/jaer/projects/pencilbalancer/PencilBalancer.java
  • Loading branch information...
Tobi Delbruck Tobi Delbruck
Tobi Delbruck authored and Tobi Delbruck committed Jul 6, 2019
2 parents ad8ee58 + 6ac67b7 commit 2c0ff9d3fa5a3f9c706c570351e0b3df322a6d56
BIN +0 Bytes (100%) jAERViewer_win64.exe
Binary file not shown.
@@ -1,4 +1,4 @@
#Thu, 13 Jun 2019 12:14:01 +0200
#Sat, 06 Jul 2019 16:56:08 -0600
annotation.processing.enabled=false
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
@@ -353,7 +353,7 @@ public APSDVSFrame(int width, int height) {
private int getIndex(int channel, int x, int y) {
int idx = x * channel + y * (NUM_CHANNELS * getWidth()) + y;
if (idx < 0 || idx >= values.length) {
throw new java.lang.ArrayIndexOutOfBoundsException(String.format("index channel=%, x=%d, y=%d is out of bounds of frame which has channels=%d, width=%d, height=%d", channel, x, y, NUM_CHANNELS, getWidth(), getHeight()));
throw new java.lang.ArrayIndexOutOfBoundsException(String.format("index channel=%d, x=%d, y=%d is out of bounds of frame which has #channels=%d, width=%d, height=%d", channel, x, y, NUM_CHANNELS, getWidth(), getHeight()));
}
return idx;
}
@@ -617,7 +617,7 @@ public synchronized void propertyChange(PropertyChangeEvent evt) {
try { // TODO debug
updateApsDvsFrame(dvsFrame);
//output = apsDvsNet.processAPSDVSFrame(apsDvsFrame); // generates PropertyChange EVENT_MADE_DECISION
//apsDvsNet.processAPSDVSFrameArray(apsDvsFrame, resHeatMap);
apsDvsNet.processAPSDVSFrameArray(apsDvsFrame, resHeatMap);
} catch (Exception e) {
log.log(Level.SEVERE, e.toString(), e); // TODO debug
}
@@ -145,7 +145,7 @@ static Tensor executeGraphAndReturnTensorWithBoolean(Graph graph, Tensor<Float>

static void executeGraphAndReturnTensorWithBooleanArray(long[][][] array, Graph graph, Tensor<Float> image, String inputLayerName, Tensor<Boolean> inputBool, String inputBoolName, String outputLayerName) {
try (Session s = new Session(graph);
Tensor<Long> result = s.runner().feed(inputLayerName, image).feed(inputBoolName, inputBool).fetch(outputLayerName).run().get(0).expect(Long.class)) {
Tensor<Float> result = s.runner().feed(inputLayerName, image).feed(inputBoolName, inputBool).fetch(outputLayerName).run().get(0).expect(Float.class)) {
//result.copyTo(heatMap);
if (array != null) {
result.copyTo(array);
@@ -56,6 +56,7 @@
private float polyStddev = getFloat("polyStddev", 4.0f);
private boolean connectServoFlag = false;
private int comPortNumber = getInt("comPortNumber", 3);
private String comPortName = getString("comPortName", "ttyUSB0");
private boolean obtainTrueTablePosition = getBoolean("obtainTrueTablePosition", false);
private float gainAngle = getFloat("gainAngle", 280.0f);
private float gainBase = getFloat("gainBase", 1.34f);
@@ -87,7 +88,8 @@ public PencilBalancer(AEChip chip) {
setPropertyTooltip("polyStddev", "standard deviation in pixels around line of basin of attraction for new events; increase to follow faster motion but admit more noise");
setPropertyTooltip("connectServo", "enable to connect to servos");
setPropertyTooltip("comPortNumber", "sets the COM port number used on connectServo - check the Windows Device Manager for the actual port");
setPropertyTooltip("obtainTrueTablePosition", "enable to request true table position when sending new desired position");
setPropertyTooltip("comPortName", "sets the COM port name used on connectServo - check the /dev folder for the actual port");
setPropertyTooltip("obtainTrueTablePosition", "enable to request and use true table position from linear potentiometers when sending new desired position");
setPropertyTooltip("gainAngle", "controller gain for angle of pencil; increse to more more if angle higher");
setPropertyTooltip("gainBase", "controller gain for base of object; increase to more center pencil");
setPropertyTooltip("offsetAutomatic", "find best offset in X- and Y- direction based on past desired motion");
@@ -146,9 +148,9 @@ public PencilBalancer(AEChip chip) {
computeDesiredTablePosition();
sendDesiredTablePosition();

// if (obtainTrueTablePosition == true) {
// requestAndFetchCurrentTablePosition();
// }
if (obtainTrueTablePosition == true) {
requestAndFetchCurrentTablePosition();
}
}
}

@@ -451,18 +453,19 @@ private void sendDesiredTablePosition() {

String command = String.format("!T%d,%d", Math.round(10.0 * desiredTableX), Math.round(10.0 * desiredTableY));

// if (obtainTrueTablePosition == true) {
// fetchTrueTablePositionCounter--;
// if (fetchTrueTablePositionCounter == 0) {
// command = command + "\n?C";
// fetchTrueTablePositionCounter = 3;
// }
// }
if (obtainTrueTablePosition == true) {
fetchTrueTablePositionCounter--;
if (fetchTrueTablePositionCounter == 0) {
command = command + "\n?C";
fetchTrueTablePositionCounter = 3;
}
}
// log.info("Sending " + command);
sc.sendUpdate(command);
}

// private int fetchTrueTablePositionCounter = 1;
private int fetchTrueTablePositionCounter = 1;

private void requestAndFetchCurrentTablePosition() {

String r = sc.readLine();
@@ -616,7 +619,7 @@ synchronized public void setConnectServo(boolean connectServoFlag) {
if (sc != null) {
sc.terminate();
}
sc = new ServoConnection(getComPortNumber());
sc = new ServoConnection(getComPortNumber(), getComPortName());
} else {
sc.terminate();
sc = null;
@@ -693,4 +696,13 @@ public void setComPortNumber(int comPortNumber) {
this.comPortNumber = comPortNumber;
putInt("comPortNumber", comPortNumber);
}

public String getComPortName() {
return comPortName;
}

public void setComPortName(String comPortName) {
this.comPortName = comPortName;
putString("comPortName", comPortName);
}
}
@@ -19,19 +19,23 @@
static Logger log = Logger.getLogger("ServoConnection");
private HWP_RS232 rs232Port = null;
private boolean isRunning = true;

private int portNumber=3;
private String portName = "ttyUSB0";
private static String OS = System.getProperty("os.name").toLowerCase();

TobiLogger tobiLogger=null;
private boolean enableLogging = false;
ArrayBlockingQueue<String> queue=new ArrayBlockingQueue<String>(1);
/** Constructs a new ServoConnection to a specified COM port number
@param comPort e.g. 3 for COM3
@param comPort e.g. 3 for COM3, /dev/ttyUSB0
*/
public ServoConnection(int comPort) {
public ServoConnection(int comPort, String portName) {
setName("ServoConnection");
setPriority(MAX_PRIORITY);
setPortNumber(comPort);
setPortName(portName);
log.info("Starting consumer thread for connection to servo board");

this.start();
@@ -68,6 +72,7 @@ public void run() {

public void terminate() {
isRunning = false;
rs232Port.close();
}

private void connectServo() {
@@ -77,8 +82,10 @@ private void connectServo() {
HWPort.PortIdentifier thisPI = null;
HWPort.PortAttribute thisPA = null;

String serialPort = (OS.equals("linux")) ? " /dev/"+getPortName() : " COM"+getPortNumber();

for (HWPort.PortIdentifier pi : rs232Port.getPortIdentifierList()) {
if ((pi.display).equals(" COM"+portNumber)) {
if ((pi.display).equals(serialPort)) {
thisPI = pi;
}
}
@@ -113,7 +120,9 @@ public void sendUpdate(String command) {
}

public String readLine() {
String r = null; // readback currently not implemented!
//String r = null; // readback currently not implemented!
String r = rs232Port.readLine();

return (r);
}

@@ -149,4 +158,12 @@ public int getPortNumber() {
public void setPortNumber(int portNumber) {
this.portNumber = portNumber;
}

public String getPortName() {
return portName;
}

public void setPortName(String portName) {
this.portName = portName;
}
}

0 comments on commit 2c0ff9d

Please sign in to comment.
You can’t perform that action at this time.