

try:
    import vrep
except:
    print ('--------------------------------------------------------------')
    print ('"vrep.py" could not be imported. This means very probably that')
    print ('')

import time

print ('Program started')
vrep.simxFinish(-1) # just in case, close all opened connections
clientID=vrep.simxStart('127.0.0.1',19999,True,True,5000,5) # Connect to V-REP
if clientID!=-1:
    print ('Connected to remote API server')

    # Now try to retrieve data in a blocking fashion (i.e. a service call):
    res,objs=vrep.simxGetObjects(clientID,vrep.sim_handle_all,vrep.simx_opmode_blocking)
    if res==vrep.simx_return_ok:
        print ('Number of objects in the scene: ',len(objs))
    else:
        print ('Remote API function call returned with error code: ',res)

    time.sleep(2)

    # Now retrieve streaming data (i.e. in a non-blocking fashion):
    startTime=time.time()
    vrep.simxGetIntegerParameter(clientID,vrep.sim_intparam_mouse_x,vrep.simx_opmode_streaming) # Initialize streaming
    while time.time()-startTime < 5:
        returnCode,data=vrep.simxGetIntegerParameter(clientID,vrep.sim_intparam_mouse_x,vrep.simx_opmode_buffer) # Try to retrieve the streamed data
        if returnCode==vrep.simx_return_ok: # After initialization of streaming, it will take a few ms before the first value arrives, so check the return code
            print ('Mouse position x: ',data) # Mouse position x is actualized when the cursor is over V-REP's window
        time.sleep(0.005)

    # Now send some data to V-REP in a non-blocking fashion:
    vrep.simxAddStatusbarMessage(clientID,'Hello V-REP!',vrep.simx_opmode_oneshot)

    # Before closing the connection to V-REP, make sure that the last command sent out had time to arrive. You can guarantee this with (for example):
    vrep.simxGetPingTime(clientID)

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

# Copyright 2006-2016 Coppelia Robotics GmbH. All rights reserved. 
# marc@coppeliarobotics.com
# www.coppeliarobotics.com
# 
# -------------------------------------------------------------------
# THIS FILE IS DISTRIBUTED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTY. THE USER WILL USE IT AT HIS/HER OWN RISK. THE ORIGINAL
# AUTHORS AND COPPELIA ROBOTICS GMBH WILL NOT BE LIABLE FOR DATA LOSS,
# DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR
# MISUSING THIS SOFTWARE.
# 
# You are free to use/modify/distribute this file for whatever purpose!
# -------------------------------------------------------------------
#
# This file was automatically created for V-REP release V3.3.0 on February 19th 2016

# Make sure to have the server side running in V-REP: 
# in a child script of a V-REP scene, add following command
# to be executed just once, at simulation start:
#
# simExtRemoteApiStart(19999)
#
# then start simulation, and run this program.
#
# IMPORTANT: for each successful call to simxStart, there
# should be a corresponding call to simxFinish at the end!
@@ -1,8 +1,1099 @@
+# Copyright 2006-2016 Coppelia Robotics GmbH. All rights reserved. %0A# marc@coppeliarobotics.com%0A# www.coppeliarobotics.com%0A# %0A# -------------------------------------------------------------------%0A# THIS FILE IS DISTRIBUTED %22AS IS%22, WITHOUT ANY EXPRESS OR IMPLIED%0A# WARRANTY. THE USER WILL USE IT AT HIS/HER OWN RISK. THE ORIGINAL%0A# AUTHORS AND COPPELIA ROBOTICS GMBH WILL NOT BE LIABLE FOR DATA LOSS,%0A# DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR%0A# MISUSING THIS SOFTWARE.%0A# %0A# You are free to use/modify/distribute this file for whatever purpose!%0A# -------------------------------------------------------------------%0A#%0A# This file was automatically created for V-REP release V3.3.0 on February 19th 2016%0A%0A# Make sure to have the server side running in V-REP: %0A# in a child script of a V-REP scene, add following command%0A# to be executed just once, at simulation start:%0A#%0A# simExtRemoteApiStart(19999)%0A#%0A# then start simulation, and run this program.%0A#%0A# IMPORTANT: for each successful call to simxStart, there%0A# should be a corresponding call to simxFinish at the end!
 %0A%0Atry:%0A 
@@ -3088,1095 +3088,4 @@
 ')%0A%0A
-# Copyright 2006-2016 Coppelia Robotics GmbH. All rights reserved. %0A# marc@coppeliarobotics.com%0A# www.coppeliarobotics.com%0A# %0A# -------------------------------------------------------------------%0A# THIS FILE IS DISTRIBUTED %22AS IS%22, WITHOUT ANY EXPRESS OR IMPLIED%0A# WARRANTY. THE USER WILL USE IT AT HIS/HER OWN RISK. THE ORIGINAL%0A# AUTHORS AND COPPELIA ROBOTICS GMBH WILL NOT BE LIABLE FOR DATA LOSS,%0A# DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR%0A# MISUSING THIS SOFTWARE.%0A# %0A# You are free to use/modify/distribute this file for whatever purpose!%0A# -------------------------------------------------------------------%0A#%0A# This file was automatically created for V-REP release V3.3.0 on February 19th 2016%0A%0A# Make sure to have the server side running in V-REP: %0A# in a child script of a V-REP scene, add following command%0A# to be executed just once, at simulation start:%0A#%0A# simExtRemoteApiStart(19999)%0A#%0A# then start simulation, and run this program.%0A#%0A# IMPORTANT: for each successful call to simxStart, there%0A# should be a corresponding call to simxFinish at the end!

add commit back (after rebase)