Page 1 of 1

Read from txt file

Posted: 14 May 2022, 10:16
by blackbird
Hi, i want to move robot by reading from txt file with python. How can i do that?

Re: Read from txt file

Posted: 16 May 2022, 11:30
by fferri

Code: Select all

#python

from zmqRemoteApi import RemoteAPIClient
client = RemoteAPIClient()
sim = client.getObject('sim')

with open('file.txt','rt') as f:
    for line in f:
        # do something with line
        # e.g. parse value then call sim.setJointTargetPosition

Re: Read from txt file

Posted: 17 May 2022, 07:22
by coppelia
Or, from within CoppeliaSim:

Code: Select all

#python

def sysCall_thread():
    with open('file.txt','rt') as f:
        for line in f:
            print(line)
Cheers

Re: Read from txt file

Posted: 17 May 2022, 11:06
by blackbird
Thanks...