Ejemplo n.º 1
0
BF = Bag_Folder.init(
    '/home/karlzipser/Desktop/direct_home_06Dec16_16h01m42s_Mr_Blue',
    preprocessed_dir='.preprocessed2',
    left_image_bound_to_data_name='left_image_bound_to_data.pkl',
    NUM_STATE_ONE_STEPS=10)

#plot(BF['data']['raw_timestamps'],BF['data']['state_one_steps'],'bo-')
plot(BF['data']['good_start_timestamps'],
     zeros(len(BF['data']['good_start_timestamps'])) + 100, 'go')
#plot(BF['data']['raw_timestamps'],2000*np.array(BF['data']['raw_timestamp_deltas']),'r')
#plot(BF['data']['raw_timestamps'],100*BF['data']['encoder'],'r')
#plot(BF['data']['raw_timestamps'],100*BF['data']['state'],'r')
#plot(BF['data']['raw_timestamps'],100*BF['data']['acc_z'],'r')

bf = BF['bag_file_num_dic'][15]
bid = Bag_File.load_images(bf)
bag_left_timestamps = sorted(bid['left'].keys())
plot(bag_left_timestamps, 2000 + np.zeros(bag_left_timestamps), 'go')

good_bag_timestamps = list(
    set(BF['data']['good_start_timestamps']) & set(bag_left_timestamps))
plot(good_bag_timestamps, 2000 + np.zeros(len(good_bag_timestamps)), 'ro')

ts = sorted(bid['left'].keys())
for t in ts:
    mi(bid['left'][t], 'left')
    #mi(bid['right'][BF['left_image_bound_to_data'][t]['right_image']],'right')
    plt.pause(0.0001)

