Esempio n. 1
0
 def _get_signal(self, name, int_type=False):
     s = self._com(remote_api.simxGetStringSignal, name, get=True)
     if int_type:
         data = remote_api.simxUnpackInts(s)
     else:
         data = remote_api.simxUnpackFloats(s)
     return np.array(data)
Esempio n. 2
0
    cmdID = 1  # this command id means: 'display a text in a message box'
    cmdCnt = 0
    cmdData = b'Hello world!'
    dataToSend = getCmdString(cmdID, cmdCnt, cmdData)
    vrep.simxWriteStringStream(clientID, 'commandsFromRemoteApiClient',
                               dataToSend, vrep.simx_opmode_oneshot)
    replyData = waitForCmdReply(cmdCnt)
    if sys.version_info[0] == 3:
        replyData = str(replyData, 'utf-8')
    print('Return string: ', replyData
          )  # display the reply from V-REP (in this case, just a string)

    # 2. Now create a dummy object at coordinate 0.1,0.2,0.3:
    cmdID = 2  # this command id means: 'create a dummy at a specific coordinate with a specific name'
    cmdCnt = cmdCnt + 1
    cmdData = b'MyDummyName' + vrep.simxPackFloats([0.1, 0.2, 0.3])
    dataToSend = getCmdString(cmdID, cmdCnt, cmdData)
    vrep.simxWriteStringStream(clientID, 'commandsFromRemoteApiClient',
                               dataToSend, vrep.simx_opmode_oneshot)
    replyData = waitForCmdReply(cmdCnt)
    print(
        'Dummy handle: ',
        vrep.simxUnpackInts(replyData)[0]
    )  # display the reply from V-REP (in this case, the handle of the created dummy)

    # Now close the connection to V-REP:
    vrep.simxFinish(clientID)
else:
    print('Failed connecting to remote API server')
print('Program ended')
Esempio n. 3
0
#errorCode, signalValue = vrep.simxReadStringStream(clientID, 'dvsData', vrep.simx_opmode_streaming)
#time.sleep(5)
#errorCode, dvsSignal = vrep.simxReadStringStream(clientID, 'dvsData', vrep.simx_opmode_buffer)
#dvsSignalArray = vrep.simxUnpackInts(dvsSignal)
vrep.simxStartSimulation(clientID, vrep.simx_opmode_oneshot)

# Get events from DVS camera
errorCode, signalValue = vrep.simxReadStringStream(clientID, 'dvsData',
                                                   vrep.simx_opmode_streaming)
time.sleep(0.01)

# Synchronize and get DVS data
vrep.simxSynchronousTrigger(clientID)
errorCode, dvsSignal = vrep.simxReadStringStream(clientID, 'dvsData',
                                                 vrep.simx_opmode_buffer)
dvsSignalArray = vrep.simxUnpackInts(dvsSignal)
dvsEventsList = numpy.reshape(dvsSignalArray,
                              [int(len(dvsSignalArray) / 4), 4]).T

#Prepare figure to display the results
fig = plt.figure()
while (True):
    print('Receiving DVS data ...\n')
    errorCode, dvsSignal = vrep.simxReadStringStream(clientID, 'dvsData',
                                                     vrep.simx_opmode_buffer)
    dvsSignalArray = vrep.simxUnpackInts(dvsSignal)
    dvsEventsList = numpy.concatenate(
        (dvsEventsList,
         numpy.reshape(dvsSignalArray, [int(len(dvsSignalArray) / 4), 4]).T),
        1)