for model_name in models: spawn_model(model_name) for i in range(5): # make five attempts to get a valid a point cloud then give up sample_was_good = False try_count = 0 while not sample_was_good and try_count < 5: sample_cloud = capture_sample() sample_cloud_arr = ros_to_pcl(sample_cloud).to_array() # Check for invalid clouds. if sample_cloud_arr.shape[0] == 0: print('Invalid cloud detected') try_count += 1 else: sample_was_good = True # Extract histogram features chists = compute_color_histograms(sample_cloud, using_hsv=False) normals = get_normals(sample_cloud) nhists = compute_normal_histograms(normals) feature = np.concatenate((chists, nhists)) labeled_features.append([feature, model_name]) delete_model() pickle.dump(labeled_features, open('training_set.sav', 'wb'))
labeled_features = [] for model_name in models: spawn_model(model_name) for i in range(1000): # make five attempts to get a valid a point cloud then give up sample_was_good = False try_count = 0 while not sample_was_good and try_count < 5: sample_cloud = capture_sample() sample_cloud_arr = ros_to_pcl(sample_cloud).to_array() # Check for invalid clouds. if sample_cloud_arr.shape[0] == 0: print('Invalid cloud detected') try_count += 1 else: sample_was_good = True # Extract histogram features chists = compute_color_histograms(sample_cloud, using_hsv=True) normals = get_normals(sample_cloud) nhists = compute_normal_histograms(normals) feature = np.concatenate((chists, nhists)) labeled_features.append([feature, model_name]) delete_model() pickle.dump(labeled_features, open('training_set.sav', 'wb'))