gladevcp crashes with a segfault after working properly
from stl import mesh
from mpl_toolkits import mplot3d
from matplotlib import pyplot
def __init__(self, halcomp,builder,useropts):
self.halcomp = halcomp
self.builder = builder
self.nhits = 3
figure = pyplot.figure()
axes = figure.gca(projection='3d')
your_mesh = mesh.Mesh.from_file('HalfDonut.stl')
axes.add_collection3d(mplot3d.art3d.Poly3DCollection(your_mesh.vectors, facecolors='b', edgecolor='k', linewidth=0.2))
# Auto scale to the mesh size
scale = your_mesh.points.flatten(-1)
axes.auto_scale_xyz(scale, scale, scale)
self.axes = axes
this basically works fine. Means: When axis comes up there is my new tab inside axis with my gladevcp UI and a separate window displaying a 3D Plot from matplotlib.
In my tab there is a button with an event handler that just changes the parameter dist (zoom factor of the separate window's 3D Plot) and send a signal to redraw:
print "on_button_press called"
self.nhits += 1
# Show the plot to the screen
self.axes.dist = self.nhits
this often works fine. The zoom factor is changed and the 3D Plot redrawed in the separate window but sometimes it crashes - means I can press the button several times and it works but when pressing again the separate window disappears and the gladevcp tab inside axis is blanked out - there is nothing in the tab any more. Looking at DMESG it brings up an error:
gladevcp: segfault at c ip 080b65ab sp bfcb2f10 error 4 in python2.7[8048000+245000]
Probably there is not somebody using the same combination of gladevcp + matplotlib + numpy but maybe this looks familiar to you and somebody can give me a hint what is going wrong.
Does the gladevcp loosing somehow a handle to the other window and the garbage collector is deleting my 3D plot instance - maybe a stupid comment.
Would be nice if somebody with more experience in gladevcp can help me here since I need the matplotlib to visualize where I am with my robot on linuxcnc in a 3D model.
That makes it fairly easy to connect joint positions to the model, and the zoom / pan etc functions are built in to the display.
sounds like a good alternative. I was using matplotlib because it is easy to use from a numpy-stl model and I anyhow do the calculation with numpy and loading data with numpy-stl.
The Robot models I saw are created often by a few basic shapes (cylinder, ...) but my model consiting of STL files (many triangles). Do you know if there is experience with vismach and 10K to 100K triangles? Does it perform well? This is also were I got issues with matplotlib. Meanwhile I found a setup with less crashes but performance is good for models of a few thousand of triangles but poor for more.
robottom wrote: Do you know if there is experience with vismach and 10K to 100K triangles?
I don't know, I haven't tried it.
I would argue that for visualisation you don't _need_ 100k triangles, though.
The sim/axis/vismach/vmc_toolchange config uses STL files, just make a copy and replace the files with your files. It will look wrong and will animate wrongly, but you will get an idea of the quality of the rendering
thanks a lot for the perfect hint with exchanging the stl file. This is an easy test. I did it with an stl file of 35k faces and the model is extremly fast (opening, rotating, ...).
I checked the vismach page you linked above and the examples. It looks like vismach is just created for the purpose of machine simulations. Is there an underlying visualization tool and data model that I can access. There are several features I use in the combination of numpy, numpy-stl and matplotlib like:
- accessing/looping through the faces and calculating on the vertices
- accessing the normals of faces (calculated by numpy-stl)
- plotting additional marker in the 3D object (normals visualization, boxes surrounding the TCP position in the model)
- manipulating the view from a glacevcp UI inputs (buttons, values, ...)
At the first glance it looks like this is not easily possible since the vismach is more closed than my current approach.
I would love to work with vismach since it looks good, much faster rendering, ...
robottom wrote: I checked the vismach page you linked above and the examples. It looks like vismach is just created for the purpose of machine simulations. Is there an underlying visualization tool and data model that I can access.
Not that I know of, as far as I know it is only intended for machine visualisation, not for any advanced analysis.
I think it is probably just a thin layer over OpenGL.
The source code, is, of course, available for inspection:
How should I update the glade to test it?
@Andy: I'm trying to figure out if vismach is an alternative. I did the test in the toolchanger example as stated above. This was working fine. But when I try this in the puma560 simulation my stl-file is not comming up. I copied the puma560gui.py into the folder, changed the call in the .hal file. When I simply add the .stl file nothing is dispalyed. When I change the link1 (original file link1.obj with torso.stl) by:
link1 = AsciiSTL(filename="torso.stl");
#link1 = AsciiOBJ(filename="puma_link1.obj");
link1 = Color([0.18,0.19,0.2,1],[link1])
link1 = Rotate([link1], 180,0,0,1)
There is simply the link1 missing in vismach but not exchanged with torso.stl.
I checked link1.obj and torso.stl in meshlab (dimensions, position, ...) so it is simply not hidden somewhere. All that looks good (torso is 2 times bigger).
In the toolchanger example the .stl-File is correctly displayed in the model. What is different with the puma560gui.py? The code is used (otherwise the link1.obj would not be missing in the vismach display)??
My goal at the end is to have the additional .stl displayed in the view together with the robot simulation. This would be great.
Many thanks again.
But still the first question would be of interest.