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


Python vrep.simxStartSimulation函数代码示例

本文整理汇总了Python中vrep.simxStartSimulation函数的典型用法代码示例。如果您正苦于以下问题:Python simxStartSimulation函数的具体用法?Python simxStartSimulation怎么用?Python simxStartSimulation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(self):

        self.ip = '127.0.0.1'
        self.port = 19997
        self.scene = './simu.ttt'
        self.gain = 2
        self.initial_position = [3,3,to_rad(45)]

        self.r = 0.096 # wheel radius
        self.R = 0.267 # demi-distance entre les r

        print('New pioneer simulation started')
        vrep.simxFinish(-1)
        self.client_id = vrep.simxStart(self.ip, self.port, True, True, 5000, 5)

        if self.client_id!=-1:
            print ('Connected to remote API server on %s:%s' % (self.ip, self.port))
            res = vrep.simxLoadScene(self.client_id, self.scene, 1, vrep.simx_opmode_oneshot_wait)
            res, self.pioneer = vrep.simxGetObjectHandle(self.client_id, 'Pioneer_p3dx', vrep.simx_opmode_oneshot_wait)
            res, self.left_motor = vrep.simxGetObjectHandle(self.client_id, 'Pioneer_p3dx_leftMotor', vrep.simx_opmode_oneshot_wait)
            res, self.right_motor = vrep.simxGetObjectHandle(self.client_id, 'Pioneer_p3dx_rightMotor', vrep.simx_opmode_oneshot_wait)

            self.set_position(self.initial_position)
            vrep.simxStartSimulation(self.client_id, vrep.simx_opmode_oneshot_wait)

        else:
            print('Unable to connect to %s:%s' % (self.ip, self.port))
开发者ID:dtbinh,项目名称:mines_olp,代码行数:27,代码来源:vrep_pioneer_simulation.py

示例2: restart

    def restart(self,earlyStop = False):
        if (self.cid != None):
            vrep.simxStopSimulation(self.cid, self.mode())
            vrep.simxSynchronousTrigger(self.cid)
        vrep.simxFinish(-1)  # just in case, close all opened connections
        time.sleep(1)
        self.connect()
        time.sleep(1)

        vrep.simxLoadScene(self.cid, '/home/elias/[email protected]/_Winter2015/CSC494/Scenes/Base_Quad.ttt', 0, self.mode())
        if earlyStop:
            vrep.simxStopSimulation(self.cid, self.mode())
            vrep.simxSynchronousTrigger(self.cid)
            vrep.simxFinish(-1)  # just in case, close all opened connections
            return
        vrep.simxStartSimulation(self.cid, self.mode())
        self.runtime = 0
        err, self.copter = vrep.simxGetObjectHandle(self.cid, "Quadricopter_base",
                                               vrep.simx_opmode_oneshot_wait)
        err, self.target = vrep.simxGetObjectHandle(self.cid, "Quadricopter_target",
                                               vrep.simx_opmode_oneshot_wait)

        err, self.front_camera = vrep.simxGetObjectHandle(self.cid, 'Quadricopter_frontCamera', vrep.simx_opmode_oneshot)

        err, lin, ang = vrep.simxGetObjectVelocity(self.cid, self.copter, vrep.simx_opmode_streaming)
        self.getTargetStart()
        for i in range(4):
            self.propellerScripts[i] = vrep.simxGetObjectHandle(self.cid,
                                                            'Quadricopter_propeller_respondable' + str(i) + str(1),
                                                            self.mode())
开发者ID:Etragas,项目名称:GPSDrone,代码行数:30,代码来源:Simulation.py

示例3: reset_simulation

def reset_simulation(clientID):
    vrep.simxStopSimulation(clientID, vrep.simx_opmode_oneshot)
    time.sleep(1) # um pequeno sleep entre o stop e o start
    vrep.simxStartSimulation(clientID, vrep.simx_opmode_oneshot)
    for move in startMoves:
        JointControl(clientID, 0, Body, move)
        time.sleep(0.1)
开发者ID:TomasSQ,项目名称:vrepSimulation,代码行数:7,代码来源:algoritmos_geneticos_v1_runner.py

