MAX_COLOR = 25.

# Set up paths for logging the data from the simulation run
if not os.path.exists('./figures/' + str(reward_function)): 
    os.makedirs('./figures/' + str(reward_function))
logging.basicConfig(filename = './figures/'+ reward_function + '/robot.log', level = logging.INFO)
logger = logging.getLogger('robot')

# Create a random enviroment sampled from a GP with an RBF kernel and specified hyperparameters, mean function 0 
# The enviorment will be constrained by a set of uniformly distributed  sample points of size NUM_PTS x NUM_PTS
ranges = (0., 10., 0., 10.)

world = envlib.Environment(ranges = ranges,
                           NUM_PTS = 20, 
                           variance = 100.0, 
                           lengthscale = 1.0, 
                           visualize = True,
                           seed = seed,
                           MIN_COLOR=MIN_COLOR, 
                           MAX_COLOR=MAX_COLOR)

# Create the evaluation class used to quantify the simulation metrics
evaluation = evalib.Evaluation(world = world, reward_function = reward_function)

# Populate a world with obstacles
# ow = obslib.FreeWorld()
# ow = obslib.BlockWorld(ranges, 1, dim_blocks= (2,2), centers=[(7,7)])
ow = obslib.ChannelWorld(ranges, (2.5,7), 3, 0.2)

# Create the point robot
robot = roblib.Robot(sample_world = world.sample_value, #function handle for collecting observations
                     start_loc = (5.0, 5.0, 0.0), #where robot is instantiated
Esempio n. 2
0
logging.basicConfig(filename = './figures/'+ REWARD_FUNCTION + '/robot.log', level = logging.INFO)
logger = logging.getLogger('robot')

#设置world的范围
ranges = (0., 10., 0., 10.)

#加载无障碍物环境
ow = obslib.FreeWorld() #a world without obstacles

#创建机器人能够识别的环境
#没有观测值的预设先验的环境更新
world = envlib.Environment(ranges = ranges,
                           NUM_PTS = 20,
                           variance = 100.0,
                           lengthscale = 1.0,
                           visualize = False,
                           seed = SEED,
                           MIN_COLOR=MIN_COLOR,
                           MAX_COLOR=MAX_COLOR,
                           obstacle_world = ow,
                           noise=10.0)
#将更新好后的地图和奖励函数类型
# Create the evaluation class used to quantify the simulation metrics
#只初始化参数没有动作
evaluation = evalib.Evaluation(world = world, reward_function = REWARD_FUNCTION)
#设置机器人参数

robot = roblib.Robot(sample_world = world.sample_value, #function handle for collecting observations
                     start_loc = (5.0, 5.0, 0.0), #where robot is instantiated
                     dimension = 2,
                     extent = ranges, #extent of the explorable environment
                     kernel_file = None,
Esempio n. 3
0
    NOISE = 0.19836 / 10.0
else:
    gp_world = None
    # VAR = 50.0
    # LEN = 5.0
    # NOISE = 0.1
    VAR = 100.0
    LEN = 1.0
    NOISE = 1.0

world = envlib.Environment(ranges = ranges,
                           NUM_PTS = 100, 
                           variance = VAR,
                           lengthscale = LEN,
                           noise = NOISE,
                           visualize = True,
                           seed = SEED,
                           MAX_COLOR = MAX_COLOR,
                           MIN_COLOR = MIN_COLOR,
			   model = gp_world,
                           obstacle_world = ow)

# Create the evaluation class used to quantify the simulation metrics
evaluation = evalib.Evaluation(world = world, reward_function = REWARD_FUNCTION)

# Generate a prior dataset
'''
x1observe = np.linspace(ranges[0], ranges[1], 5)
x2observe = np.linspace(ranges[2], ranges[3], 5)
x1observe, x2observe = np.meshgrid(x1observe, x2observe, sparse = False, indexing = 'xy')  
data = np.vstack([x1observe.ravel(), x2observe.ravel()]).T
# The enviorment will be constrained by a set of uniformly distributed  sample points of size NUM_PTS x NUM_PTS
ranges = (0., 10., 0., 10.)

# Create obstacle world
ow = obslib.FreeWorld()
# ow = obslib.ChannelWorld(ranges, (3.5, 7.), 3., 0.3)
# ow = obslib.BugTrap(ranges, (2.2, 3.0), 4.6, orientation = 'left', width = 5.0)
# ow = obslib.BlockWorld(ranges,12, dim_blocks=(1., 1.), centers=[(2.5, 2.5), (7.,4.), (5., 8.), (8.75, 6.), (3.5,6.), (6.,1.5), (1.75,5.), (6.2,6.), (8.,8.5), (4.2, 3.8), (8.75,2.5), (2.2,8.2)])

world = envlib.Environment(
    ranges=ranges,
    NUM_PTS=20,
    variance=
    100.0,  # TODO: why is only the lengthscale a vector for asymmetric kernels? 
    lengthscale=LENGTHSCALE,
    noise=0.5,
    dim=DIM,
    visualize=True,
    seed=SEED,
    MIN_COLOR=MIN_COLOR,
    MAX_COLOR=MAX_COLOR,
    obstacle_world=ow,
    time_duration=DURATION)
# noise= 5.0)

# Create the evaluation class used to quantify the simulation metrics
evaluation = evalib.Evaluation(world=world, reward_function=REWARD_FUNCTION)

# Generate a prior dataset
x1observe = np.linspace(ranges[0], ranges[1], 20)
x2observe = np.linspace(ranges[2], ranges[3], 20)
x1observe, x2observe = np.meshgrid(x1observe,