def Start(self): if self._auto: logging.debug('Starting automatic device deployment.') node_name = boot_data.GetNodeName(self._output_dir) self._host = self.__Discover(node_name) if self._host and self._WaitUntilReady(retries=0): logging.info('Connected to an already booted device.') self._new_instance = False return logging.info('Netbooting Fuchsia. ' + 'Please ensure that your device is in bootloader mode.') bootserver_path = os.path.join(SDK_ROOT, 'tools', 'bootserver') bootserver_command = [ bootserver_path, '-1', '--efi', EnsurePathExists(boot_data.GetTargetFile(self._GetTargetSdkArch(), 'local.esp.blk')), '--fvm', EnsurePathExists(boot_data.GetTargetFile(self._GetTargetSdkArch(), 'fvm.sparse.blk')), '--fvm', EnsurePathExists( boot_data.ConfigureDataFVM(self._output_dir, boot_data.FVM_TYPE_SPARSE)), EnsurePathExists(boot_data.GetTargetFile(self._GetTargetSdkArch(), 'zircon.bin')), EnsurePathExists(boot_data.GetTargetFile(self._GetTargetSdkArch(), 'bootdata-blob.bin')), '--'] + boot_data.GetKernelArgs(self._output_dir) logging.debug(' '.join(bootserver_command)) subprocess.check_call(bootserver_command) # Setup loglistener. Logs will be redirected to stdout if the device takes # longer than expected to boot. loglistener_path = os.path.join(SDK_ROOT, 'tools', 'loglistener') loglistener = subprocess.Popen([loglistener_path, node_name], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=open(os.devnull)) self._SetSystemLogsReader( log_reader.LogReader(loglistener, loglistener.stdout)) logging.debug('Waiting for device to join network.') for retry in xrange(CONNECT_RETRY_COUNT): if retry == CONNECT_RETRY_COUNT_BEFORE_LOGGING: self._system_logs_reader.RedirectTo(sys.stdout); self._host = self.__Discover(node_name) if self._host: break time.sleep(CONNECT_RETRY_WAIT_SECS) if not self._host: raise Exception('Couldn\'t connect to device.') logging.debug('host=%s, port=%d' % (self._host, self._port)) self._WaitUntilReady();
num_frames = 400 F = np.array([[1.65378644e+03, 0.00000000e+00, 9.35778810e+02], [0.00000000e+00, 1.66564440e+03, 5.29772404e+02], [0.00000000e+00, 0.00000000e+00, 1.00000000e+00]]) dist = np.array( [[-0.48381301, 0.43026754, -0.00087523, 0.00879241, -0.31198885]]) # Open windows for output orig_window = "Original Video" new_window = "Adjusted Video" cv2.namedWindow(orig_window, cv2.WINDOW_AUTOSIZE) cv2.namedWindow(new_window, cv2.WINDOW_AUTOSIZE) # Start log reader and mono rectifiers left_reader = lr.LogReader(l_logname, l_first_data_time_ms) left_reader.set_desired_loc_func( l_rect_start_time_ms, l_rect_start_time_ms + (num_frames + 2) * 1000 / 30) left_mono = mr.MonoRectify(l_fname, left_reader, F, dist, -76) left_mono.seek_time(l_rect_start_time_ms) right_reader = lr.LogReader(r_logname, r_first_data_time_ms) right_reader.set_desired_loc_func( r_rect_start_time_ms, r_rect_start_time_ms + (num_frames + 2) * 1000 / 30) right_mono = mr.MonoRectify(r_fname, right_reader, F, dist, -74) right_mono.seek_time(r_rect_start_time_ms) #plt.figure(1) #plt.show() rectifier = sr.StereoRectify(left_mono, right_mono, yaw_offset=0)
def initialize(self, path_docs, path_ppds=None, path_digests=None, debug_mode=False, threads_count=8): """ @param path_docs: path to local directory with documents to print @param path_ppds: path to local directory with PPD files to test; if None is set then all PPD files from the SCS server are downloaded and tested @param path_digests: path to local directory with digests files for test documents; if None is set then content of printed documents is not verified @param debug_mode: if set to True, then the autotest temporarily remounts the root partition in R/W mode and changes CUPS configuration, what allows to extract pipelines for all tested PPDs and rerun the outside CUPS @param threads_count: number of threads to use """ # Calculates absolute paths for all parameters self._location_of_test_docs = self._calculate_full_path(path_docs) self._location_of_PPD_files = self._calculate_full_path(path_ppds) location_of_digests_files = self._calculate_full_path(path_digests) # This object is used for running tasks in many threads simultaneously self._processor = multithreaded_processor.MultithreadedProcessor( threads_count) # This object is responsible for parsing CUPS logs self._log_reader = log_reader.LogReader() # This object is responsible for the system configuration self._configurator = configurator.Configurator() self._configurator.configure(debug_mode) # Reads list of test documents self._docs = helpers.list_entries_from_directory( path=self._location_of_test_docs, with_suffixes=('.pdf'), nonempty_results=True, include_directories=False) # Get list of PPD files ... if self._location_of_PPD_files is None: # ... from the SCS server self._ppds = self._get_filenames_from_PPD_indexes() else: # ... from the given local directory # Unpack archives with all PPD files: path_archive = self._calculate_full_path('ppds_all.tar.xz') path_target_dir = self._calculate_full_path('.') file_utils.rm_dir_if_exists( os.path.join(path_target_dir, 'ppds_all')) subprocess.call( ['tar', 'xJf', path_archive, '-C', path_target_dir]) path_archive = self._calculate_full_path('ppds_100.tar.xz') file_utils.rm_dir_if_exists( os.path.join(path_target_dir, 'ppds_100')) subprocess.call( ['tar', 'xJf', path_archive, '-C', path_target_dir]) # Load PPD files from the chosen directory self._ppds = helpers.list_entries_from_directory( path=self._location_of_PPD_files, with_suffixes=('.ppd', '.ppd.gz'), nonempty_results=True, include_directories=False) self._ppds.sort() # Load digests files self._digests = dict() if location_of_digests_files is None: for doc_name in self._docs: self._digests[doc_name] = dict() else: path_blacklist = os.path.join(location_of_digests_files, 'blacklist.txt') blacklist = helpers.load_blacklist(path_blacklist) for doc_name in self._docs: digests_name = doc_name + '.digests' path = os.path.join(location_of_digests_files, digests_name) self._digests[doc_name] = helpers.parse_digests_file( path, blacklist) # Prepare a working directory for pipelines if debug_mode: self._pipeline_dir = tempfile.mkdtemp(dir='/tmp') else: self._pipeline_dir = None
fname = "c:\\Users\\Joseph\Videos\\Flight With Ball\\Ball_sysid.log" #fname = "c:\\Users\\Joseph\Videos\\Flight With Ball\\Right.log" t0 = 58000 #t0 = 186500 tspan = 160000 - t0 #tspan = 12000 #t0 = 92000 #tspan = 96000-92000 f = 50. #50 Hz sampling rate g = 9.8 m = 2.9 #kg. Fix this. w = 0.2357 l = 0.1516 reader = lr.LogReader(fname,-343.67) t_ms = np.linspace(t0, t0+tspan, tspan*f/1000) t_s = t_ms/1000. gyr = reader.get_gyr(t_ms) pos = reader.get_ekf_loc_1d(t_ms) att = np.deg2rad(reader.get_ekf_att(t_ms)) motor_vals = reader.get_motor_vals(t_ms) motor_vals = motor_vals - 1143 # THIS IS IMPORTANT. 1190 for Camera quad. motor_means = np.mean(motor_vals,axis=1) ned_vel = reader.get_ekf_vel(t_ms) body_vel = np.zeros(ned_vel.shape) for i in range(0,t_ms.shape[0]): R = get_R(att[:,i]) body_vel[:,i] = R.dot(ned_vel[:,i])
#fname = "c:\\Users\\Joseph\Videos\\Planar Test\\Rotation.MP4" #rect_start_time = 0 #first_data_time = 0 F = np.array([[ 1.65378644e+03, 0.00000000e+00, 9.35778810e+02], [ 0.00000000e+00, 1.66564440e+03, 5.29772404e+02], [ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]]) dist = np.array([[-0.48381301, 0.43026754, -0.00087523, 0.00879241, -0.31198885]] ) # Open windows for output orig_window = "Original Video" new_window = "Adjusted Video" cv2.namedWindow(orig_window,cv2.WINDOW_AUTOSIZE) cv2.namedWindow(new_window,cv2.WINDOW_AUTOSIZE) # Start log reader and mono rectifier reader = lr.LogReader("c:\\Users\\Joseph\\Videos\\Planar Test\\Planar.log",first_data_time) mono = mr.MonoRectify(fname, reader, F, dist, 0) mono.seek_time(rect_start_time) for i in range(0,num_frames): #target_loc = locs[i,:] #print target_loc #target_loc = np.array([target_loc]) #new_frame, orig_frame = mono.get_frame(0, 0, target_loc, 310) new_frame, orig_frame = mono.get_frame(160,0,5.18,np.array([[0.,0.,-2]])) cv2.imshow(orig_window,orig_frame[::2,::2,:]) cv2.imshow(new_window,new_frame[::2,::2,:]) cv2.waitKey(20)
#rect_start_frame = 4250 # Index of frame to start rectifying at # first_data_frame occurs 10 frames after the green light appears on the pixhawk fname = "c:\\Users\\Joseph\Videos\\2015-04-07 23-51-23 3.MP4" rect_start_frame = 2240 first_data_frame = 310 first_data_time_ms = 10010. F = np.array([[1.50017800e+03, 0.00000000e+00, 9.45583379e+02], [0.00000000e+00, 1.50991558e+03, 5.40817307e+02], [0.00000000e+00, 0.00000000e+00, 1.00000000e+00]]) dist = np.array( [[-0.47135957, 0.32651474, -0.00792725, -0.0019949, -0.13798072]]) # Open windows for output orig_window = "Original Video" new_window = "Adjusted Video" cv2.namedWindow(orig_window, cv2.WINDOW_AUTOSIZE) cv2.namedWindow(new_window, cv2.WINDOW_AUTOSIZE) # Start log reader and mono rectifier reader = lr.LogReader("2015-04-07 23-51-23 3.bin.log", first_data_time_ms) mono = mr.MonoRectify(fname, reader, F, dist) mono.seek_frame(rect_start_frame) while (True): new_frame, orig_frame = mono.get_frame(287.72) cv2.imshow(orig_window, orig_frame[::2, ::2, :]) cv2.imshow(new_window, new_frame[::2, ::2, :]) cv2.waitKey(20)