示例4: start_sim

 def start_sim(self):
     time.sleep(self.sleep_sec_min)
     vrep.simxStartSimulation(self.clientID, vrep.simx_opmode_oneshot)
     self.gripper_enabled = False
     self.__update_all_object_positions()
     self.cylinder_height = self.get_object_height(self.cylinder_handle)
     self.cylinder_z_locus = self.get_position(self.cylinder_handle)[2]
     self.bin_position = self.get_position(self.bin_handle)
开发者ID:anandsaha,项目名称:stash,代码行数:8,代码来源:robot.py

示例5: connect

 def connect(self):
     global SYNC
     self.cid = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)  # Connect to V-REP
     if self.cid != -1:
         print ('Connected to V-REP remote API serv'
                '\er, client id: %s' % self.cid)
         vrep.simxStartSimulation(self.cid, vrep.simx_opmode_oneshot)
         if SYNC:
             vrep.simxSynchronous(self.cid, True)
     else:
         print ('Failed connecting to V-REP remote API server')
         exit()
开发者ID:Etragas,项目名称:GPSDrone,代码行数:12,代码来源:Simulation.py

示例6: startsim

    def startsim(self):
        """
        Start the simulation in synchronous mode to achieve exact simulation
        independent of the framerate. To be able to do this, you have to 
        connec to the port 19997 of vrep, edit the file
        `remoteApiConnections.txt` to contain something like

            portIndex1_port           = 19997
            portIndex1_debug          = true
            portIndex1_syncSimTrigger = false

        """
        self.set_led(8,0)
        vrep.simxStartSimulation(self._clientID, vrep.simx_opmode_oneshot)
        vrep.simxSynchronous(self._clientID, True)
        self.stepsim(1)
开发者ID:RL-LDV-TUM,项目名称:epuck-vrep,代码行数:16,代码来源:ePuckVRep.py

示例7: wait_until_simulator_started

def wait_until_simulator_started(clientID):
    while True:
        try:
            if vrep.simxStartSimulation(clientID, vrep.simx_opmode_oneshot_wait) == vrep.simx_return_ok:
                break
        except KeyboardInterrupt:
            sys.exit('Program Ended')
开发者ID:RyoheiGoto,项目名称:inverted_pendulum,代码行数:7,代码来源:simulator.py

示例8: __init__

    def __init__(self, sim_dt=0.05, nengo_dt=0.001, sync=True):
        vrep.simxFinish(-1) # just in case, close all opened connections
        self.cid = vrep.simxStart('127.0.0.1',19997,True,True,5000,5)
        self.sync = sync

        if self.cid != -1:
            print ('Connected to V-REP remote API server, client id: %s' % self.cid)
            vrep.simxStartSimulation( self.cid, vrep.simx_opmode_oneshot )
            if self.sync:
              vrep.simxSynchronous( self.cid, True )
        else:
            print ('Failed connecting to V-REP remote API server')
            exit(1)
        self.count = 0
        self.sim_dt = sim_dt
        self.nengo_dt = nengo_dt
开发者ID:bjkomer,项目名称:nengo_vrep,代码行数:16,代码来源:robots.py

示例9: startSim

 def startSim(self, clientID, screen=True):
     vrep.simxSetIntegerParameter(clientID,vrep.sim_intparam_dynamic_engine,bulletEngine ,vrep.simx_opmode_oneshot_wait)
     vrep.simxSetFloatingParameter(clientID,vrep.sim_floatparam_simulation_time_step, simulatioTimeStepDT, vrep.simx_opmode_oneshot_wait)
     error=vrep.simxStartSimulation(clientID,vrep.simx_opmode_oneshot)
     if not screen:
         vrep.simxSetIntegerParameter(clientID,vrep.sim_intparam_visible_layers,2,vrep.simx_opmode_oneshot_wait)
         #vrep.simxSetBooleanParameter(clientID,vrep.sim_boolparam_display_enabled,0,vrep.simx_opmode_oneshot_wait)
     return error
