parser for circular interpolation

This commit is contained in:
Nikolay Khabarov
2017-05-22 04:01:45 +03:00
parent d77d8e0b20
commit 0de4f3dc00
9 changed files with 247 additions and 21 deletions
+5 -1
View File
@@ -1,3 +1,4 @@
G17
G0 X90 Y90
G1 Z10
f1800
@@ -9,4 +10,7 @@ G2 X90 Y90 I-10 J10 ; three quoter circle
G3 X90 Y90 Z 20 I-10 J-10 ; spiral
G2 X92.07 Y85 I-5 J-5 ; small arc
G2 X90 Y90 I-7.07 J0; more then 270 degree arc
G18
G2 X90 Y90 K-5
G19
G2 X90 Y90 K-5
-1
View File
@@ -2,7 +2,6 @@ import unittest
import math
from cnc.coordinates import *
from cnc.enums import *
from cnc.gcode import *
+40
View File
@@ -69,6 +69,37 @@ class TestGMachine(unittest.TestCase):
self.assertRaises(GMachineException,
m.do_command, GCode.parse_line("G1X0Y0Z-1"))
def test_g2_g3(self):
m = GMachine()
self.assertRaises(GMachineException,
m.do_command, GCode.parse_line("G3I1J1F-1"))
m.do_command(GCode.parse_line("G19"))
self.assertRaises(GMachineException,
m.do_command, GCode.parse_line("G3I1J0K0"))
m.do_command(GCode.parse_line("G18"))
self.assertRaises(GMachineException,
m.do_command, GCode.parse_line("G3I0J1K0"))
m.do_command(GCode.parse_line("G17"))
self.assertRaises(GMachineException,
m.do_command, GCode.parse_line("G3I0J0K1"))
self.assertRaises(GMachineException,
m.do_command, GCode.parse_line("G2X99999999Y99999999I1J1"))
self.assertRaises(GMachineException,
m.do_command, GCode.parse_line("G2X2Y2Z99999999I1J1"))
self.assertEqual(m.position(), Coordinates(0, 0, 0))
self.assertRaises(GMachineException,
m.do_command, GCode.parse_line("G2X4Y4I2J2"))
self.assertRaises(GMachineException,
m.do_command, GCode.parse_line("G3X4Y4I2J2"))
m.do_command(GCode.parse_line("G1X1"))
m.do_command(GCode.parse_line("G2J1"))
m.do_command(GCode.parse_line("G3J1"))
self.assertEqual(m.position(), Coordinates(1, 0, 0))
m.do_command(GCode.parse_line("G1X5Y5"))
m.do_command(GCode.parse_line("G2X0Y0Z5I-2J-2"))
self.assertEqual(m.position(), Coordinates(0, 0, 5))
def test_g4(self):
m = GMachine()
st = time.time()
@@ -77,6 +108,15 @@ class TestGMachine(unittest.TestCase):
self.assertRaises(GMachineException,
m.do_command, GCode.parse_line("G4P-0.5"))
def test_g17_g18_g19(self):
m = GMachine()
m.do_command(GCode.parse_line("G19"))
self.assertEqual(m.plane(), PLANE_YZ)
m.do_command(GCode.parse_line("G18"))
self.assertEqual(m.plane(), PLANE_ZX)
m.do_command(GCode.parse_line("G17"))
self.assertEqual(m.plane(), PLANE_XY)
def test_g20_g21(self):
m = GMachine()
m.do_command(GCode.parse_line("G20"))