Page 1 of 1

Extending/ replacing Lua in V-rep

Posted: 06 Dec 2017, 17:55
by atoz
Hi,

I'm looking to get a fullscreen screenshot programatically during simulation. To that end, I've found that I need to use WxLua which I've downloaded fromhere.

Now I'm wondering how do I need to arrange the the .dll, .exe & .lua files from the downloaded folder in the V-rep installation folder so that it uses wxLua rather than the original Lua? I read something about this in the vrep manual but I can't find it now.

Your help would be much appreciated. Thanks

Just to add, I've tried copying and pasting "wx.dll" into the V-rep directory root. Then running require("wx") gives the following error:

Code: Select all

Lua runtime error: error loading module 'wx' from file '.\wx.dll':
	%1 is not a valid Win32 application.

stack traceback:
	[C]: ?
	[C]: in function 'require'
	[string "SCRIPT Dummy"]:5: in main chunk

Re: Extending/ replacing Lua in V-rep

Posted: 07 Dec 2017, 13:57
by atoz
I've also tried the plugin route to create screenshots using the windows API in C++ but this seems to only work in non-fullscreen mode. The code I'm using looks like this:

Code: Select all

// copy screen to bitmap
    HDC     hScreen = GetDC(NULL);
    HDC     hDC     = CreateCompatibleDC(hScreen);
    HBITMAP hBitmap = CreateCompatibleBitmap(hScreen, abs(b.x-a.x), abs(b.y-a.y));
    HGDIOBJ old_obj = SelectObject(hDC, hBitmap);
    BOOL    bRet    = BitBlt(hDC, 0, 0, abs(b.x-a.x), abs(b.y-a.y), hScreen, a.x, a.y, SRCCOPY);
 
	// save bitmap to file
	CImage image;
	image.Attach(hBitmap);
	//std::cout << "File: " << filename.c_str() << "\n";
	image.Save(filename.c_str());
When V-rep is in fullscreen mode, only the first frame of the simulation is repeatedly saved. Is this because of lack of access to screen buffer during fullscreen? Thanks

Re: Extending/ replacing Lua in V-rep

Posted: 10 Dec 2017, 21:27
by coppelia
Hello,

yes, the fullscreen mode is currently a little bit buggy.
In order to use a different lua library than the default library, you will have to do simply replace the lua5.1.dll (or lua51.dll) in the V-REP folder with your new library. This should work if the other lua library has the exact same API signatures as the standard lua library. V-REP can also use a different lua library by setting variable useExternalLuaLibrary to true in system/usrset.txt. When you do this, it should use the lua51jit.dll instead. So this mechanism is also available.
But I have to admit I have no idea or experience with WxLua..

Cheers