[Home]Gremlin

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Showing revision 2

Gremlin Development Notes

Gremlin is a backplot application that may be used with user interfaces.

For now, this will be a place for notes on particular issues with Gremlin. Hopefully, it will become a comprehensive reference that may be used to create a formal entry into the manual.

Adding Rear Tool Lathe Features

Some features are needed for the development of a user interface for a lathe using a tool post or changer located behind the spindle. Primarily, the X axis direction has been changed so that the X plus direction points away from the normal operator position. The issues that come from this are:

1.1. How best to flag this configuration so that software applies the proper actions?

The solution so far is to check the .ini file GEOMETRY tag for "-XY". The the code path parallels the code for LATHE=1:

gremlin.py

...
class Gremlin(gtk.gtkgl.widget.DrawingArea, glnav.GlNavBase,
              rs274.glcanon.GlCanonDraw):
...
        temp = inifile.find("DISPLAY", "LATHE")
        self.lathe_option = bool(temp == "1" or temp == "True" or temp == "true" )
        temp2 = inifile.find("DISPLAY", "GEOMETRY")
        self.is_rear_tp_lathe = bool(temp2 == "-XZ")
...
    def is_lathe(self): return self.lathe_option
    def is_rear_tool_post_lathe(self): return self.is_rear_tp_lathe

glcanon.py

...
class GLCanon(Translated, ArcsToSegmentsMixin):
...
    def draw_axes(self, n, letters="XYZ"):
...
            if self.is_lathe():
...
    def calc_extents(self):

        self.min_extents, self.max_extents, self.min_extents_notool, self.max_extents_notool = gcode.calc_extents(self.arcfeed, self.feed, self.traverse)
        if self.is_rear_tp_lathe:
            # the min/max come in from gcode_calc extents as the negative of the actual value
            # if we're displaying a plot for a rear TP lathe
            self.min_extents[0] *= (-1)
            self.max_extents[0] *= (-1)   
...
    def draw_axes(self, n, letters="XYZ"):
        glNewList(n, GL_COMPILE)
        x,y,z,p = 0,1,2,3
        s = self.stat
        view = self.get_view()


        glColor3f(*self.colors['axis_x'])
        glBegin(GL_LINES)
        if self.is_rear_tool_post_lathe():
            glVertex3f(-1.0,0.0,0.0)
        else:
            glVertex3f(1.0,0.0,0.0)
        glVertex3f(0.0,0.0,0.0)
        glEnd()

        if view != x:
            glPushMatrix()
            if self.is_lathe():
                if self.is_rear_tool_post_lathe(): 
                    glTranslatef(-1.3, 0, 0)
                    glRotatef(-90, 0, 0, 1)
                    glRotatef(90, 0, 1, 0)
                else:
                    glTranslatef(1.3, -0.1, 0)
                    glTranslatef(0, 0, -0.1)
                    glRotatef(-90, 0, 1, 0)
                    glRotatef(90, 1, 0, 0)
                    glTranslatef(0.1, 0, 0)
...

1.2. The Gremlin X axis origin arrow needs to point up instead of down

glcanon.py

...
        glColor3f(*self.colors['axis_x'])
        glBegin(GL_LINES)
        if self.is_rear_tool_post_lathe():
            glVertex3f(-1.0,0.0,0.0)  # Draws line up
        else:
            glVertex3f(1.0,0.0,0.0)  # Draws line down
        glVertex3f(0.0,0.0,0.0)
        glEnd()

        if view != x:
            glPushMatrix()
            if self.is_lathe():
                if self.is_rear_tool_post_lathe(): 
                    glTranslatef(-1.3, 0, 0)  # Draws an X above the line
                    glRotatef(-90, 0, 0, 1)
                    glRotatef(90, 0, 1, 0)  # Rotates it to face the viewer
                else:
                    glTranslatef(1.3, -0.1, 0)
                    glTranslatef(0, 0, -0.1)
                    glRotatef(-90, 0, 1, 0)
                    glRotatef(90, 1, 0, 0)
                    glTranslatef(0.1, 0, 0)
...

1.3. The tool tip image is on the wrong side of the tool's control point

glcanon.py

...
            glBegin(GL_TRIANGLE_FAN)
            glVertex3f(
                radius * dx + radius * math.sin(circleminangle) + sz * sinmin,
                0,
                radius * dy + radius * math.cos(circleminangle) + sz * cosmin)
            for i in range(37):
                #t = circleminangle + i * (circlemaxangle - circleminangle)/36.
                t = circleminangle + i * (circlemaxangle - circleminangle)/36.
                if self.is_rear_tool_post_lathe():
                    glVertex3f(-1 * radius*dx + radius * math.sin(t), 0.0, radius*dy + radius * math.cos(t))
                else:
                    glVertex3f(radius*dx + radius * math.sin(t), 0.0, radius*dy + radius * math.cos(t))
            glVertex3f(
                radius * dx + radius * math.sin(circlemaxangle) + sz * sinmax,
                0,
                radius * dy + radius * math.cos(circlemaxangle) + sz * cosmax)

            glEnd()
...
Study of how tool orientation 9 is drawn
...
        if orientation == 9:
            glBegin(GL_TRIANGLE_FAN)
            for i in range(37):  # 10 degree increments in 360
                t = i * math.pi / 18  # angle in Radians
                glVertex3f(radius * math.cos(t), 0.0, radius * math.sin(t))
            glEnd()
...
This image shows a circle using the same GL_TRIANGLE_FAN method except at 30 degree increments.
upload:to9_fan-1.png
This sheds light on the other tool orientations which prompts a proper fix.

1.4. The soft limit and grid borders are reversed on the X axis

I haven't a clue yet.

1.5. The part X axis extent bar is reversed

Fixed by Rogge

Created 2013/01/23, Kirk Wallace


LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions | View current revision
Edited January 23, 2013 11:11 pm by Kirk Wallace (diff)
Search:
Published under a Creative Commons License