From 134148201195adcb084cc4c526a66de8becd3490 Mon Sep 17 00:00:00 2001 From: "brad.zdanivsky" Date: Sun, 13 Nov 2011 20:01:34 +0000 Subject: [PATCH] Added, "aboutface" and "offcenter" to optional settings for calibrating turn times (ms to degrees). Only do 'find home' cal on a full battery. --- .../developer/terminal/AbstractTerminal.java | 16 +++--- .../src/developer/terminal/FindHome.java | 54 +++++++++++-------- .../src/developer/terminal/Terminal.java | 2 +- 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/oculus/WEB-INF/src/developer/terminal/AbstractTerminal.java b/oculus/WEB-INF/src/developer/terminal/AbstractTerminal.java index 887a852..1d2869b 100644 --- a/oculus/WEB-INF/src/developer/terminal/AbstractTerminal.java +++ b/oculus/WEB-INF/src/developer/terminal/AbstractTerminal.java @@ -81,18 +81,22 @@ public void run() { break; } } - try { + + //try { - in.close(); + /* in.close(); in = null; out.close(); out.close(); - socket.close(); + socket.close();*/ System.out.println(".. clean exit..."); - } catch (IOException e) { - e.printStackTrace(); - } + + shutdown(); + + //} catch (IOException e) { + // e.printStackTrace(); + //} } }).start(); } diff --git a/oculus/WEB-INF/src/developer/terminal/FindHome.java b/oculus/WEB-INF/src/developer/terminal/FindHome.java index f1f485b..b2d3d30 100644 --- a/oculus/WEB-INF/src/developer/terminal/FindHome.java +++ b/oculus/WEB-INF/src/developer/terminal/FindHome.java @@ -5,8 +5,6 @@ import developer.CommandServer; -//import oculus.State; -//import oculus.PlayerCommands; import oculus.OptionalSettings; import oculus.State; import oculus.Util; @@ -15,6 +13,7 @@ public class FindHome extends AbstractTerminal { long start = System.currentTimeMillis(); boolean looking = true; + int fullspin = 605; public FindHome(String ip, String port, final String user, final String pass) throws NumberFormatException, UnknownHostException, IOException { @@ -25,8 +24,9 @@ public FindHome(String ip, String port, final String user, final String pass) /** wait on the camera and battery, dock */ public void connect() { + out.println("settings"); out.println("state"); - Util.delay(500); + Util.delay(2000); while (true) { if (state.get(State.batterystatus) == null) { @@ -60,20 +60,22 @@ public void connect() { System.out.println(".. docked, so undocking."); out.println("undock"); - Util.delay(2500); + Util.delay(2300); out.println("move backward"); - Util.delay(1000); + Util.delay(700); out.println("stop"); - Util.delay(1000); + Util.delay(700); // turn round some int nudges = state.getInteger(OptionalSettings.offcenter.toString()); - if(nudges != State.ERROR) System.out.println("...found offest: " + nudges); + int aboutface = state.getInteger(OptionalSettings.aboutface.toString()); + System.out.println("...found offest: " + nudges + " aboutface: " + aboutface); + + if(fullspin<600) fullspin = 600; - // find perfect 360 time out.println("move left"); - Util.delay(6300); + Util.delay(fullspin); out.println("stop"); Util.delay(1000); } @@ -86,9 +88,9 @@ public void connect() { } - out.println("settings nudgedelay 250"); - out.println("settings stopdelay 300"); - out.println("settings volume 100"); + out.println("settings nudgedelay 290"); + out.println("settings stopdelay 100"); + out.println("settings volume 90"); out.println("state foo true"); } @@ -99,7 +101,7 @@ public void execute() { connect(); int nudges = spinFind(); - + System.out.println("spin time = " + (fullspin/2)); out.println("settings " + OptionalSettings.offcenter.toString() +" "+ nudges); // hand over control, wait for docking... @@ -115,12 +117,16 @@ public void execute() { System.out.println("[" + (System.currentTimeMillis() - start) + "] ms into autodocking."); if ((System.currentTimeMillis() - start) > State.TWO_MINUTES) { + System.out.println("FindHome, Aborting..."); + // nudges = spinFind(); + /* out.println("beep"); out.println("beep"); out.println("beep"); - shutdown(); + */ shutdown(); + } @@ -142,15 +148,15 @@ public void execute() { out.println("memory"); // save scan setting + out.println("settings " + OptionalSettings.aboutface.toString() + " " + ((double)fullspin/2)); - - + Util.delay(500); // out.println("restart") out.println("bye"); - - Util.delay(500); - System.out.println("find home closed its self??"); Util.delay(500); + + System.out.println("... find home closed its self??"); + Util.delay(5000); shutdown(); } @@ -191,19 +197,21 @@ public int spinFind(){ } if(out==null) { - System.out.println("errrorrrrr: socket closed, shutdown"); - shutdown(); + if(out.checkError()){ + System.out.println("errrorrrrr: socket closed, shutdown"); + shutdown(); + } } // call every so often - if ((i++ % 5) == 0) { + if ((i++ % 3) == 0) { System.out.println(i + " : publish again, look back one" ); out.println("nudge right"); out.println("publish camera"); out.println("memory"); Util.delay(4000); - state.dump(); + // state.dump(); } diff --git a/oculus/WEB-INF/src/developer/terminal/Terminal.java b/oculus/WEB-INF/src/developer/terminal/Terminal.java index c9dcdd5..016e5ed 100644 --- a/oculus/WEB-INF/src/developer/terminal/Terminal.java +++ b/oculus/WEB-INF/src/developer/terminal/Terminal.java @@ -4,7 +4,7 @@ import java.net.*; /** - * Bare bones terminal client for Oculus. Stdin and Stdout get mapped to socket of given parameters. + * Bare bones telnet terminal client for Oculus. Stdin and Stdout get mapped to socket of given parameters. */ public class Terminal {