Crash when compiling without Qt

Report crashes, strange behaviour, or apparent bugs
Post Reply
alrightyaphrodite
Posts: 1
Joined: 02 Jul 2018, 12:54

Crash when compiling without Qt

Post by alrightyaphrodite »

Hello,
I tried to run V-REP on a server, so I wanted to compile it without Qt. Loosely, I followed this guide. Things I did differently:
- replace `./programming/include` with this repo
- modify `makefile:14` to say `CFLAGS += "-I/usr/include/lua5.1"` (the path is my Lua include directory, where the .h files are)
- in `./v_rep/sourceCode/interfaces/v_rep_internal.cpp`, add `#include <algorithm>`, because it was complaining about `sort` not being in `std`

After these changes, V-REP compiled and when I copied libv_rep.so to the project root folder, it ran. However, V-REP seems to hang once the simulation has been stopped. I used the following code to test:

Code: Select all

import argparse
import atexit
import os
import time

import vrep

scene_path = "some_scene.ttt"  # Created in V-REP 3.4

opM_get = vrep.simx_opmode_blocking
opM_set = vrep.simx_opmode_oneshot
API_RETURN_CODES = ['simx_return_ok',
                    'simx_return_novalue_flag',
                    'simx_return_timeout_flag',
                    'simx_return_illegal_opmode_flag',
                    'simx_return_remote_error_flag',
                    'simx_return_split_progress_flag',
                    'simx_return_local_error_flag',
                    'simx_return_initialize_error_flag']


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--server-port', type=int, default=19997)
    args = parser.parse_args()

    cid = -1
    started = False
    loaded = False

    def on_exit():
        if started:
            check_result(vrep.simxStopSimulation(cid, vrep.simx_opmode_blocking))
            time.sleep(3)
            vrep.simxFinish(cid)

    atexit.register(on_exit)

    for it in range(3):
        cid = -1
        while cid == -1:
            print("Attempting to connect...")
            cid = vrep.simxStart(
                connectionAddress="127.0.0.1",
                connectionPort=args.server_port,
                waitUntilConnected=True,
                doNotReconnectOnceDisconnected=True,
                timeOutInMs=1000,
                commThreadCycleInMs=0)
            print("Connected with CID {}".format(cid))

        started = True
        vrep.simxSetIntegerSignal(cid, "sanity", 123, opM_set)
        assert check_result(vrep.simxGetIntegerSignal(cid, "sanity", opM_get))[0] == 123

        if not loaded:
            check_result(vrep.simxLoadScene(cid, scene_path, 0, vrep.simx_opmode_blocking))
            loaded = True

        vrep.simxSynchronous(cid, True)

        print("------ Starting simulation")
        check_result(vrep.simxStartSimulation(cid, vrep.simx_opmode_blocking))

        for j in range(3):
            print("Simulating")
            check_result(vrep.simxSynchronousTrigger(cid))

        print("Stopping simulation")
        check_result(vrep.simxStopSimulation(cid, vrep.simx_opmode_blocking))
        time.sleep(3)

        print("Checking")
        assert check_result(vrep.simxGetIntegerSignal(cid, "sanity", opM_get))[0] == 123
        print("Checked")
        vrep.simxFinish(cid)
        started = False

    print("Looks ok.")


def check_result(ret_tuple, tolerance=vrep.simx_return_novalue_flag):
    istuple = isinstance(ret_tuple, tuple)
    ret = ret_tuple[0] if istuple else ret_tuple
    if (ret != vrep.simx_return_ok) and (ret != tolerance):
        raise RuntimeError("Remote API return code: ({}: {})".format(
            ret, API_RETURN_CODES[ret.bit_length()]))

    return ret_tuple[1:] if istuple else None


if __name__ == '__main__':
    main()
When I run this with precompiled V-REP, it runs to the end. However with my compilation:

Code: Select all

Attempting to connect...
Connected with CID 0
------ Starting simulation
Simulating
Simulating
Simulating
Stopping simulation
Checking
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/me/vrep_sanity_check.py", line 95, in <module>
    main()
  File "/home/me/vrep_sanity_check.py", line 76, in main
    assert check_result(vrep.simxGetIntegerSignal(cid, "sanity", opM_get))[0] == 123
  File "/home/me/vrep_sanity_check.py", line 89, in check_result
    ret, API_RETURN_CODES[ret.bit_length()]))
RuntimeError: Remote API return code: (3: simx_return_timeout_flag)
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/home/me/vrep_sanity_check.py", line 35, in on_exit
    check_result(vrep.simxStopSimulation(cid, vrep.simx_opmode_blocking))
  File "/home/me/vrep_sanity_check.py", line 89, in check_result
    ret, API_RETURN_CODES[ret.bit_length()]))
RuntimeError: Remote API return code: (3: simx_return_timeout_flag)
Interestingly, when I run this again, the connection succeeds:

Code: Select all

Attempting to connect...
Connected with CID 0
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/me/vrep_sanity_check.py", line 95, in <module>
    main()
  File "/home/me/vrep_sanity_check.py", line 56, in main
    assert check_result(vrep.simxGetIntegerSignal(cid, "sanity", opM_get))[0] == 123
  File "/home/me/vrep_sanity_check.py", line 89, in check_result
    ret, API_RETURN_CODES[ret.bit_length()]))
