Data Transfer (CoppeliaSim -> Python)

Typically: "How do I... ", "How can I... " questions
Post Reply
nadeenelhadad
Posts: 13
Joined: 28 Feb 2025, 06:37

Data Transfer (CoppeliaSim -> Python)

Post by nadeenelhadad »

Hello!

I've set up this catalyst-rl tutorial that uses CoppeliaSim 4.1 to perform reinforcement learning on a simple peg-in-hole task.
https://github.com/arrival-ltd/catalyst-rl-tutorial

My question is pretty direct. This repository uses PyRep to connect CoppeliaSim to an external python environment file. I was able to print the contact forces generated during simulation inside CoppeliaSim itself, but I need to return it to the python file to use it for different things.

Apparently, the only transfer module in 4.1 is b0 remote API (?). And apparently, I also can't transfer this force data through PyRep itself (?). Is there something I can use to do this?

Thanks!
coppelia
Site Admin
Posts: 10747
Joined: 14 Dec 2012, 00:25

Re: Data Transfer (CoppeliaSim -> Python)

Post by coppelia »

Hello,

CoppeliaSim V4.1 is old. Many things have changed and improved since then. But within that old framework, if you want to access additional infos from CoppeliaSim, then you can use any of the 2 following approaches:
  • Modify PyRep and add the missing function (e.g. simGetContactInfo). You'd start by modifying PyRep/pyrep/backend/lib.py
  • Otherwise, use the legacy rmote API or the B0-based remote API. This approach involves some communication overlay and will be slower than above first approach.
Cheers
nadeenelhadad
Posts: 13
Joined: 28 Feb 2025, 06:37

Re: Data Transfer (CoppeliaSim -> Python)

Post by nadeenelhadad »

Hi!

Thanks for getting back to me. I've used b0-based remote API. By slow, do you mean there's a lag between the simulation and python? Even in synchronized mode?

I have one more question: If I'm using b0-based remote API through the add-on, can I change the settings somehow so that it runs automatically every time CoppeliaSim launches instead of manually through the add-ons list?
In this link, it's said the way is to remove the sysCall_info() function in the lua script of the add-on, but it wasn't in that file in the first place.
https://manual.coppeliarobotics.com/en/ ... erSide.htm

I'm kind of "forced" to use CoppeliaSim 4.1 just because I'm working with a tutorial that's working with PyRep, so updating is a very restricting option for me considering the discrepancies.
And the PyRep modification tip is really helpful as well. I'll give it a try. But I want to see how far I can go with the b0 api.

Thanks!

Update: The PyRep repo doesn't have a lib.py but it does have a sim.py in the same folder you mentioned (which is the
one that contains the functions, I believe). And simGetContactInfo IS part of the implementation, apparently. Does that mean I can use it straight away?
coppelia
Site Admin
Posts: 10747
Joined: 14 Dec 2012, 00:25

Re: Data Transfer (CoppeliaSim -> Python)

Post by coppelia »

Update: The PyRep repo doesn't have a lib.py but it does have a sim.py in the same folder you mentioned (which is the
one that contains the functions, I believe). And simGetContactInfo IS part of the implementation, apparently. Does that mean I can use it straight away?
Then probably yes. We are no PyRep experts, and you'll have to try

You can have yur add-on start automatically, check the user manual related to version 4.1 and add-ons.

Cheers
Post Reply