• No se han encontrado resultados

2. Pruebas de aceptación y medidas para el comisionamiento

2.1 Instrumentación

In order to generate the enhanced voxelmaps, first, the surface voxel structure S is created in a similar fashion as the primitive pointshell: all triangles are traversed and the surface voxels in their bounding boxes are projected employing the methods explained in Section3.2.1. The sign of the distance in the surface voxels is determined by observing the direction of the vector that points from the voxel center C to the projected point with respect to the gradient of the voxel value (as computed in (3.12)): if the dot product of both is positive, the distance is negative, otherwise it is positive – recall that the gradient or normal vectors point inwards the object.

Second, the floating point distance structure W is created using S. All voxels are traversed and their closest surface voxel is computed performing iterative gradient descent in the discrete voxelmap, as illustrated in Figure3.5. Let C be the voxel center of a point P in an iteration, then the next P0 closer point to the surface will be

P0 = C + ξ∇s v(C) | {z } step length n(C) = C + ξ∇s v(C) ∇v(C) k∇v(C)k, (3.23)

where ξ∇= 0.8for the first iteration and ξ∇= 1.0for the successive ones (values obtained

Figure 3.5: Gradient or steepest descent in the voxelmap: The closest surface voxel of a voxel center C where a point Pi lies is found by moving in the direction of the voxel value gradient in C: n(C) = k∇v(C)k∇v(C) . The gradient is computed with the voxel values in the neighborhood of C, NV(C), as defined in (3.12). The magnitude of the step is given by the voxel size s weighted by σ, being ξ∇= 0.8 for the first iteration and ξ∇= 1.0 for the successive ones until a voxel with v = 0 is found. The distance from C to the triangle stored in the closest surface voxel found is computed as explained in Section 3.2.1. Triangles stored in the neighbor voxels of the closest surface voxel are also checked to minimize the limitations of the gradient descent in discrete coordinates. 0 0 -1 1 1 1 2 -1 -2 -2 -3 -3 -3 -3 -3 -3 -4 -4 -4 -4 -4 -4 -4 -5 P S X Y 1 2 3 4 5 6 1 2 3 4 5 6 7 C 0 -5 s 0

The computation finishes as soon as P0 lies in a voxel with v = 0 (surface voxel), which

usually occurs in 2 − 3 iterations. The default neighborhood is of width 3 (i. e., NV,1,

see (3.5)). Once the surface voxel is found, the closest surface point S is computed by projecting the original point (or voxel center) on the triangle defined by the vertices stored in the surface voxel, following the optimization method explained in Section3.2.1. Depending on the voxel size s (i. e., discretization factor), this heuristic could lead to incorrect surface voxels, particularly as the voxel layer value v(C) increases. In order to reduce that error, all the triangles associated to the surface voxels in the neighborhood of the closest surface voxel are checked, taking the one which yields the smallest distance value.

This gradient descent method is an essential function also integrated in the primitive voxelmap that can be used to deliver surface voxels associated to any point in space during online queries.

The generation complexity is worst case O(n+m), with n being the number of voxels and m the number of triangles. As in the case of primitive data structures, the factor m is negligible in regular situations, but it must be considered in case the object has large amounts of triangles and the chosen resolution is very small. Using a resolution of around s = 5 mm, usual generation times are of about 1 − 3 minutes for desktop-sized objects. The time required for creating an enhanced distance field will always be longer than the one of a primitive pointshell alone. In fact, generating a distance field consists in building (i) a primitive voxelmap, (ii) a structure similar to the pointshell (S), and, finally, (iii) a field with the same amount of elements as the primitive voxelmap but with more accurate and expensive computations per voxel (W).

As for the primitive data structures, enhanced voxelmaps can be saved in files for later use. If pre-computed gradient vectors and additional support information are stored per voxel, files sizes easily reach tens of megabytes for regular resolutions (s = 5 mm,

desktop-size objects). Exemplary computation time, file size and snapshots with varied resolutions (s) are provided in [SHPH08] and in Figure 3.16. The files size, and more importantly, the resulting memory footprint, are a clear limitation factor when it comes to choosing between primitive layered voxelmaps or floating points distance fields. It is worth to mention that in the latter enhanced voxelmaps only one triangle is registered per voxel. This is not relevant in regular situations (i. e., average triangle area at least bigger than s2), but it might lead to accuracy losses when the density of triangles per

voxel increases.

3.2.3.2 The Signed Distance Voxelmap Function V (P )

Given a point and its associated normal vector (P, n(P )), the signed distance voxelmap function V (P ) is defined to yield during realtime operations the signed distance of the point with respect to the surface encoded in the voxelmap. This signed distance can be the smallest Euclidean distance to collision (V (P ) ≤ 0, non colliding) or the point penetration value (V (P ) > 0, colliding) in the object modeled by the voxelmap. In the latter case, the penalty collision force fi and torque ti associated with the colliding single

point Pi (and its normal ni) of the pointshell are defined as spring-like forces that follow

Hooke’s law of elasticity:

fi = kPV (Pi)ni, ti =

−−→

GPi× fi, (3.24)

being kP the penalty stiffness gain and

−−→

GPi the vector from the center of mass (CoM)

of the pointshell G to the point Pi. In practice, in order to avoid computing the vector,

all poinsthell points are defined with respect to the center of mass (CoM) G, which is shifted to the origin (i. e., G = (0, 0, 0)T).

Three different implementations of the signed distance function are defined (in the order of increasing accuracy):

VL, distance function using layered voxel values (v),

VS, distance function employing the stored surface points (encoded in S), and

VI, distance function which interpolates the neighbouring floating point distance values

(enconded in W).

The layered distance function, illustrated in Figure 3.6 (a,b), can be computed with both the primitive and the enhanced voxelmap and is given by

0 0 0 0 0 0 0 0 -1 -1 -1 1 v(Pi) = 0 ni fi di s Ci Pi C (a) (b) (c) (d) P V P V S(P )P =VP P =QP z x yw P wz wC =w(C ) wy wx d ∆x = s ∆X = 1

Figure 3.6: (a) Voxelized and point-sampled objects in collision. Each voxel has its voxel layer value v related to its penetration in the voxelmap, and each point Piits inwards pointing normal vector ni. (b) A single point penalty force fi can be computed scaling the normal vector with its penetration. (c) Distance computation between a signed distance field A and a point-sphere B: if bounding boxes do not overlap, the first consists in projecting the sphere centers and points PAon the bounding box of the distance field P0B; then, distance values can be interpolated or the closest surface point of the projected point can be found using the surface map. (d) A voxel (blue) surrounded by its neighbor voxel values (red). A valid neighborhood (orange) is selected for linear interpolation of the distance or penetration using the gradient ∇v built out of the neighbor voxel values vx, vy, and vz.

with d =−P C−→ being the vector from the point P to the voxel center C and ξV the voxel

form factor applied to the voxel size s. This form factor can range from ξV = 1, for cases

in which the voxel value gradient is aligned with any of the voxelmap axes, to ξV =

√ 3, when the gradient is aligned with any of the voxel diagonals; in practice, its value is usually fixed to the mean ξV = 12(1 +

3), although ξV = 1yields the most conservative

distance to collision computation.

Whereas the first term ξV s v(P )from (3.25) refers to the global approximated signed

distance in the voxelmap, the second term nTd accounts for the local distance within

the voxel. This second term is particularly relevant in case the point is in a surface voxel (v = 0), but negligible for high voxel values or small voxel sizes.

The distance function which accesses the surface points stored in the surface voxel structure S is defined as

VS(P ) = kP − S(P )k (3.26)

with S(P ) being the closest point S constrained to the surface encoded in the voxelmap for a point P in space. This point is obtained in two steps, similarly as when W is generated: first, the voxel of W where P lies (analogous to TableB.1(c)) and which con- tains the index of the closest surface voxel in S is determined; second, the pre-computed projected point of that surface voxel is taken, which is the delivered approximation of S. This process is schematically shown in Figure 3.6 (c). In the figure, the special case

in which the poinsthell P is completely out of the boundaries of the voxelmap V is de- picted; in such a situation, the closest boundary voxel to the point P must be found in a previous step (see TableB.1 (c)), and then, W and S are accessed to obtain S(P ), as described.

In summary, S(P ) can be interpreted as a surface map function, which, given a point on the pointshell PP, yields its closest point on the surface of the voxelmap PV:

S : R3→ R3, P V = S(PP) such that        v(PV) = 0, δ2 = kPV− PPk2 ( min δ2 if V (P P) < 0 (outside), max δ2 otherwise.