コード例 #1
0
    def reset(self):
        # 시물레이션 종료, 재시작
        vrep.simxSynchronous(self.vrep_client_id,True)
        print("ENV reset")
        vrep.simxStopSimulation(clientID=self.vrep_client_id,operationMode=vrep.simx_opmode_blocking)
        print('sim stopped')
        time.sleep(0.5)
        self.streaming()
        # 골넘버 초기화
        global goal_number
        goal_number = 0
        vrep.simxStartSimulation(clientID=self.vrep_client_id,operationMode=vrep.simx_opmode_blocking)
        print('sim started')
        time.sleep(0.2)
        # 골 거리 초기화
        self.goal_distance_calculate()
        vrep.simxSynchronousTrigger(self.vrep_client_id)
        vrep.simxSynchronousTrigger(self.vrep_client_id)
        vrep.simxSynchronousTrigger(self.vrep_client_id)
        vrep.simxSynchronousTrigger(self.vrep_client_id)
        time.sleep(1)
        # 라이다 데이터 수집
        self.getMinLidarData()

        
        return True
コード例 #2
0
from api import vrep
import sys
import time
import math

try:
    vrep.simxFinish(-1)  # just in case, close all opened connections
except:
    pass

clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)
if clientID != -1:
    print("Connected to remote API server")

    vrep.simxStopSimulation(clientID, operationMode=vrep.simx_opmode_blocking)

    _, handle = vrep.simxGetObjectHandle(clientID, 'dualarm_mobile',
                                         vrep.simx_opmode_blocking)
    time.sleep(1)

    vrep.simxSetObjectPosition(clientID, handle, -1, [0.0, 0.0, 0.1],
                               vrep.simx_opmode_blocking)
    time.sleep(1)

    vrep.simxSetObjectOrientation(clientID, handle, -1,
                                  [math.pi, math.pi / 2, 0.0],
                                  vrep.simx_opmode_blocking)
    time.sleep(1)

    #vrep.simxFinish(clientID)
    #time.sleep(1)
コード例 #3
0
    clientID=vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5) # Connect to V-REP

    if clientID != -1:
        print('Connected to remote API server')

        # enable the synchronous mode on the client:
        vrep.simxSynchronous(clientID, True)

        # start the simulation:
        vrep.simxStartSimulation(clientID,vrep.simx_opmode_blocking)
        vrep.simxSynchronousTrigger(clientID) # skip first timestep. LiDAR returns zero-size array at first timestep

        # get LiDAR measurement
        vrep.simxSynchronousTrigger(clientID)
        e, lrf = readLiDAR(clientID, 'measurement', opmode_blocking)

        # plot measurement
        theta = np.linspace(0, 2*np.pi, len(lrf))
        polarplot = plt.polar(theta, lrf)
        plt.show(polarplot)

        # stop the simulation:
        vrep.simxStopSimulation(clientID,vrep.simx_opmode_blocking)

        # Now close the connection to V-REP:
        vrep.simxFinish(clientID)
    else:
        print ('Failed connecting to remote API server')
    print ('Program ended')