| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 732 人关注过本帖
标题:还是关于那个yield的问题,删去了部分不必要的程序,加了些注释,还望高手赐 ...
只看楼主 加入收藏
icebreaker_l
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-7-2
结帖率:0
收藏
 问题点数:0 回复次数:0 
还是关于那个yield的问题,删去了部分不必要的程序,加了些注释,还望高手赐教



import simplesim.configuration

from simplesim.Main.SimSetup import *

#we derive our simulation class from SimSetup.
class Pro_test(SimSetup):    #类定义
    """
  
   
    def setup_ManyEgos(self):   #这个函数产生5辆车,egoCar1.......egoCar5,并设置了相应的属性
        """
        Setup the ego object.
        """
        for i in range(1,6):
           #using static agents (un-movable)
           a = createAgent('Agents.StaticAgent','egoCar%d' % i)
   #        a.egoCarSetup = CarSetups.Mercedes_Sprinter(a)
           a.setMesh(self.egomesh)
           a.addWorld('AWEInterface',self.awemesh)
           a.setAweMaterial(self.matagentfile)
           a.addWorld('LogWorld','')
           a.setTrajectoryObject(NewPosition(random.randint(1, 30)+i*50,0,0,180,0,0))  

     
           


      
    def setup_Radar(self):        #函数设置了雷达的工作方式
        #create a new radar simulation (using datetime as identifier)
        self.aweComponent().setParam_useSimulation('date')
        #wait for simulation results
        self.aweComponent().setParam_openLoopSimulation(False)
        #show interaction points of radar paths and environment
        self.aweComponent().setParam_showInteractionPoints(False)
        #set raytracer options (trace depth etc.)
        self.aweComponent().setParam_options(AweDefaultOptions())   
        
        
    def sensorSetup(self):     # 传感器的设置
        if self.sensorActive:
            actSensor = self.createSensor('Agents.Sensors.AweSensor','awesens_tx')
            actSensor.setTrajectoryObject(NewPosition(-2.0,0.0,2.8))
            #actSensor.setXYZ(-2.0,0.0,2.8)
            actSensor.attachTo('egoCar4')  #这里是我想改变的地方
            actSensor.SetSampleTime(1)
            actSensor.deactivateReceiver()
            actSensor = self.createSensor('Agents.Sensors.AweSensor','awesens_rx')
            actSensor.setTrajectoryObject(NewPosition(-2.0,0.0,2.8))
            ##actSensor.setXYZ(-2.0,0.0,2.8)
            actSensor.attachTo('egoCar6')    #这里是我想改变的地方
            actSensor.SetSampleTime(1)
            actSensor.deactivateTransmitter()
            self.getApplication().setScreenShotMode(False)

            self.setup_Radar()

    def setup(self):    #设置好了仿真条件和变量
        """
        Setup the simulation. Add and configure agents, set simulation parameters, ...
        """
#        self.setup_Ego()
        self.setup_ManyEgos()
        self.setup_Terrain()
        self.setup_Camera()
#        self.sensorSetup()

    def simulate(self):
        """
        Simulation loop, defines simulation times in milliseconds.
        """
        #simulate 0 to 12 seconds in 20 ms steps
        for i in range(0,12000,20):            # 这里是我想问的地方,每过20ms后,我想改变sensorSetup里面设置
            yield i #calculate time step i        #这个yield到底该怎么用呢?
            print i #print something to stdout        

#import all simplesim packages
from importAll import *

#the "main" entry point:
if __name__ == "__main__":
    doSim(Pro_test())
是不是可以在def simulate(self):函数里,每次执行的时候调用sensorSetup(self): "egoCar"的ID值传过去呢?
搜索更多相关主题的帖子: yield 注释 删去 
2010-07-03 13:39
快速回复:还是关于那个yield的问题,删去了部分不必要的程序,加了些注释,还望 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015977 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved