def _resample_test(): try: print 'Test resampling data without padding...' data,geodict = Grid2D._createSampleData(9,7) gdalgrid = GDALGrid(data,geodict) gdalgrid.save('test.bil') newdict = {'xmin':3.0,'xmax':4.0,'ymin':3.0,'ymax':4.0,'xdim':1.0,'ydim':1.0} newdict = Grid2D.fillGeoDict(newdict) gdalgrid3 = GDALGrid.load('test.bil',samplegeodict=newdict,resample=True) output = np.array([[34,35], [41,42]]) np.testing.assert_almost_equal(gdalgrid3._data,output) print 'Passed resampling data without padding...' print 'Test resampling data with padding...' data,geodict = Grid2D._createSampleData(4,4) gdalgrid = GDALGrid(data,geodict) gdalgrid.save('test.bil') newdict = {'xmin':0.0,'xmax':4.0,'ymin':0.0,'ymax':4.0,'xdim':1.0,'ydim':1.0} newdict = Grid2D.fillGeoDict(newdict) gdalgrid3 = GDALGrid.load('test.bil',samplegeodict=newdict,resample=True,doPadding=True) output = np.array([[np.nan,np.nan,np.nan,np.nan,np.nan], [np.nan,2.5,3.5,4.5,np.nan], [np.nan,6.5,7.5,8.5,np.nan], [np.nan,10.5,11.5,12.5,np.nan], [np.nan,np.nan,np.nan,np.nan,np.nan]]) np.testing.assert_almost_equal(gdalgrid3._data,output) print 'Passed resampling data with padding...' except AssertionError,error: print 'Failed resample test:\n %s' % error
def _subset_test(): try: print 'Testing subsetting of non-square grid...' data,geodict = Grid2D._createSampleData(6,4) gdalgrid = GDALGrid(data,geodict) gdalgrid.save('test.bil') newdict = {'xmin':1.5,'xmax':2.5,'ymin':1.5,'ymax':3.5,'xdim':1.0,'ydim':1.0} gdalgrid3 = GDALGrid.load('test.bil',samplegeodict=newdict) output = np.array([[9,10], [13,14], [17,18]]) np.testing.assert_almost_equal(gdalgrid3._data,output) print 'Passed subsetting of non-square grid.' except AssertionError,error: print 'Failed subset test:\n %s' % error
def _pad_test(): try: print 'Test padding data with null values...' data,geodict = Grid2D._createSampleData(4,4) gdalgrid = GDALGrid(data,geodict) gdalgrid.save('test.bil') newdict = {'xmin':-0.5,'xmax':4.5,'ymin':-0.5,'ymax':4.5,'xdim':1.0,'ydim':1.0} gdalgrid2 = GDALGrid.load('test.bil',samplegeodict=newdict,doPadding=True) output = np.array([[np.nan,np.nan,np.nan,np.nan,np.nan,np.nan], [np.nan,0.0,1.0,2.0,3.0,np.nan], [np.nan,4.0,5.0,6.0,7.0,np.nan], [np.nan,8.0,9.0,10.0,11.0,np.nan], [np.nan,12.0,13.0,14.0,15.0,np.nan], [np.nan,np.nan,np.nan,np.nan,np.nan,np.nan]]) np.testing.assert_almost_equal(gdalgrid2._data,output) print 'Passed padding data null values.' except AssertionError,error: print 'Failed padding test:\n %s' % error
# Define the x and y coordinates for 3 corners of the grid grid_corners1: GridCorners = [ XYPoint(x = 0.25, y = 0), # Starting position XYPoint(x = 0.46, y = 0.1), # Length of the grid XYPoint(x = 0.42, y = 0.35), # width of the grid ] # Symmetrical grid grid_corners2: GridCorners = [ XYPoint(x = 0.25, y = 0), XYPoint(x = 0.46,y = -0.1), XYPoint(x = 0.42, y = -0.35), ] # Using the corners and an amount of rows and columns, make the Grid2D my_test_grid1 = Grid2D(grid_corners1, rows = 4, columns = 4) my_test_grid2 = Grid2D(grid_corners2, rows = 4, columns = 4) # Connect to Eva host_ip = "your host" token = "your token" eva = Eva(host_ip, token) # Set some default poses and a default orientation pose_home = [0.057526037, 0.7658633, -1.9867575, 0.026749607, -1.732109, -0.011505207] end_effector_orientation = {'w': 0.0, 'x': 0.0, 'y': 1.0, 'z': 0.0} # Be carefull with this dimension - depending on the type of gripper grid_z_position: float = 0.27
def __init__(self, grid_width, grid_height, visited=None): Grid2D.__init__(self, grid_width, grid_height, visited)
from typing import List, Tuple, NamedTuple import time from evasdk import Eva from grid2d import Grid2D, GridCorners, XYPoint # Define the x and y coordinates for 3 corners of the grid grid_corners: GridCorners = [ XYPoint(x = 0.25, y = 0), XYPoint(x = 0.35, y = 0), XYPoint(x = 0.35, y = 0.4), ] # Using the corners and an amount of rows and columns, make the Grid2D my_test_grid = Grid2D(grid_corners, rows = 4, columns = 4) # Connect to Eva host_ip = input("Please enter a Eva IP: ") token = input("Please enter a valid Eva token: ") eva = Eva(host_ip, token) # Set some default poses and a default orientation pose_home = [0.057526037, 0.7658633, -1.9867575, 0.026749607, -1.732109, -0.011505207] end_effector_orientation = {'w': 0.0, 'x': 0.0, 'y': 1.0, 'z': 0.0} grid_z_position: float = 0.4 print("Waiting for Robot lock") with eva.lock(): print('Eva moving to home position') eva.control_go_to(pose_home) # For each grid position in the Grid2D