예제 #1
0
    def __init__(self, display, x1, y1, x2, y2):
        BaseObj.__init__(self, BaseObj.WALL)
        zoom = display.zoom

        self.x1 = x1
        self.y1 = y1
        self.x2 = x2
        self.y2 = y2
        #fudge factor - to avoid rounding errors resulting in values
        #where a valid intersection is ignored because it's not "in"
        #the object.
        self.fudge = 0.000001 
        self.vis = WallVis(display, x1, y1, x2, y2)
        if x1 < x2:
            self.minx = x1
            self.maxx = x2
        else:
            self.minx = x2
            self.maxx = x1

        if y1 < y2:
            self.miny = y1
            self.maxy = y2
        else:
            self.miny = y2
            self.maxy = y1
        self.draw()
예제 #2
0
    def __init__(self, display, x1, y1, x2, y2):
        BaseObj.__init__(self, BaseObj.WALL)
        zoom = display.zoom

        self.x1 = x1
        self.y1 = y1
        self.x2 = x2
        self.y2 = y2
        #fudge factor - to avoid rounding errors resulting in values
        #where a valid intersection is ignored because it's not "in"
        #the object.
        self.fudge = 0.000001 
        self.vis = WallVis(display, x1, y1, x2, y2)
        if x1 < x2:
            self.minx = x1
            self.maxx = x2
        else:
            self.minx = x2
            self.maxx = x1

        if y1 < y2:
            self.miny = y1
            self.maxy = y2
        else:
            self.miny = y2
            self.maxy = y1
        self.draw()
    def __init__(self, display, x, y, r):
        BaseObj.__init__(self, BaseObj.CONE)
        zoom = display.zoom

        self.x = x
        self.y = y
        self.r = r
        self.vis = ConeVis(display, x, y, r)
        self.minx = x - r
        self.maxx = x + r
        self.miny = y - r
        self.maxy = y + r
        self.draw()
예제 #4
0
    def __init__(self, display, x, y, r):
        BaseObj.__init__(self, BaseObj.CONE)
        zoom = display.zoom

        self.x = x
        self.y = y
        self.r = r
        self.vis = ConeVis(display, x, y, r)
        self.minx = x - r
        self.maxx = x + r
        self.miny = y - r
        self.maxy = y + r
        self.draw()
예제 #5
0
 def __init__(self, display, size, scale, time):
     BaseObj.__init__(self, BaseObj.ROBOT)
     self.rand = Random()
     self.tick = 0
     self.ir_angle = [0,0] #angle is in radians
     self.target_ir_angle = [0,0] #angle is in radians
     self.target_speed = [0,0]
     self.wheel_speed = [0,0]
     self.wheel_accel = [10,10]
     self.encoder = [0.0,0.0]
     self.prev_time = 0
     self.x = 0
     self.y = 0
     self.size = size
     #dist between wheel centres is 23.5cm, robot is 26cm wide
     self.wheelbase = 22.5*self.size/26.0
     self.scale = scale
     self.noise_model = NO_NOISE
     self.max_ir_range = [0 , 0]
     self.max_ir_range[FRONT] = 100/26 * size
     self.max_ir_range[SIDE] = 40/26 * size
     self.max_us_range = 3 * size
     self.ir_dist = [self.max_ir_range[FRONT], self.max_ir_range[FRONT], 
                     self.max_ir_range[SIDE], self.max_ir_range[SIDE]]
     self.ir_sample_time = time
     self.ir_scan_speed = 20 * 3.14/180  #20 degrees per update
     self.us_dist = self.max_us_range
     self.last_ir_front_reading = 0
     self.last_ir_side_reading = 0
     self.last_us_reading = 0
     self.always_show_front_ir = False
     self.always_show_side_ir = False
     self.always_show_us = False
     self.async_enabled = False
     self.async_update_interval = 100
     self.async_last_update = 0
     self.async_us = False
     self.async_iflr = False
     self.async_islr = False
     self.async_melr = False
     self.angle = 0  #angle is in radians
     self.bump = [False,False]
     self.bump_got = [False,False]
     self.latch_bump = False
     self.line_y = -0.4 * size
     self.line_spacing = 0.05 * size
     self.line_readings = [127,127,127]
     self.last_line_reading = 0
     self.vis = RobotVis(display, 100, 100, 30, self.size,
                         self.max_ir_range[FRONT], self.max_ir_range[SIDE])
     self.reset_origin()
