OcTree Plugin

Typically: "How do I... ", "How can I... " questions
formica
Posts: 52
Joined: 13 Mar 2013, 12:13

Re: OcTree Plugin

Post by formica » 10 Nov 2015, 12:18

ok, now it's the time of understanding how to draw inside the scene.
I'm using freeglut on ubuntu linux.
1. I guess that I have to skip glutInit(), glutCreateWindow and so on... so I need to understand how to insert my opengl code, through a plugin, inside the main loop of vrep, triggering with the sim_message_eventcallback_opengl inside v_repMessage.

2. I do not undersand how to pass data between my new Lua function callback and the event simulator callback (eventcallback_opengl). The Lua functions should turn on and off the Octree space decomposition, define the size, and mantain an handle.

Any advice is welcome.

cheers

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

Re: OcTree Plugin

Post by coppelia » 11 Nov 2015, 11:19

That's one of the reason why simAddDrawingObject is a bit simpler, you do not have to deal with openGl.

But if you go the other way like in your case, normally, you simply add following header:

Code: Select all

#include <GL/gl.h>
Then, when your callback gets called, you can simply use (for instance):

Code: Select all

glBegin(GL_POINTS);
glVertex3f(x,y,z);
...
glEnd();
Not sure if things would work ok with glut..

If you need to pass some parameters to the plugin from V-REP, then you need to create custom lua functions. Then, calling those functions, your plugin will be called-back, and in there, you can create an object, set parameters, etc. The rendering callback can then use those objects/parameters to do the proper rendering.

Take the example of the plugin located in programming/v_repExtVision: in there, several custom Lua functions are registered, and used from various simulation models (e.g. Models/components/sensors/anaglyphStereoSensor.ttm). Check also the child script attached to that model, specially the call simExtVision_handleAnaglyphStereo (which is a custom Lua function, registered by the v_repExtVision plugin).

Cheers

formica
Posts: 52
Joined: 13 Mar 2013, 12:13

Re: OcTree Plugin

Post by formica » 13 Nov 2015, 11:56

Hi coppelia,
I have done it.

https://drive.google.com/file/d/0B-tdcj ... sp=sharing

Now I would like to
1. make the structure DETECTABLE and COLLIDABLE.
2. export in the simulator one handle for any cube
3. how to create an handle for a custom opengl object?

Is it possible from the plugin?
I guess that I have to interact, in some way, with the phisics engine (at least for a collidable property).

Regards

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

Re: OcTree Plugin

Post by coppelia » 13 Nov 2015, 14:13

The best is to generate your own handles for your structure (or parts of the structure) in your plugin. But make that handle available via a custom Lua function, if you need to access/interact with it from a script.

Then you can create shapes (e.g. cubes) that have the properties you wish, on the fly, using for instance:
Then you might need to link the created shape's handle with its corresponding OcTree handle, or similar, depending on what you exactly want to do.

Cheers

formica
Posts: 52
Joined: 13 Mar 2013, 12:13

Re: OcTree Plugin

Post by formica » 13 May 2016, 18:34

Hi coppelia, I think that you did it faster than me! :D
Nice work!!

The new octree object in the BETA release are almost perfect for me... but I need some extra functionalities (retrieving the level of an octree node, labeling some node), so I need to access to the data structure...
Can I do this writing a plugin? Can you give me some insight?

Regards
formica

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

Re: OcTree Plugin

Post by coppelia » 16 May 2016, 06:50

Hello Roberto,

the functionality is located in the meshCalculationPlugin. As soon as version 3.3.1 will be out, you will be able to modify it. But we'll try until then to add that extra functionality, since it makes sense.

Cheers

formica
Posts: 52
Joined: 13 Mar 2013, 12:13

Re: OcTree Plugin

Post by formica » 16 May 2016, 09:15

Thanks Coppelia,
could you estimate when it will be released?

Regards
Roberto

formica
Posts: 52
Joined: 13 Mar 2013, 12:13

Re: OcTree Plugin

Post by formica » 17 May 2016, 12:12

WOW, V 3.3.1 is out!
Did you released the source code as well (or just the MeshCalc/Octree Plugin code)?

Regards

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

Re: OcTree Plugin

Post by coppelia » 17 May 2016, 17:19

Hello Roberto,

the source code for the octree structure and calculations is included in the mesh calculation plugin, its source code can be downloaded here.

We have added an option to some functions, so that you can provide a custom tag to each voxel. You can check the tag and also the voxel location via simCheckOctreePointOccupancy.

Cheers

formica
Posts: 52
Joined: 13 Mar 2013, 12:13

Re: OcTree Plugin

Post by formica » 18 May 2016, 17:29

Thanks for the feedback, coppelia.
I'm trying to use the new functionality, but I'm not able to retriev the tag with CheckOctreePointOccupancy

Code: Select all

if (sim_call_type==sim_childscriptcall_initialization) then
	
    octreeHandle = simGetObjectHandle('Octree')
    points = {0.5,0.5,0.5,0.6,0.6,0.6}
    colors = {255,255,0,0,0,255}
    tags = {150,200}
    simInsertVoxelsIntoOctree(octreeHandle,2,{0.3,0.3,0.3},{0,255,100},{100})
    simInsertVoxelsIntoOctree(octreeHandle,2,points,colors,tags)
    
end

if (sim_call_type==sim_childscriptcall_actuation) then

    result,tag,locationLow,locationHigh = simCheckOctreePointOccupancy(octreeHandle,1,{0.3,0.3,0.3},{100})
    print('-----')
    print(result)
    print(tag)
    print(locationLow)
    print(locationHigh)
    
end


if (sim_call_type==sim_childscriptcall_sensing) then


end


if (sim_call_type==sim_childscriptcall_cleanup) then

end
I obtain this output:

Code: Select all

-----
1
0
4035
0
Any idea?

Post Reply