def computeIdealReadings(worldPath, xMin, xMax, y, numStates, numObs): """ :param worldPath: string naming file to read the world description from :param xMin: minimum x coordinate for center of robot :param xMax: maximum x coordinate for center of robot :param y: constant y coordinate for center of robot :param numStates: number of discrete states into which to divide the range of x coordinates :param numObs: number of discrete observations into which to divide the range of good sonar observations, between 0 and ``goodSonarRange`` :returns: list of ``numStates`` values, each of which is between 0 and ``numObs-1``, which lists the ideal discretized sonar reading that the robot would receive if it were at the midpoint of each of the x bins. """ # read obstacles from the map world = soarWorld.SoarWorld(worldPath) xStep = (xMax - xMin) / float(numStates) readings = [] # Start in the middle of the first box x = xMin + (xStep / 2.0) for ix in range(numStates): # left-hand sonar reading assuming we're heading to the right readings.append(discreteSonarValue(\ idealSonarReading(util.Pose(x, y, 0), sonarDist.sonarPoses[0], world), numObs)) x = x + xStep return readings
def __init__(self, worldPath, gridSquareSize, windowWidth = 400): """ Reads in a world file. Gets boundary dimensions and aspect ratio from there. Grid cells are square, with size gridSquareSize @param worldPath: String representing path to a soar world definition file @param gridSquareSize: size, in world coordinates, of a grid square @param windowWidth: size, in pixels, to make the window for drawing this map """ self.world = soarWorld.SoarWorld(worldPath) gridMap.GridMap.__init__(self, 0, float(self.world.dimensions[0]), 0, float(self.world.dimensions[1]), gridSquareSize, windowWidth)