[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/vu/tools/java/isis/nest/localization/rips
ABCDMeasurement.java, 1.2, 1.3 LocalizationData.java, 1.3,
1.4 compilationInstructions.txt, 1.1,
1.2 footballFieldData.zip, 1.1, 1.2
Brano Kusy
kusyb at users.sourceforge.net
Thu Sep 14 12:58:48 PDT 2006
Update of /cvsroot/tinyos/tinyos-1.x/contrib/vu/tools/java/isis/nest/localization/rips
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv27458
Modified Files:
ABCDMeasurement.java LocalizationData.java
compilationInstructions.txt footballFieldData.zip
Log Message:
more data, related code updates
Index: ABCDMeasurement.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/vu/tools/java/isis/nest/localization/rips/ABCDMeasurement.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ABCDMeasurement.java 12 Sep 2006 05:20:39 -0000 1.2
--- ABCDMeasurement.java 14 Sep 2006 19:58:45 -0000 1.3
***************
*** 121,124 ****
--- 121,239 ----
}*/
+ public void computeDistFast( PrintStream log )
+ {
+ ArrayList valid_measurements = new ArrayList();
+ int good_freq = 0;
+
+ // the average q-range of the frogs
+ double sum = 0;
+
+ // ArrayList n = new ArrayList();
+ ArrayList<Double> xal = new ArrayList<Double>();
+ // ArrayList offset = new ArrayList();
+ // ArrayList k = new ArrayList();
+ ArrayList<Double> jal = new ArrayList<Double>();
+
+ // calculate initial frog positions and jump lengths
+ double accumulatedPhaseError = 0.0;
+ Iterator it = phaseOffsetMeasurments.iterator();
+ while( it.hasNext() )
+ {
+ PhaseOffset o = (PhaseOffset)it.next();
+
+ if (o == null || !o.valid)
+ continue;
+
+ // calculate the phase offset
+ double phase_offset = o.offset;
+ // store phase offset
+ // offset.add(new Double(phase_offset));
+ // calculate scaling constant
+ double k_ = o.k;
+ // store k
+ // k.add(new Double(k_));
+
+ // calculate n for the starting position of the frog of the channel
+ int n_ = (int) Math.round((k_ * -Constants.MAX_ABCD_RANGE - phase_offset)
+ / (2 * Math.PI));
+ // n.add(new Integer(n_));
+
+ // calculate position for the starting position of the frog of the
+ // channel
+ xal.add(new Double((phase_offset + n_ * 2 * Math.PI) / k_));
+
+ // calculate jump length for the frog of the channel
+ jal.add(new Double(2 * Math.PI / k_));
+
+ // increase average
+ sum += ((Double) xal.get(good_freq)).doubleValue();
+
+ // increase number of frog positions in average
+ good_freq++;
+ }
+
+ // convert xal to array of doubles
+ double[] x = new double[good_freq];
+ for (int i = 0; i < xal.size(); i++)
+ x[i] = ((Double) xal.get(i)).doubleValue();
+
+ // convert jal to array of doubles
+ double[] j = new double[good_freq];
+ for (int i = 0; i < jal.size(); i++)
+ j[i] = ((Double) jal.get(i)).doubleValue();
+
+ // precalculate weight of a frog in avg and var
+ double frogWeight = 1.0 / good_freq;
+
+ // calculate average of frog positions
+ double avg = sum * frogWeight;
+
+ // calculate variance of frog positions
+ double var = 0;
+ for (int i = 0; i < good_freq; ++i)
+ var += Math.pow(avg - x[i], 2);
+ var *= frogWeight;
+
+ double min_error = Double.MAX_VALUE;
+ double best_x = 0;
+
+ while (avg < Constants.MAX_ABCD_RANGE) {
+ double error = Math.sqrt(var);
+
+ // update best error and the corresponding distance
+ if (error < min_error) {
+ min_error = error;
+ best_x = avg;
+ }
+ if( log!=null )
+ {
+ log.println( avg + "\t" + error );
+ }
+
+ // find the last frog
+ int lastFrog = 0;
+ for (int i = 1; i < good_freq; ++i)
+ if (x[i] < x[lastFrog])
+ lastFrog = i;
+
+ // decrease average and variance with the position of last frog
+ var -= Math.pow(x[lastFrog] - avg, 2) * frogWeight;
+ avg -= x[lastFrog] * frogWeight;
+
+ // jump the last frog
+ x[lastFrog] += j[lastFrog];
+
+ // increase average and variance with the new position of last frog
+ avg += x[lastFrog] * frogWeight;
+ var += Math.pow(x[lastFrog] - avg, 2) * frogWeight;
+
+ }
+
+ calc_dist = best_x;
+ dist_dev = min_error;
+ valid = true;
+ }
+
+
public void computeDist( PrintStream log )
{
Index: LocalizationData.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/vu/tools/java/isis/nest/localization/rips/LocalizationData.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** LocalizationData.java 12 Sep 2006 05:20:39 -0000 1.3
--- LocalizationData.java 14 Sep 2006 19:58:45 -0000 1.4
***************
*** 167,180 ****
while (line != null)
{
! StringTokenizer t = new StringTokenizer(line);
! int id = Integer.parseInt(t.nextToken());
! sensors.put(new Integer(id),
! new Sensor(id,
! 0,
! Double.parseDouble(t.nextToken()),
! Double.parseDouble(t.nextToken()),
! Double.parseDouble(t.nextToken()),
! Integer.parseInt(t.nextToken()) == 1,
! false));
line = r.readLine();
}
--- 167,182 ----
while (line != null)
{
! if(line.length() > 0 && line.charAt(0) != '#'){
! StringTokenizer t = new StringTokenizer(line);
! int id = Integer.parseInt(t.nextToken());
! sensors.put(new Integer(id),
! new Sensor(id,
! 0,
! Double.parseDouble(t.nextToken()),
! Double.parseDouble(t.nextToken()),
! Double.parseDouble(t.nextToken()),
! Integer.parseInt(t.nextToken()) == 1,
! false));
! }
line = r.readLine();
}
***************
*** 754,758 ****
public void computeRange(ABCDMeasurement m){
m.real_dist = getABCDDist(m.sensor_A, m.sensor_B, m.sensor_C, m.sensor_D);
! m.computeDist(null);
m.error = Math.abs(m.real_dist - m.calc_dist);
}
--- 756,760 ----
public void computeRange(ABCDMeasurement m){
m.real_dist = getABCDDist(m.sensor_A, m.sensor_B, m.sensor_C, m.sensor_D);
! m.computeDistFast(null);
m.error = Math.abs(m.real_dist - m.calc_dist);
}
Index: compilationInstructions.txt
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/vu/tools/java/isis/nest/localization/rips/compilationInstructions.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** compilationInstructions.txt 12 Sep 2006 05:17:21 -0000 1.1
--- compilationInstructions.txt 14 Sep 2006 19:58:45 -0000 1.2
***************
*** 24,32 ****
scale experiment, which was described in our IPSN'06 paper:
1.) start RipsDisplay in the MessageCenter framework
2.) unpack contents of footballFieldData.zip to some directory
(we suggest c:\tmp\rips\data as this is the default load/save dir)
3.) click the Load button at the bottom of the RipsDisplay and navigate to
! the unpacked footballFieldData.ranges file
4.) after successful load, you should be able to see data in "Ranging" tab
5.) you can select/unselect the motes to be anchors in "Motes" tab
--- 24,34 ----
scale experiment, which was described in our IPSN'06 paper:
+ Localization - compute locations from the ranging data
+ ============ (FootballFieldData.ranges)
1.) start RipsDisplay in the MessageCenter framework
2.) unpack contents of footballFieldData.zip to some directory
(we suggest c:\tmp\rips\data as this is the default load/save dir)
3.) click the Load button at the bottom of the RipsDisplay and navigate to
! the unpacked "footballFieldData.ranges" file
4.) after successful load, you should be able to see data in "Ranging" tab
5.) you can select/unselect the motes to be anchors in "Motes" tab
***************
*** 38,44 ****
wait, the better results you get)
! the experiment covered 12000 m^2 area with 16 motes, i was able to get the maximum
! location error under 10cm, using 4 corner motes as anchors. if you have question or
! problems, send me email at kusy at isis.vanderbilt.edu
\ No newline at end of file
--- 40,67 ----
wait, the better results you get)
! the experiment covered 12000 m^2 area with 16 motes, i was able to get the maximum
! location error under 10cm, using 4 corner motes as anchors.
!
! Ranging - compute ranges from phase measurements at multiple radiochannels
! ======= (FootballFieldPhaseData.phase)
!
! 1.) start RipsDisplay in the MessageCenter framework
! 2.) unpack contents of footballFieldData.zip to some directory
! (we suggest c:\tmp\rips\data as this is the default load/save dir)
! 3.) click the Load button at the bottom of the RipsDisplay and navigate to
! the unpacked "footballFieldPhaseData.phase" file
! 4.) after successful load, you should be able to see data in "Rcvd data" tab
! 5.) go to "Ranging" tab and click "Recalculate"
! WARNING, this step will take a few minutes to complete. this is because
! 8526 ranges need to be computed.
! 6.) after the computation is ready (your CPU load drops), you'll be able to
! see computed ranges in the "Ranging" tab
! 7.) computed ranges can be used to localize the motes in the "Localization" tab,
! by clicking the "Start localization" button
! (to avoid the time consuming range computation, the computed ranges can be
! copy-and-pasted to a text file, which can be loaded back to our GUI; file
! extension must be ".ranges")
!
! if you have questions or problems, send me email at kusy at isis.vanderbilt.edu
\ No newline at end of file
Index: footballFieldData.zip
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/vu/tools/java/isis/nest/localization/rips/footballFieldData.zip,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
Binary files /tmp/cvsbavLvC and /tmp/cvsU3MMCU differ
More information about the Tinyos-contrib-commits
mailing list