RuntimeError: Remote API return code: (3: simx_return_timeout_flag)
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/home/me/vrep_sanity_check.py", line 35, in on_exit
    check_result(vrep.simxStopSimulation(cid, vrep.simx_opmode_blocking))
  File "/home/me/vrep_sanity_check.py", line 89, in check_result
    ret, API_RETURN_CODES[ret.bit_length()]))
RuntimeError: Remote API return code: (3: simx_return_timeout_flag)
V-REP's output is this:

Code: Select all

Using the default Lua library.
Add-on script 'vrepAddOnScript-addOnScriptDemo.lua' was loaded.
Simulator launched.
QCoreApplication::applicationFilePath: Please instantiate the QApplication object first
Plugin 'MeshCalc': loading...
Plugin 'MeshCalc': load succeeded.
Plugin 'BlueZero': loading...
Error with plugin 'BlueZero': load failed (could not load). The plugin probably couldn't load dependency libraries. For additional infos, modify the script 'libLoadErrorCheck.sh', run it and inspect the output.
Plugin 'BubbleRob': loading...
Plugin 'BubbleRob': load succeeded.
Plugin 'Bwf': loading...
Plugin 'Bwf': load succeeded.
Plugin 'Collada': loading...
V-REP runs in headless mode. Cannot start 'Collada' plugin.
Error with plugin 'Collada': load failed (failed initialization).
Plugin 'ConvexDecompose': loading...
Plugin 'ConvexDecompose': load succeeded.
Plugin 'CustomUI': loading...
Initialization failed, running in headless mode. Cannot start 'CustomUI' plugin.
Error with plugin 'CustomUI': load failed (failed initialization).
Plugin 'DynamicsBullet-2-78': loading...
Plugin 'DynamicsBullet-2-78': load succeeded.
Plugin 'DynamicsBullet-2-83': loading...
Plugin 'DynamicsBullet-2-83': load succeeded.
Plugin 'DynamicsNewton': loading...
Plugin 'DynamicsNewton': load succeeded.
Plugin 'DynamicsOde': loading...
Plugin 'DynamicsOde': load succeeded.
Plugin 'DynamicsVortex': loading...
Plugin 'DynamicsVortex': load succeeded.
Plugin 'ExternalRenderer': loading...
Plugin 'ExternalRenderer': load succeeded.
Plugin 'ICP': loading...
Plugin 'ICP': warning: replaced variable 'simICP'
Plugin 'ICP': load succeeded.
Plugin 'Image': loading...
Error with plugin 'Image': load failed (could not load). The plugin probably couldn't load dependency libraries. For additional infos, modify the script 'libLoadErrorCheck.sh', run it and inspect the output.
Plugin 'K3': loading...
Plugin 'K3': load succeeded.
Plugin 'LuaCommander': loading...
LuaCommander: cannot find the statusbar widget
Error with plugin 'LuaCommander': load failed (failed initialization).
Plugin 'LuaRemoteApiClient': loading...
Plugin 'LuaRemoteApiClient': load succeeded.
Plugin 'Mtb': loading...
Plugin 'Mtb': load succeeded.
Plugin 'OMPL': loading...
Plugin 'OMPL': warning: replaced variable 'simOMPL'
Plugin 'OMPL': load succeeded.
Plugin 'OpenMesh': loading...
Plugin 'OpenMesh': load succeeded.
Plugin 'PovRay': loading...
Plugin 'PovRay': load succeeded.
Plugin 'Qhull': loading...
Plugin 'Qhull': load succeeded.
Plugin 'RRS1': loading...
Plugin 'RRS1': load succeeded.
Plugin 'ReflexxesTypeII': loading...
Plugin 'ReflexxesTypeII': load succeeded.
Plugin 'RemoteApi': loading...
Starting a remote API server on port 19997
Starting a remote API server on port 20102
Plugin 'RemoteApi': load succeeded.
Plugin 'RosInterface': loading...
Error with plugin 'RosInterface': load failed (could not load). The plugin probably couldn't load dependency libraries. For additional infos, modify the script 'libLoadErrorCheck.sh', run it and inspect the output.
Plugin 'SDF': loading...
Plugin 'SDF': warning: replaced variable 'simSDF'
Plugin 'SDF': load succeeded.
Plugin 'SurfaceReconstruction': loading...
Plugin 'SurfaceReconstruction': warning: replaced variable 'simSurfRec'
Plugin 'SurfaceReconstruction': load succeeded.
Plugin 'Urdf': loading...
V-REP runs in headless mode. Cannot start 'Urdf' plugin.
Error with plugin 'Urdf': load failed (failed initialization).
Plugin 'Vision': loading...
Plugin 'Vision': load succeeded.
Using the 'MeshCalc' plugin.
Initializing the Bullet physics engine in plugin 'DynamicsBullet_2_78'...
Engine version: 2.78
Plugin version: 10
Initialization successful.
System: Linux Mint 17.3 (based on Ubuntu 14.04)
The scene loaded was created in V-REP 3.4.

Any ideas would be helpful. Because V-REP didn't output any error, I don't have much to go by anymore. Is there a way to enable some debugging messages when running headless?

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

Re: Crash when compiling without Qt

Post by coppelia »

Hello,

V-REP is hanging, not crashing, right? You can try to enabled a few of the debug variables in file system/usrset.txt, e.g. debugInternalFunctionAccess, debugCApiAccess or debugLuaApiAccess. MAybe that can tell us a bit more where...

Cheers

Post Reply