예제 #6
0
    def __init__(self, display, x, y, r, num):
        BaseObj.__init__(self, BaseObj.TARGET)
        zoom = display.zoom

        self.x = x
        self.y = y
        self.r = r
        self.num = num
        self.vis = TargetVis(display, x, y, r, num)
        self.minx = x - r
        self.maxx = x + r
        self.miny = y - r
        self.maxy = y + r
        self.draw()
    def __init__(self, display, x1, y1, x2, y2, x3, y3, x4, y4, drag1, drag2):
        BaseObj.__init__(self, BaseObj.CARPET)
        zoom = display.zoom

        self.coords = [x1,y1, x2, y2, x3, y3, x4, y4]
        self.drag1 = drag1
        self.drag2 = drag2
        self.vis = CarpetVis(display, self.coords)

        #compute bounding box
        self.minx = min(x1,x2,x3,x4)
        self.maxx = max(x1,x2,x3,x4)
        self.miny = min(y1,y2,y3,y4)
        self.maxy = max(y1,y2,y3,y4)
        self.draw()
예제 #8
0
    def __init__(self, display, x1, y1, x2, y2, x3, y3, x4, y4, drag1, drag2):
        BaseObj.__init__(self, BaseObj.CARPET)
        zoom = display.zoom

        self.coords = [x1, y1, x2, y2, x3, y3, x4, y4]
        self.drag1 = drag1
        self.drag2 = drag2
        self.vis = CarpetVis(display, self.coords)

        #compute bounding box
        self.minx = min(x1, x2, x3, x4)
        self.maxx = max(x1, x2, x3, x4)
        self.miny = min(y1, y2, y3, y4)
        self.maxy = max(y1, y2, y3, y4)
        self.draw()
    def __init__(self, display, x1, y1, x2, y2):
        BaseObj.__init__(self, BaseObj.LINE)
        zoom = display.zoom

        # we extend the line a few pixels beyond the end position so
        # we don't end up with gaps between consecutive lines
        extension = 3

        self.x1 = x1
        self.y1 = y1
        self.x2 = x2
        self.y2 = y2

        if x1 == x2:
            if y2 > y1:
                self.y2 = y2 + extension
                self.y1 = y1 - extension
            else:
                self.y2 = y2 - extension
                self.y1 = y1 + extension
        else:
            angle = atan2((y2 - y2), (x2 - x1))
            self.y2 = y2 + (extension * sin(angle))
            self.x2 = x2 + (extension * cos(angle))
            self.y1 = y1 - (extension * sin(angle))
            self.x1 = x1 - (extension * cos(angle))
            

        self.vis = LineVis(display, x1, y1, x2, y2)
        if x1 < x2:
            self.minx = self.x1
            self.maxx = self.x2
        else:
            self.minx = self.x2
            self.maxx = self.x1

        if y1 < y2:
            self.miny = self.y1
            self.maxy = self.y2
        else:
            self.miny = self.y2
            self.maxy = self.y1
        self.draw()
예제 #10
0
    def __init__(self, display, x1, y1, x2, y2):
        BaseObj.__init__(self, BaseObj.LINE)
        zoom = display.zoom

        # we extend the line a few pixels beyond the end position so
        # we don't end up with gaps between consecutive lines
        extension = 3

        self.x1 = x1
        self.y1 = y1
        self.x2 = x2
        self.y2 = y2

        if x1 == x2:
            if y2 > y1:
                self.y2 = y2 + extension
                self.y1 = y1 - extension
            else:
                self.y2 = y2 - extension
                self.y1 = y1 + extension
        else:
            angle = atan2((y2 - y2), (x2 - x1))
            self.y2 = y2 + (extension * sin(angle))
            self.x2 = x2 + (extension * cos(angle))
            self.y1 = y1 - (extension * sin(angle))
            self.x1 = x1 - (extension * cos(angle))

        self.vis = LineVis(display, x1, y1, x2, y2)
        if x1 < x2:
            self.minx = self.x1
            self.maxx = self.x2
        else:
            self.minx = self.x2
            self.maxx = self.x1

        if y1 < y2:
            self.miny = self.y1
            self.maxy = self.y2
        else:
            self.miny = self.y2
            self.maxy = self.y1
        self.draw()