Пример #1
0
 def __init__(self,
              dimensions,
              offsets,
              scale,
              root=None,
              run=1,
              background=None):
     TkSimulator.__init__(self,
                          dimensions=dimensions,
                          offsets=offsets,
                          scale=scale,
                          root=root,
                          run=run)
     self.backgroundFile = background
     if (self.backgroundFile != None):
         try:
             self.backgroundImage = ImageTk.PhotoImage(
                 Image.open(background), master=self)
             self.canvas.create_image(0,
                                      0,
                                      anchor="nw",
                                      image=self.backgroundImage,
                                      tags="background")
         except:
             self.backgroundImage = None
             print "Error opening image file ", background, " I will ignore it."
             print "", sys.exc_info()[0]
             print "", sys.exc_info()[1]
             print "", sys.exc_info()[2]
Пример #2
0
    def redraw(self):
        TkSimulator.redraw(self)

        # if we have a background image, redraw it as well.
        try:
            if (self.backgroundImage != None):
                self.canvas.create_image(0,
                                         0,
                                         anchor="nw",
                                         image=self.backgroundImage,
                                         tags="background")
                self.canvas.lower("background", "line")
        except:
            pass
Пример #3
0
def INIT():
    # (width, height), (offset x, offset y), scale:
    sim = TkSimulator((441, 434), (22, 420), 40.357554)
    # x1, y1, x2, y2 in meters:
    sim.addBox(0, 0, 10, 10)
    sim.addBox(1, 7.5, 9, 8)
    sim.addBox(2, 3, 8, 6)
    # (x, y) meters, brightness usually 1 (1 meter radius):
    sim.addLight(5, 9, 1)
    # port, name, x, y, th, bounding Xs, bounding Ys, color
    # (optional TK color name):
    sim.addRobot(
        60000,
        TkPioneer("RedPioneer", 5, 2, -0.86,
                  ((.225, .225, -.225, -.225), (.175, -.175, -.175, .175))))
    # add some sensors:
    sim.robots[0].addDevice(PioneerFrontSonars())
    sim.robots[0].addDevice(PioneerFrontLightSensors())
    return sim
   def redraw(self):
      # first we call the redraw of the super-class
      TkSimulator.redraw(self)
      # we now add our markers
      for (markerX,markerY) in self.markerLoc.keys():
         markerName = self.markerLoc[(markerX,markerY)]
	 markerAngle = self.markerAngle[markerName]

	 tipX = markerX+(.25*math.cos(markerAngle))
	 tipY = markerY+(.25*math.sin(markerAngle))
	 rightX = markerX+(.25*math.cos(markerAngle+(math.pi/2)))
	 rightY = markerY+(.25*math.sin(markerAngle+(math.pi/2)))
	 leftX = markerX+(.25*math.cos(markerAngle+(math.pi)))
	 leftY = markerY+(.25*math.sin(markerAngle+(math.pi)))

	 self.canvas.create_polygon([(self.scale_x(tipX),self.scale_y(tipY)),
	                             (self.scale_x(leftX),self.scale_y(leftY)),
	                             (self.scale_x(rightX),self.scale_y(rightY))],
	                            tag="line", fill='green')
	 self.canvas.create_text(self.scale_x(markerX),
	                         self.scale_y(markerY), text=markerName,
				 fill='red')
Пример #5
0
def INIT():
    sim = TkSimulator((441,434), (22,420), 40.357554)
    
    sim.addBox(0, 0, 10, 10)

    sim.addLight(5, 6, 1)

    sim.addRobot(60000, TkPioneer("RedPioneer",
                                  5, 2, -0.86,
                                  ((.225, .225, -.225, -.225),
                                   (.175, -.175, -.175, .175))))
    # add some sensors:
    sim.robots[0].addDevice(PioneerFrontSonars())
    sim.robots[0].addDevice(PioneerFrontLightSensors())
    return sim
Пример #6
0
def INIT():
    # (width, height), (offset x, offset y), scale:
    sim = TkSimulator((441,434), (22,420), 40.357554)  
    # x1, y1, x2, y2 in meters:
    sim.addBox(0, 0, 10, 10)
    sim.addBox(3, 4, 7, 4.5)
    sim.addBox(2.5, 2, 3, 4.5)
    sim.addBox(7, 2, 7.5, 4.5)
    # (x, y) meters, brightness usually 1 (1 meter radius):
    sim.addLight(5, 6, 1)
    # port, name, x, y, th, bounding Xs, bounding Ys, color
    # (optional TK color name):
    sim.addRobot(60000, TkPioneer("RedPioneer",
                                  5, 2, -0.86,
                                  ((.225, .225, -.225, -.225),
                                   (.175, -.175, -.175, .175))))
    # add some sensors:
    sim.robots[0].addDevice(PioneerFrontSonars())
    sim.robots[0].addDevice(PioneerFrontLightSensors())
    return sim
