<s> from __future__ import division <EOL> import numpy as np <EOL> from lfd . environment . simulation import StaticSimulation <EOL> from lfd . environment . simulation_object import BoxSimulationObject <EOL> from lfd . registration . registration import TpsRpmRegistrationFactory <EOL> from lfd . registration . plotting_openrave import registration_plot_cb <EOL> from lfd . demonstration . demonstration import Demonstration , SceneState <EOL> np . random . seed ( <NUM_LIT:0> ) <EOL> table_height = <NUM_LIT> <EOL> table = BoxSimulationObject ( "<STR_LIT>" , [ <NUM_LIT:1> , <NUM_LIT:0> , table_height - <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , dynamic = False ) <EOL> sim = StaticSimulation ( ) <EOL> sim . add_objects ( [ table ] ) <EOL> sim . create_viewer ( ) <EOL> def generate_cloud ( x_center_pert = <NUM_LIT:0> , max_noise = <NUM_LIT> ) : <EOL> grid = np . array ( np . meshgrid ( np . linspace ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , np . linspace ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) ) . T . reshape ( ( - <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> grid = np . c_ [ grid , np . zeros ( len ( grid ) ) ] + np . array ( [ <NUM_LIT> , <NUM_LIT:0> , table_height + max_noise ] ) <EOL> cloud = grid + x_center_pert * np . c_ [ ( <NUM_LIT> - np . abs ( grid [ : , <NUM_LIT:1> ] - <NUM_LIT:0> ) ) / <NUM_LIT> , np . zeros ( ( len ( grid ) , <NUM_LIT:2> ) ) ] + ( np . random . random ( ( len ( grid ) , <NUM_LIT:3> ) ) - <NUM_LIT:0.5> ) * <NUM_LIT:2> * max_noise <EOL> return cloud <EOL> demos = { } <EOL> for x_center_pert in np . arange ( - <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:0.1> ) : <EOL> demo_name = "<STR_LIT>" . format ( x_center_pert ) <EOL> demo_cloud = generate_cloud ( x_center_pert = x_center_pert ) <EOL> demo_scene_state = SceneState ( demo_cloud , downsample_size = <NUM_LIT> ) <EOL> demo = Demonstration ( demo_name , demo_scene_state , None ) <EOL> demos [ demo_name ] = demo <EOL> test_cloud = generate_cloud ( x_center_pert = <NUM_LIT> ) <EOL> test_scene_state = SceneState ( test_cloud , downsample_size = <NUM_LIT> ) <EOL> plot_cb = lambda i , i_em , x_nd , y_md , xtarg_nd , wt_n , f , corr_nm , rad : registration_plot_cb ( sim , x_nd , y_md , f ) <EOL> reg_factory = TpsRpmRegistrationFactory ( demos ) <EOL> regs = reg_factory . batch_register ( test_scene_state , callback = plot_cb ) </s>
