當前位置: 首頁>>代碼示例>>Python>>正文


Python Tracker.update方法代碼示例

本文整理匯總了Python中tracker.Tracker.update方法的典型用法代碼示例。如果您正苦於以下問題:Python Tracker.update方法的具體用法?Python Tracker.update怎麽用?Python Tracker.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tracker.Tracker的用法示例。


在下文中一共展示了Tracker.update方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import update [as 別名]
def main ():

    #Introduction
    print ("This program graphically depicts the flight of a cannonball. ")
    print ()

    #Get inputs
    a = eval(input("Enter the launch angle in degrees: "))
    v = eval(input("Enter the initial velocity in meters per second: "))
    h = eval(input("Enter the initial height in meters: "))

    #Create tracker
    projectile = Projectile(a, v, h)
    win = GraphWin(200, 200)
    win.setCoords(0.0, 0.0, 25.0, 25.0)
    tracker = Tracker(win, projectile)
    time = 0.0
    while projectile.getY() >= -5:
        time += .0005
        projectile.update(time)
        tracker.update()

    #Close window
    win.getMouse()
    win.close()
開發者ID:MichelleJaeg,項目名稱:Exercises-from-Chapter-10,代碼行數:27,代碼來源:337.15.py

示例2: main

# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import update [as 別名]
def main ():

    #Introduction
    print ("This program uses a cannonball to shoot at a target.")

    #Create graphics window
    win = GraphWin(200, 200)
    win.setCoords(0.0, 0.0, 25.0, 25.0)
    target = Target(win)

    flag = False
    targetHit = False
    while not flag:

    #Get inputs
        print ()
        a = eval(input("Enter the launch angle in degrees: "))
        v = eval(input("Enter the initial velocity in meters per second: "))
        h = eval(input("Enter the initial height in meters: "))

    #Create tracker
        projectile = Projectile(a, v, h)
        tracker = Tracker(win, projectile)
        time = 0.0
        while projectile.getY() >= -5:
            time += .0005
            projectile.update(time)
            tracker.update()

    #Calculate if cannonball hit target
            points = target.points()
            center = tracker.circ.getCenter()
            center_x = center.getX()
            center_y = center.getY()
            radius = tracker.circ.getRadius()
            for point in points:
                x = point.getX()
                y = point.getY()
                square_dist = (center_x-x) ** 2 + (center_y-y) ** 2
                if square_dist <= radius ** 2:
                    targetHit = True
        if targetHit:
            print ("\nYou hit the target!")
            flag = True
        else:
            flag = False
            print ("\nTry again!")


    #Close window
    win.getMouse()
    win.close()
開發者ID:MichelleJaeg,項目名稱:Exercises-from-Chapter-10,代碼行數:54,代碼來源:338.16.py

示例3: main

# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import update [as 別名]
def main():

    options, files = getopt.getopt(sys.argv[1:], 'ivt:', ['info', 'verbose', 'threads:'])

    for flag, value in options:
        if flag == '-v' or flag == '--verbose':
            configuration['verbose'] = True
        elif flag == '-t' or flag == '--threads':
            try:
                configuration['threads'] = int(value)
            except:
                usage()
        elif flag == '-i' or flag == '--info':
            configuration['info'] = True
        else:
            usage()

    if len(files) != 1:
        usage()

    try:
        torrent = Torrent(files[0])
    except:
        print 'Impossible to read torrent file/magnet link:', files[0]
        exit(1)

    if configuration['info'] == True:
        torrent.show()
        exit(0)

    torrent.start()

    generate_clientid()

    tracker = Tracker(torrent.data['announce'])
    tracker.update(torrent)

    swarm = Swarm()
    swarm.update_peers(tracker)

    threads = configuration['threads']
開發者ID:guillermobox,項目名稱:bget,代碼行數:43,代碼來源:bget.py

示例4: float

# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import update [as 別名]
a.home_altitude  = float(v[2])
a.altitude       = a.home_altitude
a.yaw            = float(v[3])
a.latitude = a.home_latitude
a.longitude = a.home_longitude

a.set_yaw_degrees(a.yaw)

print("Starting at lat=%f lon=%f alt=%f heading=%.1f" % (
    a.home_latitude,
    a.home_longitude,
    a.altitude,
    a.yaw))

frame_time = 1.0/opts.rate
sleep_overhead = 0

while True:
    frame_start = time.time()
    sim_recv(state)
    a.update(state)
    sim_send(a)
    t = time.time()
    frame_end = time.time()
    if frame_end - frame_start < frame_time:
        dt = frame_time - (frame_end - frame_start)
        dt -= sleep_overhead
        if dt > 0:
            time.sleep(dt)
        sleep_overhead = 0.99*sleep_overhead + 0.01*(time.time() - frame_end)
開發者ID:0919061,項目名稱:ardupilot,代碼行數:32,代碼來源:sim_tracker.py

示例5: App

# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import update [as 別名]
class App(object):
	"""Manage application controllers, respond to user input, run master loop.

	This class wraps together the various components of the application. It is
	the application entry point. On startup, it creates an instance of each
	controller. The run() method starts each controller and runs the master loop
	until the user quits.

	Settings:
		experimentName: used to label the output directory and in output metadata
		keyBindings: a dictionary where the keys are 'quit', 'toggleStimulator',
			and 'triggerStimulator', and the values are one-character strings
			representing the button that triggers the action specified by the key
		outputRootDir: directory where the folder containing trial data will be
			created
	"""

	def __init__(self, **kwargs):
		"""Initialize the keycode bindings and all controllers, create output dir."""
		settings = {
			'experimentName' : 'someNameHere',
			'outputRootDir' : os.path.normpath(os.path.expanduser("~/kauferdata")),
			'keyBindings' : {
				'quit' : 'q',
				'toggleStimulator' : 't',
				'triggerStimulator' : 's'
				},
			'audio' : {},
			'gui' : {},
			'stimulator' : { 'activeProtocolName' : 'nucleusAccumbensExample' },
			'tracker' : {},
			'videoIn' : {},
			'videoOut' : {},
			'writer' : {},
			}
		settings.update(kwargs)
		trialDir = "{0}_{1}_{2}".format(time.strftime("%y%m%d%H%M%S"),
				settings['experimentName'], settings['stimulator']['activeProtocolName'])
		settings['outputDataDir'] = os.path.join(settings['outputRootDir'], trialDir)
		self.keyBindings = settings['keyBindings']
		self.keycodeBindings = {k: getattr(opencvgui.keycodes, v)
				for k,v in self.keyBindings.items() }
		os.makedirs(os.path.join(settings['outputDataDir'], 'audio'))
		self.writeExperimentData(settings)
		for x in ['audio', 'videoOut', 'writer']:
			kwargs[x] = {} if not kwargs.has_key(x) else kwargs[x]
			kwargs[x]['outputDataDir'] = settings['outputDataDir']

		# gui and writer both need a reference to the app instance because they
		# draw on the state of so many other controllers
		self.audio = Audio(**settings['audio'])
		self.gui = Gui(self, **settings['gui'])
		self.stimulator = Stimulator(**settings['stimulator'])
		self.tracker = Tracker(**settings['tracker'])
		self.videoIn = VideoIn(**settings['videoIn'])
		self.videoOut = VideoOut(**settings['videoOut'])
		self.writer = Writer(self, **settings['writer'])

	def run(self):
		"""Respond to user input and run the master application loop.

		This method has three basic sections. Before the loop starts, the start()
		method is called on all controllers. The central loop calls update() on
		each controller until it is terminated by a user-issued quit keystroke.
		Keystrokes are listened for at the start of each loop iteration.
		"""
		self.printKeybindings()
		self.startTime = self.lastTime = time.clock()
		self.audio.start()
		self.gui.start()
		self.stimulator.start()
		self.tracker.start()
		self.videoIn.start()
		self.videoOut.start()
		self.writer.start()

		while True:

			# respond to user input
			lastKeyStroke = cv2.waitKey(20)  # 20 is the number of ms to wait for key
			if lastKeyStroke != -1: # -1 means there was no keystroke
				if lastKeyStroke == self.keycodeBindings['quit']:
					break
				if lastKeyStroke == self.keycodeBindings['triggerStimulator']:
					self.stimulator.trigger()
				if lastKeyStroke == self.keycodeBindings['toggleStimulator']:
					self.stimulator.toggle()

			# update state
			self.currTime = time.clock()
			self.totalTimeElapsed = self.currTime - self.startTime
			self.audio.update()
			self.videoIn.update()
			self.tracker.update(self.videoIn, self.currTime)
			self.stimulator.update(self.currTime, self.tracker)
			self.videoOut.update(self.videoIn, self.tracker, self.stimulator)
			self.gui.update()
			self.lastTime = self.currTime
			self.writer.update()

#.........這裏部分代碼省略.........
開發者ID:smackesey,項目名稱:kaufer_prosocial,代碼行數:103,代碼來源:app.py

示例6: __init__

# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import update [as 別名]
class Cannon:


    def __init__(self, window):

        self.gwin = window

        self.projectile = Projectile(0, 0, 10)
        self.tracker = Tracker(self.gwin, self.projectile)
        self.target = Target(self.gwin)
        self.hits = False


    def shoot(self, angle, speed):
        """Shoots projectile at desired angle and speed"""

        # Calculate initial values speed across x and y axis and airtime
        xspeed = speed * math.cos(math.radians(angle))
        yspeed = speed * math.sin(math.radians(angle))
        hangtime = 2 * yspeed / G

        # Delay
        dtime = 0.001 

        while hangtime > 0:
            avg_yspeed = (yspeed + yspeed - G * dtime) / 2
            dx = xspeed * dtime
            dy = avg_yspeed * dtime
            time.sleep(dtime)
            self.projectile.move(dx, dy)
            self.tracker.update()
            if self.__hits_target():
                self.hits = True
                break
            yspeed -= G * dtime
            hangtime -= dtime


    def reset(self):
        """Reset projectile to its initial position"""
        
        self.projectile.move(-self.projectile.get_x(), -self.projectile.get_y())
        self.tracker.update()
        self.hits = False


    def __hits_target(self):
        """Helper function that returns true if projectile hits the target,
        false otherwise.
        """

        # Get current coordinates of projectile and its radius
        pj_radius = self.projectile.get_radius()
        pj_xcoord = self.projectile.get_x()
        pj_ycoord = self.gwin.height - self.projectile.get_y()

        # Get outer-most coordinates of target
        tg_xmin = self.target.get_xmin()
        tg_xmax = self.target.get_xmax()
        tg_ymin = self.target.get_ymin()
        tg_ymax = self.target.get_ymax()

        '''Test if projectile 'hits' target using circle's equation
               x^2 + y^2 = r^2
        '''
        step = pj_radius / 10
        start, stop = pj_ycoord + pj_radius, pj_ycoord - pj_radius
        if stop < tg_ymax:
            stop = tg_ymax
        while start > stop:
            x1_at_y = pj_xcoord + math.sqrt(pj_radius**2 - (start-pj_ycoord)**2)
            x2_at_y = pj_xcoord - math.sqrt(pj_radius**2 - (start-pj_ycoord)**2)
            test_x1 = x1_at_y >= tg_xmin and x1_at_y <= tg_xmax
            test_x2 = x2_at_y >= tg_xmin and x2_at_y <= tg_xmax
            if (test_x1 or test_x2) and pj_ycoord+pj_radius >= tg_ymax:
                return True
            start -= step

        return False
開發者ID:AigarsG,項目名稱:zelle,代碼行數:81,代碼來源:cannon.py

示例7: Config

# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import update [as 別名]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from tracker import Tracker
from config import Config
from outputs.json_output import JsonOutput
from outputs.colored_shell import ColoredShell
from outputs.raw import RawText

if __name__ == '__main__':
    config = Config()
    out = {'json': JsonOutput,
           'colored-shell': ColoredShell,
           'raw': RawText}.get(config.output_style)(config)
    t = Tracker(config, out)

    if config.update:
        t.update()

    if config.find_changes:
        t.find_changes()
開發者ID:duffy151,項目名稱:amazon-wishlist-pricetracker,代碼行數:32,代碼來源:track.py

示例8: main

# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import update [as 別名]
def main():
	# Draw the window to simulate green field and sky.
	
	win = GraphWin("Shoot a Cannon!", 850,850)
	win.setCoords(0,-50,700,700)
	win.setBackground("lightblue")
	ground = Rectangle(Point(0,-100),Point(700,0))
	ground.setFill("green")
	cloud1 = Oval(Point(153,420),Point(390,580))
	cloud1.setFill("white")
	cloud1.setWidth(2)
	cloud2 = Oval(Point(23,232),Point(230,400))
	cloud2.setFill("white")
	cloud2.setWidth(2)
	cloud3 = Oval(Point(434,370),Point(610,520))
	cloud3.setFill("white")
	cloud3.setWidth(2)
	tangle = Text(Point(30,680), "     Angle: ")
	tvel = Text(Point(30,650), "Velocity:")
	anginp = Entry(Point(70,680),3)
	velinp = Entry(Point(70,650),3)
	fbutton = CButton(win,Point(55,590),30,"FIRE!")
	fbutton.activate()
	quitbutton = CButton(win,Point(630,660),30,"Quit")
	quitbutton.activate()
	ground.draw(win)
	cloud1.draw(win)
	cloud2.draw(win)
	cloud3.draw(win)
	tangle.draw(win)
	tvel.draw(win)
	anginp.draw(win)
	anginp.setText("0")
	velinp.setText("0")
	velinp.draw(win)
	target = Target(win)
	
	
	
	
	
	pt = win.getMouse()
	shots = 0
	while not quitbutton.clicked(pt):
		try:
			if fbutton.clicked(pt):
			
				ang = float(anginp.getText())
				vel = float(velinp.getText())
				
				shot = Projectile(ang,vel,0)
				ball = Tracker(win,shot)
				
				
				
					
				
				while shot.getY() >= 0 and target.Hit(shot) == False and shot.getX() < 750:
					sleep(.025)
					shot.update(.1)
					ball.update(win,shot)
					target.Hit(shot)
					
					
					if target.Hit(shot) == True:
						shots += 1
						wintxt = Text(Point(325,500), "You Hit the Target in %d shot(s)!" % shots)
						wintxt.setSize(36)
						wintxt.setTextColor("red")
						wintxt.draw(win)
						exit
					
				shots += 1
		except ValueError:
			exit
			
			
		
		pt = win.getMouse()
開發者ID:synertia,項目名稱:CannonShooter,代碼行數:81,代碼來源:vcball.py


注:本文中的tracker.Tracker.update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。