当前位置: 首页>>代码示例>>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;未经允许,请勿转载。