plot(BF['data']['steer'], BF['data']['gyro_y'], 'o')
"""
Ejemplo n.º 2
0
BF = Bag_Folder.init('/home/karlzipser/Desktop/direct_home_06Dec16_16h01m42s_Mr_Blue',
	preprocessed_dir='.preprocessed2',
	left_image_bound_to_data_name='left_image_bound_to_data.pkl',
	NUM_STATE_ONE_STEPS=10)



#plot(BF['data']['raw_timestamps'],BF['data']['state_one_steps'],'bo-')
plot(BF['data']['good_start_timestamps'],zeros(len(BF['data']['good_start_timestamps']))+100,'go')
#plot(BF['data']['raw_timestamps'],2000*np.array(BF['data']['raw_timestamp_deltas']),'r')
#plot(BF['data']['raw_timestamps'],100*BF['data']['encoder'],'r')
#plot(BF['data']['raw_timestamps'],100*BF['data']['state'],'r')
#plot(BF['data']['raw_timestamps'],100*BF['data']['acc_z'],'r')

bf = BF['bag_file_num_dic'][15]  
bid = Bag_File.load_images(bf)
bag_left_timestamps = sorted(bid['left'].keys())
plot(bag_left_timestamps,2000+np.zeros(bag_left_timestamps),'go')

good_bag_timestamps = list(set(BF['data']['good_start_timestamps']) & set(bag_left_timestamps))
plot(good_bag_timestamps,2000+np.zeros(len(good_bag_timestamps)),'ro')


ts = sorted(bid['left'].keys())
for t in ts:
	mi(bid['left'][t],'left')
	#mi(bid['right'][BF['left_image_bound_to_data'][t]['right_image']],'right')
	plt.pause(0.0001)

plot(BF['data']['steer'],BF['data']['gyro_y'],'o')
def bag_file_loader_thread(BF_dic,delay_before_delete,loaded_bag_files_names,played_bagfile_dic): 

	while True: # 50 brings us to 80.9 GiB, 75 brings us to 106.2. This is 56 loaded bag files, about 28 minutes of data, about 1% of 40 hours.
		#print ("here",time.time())
		if bag_file_loader_thread_please_exit:
			cprint('THREAD:: exiting bag_file_loader_thread()')
			return
		elif not thread_please_load_data:
			time.sleep(1)
		else:
			if len(loaded_bag_files_names) > 50: # if using flip images, halve the number of bag files loaded
				cprint('\n\nTHREAD:: pause before deleting '+bf+'\n\n,'blue','on_red')
				time.sleep(delay_before_delete)

				played_bagfile_dic_keys = []
				played_bagfile_dic_values = []
				for b in played_bagfile_dic.keys():
					played_bagfile_dic_keys.append(b)
					played_bagfile_dic_values.append(played_bagfile_dic[b])
				indicies = [i[0] for i in sorted(enumerate(played_bagfile_dic_values),key=lambda x:x[1])]
				indicies.reverse()
				ctr = 0
				for i in indicies:
					if ctr >= 25:
						break
					bf = played_bagfile_dic_keys[i]
					if bf in loaded_bag_files_names:
						#bf = a_key(loaded_bag_files_names)
						cprint('THREAD:: deleting '+bf,'blue','on_red')
						r = loaded_bag_files_names[bf]
						loaded_bag_files_names.pop(bf)
						BF = BF_dic[r]
						BF['bag_file_image_data'].pop(bf)
						ctr += 1
			try:
				r = random.choice(BF_dic.keys())
				BF = BF_dic[r]
				dic_keys = ['bag_file_image_data','good_bag_timestamps','binned_timestamps','binned_steers','bid_timestamps']
				for dk in dic_keys:
					if dk not in BF:
						BF[dk] = {}
				bf = random.choice(BF['bag_file_num_dic'])
				if bf in BF['bag_file_image_data']:
					continue
				BF['bag_file_image_data'][bf] = Bag_File.load_images(bf,color_mode="rgb8",include_flip=True)
				loaded_bag_files_names[bf] = r

				bid = BF['bag_file_image_data'][bf]

				bag_left_timestamps = sorted(bid['left'].keys())

				good_bag_timestamps = list(set(BF['data']['good_start_timestamps']) & set(bag_left_timestamps))
				
				cprint(d2s('THREAD:: ',bf.split('/')[-1],'len(good_bag_timestamps) =',len(good_bag_timestamps)),'blue')

				binned_timestamps = [[],[]]
				binned_steers = [[],[]]

				for t in good_bag_timestamps:
					steer = BF['left_image_bound_to_data'][t]['steer']
					if steer < 43 or steer > 55:
						binned_timestamps[0].append(t)
						binned_steers[0].append(steer)
					else:
						binned_timestamps[1].append(t)
						binned_steers[1].append(steer)

				BF['good_bag_timestamps'][bf] = good_bag_timestamps
				BF['binned_timestamps'][bf] = binned_timestamps
				BF['binned_steers'][bf] = binned_steers
				BF['bid_timestamps'][bf] = sorted(bid['left'].keys())

			except Exception as e:
				cprint("THREAD:: ********** Exception ***********************",'red')
				print(e.message, e.args)
Ejemplo n.º 4
0
BF = Bag_Folder.init('/home/karlzipser/Desktop/direct_home_06Dec16_16h01m42s_Mr_Blue',
	preprocessed_dir='.preprocessed2',
	left_image_bound_to_data_name='left_image_bound_to_data.pkl',
	NUM_STATE_ONE_STEPS=10)



#plot(BF['data']['raw_timestamps'],BF['data']['state_one_steps'],'bo-')
plot(BF['data']['good_start_timestamps'],zeros(len(BF['data']['good_start_timestamps']))+100,'go')
#plot(BF['data']['raw_timestamps'],2000*np.array(BF['data']['raw_timestamp_deltas']),'r')
#plot(BF['data']['raw_timestamps'],100*BF['data']['encoder'],'r')
#plot(BF['data']['raw_timestamps'],100*BF['data']['state'],'r')
#plot(BF['data']['raw_timestamps'],100*BF['data']['acc_z'],'r')

bf = BF['bag_file_num_dic'][15]  
bid = Bag_File.load_images(bf)
bag_left_timestamps = sorted(bid['left'].keys())
plot(bag_left_timestamps,2000+np.zeros(bag_left_timestamps),'go')

good_bag_timestamps = list(set(BF['data']['good_start_timestamps']) & set(bag_left_timestamps))
plot(good_bag_timestamps,2000+np.zeros(len(good_bag_timestamps)),'ro')


ts = sorted(bid['left'].keys())
for t in ts:
	mi(bid['left'][t],'left')
	#mi(bid['right'][BF['left_image_bound_to_data'][t]['right_image']],'right')
	plt.pause(0.0001)

plot(BF['data']['steer'],BF['data']['gyro_y'],'o')