当前位置: 首页>>代码示例>>Python>>正文


Python Control.load方法代码示例

本文整理汇总了Python中Control.load方法的典型用法代码示例。如果您正苦于以下问题:Python Control.load方法的具体用法?Python Control.load怎么用?Python Control.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Control的用法示例。


在下文中一共展示了Control.load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Simulator

# 需要导入模块: import Control [as 别名]
# 或者: from Control import load [as 别名]
class Simulator(tk.Tk):
    def __init__(self, dt):
        self.WIDTH = 1000.0
        self.HEIGHT = 500.0
        self.time = 0.0
        self.dt = dt
                
        tk.Tk.__init__( self )
        
        self.drone = Drone(self.dt)
        #self.drone2 = Drone(self.dt)
        self.control = Control(self.drone)
        #self.control2 = Control(self.drone2)
        self.drone.setControl(self.control)
        #self.drone2.setControl(self.control2)     

        screen = tk.Frame(self)
        screen.pack()
        
        self.canvas = tk.Canvas(screen, width=self.WIDTH, height=self.HEIGHT,borderwidth=10)
        self.canvas.grid(column=1, row=1)
        
        self.infos = InfoPanel(screen, self.drone)
        self.infos.panel.grid(column=2, row=1)
        #self.infos2 = InfoPanel(screen, self.drone2)
        #self.infos2.panel.grid(column=3, row=1)
       
        # to receive commands
        screen.focus_set()  
        
        self.drone_ui = self.canvas.create_oval(40, self.HEIGHT, 50, self.HEIGHT-10, fill = "red")
        #self.drone2_ui = self.canvas.create_oval(100, self.HEIGHT, 110, self.HEIGHT-10, fill = "blue")       

        def onBtnUpHand(e):
            self.control.onBtnUp()

        def onBtnDownHand(e):
            self.control.onBtnDown()
            
        def onBtnLeftHand(e):
            self.control.onBtnLeft()
            
        def onBtnRightHand(e):
            self.control.onBtnRight()

        def onBtnAHand(e):          
            if self.control.switch == 0:
                self.control.setSwitch(1)
                self.control.load(self.control.stay, self.drone.pos)
                
        def onBtnRHand(e):
            self.control.reset()
            
        def onBtnGHand(e):                        
            if self.control.switch == 0:
                self.control.setSwitch(1)
                self.control.load(self.control.goto, [Vector(0,50), Vector(30,100)])
                
        def onBtnOHand(e):
            self.control.resetControl()

        screen.bind("<Up>", onBtnUpHand)
        screen.bind("<Down>", onBtnDownHand)
        screen.bind("<Left>", onBtnLeftHand)
        screen.bind("<Right>", onBtnRightHand)
        screen.bind("<a>", onBtnAHand)
        screen.bind("<r>", onBtnRHand)
        screen.bind("<g>", onBtnGHand)
        screen.bind("<o>", onBtnOHand)

    def simLoop(self):        
        self.drone.refreshPos()
        #self.drone2.refreshHeight()
        if self.control.switch == 1:
            self.control.run()
            
        #self.control2.load(self.control2.goto, [self.drone.height])
        #self.control2.run()
            
        self.canvas.coords(self.drone_ui, self.drone.pos.coords[0]+40, self.HEIGHT-self.drone.pos.coords[1], self.drone.pos.coords[0]+50, self.HEIGHT-10-self.drone.pos.coords[1])
        #self.canvas.coords(self.drone2_ui, 100, self.HEIGHT-self.drone2.height, 110, self.HEIGHT-10-self.drone2.height)

        self.infos.texts.setUiTexts()
        #self.infos2.texts.setUiTexts()
        
        self.after(int(1000*self.dt), self.simLoop)
开发者ID:ricsirke,项目名称:Drone-Simulation,代码行数:88,代码来源:Simulator.py

示例2: Drone

# 需要导入模块: import Control [as 别名]
# 或者: from Control import load [as 别名]
#################################


[16.095992229752056, [1.9969525844055631, 1.8381537599239324, 0.14317915448451723]]
[4.381782581030109, [2.007821556163127, 0.27615086577017367, 0.44609716664311955]]
[0, [1.2265485343557876, 1.9855714793925145, 0.033788504112233]]

"""

from Vector import *
from Drone import *
from Control import *

drone = Drone(0.05)
control = Control(drone)
control.load(control.stay, Vector( 0,50))
control.run()
drone.refreshPos()
control.setP([1.2265485343557876, 1.9855714793925145, 0.120788504112233])

droneRoute = []
time = 0

while (abs(control.error.len()) > 1 or abs(control.derror.len()) > 1 or abs(drone.speed.len()) > 1) and time < 2000:
    """while program is not empty -> convergence"""
    droneRoute.append(drone.pos.get())
    control.run()
    drone.refreshPos()
    time += 1
    
import matplotlib.pyplot as plt
开发者ID:ricsirke,项目名称:Drone-Simulation,代码行数:33,代码来源:Fly.py


注:本文中的Control.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。