Пример #7
0
def INIT():
    # (width, height), (offset x, offset y), scale:
    sim = TkSimulator((441,434), (22,420), 40.357554)  
    # x1, y1, x2, y2 in meters:
    sim.addBox(0, 0, 10, 10)
    # (x, y) meters, brightness usually 1 (1 meter radius):
    sim.addLight(1, 1, 0.5)
    sim.addLight(2, 2, 0.5)
    sim.addLight(3, 3, 0.5)
    sim.addLight(4, 4, 0.5)
    sim.addLight(5, 5, 0.5)
    sim.addLight(6, 6, 0.5)
    sim.addLight(7, 7, 0.5)
    sim.addLight(8, 8, 0.5)
    sim.addLight(9, 9, 0.5)
    sim.addLight(10, 10, 0.5)
    # port, name, x, y, th, bounding Xs, bounding Ys, color
    # (optional TK color name):
    sim.addRobot(60002, TkPioneer("redRobot",
                                  5, 7, -0.86,
                                  ((.225, .225, -.225, -.225),
                                   (.175, -.175, -.175, .175)),
                                  "red"))
    sim.addRobot(60003, TkPioneer("blueRobot",
                                  6, 7, -0.86,
                                  ((.225, .225, -.225, -.225),
                                   (.175, -.175, -.175, .175)),
                                  "blue"))
    # add some sensors:
    sim.robots[0].addDevice(PioneerFrontLightSensors())
    sim.robots[1].addDevice(PioneerFrontLightSensors())
    sim.robots[1].addDevice(PioneerFrontSonars())
    return sim
   def __init__(self, dimensions, offsets, scale, root = None, run = 1):
        TkSimulator.__init__(self, dimensions=dimensions,
	                     offsets=offsets, scale=scale, root=root,
			     run=run)
	self.resetMarkers()
Пример #9
0
def INIT():
    # (width, height), (offset x, offset y), scale:
    sim = TkSimulator((441,434), (22,420), 40.357554)  
    # x1, y1, x2, y2 in meters:
    sim.addBox(0, 0, 10, 10, "green")
    # (x, y) meters, brightness usually 1 (1 meter radius):
    sim.addLight(5, 5, 0.3)
    # port, name, x, y, th, bounding Xs, bounding Ys, color
    # (optional TK color name):
    sim.addRobot(60000, TkPioneer("redRobot",
                                  5, 1, 0,
                                  ((.225, .225, -.225, -.225),
                                   (.175, -.175, -.175, .175)),
                                  "red"))
    sim.addRobot(60001, TkPioneer("blueRobot",
                                  5, 9, pi,
                                  ((.225, .225, -.225, -.225),
                                   (.175, -.175, -.175, .175)),
                                  "blue"))

    sim.addBox(4.8, 0.2, 5.2, 0.6, "black")
    sim.addBox(4.8, 9.4, 5.2, 9.8, "white")

    # add some sensors:
    sim.robots[0].addDevice(PioneerFrontLightSensors())
    sim.robots[0].addDevice(PioneerFrontSonars())
    sim.robots[1].addDevice(PioneerFrontLightSensors())
    sim.robots[1].addDevice(PioneerFrontSonars())
    return sim
Пример #10
0
def INIT():
    # (width, height), (offset x, offset y), scale:
    sim = TkSimulator((441, 434), (22, 420), 40.357554)
    # x1, y1, x2, y2 in meters:
    sim.addBox(0, 0, 10, 10)
    # (x, y) meters, brightness usually 1 (1 meter radius):
    sim.addLight(1, 1, 0.5)
    sim.addLight(2, 2, 0.5)
    sim.addLight(3, 3, 0.5)
    sim.addLight(4, 4, 0.5)
    sim.addLight(5, 5, 0.5)
    sim.addLight(6, 6, 0.5)
    sim.addLight(7, 7, 0.5)
    sim.addLight(8, 8, 0.5)
    sim.addLight(9, 9, 0.5)
    sim.addLight(10, 10, 0.5)
    # port, name, x, y, th, bounding Xs, bounding Ys, color
    # (optional TK color name):
    sim.addRobot(
        60002,
        TkPioneer("redRobot", 5, 7, -0.86,
                  ((.225, .225, -.225, -.225), (.175, -.175, -.175, .175)),
                  "red"))
    sim.addRobot(
        60003,
        TkPioneer("blueRobot", 6, 7, -0.86,
                  ((.225, .225, -.225, -.225), (.175, -.175, -.175, .175)),
                  "blue"))
    # add some sensors:
    sim.robots[0].addDevice(PioneerFrontLightSensors())
    sim.robots[1].addDevice(PioneerFrontLightSensors())
    sim.robots[1].addDevice(PioneerFrontSonars())
    return sim