Coppeliasim Crash

Typically: "How do I... ", "How can I... " questions
Post Reply
hassan.farag
Posts: 8
Joined: 01 Sep 2020, 07:27

Coppeliasim Crash

Post by hassan.farag »

Hello there,

I have a message on Coppeliasim for crash asking to recover auto saved scene as shown in photo https://drive.google.com/file/d/1MTtsy ... sp=sharing. And there is no crash at all, I am just stopping the simulation and starting it each 3 seconds. I need a way to disable such dialog because it interrupts the plugin and afterwards the plugin hanged. If there is a better way to stop and start the simulation, you are welcome to let me know.

Code: Select all

void onInstancePass(const sim::InstancePassFlags &flags, bool first)
    {
    // _recording_time is 5 seconds
        if (simGetSimulationTime() == _recording_time)
        {
             simStopSimulation();
            // other code
            simStartSimulation();
        }
    }
In scene, we do the following in a child script:

Code: Select all

 
function sysCall_threadmain()
  while true do
        sim.setThreadAutomaticSwitch(false)
        // control code for joint (sim.getJointPosition(),sim.setJointTargetVelocity(),sim.setJointMaxForce())
        sim.switchThread()
    	end
end    	

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

Re: Coppeliasim Crash

Post by coppelia »

Hello,

why do you stop/restart the simulation from a plugin? This is something very specific, and you are probably much better off doing that task inside of an add-on, or best, inside of a customization script. See here for an example.

You can however suppress those messages by setting

Code: Select all

doNotShowCrashRecoveryMessage = true
in system/usrset.txt.

That dialog should however not show in that situation... what version of CoppeliaSim are you using?

Also, you can't stop and start a simulation in a sequence: stopping a simulation requires several additional, final, simulation steps to happen. So that will take some time. So you should always check whether your simulation has really stopped, before restarting it again. See the example code in the link above.

Cheers

hassan.farag
Posts: 8
Joined: 01 Sep 2020, 07:27

Re: Coppeliasim Crash

Post by hassan.farag »

Thanks for your answer. I am using 4.1 version. Which system callback to invoke to restart the simulation each specific period from herehttps://www.coppeliarobotics.com/helpFi ... mCallbacks ?

I want use such block of code inside system callback

Code: Select all

if sim.getSimulationTime==3.0 then
    sim.stopSimulation()
    sim.startSimulation()
    end
.

hassan.farag
Posts: 8
Joined: 01 Sep 2020, 07:27

Re: Coppeliasim Crash

Post by hassan.farag »

Okay, thanks for the link. we will give it a try.

hassan.farag
Posts: 8
Joined: 01 Sep 2020, 07:27

Re: Coppeliasim Crash

Post by hassan.farag »

Hello there,
I create customization script with the following function

Code: Select all

function sysCall_init()
 simRemoteApi.start(19998)
end
and in python (Legacy Remote, it is enough, no need for B0) like this:

Code: Select all

clientID = sim.simxStart('127.0.0.1', 19998, True, False,
                         5000, 5)
Now, I can stop and start the simulation from python and it works fine. But I have this error in console, despite sometimes it does not affect the remote connection and sometimes it hangs the connection.

Code: Select all

[link1@customizationScript:error]   7: Invalid port number. (in function 'simRemoteApi.start@simExtRemoteApi')
 stack traceback:
 [C]: in function 'start'
 [string "link1@customizationScript"]:7: in function <[string "link1@customizationScript"]:5>
In python, I use this code to close the connection in end of execution or keyboard interrupt:

Code: Select all

sim.simxGetPingTime(clientID)
sim.simxFinish(clientID)
How to overcome this error?

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

Re: Coppeliasim Crash

Post by coppelia »

If your customization script encounters an error, it will stop working. And that's when your remote API probably also stops working correctly.

Why don't you connect to the remote API server service that is running by default on port 19997? If you do that, you do not need to explicitly start that remote API server service as you currently do in your customization script.

Cheers

hassan.farag
Posts: 8
Joined: 01 Sep 2020, 07:27

Re: Coppeliasim Crash

Post by hassan.farag »

It works, thanks

Post Reply