Commit df71e1d0 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Before removing hardwired conditionInitialDS

parent 33b2b603
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -1569,6 +1569,7 @@ public class EyesisCorrectionParameters {
    		// first - scan all file and set sourceDirectory, x3dDirectory, linkedModels,videoDirectory,resultsDirectory
    		HashMap<String,String> dir_map = new HashMap<String,String>();
            for (String line:lines){
                if (line.split("#").length > 0) {
                String[] tokens = line.split("#")[0].trim().split("[\\s,;=]+");
                if ((tokens.length > 2) && (tokens[0].toUpperCase().equals("SET"))) {
                	parse_set:
@@ -1582,6 +1583,7 @@ public class EyesisCorrectionParameters {
                	}
                }
                }
            }
            if (dir_map.containsKey("rootDirectory")) {
            	base_path=base_path.resolve(Paths.get(dir_map.get("rootDirectory")));
    			File base_dir = new File(base_path.toString());
@@ -1635,6 +1637,7 @@ public class EyesisCorrectionParameters {
			// process source sequence directories
    		ArrayList<PathFirstLast> path_list= new ArrayList<PathFirstLast>();
    		for (String line:lines){
    			if (line.split("#").length > 0) {
    				String[] tokens = line.split("#")[0].trim().split("[\\s,;=]+");
    				if ((tokens.length > 0) &&
    						(tokens[0].length() > 0) &&
@@ -1648,6 +1651,7 @@ public class EyesisCorrectionParameters {
    							((tokens.length > 3)? Integer.parseInt(tokens[3]):-1)));
    				}
    			}
    		}
            return path_list.toArray(new PathFirstLast[0]);
    	}

+19 −2
Original line number Diff line number Diff line
@@ -32,10 +32,27 @@ public class EventLogger {
			}
		}
		Arrays.sort(logger_files); // increasing start time stamps
		
		String out_did_gps_path = "/home/elphel/lwir16-proc/office_04/did_gps";
		int gps_mask = 7; // +1 - DID_GPS1_POS, +2 - DID_GPS2_POS, +4 - DID_GPS1_UBX_POS
		for (int nf = 0; nf < logger_files.length; nf++) {
			System.out.println("Printing all DID_INS_1 data in "+logger_files[nf].abs_path);
			try {
				logger_files[nf].listGPS(out_did_gps_path+"-"+String.format("%03d", nf)+".out", gps_mask, false);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		
		
		
		String out_did1_path = "/home/elphel/lwir16-proc/office_04/did_ins1";
		for (int nf = 0; nf < logger_files.length; nf++) {
			System.out.println("Printing all DID_INS_1 data in "+logger_files[nf].abs_path);
			try {
				logger_files[nf].listDid1(false);
				logger_files[nf].listDid1(out_did1_path+"-"+String.format("%03d", nf)+".out",false);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
+131 −12
Original line number Diff line number Diff line
package com.elphel.imagej.ims;

import java.awt.Point;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -381,12 +382,15 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
		}
	}
	
	public void listDid1( boolean keep) throws IOException {
	public void listDid1(String path, boolean keep) throws IOException {
		double max_offset = 1000; // m
		open();
		float [] start_ned = null;
		System.out.println (
		        "record "+
		FileWriter writer = null;
		if (path != null) {
			writer = new FileWriter (path);
		}
		String header = "record "+
		        "     master TS    "+
		        "     local TS     "+
		        "timeOfWeek " +
@@ -395,8 +399,12 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
		        "               theta               "+
		        "           uvw                "+
		        "                 lla                      "+
		        "              ned                "
		        );
		        "              ned                \n"; 
		if (writer != null) {
			writer.write(header);
		} else {
			System.out.print(header);
		}

		int type = (EventLoggerFileInfo.REC_TYPE_GPS << 4) | EventLoggerFileInfo.REC_SUBTYPE_IMX5; // 0x18 - first subpacket
		for (int nrec = 0; nrec < num_recs; nrec++) {
@@ -413,7 +421,7 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
				bb_payload.order(ByteOrder.LITTLE_ENDIAN);
				Did_ins_1 did_ins_1 = new Did_ins_1(bb_payload);
				if ((did_ins_1.uvw[0] == 0) && (did_ins_1.uvw[1] == 0) && (did_ins_1.uvw[2] == 0)) {
//					continue;
					continue;
				}
				if ((start_ned != null) &&
						(       (Math.abs(start_ned[0] - did_ins_1.ned[0]) > max_offset) ||
@@ -426,9 +434,9 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
					start_ned = did_ins_1.ned.clone();
				}
				start_ned = new float[] {0,0,0};
				System.out.println (String.format(
				String line =String.format(
						"%6d %17.6f %17.6f %10.3f %08x %08x [%8.4f, %8.4f, %8.4f] "+
				        "[%8.3f, %8.3f, %8.3f] [%12.7f, %12.7f, %12.7f] [%8.3f, %8.3f, %8.3f]",
				        "[%8.3f, %8.3f, %8.3f] [%12.7f, %12.7f, %12.7f] [%8.3f, %8.3f, %8.3f]\n",
						nrec,
						getMasterTS(nrec),
						getLocalTS(nrec),
@@ -439,18 +447,129 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
						did_ins_1.uvw[0], did_ins_1.uvw[1], did_ins_1.uvw[2],       // Velocity U, V, W in meters per second.  Convert to NED velocity using "vectorBodyToReference( uvw, theta, vel_ned )".
						did_ins_1.lla[0], did_ins_1.lla[1], did_ins_1.lla[2],       //  WGS84 latitude, longitude, height above ellipsoid (degrees,degrees,meters)
						did_ins_1.ned[0] - start_ned[0], did_ins_1.ned[1] - start_ned[1], did_ins_1.ned[2] - start_ned[2]        //  North, east and down (meters) offset from reference latitude, longitude, and altitude to current latitude, longitude, and altitude
						));
						);
				if (writer != null) {
					writer.write(line);
				} else {
					System.out.print(line);
				}
			}
		}
		if (writer != null) {
			writer.close();
		}
		if (!keep) {
			close();
		}
	}

	public void listGPS (String path, int gps_mask, boolean keep) throws IOException {
		// +1 - DID_GPS1_POS, +2 - DID_GPS2_POS, +4 - DID_GPS1_UBX_POS
//		double max_offset = 1000; // m
		open();
//		float [] start_ned = null;
		FileWriter writer = null;
		if (path != null) {
			writer = new FileWriter (path);
		}
		String header = "record "+
		        "     master TS    "+
		        "     local TS     "+
		        "timeOfWeek " +
		        "did "+
		        " status  "+
		        "                    ecef                     "+
		        "                    lla                     "+
		        "  hMSL  "+ // 7.2f
		        "  hAcc  "+ // 7.3f
		        "  vAcc  "+ // 7.3f
		        "  pDop  "+ // 7.3f
		        "cnoMean "+ // 7.3f
		        "  towOffset "+ // 11.4f
		        " lS  " + // 3d
		        "sat " + // 3d
		        "sgm " + // 3d
		        "rsv\n";// 3d 
		if (writer != null) {
			writer.write(header);
		} else {
			System.out.print(header);
		}

		int type = (EventLoggerFileInfo.REC_TYPE_GPS << 4) | EventLoggerFileInfo.REC_SUBTYPE_IMX5; // 0x18 - first subpacket
		for (int nrec = 0; nrec < num_recs; nrec++) {
			int [] full_type = getFullType(bb, nrec);
			if ((full_type != null) && (full_type[0] == type) &&
					(
					(((gps_mask & 1) != 0) && (full_type[1] == Imx5.DID_GPS1_POS)) ||
					(((gps_mask & 2) != 0) && (full_type[1] == Imx5.DID_GPS2_POS)) ||
					(((gps_mask & 4) != 0) && (full_type[1] == Imx5.DID_GPS1_UBX_POS))
					)
					) {
				byte [] payload = getDidPayload(
						null, // next_fileinfo, // may be null if payload does not extend beyond single record 
						nrec);
				if (payload == null) {
					System.out.println("EventLoggerFileInfo(): payload == null, nrec="+nrec);
					break;
				}
				ByteBuffer bb_payload = ByteBuffer.wrap(payload);
				bb_payload.order(ByteOrder.LITTLE_ENDIAN);
				
				Did_gps_pos did_gps_pos = new Did_gps_pos(bb_payload);
				if ((did_gps_pos.lla[0] == 0) && (did_gps_pos.lla[1] == 0) && (did_gps_pos.lla[2] == 0)) {
					continue;
				}
				
				// replace with GPS fix type?
				/*
				if ((did_ins_1.uvw[0] == 0) && (did_ins_1.uvw[1] == 0) && (did_ins_1.uvw[2] == 0)) {
					continue;
				}
				if ((start_ned != null) &&
						(       (Math.abs(start_ned[0] - did_ins_1.ned[0]) > max_offset) ||
								(Math.abs(start_ned[1] - did_ins_1.ned[1]) > max_offset) ||
								(Math.abs(start_ned[2] - did_ins_1.ned[2]) > max_offset)
								)){
					start_ned = null;
				}
				if (start_ned == null) {
					start_ned = did_ins_1.ned.clone();
				}
				start_ned = new float[] {0,0,0};
				*/
				String line =String.format(
						"%6d %17.6f %17.6f %10.3f %3d %08x [%13.4f, %13.4f, %13.4f] "+
				        "[%12.7f, %12.7f, %12.7f] %7.2f %7.3f %7.3f %7.3f %7.3f %11.4f "+
						"%3d %3d %3d %3d\n",
						nrec,
						getMasterTS(nrec),
						getLocalTS(nrec),
						0.001 * did_gps_pos.timeOfWeekMs,
						full_type[1], // DID
						did_gps_pos.status,
						did_gps_pos.ecef[0], did_gps_pos.ecef[1], did_gps_pos.ecef[2], // Position in ECEF {x,y,z} (m)
						did_gps_pos.lla[0], did_gps_pos.lla[1], did_gps_pos.lla[2],       //  WGS84 latitude, longitude, height above ellipsoid (degrees,degrees,meters)
						did_gps_pos.hMSL, did_gps_pos.hAcc, did_gps_pos.vAcc, did_gps_pos.pDop, did_gps_pos.cnoMean,
						did_gps_pos.towOffset,
						did_gps_pos.leapS, did_gps_pos.satsUsed, did_gps_pos.cnoMeanSigma, did_gps_pos.reserved
						);
				if (writer != null) {
					writer.write(line);
				} else {
					System.out.print(line);
				}
			}
		}
		if (writer != null) {
			writer.close();
		}
		if (!keep) {
			close();
		}
	}
	
	
	
	byte [] getDidPayload(
			EventLoggerFileInfo next_fileinfo, // may be null if payload does not extend beyond single record 
			int nrec) throws IOException {
Loading