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


Python Simulation.sync方法代码示例

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


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

示例1: get_sample

# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import sync [as 别名]
def get_sample(traj_dist,experiment_id):
    #Start a simulation and do the stuff
    functions = {}
    args = {}
    real_fun(functions)

    states = np.genfromtxt('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj'+str(experiment_id+1)+'state.txt', delimiter=',',dtype=np.float32)
    actions = np.genfromtxt('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj'+str(experiment_id+1)+'action.txt' ,dtype=np.float32)
    T,d = states.shape

    #Create simulation
    Sim = Simulation(function=functions["Traj{}".format(str(experiment_id+1))], args=[[0,0,3],0])
    Sim.restart()

    f = open('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj{}pred.txt'.format(experiment_id+1),'w+')
    r = open('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj{}residuals.txt'.format(experiment_id+1),'w+')

    for timestep in range(T):
        states[timestep,:] = normalize(state_norms[experiment_id],controller.getDif(Sim.cid,Sim.copter,Sim.target))
        old = actions[timestep,:].copy()
        actions[timestep,:] = denormalize(action_norms[experiment_id], get_action(traj_dist,states[timestep,:],timestep)[0])
        Sim.forward(actions[timestep,:].tolist())
        f.write(str(actions[timestep,:])+'\n')
        r.write(str(old-actions[timestep,:])+'\n')
        #Sim.forward()
        Sim.sync()
    print(vrep.simxStopSimulation(Sim.cid,vrep.simx_opmode_oneshot_wait))
    f.close()
    r.close()
    return states,actions
开发者ID:Etragas,项目名称:GPSDrone,代码行数:32,代码来源:lqr.py

示例2: real_fun

# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import sync [as 别名]
from Simulation import *
from function_names import *
import numpy as np
from numpy import *

functions = {}
args = {}
real_fun(functions)

states = genfromtxt('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj7state.txt', delimiter=',',dtype=float32)
actions = genfromtxt('/home/elias/[email protected]/_Winter2015/CSC494/Trajectories/Traj7action.txt' ,dtype=float32)


T,d = states.shape
#Create simulation
Sim = Simulation(function=functions["Traj7"], args=[[0,0,3],0])
Sim.restart()

for x in range(T):
    Sim.forward(actions[x,:].tolist())
    #Sim.forward()
    print(controller.getDif(Sim.cid,Sim.copter,Sim.target))
    print(actions[x,:])
    raw_input()
    Sim.sync()
开发者ID:Etragas,项目名称:GPSDrone,代码行数:27,代码来源:Sim_Demo.py


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