Remote API to replace script functions

Typically: "How do I... ", "How can I... " questions
Post Reply
lumeqi
Posts: 29
Joined: 04 Dec 2023, 06:20

Remote API to replace script functions

Post by lumeqi »

Hello,
I don't want to write the code in the script of CoppeliaSim objects, but I want to write the configuration code in my project based on the ZeroMQ Remote API in Python. Is there any API that is similar to the different functions in the script, such as sysCall_actuation in the script. When setting up the inverse kinematics mode of the robotic arm, I wrote some code in this position. When I write the code in my Python project, what interface do I need to use to achieve the function similar to sysCall_actuation?
Thank you for your help.

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: Remote API to replace script functions

Post by coppelia »

Hello,

when running a ZeroMQ remote API client code, then you typically do not have those system callback function, e.g. sysCall_init, sysCall_actuation, sysCall_sensing, etc, since your client code will run in a different process from CoppeliaSim, and will be relatively independent. But you can run in stepping mode, and organize your code as in following example:

Code: Select all

from coppeliasim_zmqremoteapi_client import RemoteAPIClient

client = RemoteAPIClient()
sim = client.require('sim')
sim.setStepping(True)

# Place your 'init' code here:
...

sim.startSimulation()
while sim.getSimulationTime() < 3:
    # Place your 'actuation' code here:
    ...
    
    # Place your 'sensing' code here:
    ...
    
    sim.step()  # triggers next simulation step
    
sim.stopSimulation()
Note however that your code in the:
  • init section above will be executed in CoppeliaSim's sysCall_nonSimulation section
  • actuation section above will be executed in CoppeliaSim's sysCall_actuation section
  • sensing section above will also be executed in CoppeliaSim's sysCall_actuation section
Cheers

Post Reply