git.haldean.org droidcopter / d0f66c0
updates postrun Benjamin Bardin 8 years ago
4 changed file(s) with 25 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
4545 /** The maximum change in motor speed permitted at one time if the chopper is stabilizing. Must be positive. */
4646 public static final double MAX_DSTABLE = .1;
4747
48 public static final double MAX_AUTO_MOTOR = .67;
49
4850 /** Tag for logging */
4951 public static final String TAG = new String("chopper.Guidance");
5052
428430 }
429431 double t = mControlVars[3];
430432
431 mMotorSpeed[0] = Math.sqrt(constrainValue(t - 2*y + z, 0, 1));
432 mMotorSpeed[1] = Math.sqrt(constrainValue(t + 2*y + z, 0, 1));
433 mMotorSpeed[2] = Math.sqrt(constrainValue(-t - 2*x + z, 0, 1));
434 mMotorSpeed[3] = Math.sqrt(constrainValue(-t + 2*x + z, 0, 1));
433 mMotorSpeed[0] = Math.sqrt(constrainValue(t - 2*y + z, 0, MAX_AUTO_MOTOR));
434 mMotorSpeed[1] = Math.sqrt(constrainValue(t + 2*y + z, 0, MAX_AUTO_MOTOR));
435 mMotorSpeed[2] = Math.sqrt(constrainValue(-t - 2*x + z, 0, MAX_AUTO_MOTOR));
436 mMotorSpeed[3] = Math.sqrt(constrainValue(-t + 2*x + z, 0, MAX_AUTO_MOTOR));
435437 logArray("motorSpeeds", mMotorSpeed);
436438 }
437439
103103 int truncateStart = fromPos;
104104 if (fromPos == 0) {
105105 // Cycle a bit longer, to compensate for the weird start.
106 if (truncateStart >= mErrors.size()) return -1;
106107 for (; mErrors.get(truncateStart) <= 0; truncateStart++) {
107108 // If value at index is nonpositive, continue until positive.
108 if (truncateStart == mErrors.size()) return -1;
109 if (truncateStart == mErrors.size() -1) return -1;
109110 }
110111 }
111112 int negativeIndex = truncateStart;
113 if (negativeIndex >= mErrors.size()) return -1;
112114 for (; mErrors.get(negativeIndex) >= 0; negativeIndex++) {
113115 // If value at index nonnegative, continue until negative.
114 if (negativeIndex == mErrors.size()) return -1;
116 if (negativeIndex == mErrors.size() - 1) return -1;
115117 }
116118 int cycleStart = negativeIndex;
119 if (cycleStart >= mErrors.size()) return -1;
117120 for (; mErrors.get(cycleStart) <= 0; cycleStart++) {
118121 // If value at index is nonpositive, continue until positive.
119 if (negativeIndex == mErrors.size()) return -1;
122 if (cycleStart == mErrors.size() - 1) return -1;
120123 }
121124 return cycleStart;
122125 }
2929 private static final int SELECT_NUM = 3;
3030 // Number of children to expand from each selected node.
3131 private static final int EXPAND_NUM = 3;
32 private static final int START_AFTER_N_CYCLES = 900;
33 private int currentCycle = 0;
3234
3335 private static SimpleDateFormat dateFormat =
3436 new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss");
9496 double d = rn.nextDouble() * initRange + initRangeStart;
9597 mFringe.add(new PidExperiment(p, i, d));
9698 }
99 System.out.println("setting pid to 0");
100 EnsignCrusher.tunePid(mAxis.ordinal(), 0, 0.0);
101 EnsignCrusher.tunePid(mAxis.ordinal(), 1, 0.0);
102 EnsignCrusher.tunePid(mAxis.ordinal(), 2, 0.0);
97103 }
98104
99105 public void update(String message) {
100106 if (!mEnabled) return;
101107 if (!message.startsWith("GUID:ERROR")) return;
108 currentCycle++;
109 if (currentCycle < START_AFTER_N_CYCLES) return;
102110 // retrieve error for my axis
103111 String parts[] = message.split(":");
104112 Double error = new Double(parts[2 + mAxis.ordinal()]);
118126 Debug.log("WARNING: PID TUNING LOGGING FAILED");
119127 e.printStackTrace();
120128 }
129 System.out.println("New experiment, cycle " + currentCycle);
121130 mFringeIndex++;
122131 // If index <= mFringe.size(), send new PID values, return;
123 if (mFringeIndex <= mFringe.size()) {
132 if (mFringeIndex < mFringe.size()) {
124133 PidExperiment newExp = mFringe.get(mFringeIndex);
125134 EnsignCrusher.tunePid(mAxis.ordinal(), 0, newExp.getP());
126135 EnsignCrusher.tunePid(mAxis.ordinal(), 1, newExp.getI());
3636 CMD="java -Djava.library.path=/lib/:jars/worldwind/:jars/ -Xmx512m
3737 -Dsun.java2d.noddraw=true $DOCK org.haldean.chopper.server.ServerCreator
3838 host=$HOST port=$PORT $DEBUG $HEARTLESS pidlog=pidlog.txt imgdir=video/
39 debuglog=debug.txt pidTuning=dx"
39 debuglog=debug.txt"
4040 echo $CMD
4141 exec $CMD
4242 }
9797 clean
9898
9999 if [ '' == "$1" ]; then
100 export HOST='droidcopter.cs.columbia.edu'
100 # export HOST='droidcopter.cs.columbia.edu'
101 export HOST='192.168.168.65'
101102 else
102103 export HOST=$1
103104 fi