BorisBogaerts / CoppeliaSim-VR-Toolbox

This repository contains the code to experience CoppeliaSim in VR
https://www.youtube.com/watch?v=yMydjviF7yg
BSD 3-Clause "New" or "Revised" License
35 stars 18 forks source link

Running steamvr in windows and coppeliasim in linux #2

Closed logxen closed 4 years ago

logxen commented 4 years ago

I would like to run steamvr in windows and coppeliasim in linux. Does this sound at all possible? I tried port forwarding 19997 which sort of worked but it quickly crashes while attempting to transfer the scene assets. :)

BorisBogaerts commented 4 years ago

Hi, I think it should be possible. The interface uses the standard remote API from coppeliaSim. But I have no experience with running coppeliaSim on a different computer.

Some questions:

logxen commented 4 years ago

VR works with coppeliaSim with everything running on the same windows computer. I'm not sure what you mean by remote API as such ... CoppeliaSim VR Interface connects and works as expected.

The console information actually looks pretty normal. And I'm not seeing a debug.log either. The error I get is in a window titled "vtkOutputWindow" where it says: ERROR: In C:\dev\VTK-8.2.0\src\IO\Image\vtkPNGReader.cxx, line 118 vtkPNGReader (0000017986392B20): Unable to open file

I also get these errors in the CoppeliaSim status area: Lua runtime error: ...oads/CoppeliaSim_Pro_V4_0_0_Ubuntu18_04/HTC_VIVE.lua:139: attempt to concatenate global 'tempName' (a nil value) stack traceback: ...oads/CoppeliaSim_Pro_V4_0_0_Ubuntu18_04/HTC_VIVE.lua:139: in function Error: [string -unknown location]:?: Call failed. (simCallScriptFunctionEx on getTextureInformation@HTC_VIVE) Lua runtime error: ...oads/CoppeliaSim_Pro_V4_0_0_Ubuntu18_04/HTC_VIVE.lua:139: attempt to concatenate global 'tempName' (a nil value) stack traceback: ...oads/CoppeliaSim_Pro_V4_0_0_Ubuntu18_04/HTC_VIVE.lua:139: in function Error: [string -unknown location]:?: Call failed. (simCallScriptFunctionEx on getTextureInformation@HTC_VIVE) Lua runtime error: ...oads/CoppeliaSim_Pro_V4_0_0_Ubuntu18_04/HTC_VIVE.lua:139: attempt to concatenate global 'tempName' (a nil value) stack traceback: ...oads/CoppeliaSim_Pro_V4_0_0_Ubuntu18_04/HTC_VIVE.lua:139: in function Error: [string -unknown location]:?: Call failed. (simCallScriptFunctionEx on getTextureInformation@HTC_VIVE)

logxen commented 4 years ago

Ok I just checked the end with powershell as requested ... no errors. it gets Everithing loaded successfully, Connected to VREP path, and then returns to command prompt. The vrepVIVE experience looks like it's starting to load but then stops and home starts again.

BorisBogaerts commented 4 years ago

Ok, thanks for the extra info.

My current understanding of the problem: I think the interface crashes due to missing texture info. The interface works by transferring all geometric information with the coppeliaSim remote API to the VR environment. From your information, it seems that the remote API is set up correctly and works well. The only problem is that textures are transferred with png files that are saved on a temporary location (in the filesystem that runs coppeliaSim). The implementation of this is based on a windows system. The Lua script in CoppeliaSim crashes because it runs on Linux (HTC_VIVE.lua:139 Error). And the interface cannot find the png file because it is a different system, and the texture did not save correctly (ERROR: Unable to open file). VTK than crashes because it tries to access a texture with a missing image.

Suggested fix: In the HTC_VIVE.lua script on the Linux computer in the coppeliaSim folder, comment out lines: 75 and 83-95. By commenting out these lines, the interface will not attempt to send texture files.

Fingers crossed that this fixes the problem!

logxen commented 4 years ago

That was basically my guess too but I had no clue where to start looking to do something about it.

Survey says: It now works and everything loads up with no textures. You rock! :)

So now do we have to tell the script to use forward slashes or is it a little more complicated than that? It might be useful for me to be able to specify a location for it to put those files (such as a network share on the other computer).

BorisBogaerts commented 4 years ago

Ah, that's nice.

Ok, I'll try to find some time to add an option to specify a folder manually. Now a lot of it is hardcoded (in the interface itself, not only the Lua script). So simply changing the folder in the Lua script won't be enough. I'll respond in this thread if I have fixed it, after which I will close the Issue.

BorisBogaerts commented 4 years ago

Okay, apparently I programmed things properly. Who would have thought that! So the only thing you need to do is change line 141 of the HTC_VIVE.lua script to the network location (in windows format). If you then change line 140 to the same location (in Linux format), it should work.

I don't think I will change anything in the main code since this problem is case-specific. People that try this should be able to find this tread.

Could you please confirm that this fix works then I can close this issue!

logxen commented 4 years ago

Noice, I haz textures now! Thanks so much!

For anyone else looking this up later ... I made a share of on the windows system running steamvr and mounted that share from the linux vm running coppeliasim. After restoring the lines you had me comment out previously I then commented out line 139 and put the full paths into lines 140 and 141 into the script on the linux vm running coppelliasim like so:

-- os.execute("mkdir " .. tempName.."\\CoppeliaSimVR") sim.saveImage(a.texture.texture,a.texture.resolution,1,"/mnt/coppeliatemp/textureTransfer.png",100) return {}, a.texture.coordinates, {"C:\\coppeliatemp\\textureTransfer.png"}, ''

For a bit more background ... the reason behind doing this is that steamvr obviously prefers to run on windows but on the other end of CoppeliaSim the rosinterface plugin that interfaces to ROS and physical robot hardware only runs on Linux. I think this was the simplest solution to this conundrum and has the added benefit of allowing steamVR and coppeliasim to run on separate PCs for performance reasons. Each are quite capable of using a whole computer by themselves.

Thanks again and congratulations on closing your 2nd issue. :)

snbagkar commented 3 years ago

Noice, I haz textures now! Thanks so much!

For anyone else looking this up later ... I made a share of on the windows system running steamvr and mounted that share from the linux vm running coppeliasim. After restoring the lines you had me comment out previously I then commented out line 139 and put the full paths into lines 140 and 141 into the script on the linux vm running coppelliasim like so:

-- os.execute("mkdir " .. tempName.."\\CoppeliaSimVR") sim.saveImage(a.texture.texture,a.texture.resolution,1,"/mnt/coppeliatemp/textureTransfer.png",100) return {}, a.texture.coordinates, {"C:\\coppeliatemp\\textureTransfer.png"}, ''

For a bit more background ... the reason behind doing this is that steamvr obviously prefers to run on windows but on the other end of CoppeliaSim the rosinterface plugin that interfaces to ROS and physical robot hardware only runs on Linux. I think this was the simplest solution to this conundrum and has the added benefit of allowing steamVR and coppeliasim to run on separate PCs for performance reasons. Each are quite capable of using a whole computer by themselves.

Thanks again and congratulations on closing your 2nd issue. :)

Can you provide descriptive steps as to how to connect Linux and SteamVR as I am a beginner in Coppeliasim? Thanks