def __init__(self, params, **args): self.vg_pub = VoxelgridPublisher() self.selection_sub = None self.model_runner = None self.dataset_supervisor = None self.params = params self.train_or_test = args[ 'train_or_test'] if 'train_or_test' in args else 'train' if args['dataset']: self.load_dataset(args['dataset']) if args['trial']: self.load_model(lookup_trial(args['trial']))
def make_live_cheezit_video_1(): scene = get_scene('live_cheezit') trial = lookup_trial('YCB') with WindowRecorder([ "live_shape_completion.rviz* - RViz", "live_shape_completion.rviz - RViz" ], frame_rate=30.0, name_suffix="rviz", save_dir=rviz_capture_path): with CameraRecorder(filename=f'{rviz_capture_path}/live_cheezit.mp4'): contact_shape_completer = ContactShapeCompleter( scene, trial, store_request=False) contact_shape_completer.get_visible_vg() contact_shape_completer.compute_known_occ() print("Up and running") rospy.spin()
def make_aab_video_1(): # tf.random.set_seed(20210108) # Okay, but initial free space measurement does not affect any particles tf.random.set_seed(20210111) scene = get_scene('cheezit_01') trial = lookup_trial('AAB') with WindowRecorder([ "live_shape_completion.rviz* - RViz", "live_shape_completion.rviz - RViz" ], frame_rate=30.0, name_suffix="rviz", save_dir=rviz_capture_path): contact_shape_completer = ContactShapeCompleter(scene, trial, store_request=False, completion_density=1) contact_shape_completer.get_visible_vg() contact_shape_completer.compute_known_occ() print("Up and running") rospy.spin()
def generate_evaluation(details): tf.random.set_seed(20210108) scene = details.scene_type() contact_shape_completer = ContactShapeCompleter(scene, lookup_trial( details.network), completion_density=1, method=details.method) contact_shape_completer.get_visible_vg(load=True) columns = [ 'request number', 'chs count', 'particle num', 'scene', 'method', 'chamfer distance', 'projection succeeded?' ] df = pd.DataFrame(columns=columns) gt = scene.get_gt(density_factor=1) point_pub = ros_helpers.get_connected_publisher('/pointcloud', PointCloud2, queue_size=1) point_pub.publish(gt) files = sorted([f for f in scene.get_save_path().glob('req_*')]) for req_number, file in enumerate(files): print(f"{Fore.CYAN}Loading stored request{file}{Fore.RESET}") completion_req = CompleteShapeRequest() with file.open('rb') as f: completion_req.deserialize(f.read()) completion_req.num_samples = NUM_PARTICLES_IN_TRIAL resp = contact_shape_completer.complete_shape_srv(completion_req) dists = [] for particle_num, completion_pts_msg in enumerate( resp.sampled_completions): total_dist = 0 for view in contact_shape_completer.robot_views: dist = vg_chamfer_distance( contact_shape_completer.transform_from_gpuvoxels( view, completion_pts_msg), contact_shape_completer.transform_from_gpuvoxels(view, gt), scale=view.scale).numpy() print(f"Errors w.r.t. gt: {dist}") total_dist += dist dists.append(total_dist) df = df.append(pd.Series([ req_number, float(len(completion_req.chss)), particle_num, scene.name, details.method, dist, True ], index=columns), ignore_index=True) if len(dists) == 0: continue print(f"Closest particle has error {np.min(dists)}") print(f"Average particle has error {np.mean(dists)}") display_sorted_particles(resp.sampled_completions, dists) df.to_csv(get_evaluation_path(details)) print(df) contact_shape_completer.unsubscribe()
""" default_dataset_params = default_params.get_default_params() def parse_command_line_args(): parser = argparse.ArgumentParser( description='Publish shape data to RViz for viewing') parser.add_argument('--trial', required=True) parser.add_argument('--scene', required=True) parser.add_argument('--store', action='store_true') return parser.parse_args() if __name__ == "__main__": ARGS = parse_command_line_args() rospy.init_node('contact_shape_completer_service') rospy.loginfo("Data Publisher") scene = get_scene(ARGS.scene) contact_shape_completer = ContactShapeCompleter(scene, lookup_trial(ARGS.trial), store_request=ARGS.store) contact_shape_completer.get_visible_vg() contact_shape_completer.compute_known_occ() print("Up and running") rospy.spin()