Program crashes while using remote control

Report crashes, strange behaviour, or apparent bugs
Post Reply
Wet
Posts: 2
Joined: 10 Jun 2022, 10:23

Program crashes while using remote control

Post by Wet »

Hello, I'm using v4.1

In the scene, basically I'm producting some object at the start point of conveyor and at the end of the conveyor my robot (configured on IK mode and follows path) is picking object and placing some appropriate positions.;

In coppelia side everything is okey and program works with 0 error.

When I try to remote control by python, I can take and show my vision sensor image on python. Then I proccess the image, after that make my robot movements for image processing results.

Some program functions is not available on python side such as sim.followpath
I put my every single robot moves in seperate functions and I'm using "simxCallScriptFunction" method to call function.

I'm running coppelia first and then python, after taking and processing the image, program is freezing and shows nothing as an error. At this point I can not do anything with program(stopping scene etc.) and I have to reboot program.

I tried non parametic function and I also tried parametric type of function (I write down my robot moving codes on python as a string and then running the string as code on coppelia)

Both trials occurs same result --> Program is completely freezing and cant do anything.

What can be wrong or How can I fix the "freezing" problem?

Here is my codes on both sides and both methods

Image

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

Re: Program crashes while using remote control

Post by coppelia »

Hello,

not sure I completely understood, but it appears that you are trying to call a blocking function from your remote API client. This is not allowed. When calling a CoppeliaSim script function from an external application, you should execute some instructions, then return immediately.
You can however trigger a long-lasting computation, or an operation that stretches over several simulation steps, by simply e.g. setting a flag then returning immediately. The script, which should run in threaded mode, can then constantly check for that flag (and some additional parameters) and decide to start a longer operation.

Cheers

Wet
Posts: 2
Joined: 10 Jun 2022, 10:23

Re: Program crashes while using remote control

Post by Wet »

You're totally right, I was using "blocking" as operationmode on python then I realize that if my robot is moving when I call function from python, my robot has to move for 2 different code part and it causes program freezing without showing any error.

I'm using "one_shot" and I edit some part of my code to pretend moving for different functions at the same time. Finally, I solved all problems on both sides and my system works finely.

Thanks a lot. Best Regards.

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

Re: Program crashes while using remote control

Post by coppelia »

Best of course would be to use CoppeliaSim V4.3 and later, and the ZeroMQ remote API for Python: it is very easy to set-up, much easier to use, and offers all the same API functions as from within CoppeliaSim.
In CoppeliaSim V4.3 you can also find a demo scene in scenes/messaging/movementViaRemoteApi.ttt and its corresponding Python script that executes like in your case operations that lasts several time steps: programming/zmqRemoteApi/clients/python/sendMovementSequence-mov.py

Cheers

Post Reply