开发者ID:PatriciaPolero,项目名称:lucy,代码行数:8,代码来源:Simulator.py

示例10: reset

 def reset(self):
     """In VREP we reset a simulation by stopping and restarting it"""
     eCode = vrep.simxStopSimulation(self._VREP_clientId, vrep.simx_opmode_oneshot_wait)  
     if eCode != 0:
         raise Exception("Could not stop VREP simulation")
     eCode = vrep.simxStartSimulation(self._VREP_clientId, vrep.simx_opmode_oneshot_wait)   
     if eCode != 0:
         raise Exception("Could not start VREP simulation")
     vrep.simxSynchronousTrigger(self._VREP_clientId)
开发者ID:dtbinh,项目名称:Homeo,代码行数:9,代码来源:SimulatorBackend.py

示例11: run

    def run(self):

        if self.clientID!=-1:
            _ = vrep.simxStartSimulation(self.clientID,vrep.simx_opmode_oneshot_wait)

            t0 = time.time()
            while time.time() - t0 < 30:
                for bot in self.bots:
                    bot.robotCode()
开发者ID:anandvgeorge,项目名称:team_ros_plays_football,代码行数:9,代码来源:matchplay.py

示例12: connection

 def connection(self):
     """
     Make connection with v-rep simulator
     """
     print ('Waiting for connection...')
     vrep.simxFinish(-1) # just in case, close all opened connections
     self.clientID=vrep.simxStart('127.0.0.1',self.port,True,True,5000,5) # Connect to V-REP
     if self.clientID!=-1:
         print ('Connected to remote API server')
         
         # enable the synchronous mode on the client:
         if self.synchronous:
             vrep.simxSynchronous(self.clientID,True)
         
         # start the simulation:
         vrep.simxStartSimulation(self.clientID,vrep.simx_opmode_oneshot_wait)
         
     else:
         raise IOError('Failed connecting to remote API server')
开发者ID:bchappet,项目名称:dnfpy,代码行数:19,代码来源:vRepSimulator.py

示例13: __init__

    def __init__(self):
        vrep.simxFinish(-1)  # just in case, close all opened connections
        time.sleep(0.5)
        self.clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5) # tenta conectar no simulador, se salva o clientID

        # paramos a simulacao, se estiver em andamento, e comecamos denovo
       # vrep.simxStopSimulation(self.clientID, vrep.simx_opmode_oneshot)
        #time.sleep(0.5)
        vrep.simxStartSimulation(self.clientID, vrep.simx_opmode_oneshot)

        # modo da API, como eh False, esta no modo assincrono(os ticks da simulacao rodam em velocidade independente)
        vrep.simxSynchronous(self.clientID, False)
        print("connected with id ", self.clientID)

        self.oldtarget = None
        self.camera = None

        self.setup()
        self.lastimageAcquisitionTime = 0
开发者ID:Williangalvani,项目名称:ninja-trex-opencv-quadcopter-token-tracker,代码行数:19,代码来源:interface.py

示例14: run

    def run(self):
        if self.clientID!=-1:
            if not self.multirobots:
                # Start simulation if MultiRobotRunner not already starting it
                _ = vrep.simxStartSimulation(self.clientID,vrep.simx_opmode_oneshot)
            self.robotCode()

        if not self.multirobots:
            # Stop VREP simulation cleanly if MultiRobotRunner not already stopping it
            self.clean_exit()
开发者ID:anandvgeorge,项目名称:team_ros_plays_football,代码行数:10,代码来源:base_robot.py

示例15: reset

 def reset( self ):
     err = vrep.simxStopSimulation(self.cid, vrep.simx_opmode_oneshot_wait)
     time.sleep(1)
     self.pos_err = [0,0,0]
     self.ori_err = [0,0,0]
     self.lin = [0,0,0]
     self.ang = [0,0,0]
     err = vrep.simxStartSimulation(self.cid, vrep.simx_opmode_oneshot_wait)
     if SYNC:
       vrep.simxSynchronous( self.cid, True )
开发者ID:Etragas,项目名称:GPSDrone,代码行数:10,代码来源:quadcopter.py


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