Home‎ > ‎Router‎ > ‎

Gridprobe to meshlab

LinuxCNC comes with some example G code programs. One of these is Gridprobe. These instructions are for how to use gridprobe and import the data into Meshlab to create a surface.

Gridprobe


Gridprobe is a very simple scanning routine that can be used with the $5 digitizing probe.
The top of the G code program contains the configuration of the scan. The configuration for scanning the 5C coin is as follows:

( Rectangular Probing                                                   )
(                                                                       )
( This program repeatedly probes in a regular XY grid and writes the    )
( probed location to the file 'probe-results.txt' in the same directory )
( as the .ini file                                                      )

(Configuration section)
G21   (mm)
F30    (probe speed)

#1=-5  (X start)
#2=0.1 (X increment)
#3=100 (X count)

#4=-5
#5=0.1
#6=100 (Y count)

#7=0 (Z safety)
#8=-2 (Z probe)
(End configuration section)

To use this program the needle is positioned just above the coin and the coordinates set to 0. The program lifts the needle to zero and then searches down at 30mm/min until the probe is triggered.
The results are written out to a file probe-results.txt. The name of this file can be changed. The filename is in the gridprobe file.


Meshlab

The probe-results.txt file looks like the following:

 0.000000 -0.000000 -0.872405 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
-0.000000 -0.000000 -0.872405 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
-0.000000 -0.000000 -0.872405 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
-0.000000 -0.000000 -0.872897 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
-0.000000 -0.000000 -0.871913 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
-0.000000 -0.000000 -0.869944 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000


The first three columns are the xyz coordinates. I am not sure what the other columns are for. I suspect that they would be populated if the machine had more axis.

We need to remove the last 6 columns. This we are going to do on a Windows PC. I transferred the file on a USB stick.

To remove the last 6 columns I loaded the file into notepad++ then used the search and replace function. Select the last 6 columns and select Search->Replace...


Replace all will remove the columns. Save the file but change it from a .txt file to .xyz as this is what meshlab will look for.

Run Meshlab. Select File->Import mesh. Select the .xyz file. You should be looking down on a grid of points.

We will use Meshlab to create a surface from this set of points.

  • Select Filters->Point set->Compute normals for point set
  • Select Filters->Point set->Surface reconstruction: Poisson

This creates a mesh surface

Select the Show layers tool and turn off viewing the .xyz layer.

To view the mesh layer rendered select the lightbulb and Flat lines icons. You should have the following view:

Meshlab is very powerful. When scanning an object it will probably be required to scan in objects in parts from different directions.

Multiple meshes can be imported, aligned and edited. The result can be exported and provide the input to a CAM program to generate the machine toolpaths or imported into another tool for further work.


Comments