Sunday, July 24, 2005

Marching Cubes

I realized after reading through other research papers that implementing the Marching Cubes algorithm into my project would not be difficult. The octree data structure is ideal for adding the marching cubes technique.

The octree structure has branch and leaf nodes. The leaf nodes could be viewed as vertices rather than cubes. The leaf nodes are updated to reflect whether they are outside, are on the border or inside of the object. Each branch keeps track of 8 children and whether a child should be drawn. This reduces branches that need to be visited when drawing the object. If a branch has one child that is on the border, then the current branch should be drawn.

Source code was obtained that provides a lookup table with 256 entries. This is because there are 2^8 possible combinations. These can be reduced to around 15 general cases due to rotations but a lookup table lists all triangles that should be drawn for each case.

The triangles are formed using midway points between the vertices. There are 8 vertices for a cube and there are 12 midway points. These points are referenced in the lookup table. Normals can then be computed from the order of the midpoints.

Wednesday, July 20, 2005

Kinematic Chain

The order of matrix multiplication is crutial for obtaining correct orientation and position information. The kinematic chain is the order that the transformation matrices are multiplied in order to move between coordinate systems.

The haptic device has an internal kinematic chain that we will not explore, but we will use the haptics coordinate at (0,0,0) using the right hand rule and with no rotation. Having the haptic device directly in front of you. The x-axis is positive to the right. The y-axis is positive to the ceiling. The z-axis is positive in the direction away from the haptic device.

The haptics has a base coordinate system that we will use as the world coordinate system. Transformations are calculated in the following ways

Haptics (World Zero) -- This is identity 4x4 matrix
Stylus (Center of Rotation) -- Calculated and Returned from HD - HD_Current_Transform
Tool Tip (TCP) -- Calibrated from reading in points
WorkPiece (Orientation) -- Read in from calibration subroutine

Kinematic Chain
Tool Tip to Haptics

T = Tool Tip x Stylus

Tool Tip to WorkPiece

T = Tool Tip x Stylus x inverse(WorkPiece)

Freeze

Last week I put a freeze on development. No new features will be implemented in this system. The next phase of the project is testing. This week of coding is dedicated to making cosmetic changes and increasing reliability. Current features to wrap up include combining getting the dimensions and coordinate system of the stock material and creating a bounding box around the STL/TRI object and fitting it into the octree object.

The console based interface is getting updated to use GLUI. This puts a java looking panel in an openGl window. This plugs in nicely with existing code. The GLUI allows programmers to build buttons, panels, etc. manually with the same effect as with windows forms.

Force Rendering

The problem with force rendering was solved by changing a setting used with the SWIFT collision detection package. There are two options offered when creating the workspace for the collision detection. Sorting deals with the way the program sorts the objects to try to optimize the search.

Broad Phase offers the option to create tight bounding boxes around the object. This optimizes the query phase. If the object position is not inside of the bounding box, then no test is made and data will be returned from a query. This reduces the amount of computation by closely representing the object by the bounding boxes.

However, this causes a problem when making queries. There are various queries offered by the package and most allow the user to specify a threshold as to when the function should return a value. This doesn't work when the Broad Phase option is selected. When option is disabled, then queries return the distance between objects within the set tolerence.

Wednesday, July 06, 2005

Force Smoothing

The haptic device does not react well to the forces sent by the project. According to the haptics documentation, buzzing occurs when the haptic device can't render the forces. This can occur when the force is too high, there direction changes or the difference between forces is too great. The documentation recommends smoothing the forces.

Force with STL

The SWIFT collision detection package has a funtion that returns the normal vector between two objects. This can be used as the direction of the force vector. The distance between the objects is returned as well. The smoothing will keep track of past forces and take an average of the forces. Weights will be adjusted to ensure a smooth performance.

Force with octree

The force vector will be in the opposite direction of motion. The negative of the velocity vector is used to simulate resistance when contacting a cell.

A possible enhancement to this technique is adding a counter to the cells. Currently a cell is removed the first time contact is made with the tooltip. The counter could be used to remove the cell only when the counter reaches a certain limit. This would delay the removal and allow the force to be rendered for a longer time.

Initializing the Stock Material

Professor Horsch provided me with code to create a transformation matrix from reading in 3 points; origin, x-axis and y-axis. The code was included into the project but could not be tested until the haptic to screen mapping was working. After fixing the mapping last week the code was tested.

The matrix mulitplication needed is as follows:

Translation from default haptic TCP to desired Tooltip *
Current Transformation Matrix from world center point to TCP *
inverted Transformation Matrix from world center point to origin of stock material

After this multiplication, the coordinates can be used as input to the collision detection algorithms. This does not take into account orientation of the tooltip, and this doesn't matter is the tooltip is a sphere.

Counters