Extending/ replacing Lua in V-rep

Typically: "How do I... ", "How can I... " questions
Post Reply
atoz
Posts: 50
Joined: 18 Oct 2013, 09:02

Extending/ replacing Lua in V-rep

Post by atoz » 06 Dec 2017, 17:55

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

atoz
Posts: 50
Joined: 18 Oct 2013, 09:02

Re: Extending/ replacing Lua in V-rep

Post by atoz » 07 Dec 2017, 13:57

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

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

Re: Extending/ replacing Lua in V-rep

Post by coppelia » 10 Dec 2017, 21:27

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

Post Reply