View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002606 | Path | Feature | public | 2016-06-29 13:43 | 2020-10-18 19:30 |
Reporter | sliptonic | Assigned To | sliptonic | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | all | OS | all | OS Version | all |
Product Version | 0.18 | ||||
Summary | 0002606: need an R to IJ conversion function for preprocessors | ||||
Description | In Gcode, an arc is usually described like 'G2 X10 Y10 I15 J15' where XY are coordinates for the end point. IJ are offsets to the arc center point G2 (or G3) indicate whether the arc turns clockwise (or ccw) around the axis. However, it's valid in gcode to describe an arc withhout the IJ values and instead pass in an R value indicating the Radius. In this case, the controller is responsible for calculating the center point given the start, end, and radius. When importing gcode through a preprocessor script, we should not store the Path commands with the R value but should calculate the IJ values and store those. Rather than implement this in ever preprocessor script, we need an R to IJ calculation function that can be used everywhere. | ||||
Additional Information | I think this is related to issue 0002605 Path commands should always be stored in relative form but may be imported as absolute. | ||||
Tags | No tags attached. | ||||
FreeCAD Information | |||||
|
When 0002605 is done, the Path module will support both relative and absolute IJK. So it won't matter which one is used here (as long as the proper G91.1 code is inserted when needed of course) |
|
http://www.linuxcnc.org/docs/html/gcode/g-code.html#_radius_format_arcs |
|
I think this should do it (untested): # let's say we have 2 vectors, startpoint and endpoint, and radius (the value of R) import math chord = endpoint.sub(startpoint) # we take a vector between the 2 points perp = chord.cross(FreeCAD.Vector(0,0,1)) # we take its perpendicular - we can assume the arc is in the XY plane plength = math.sqrt(radius**2 + (chord.Length/2)**2) # pythagoras formula, to get the length perp needs perp.normalize() perp.scale(plength,plength,plength) # relative center center = chord.scale(0.5,0.5,0.5).add(perp) # we add the perp at the midpoint of the chord to find the center # absolute center abscenter = startpoint.add(center) |
|
Doesn't seem to be calculating quite right. Here's a test rig macro and output. =========Macro============= import math import Path def RtoIJ(startpoint, endpoint, radius): chord = endpoint.sub(startpoint) # we take a vector between the 2 points perp = chord.cross(FreeCAD.Vector(0,0,1)) # we take its perpendicular - we can assume the arc is in the XY plane plength = math.sqrt(radius**2 + (chord.Length/2)**2) # pythagoras formula, to get the length perp needs perp.normalize() perp.scale(plength,plength,plength) # relative center relativecenter = chord.scale(0.5,0.5,0.5).add(perp) # we add the perp at the midpoint of the chord to find the center print "relative center: " + str(relativecenter) print "calculated I:" + str(relativecenter.x) print "calculated J:" + str(relativecenter.y) # absolute center abscenter = startpoint.add(relativecenter) print "absolute center: " + str(abscenter) lastcommand = Path.Command("G01 X-29.992999999999999 Y36.941000000000003 Z0 ") command = Path.Command("G02 I11.183 J-8.4209999999999994 X-7.835 Y37.212000000000003 Z0") Rad = math.hypot(command.I,command.J) print "Calculated Radius: " + str(Rad) #returns about 14 as expected print "startpoint: " + str(lastcommand.Placement.Base) print "endpoint: " + str(command.Placement.Base) print "original I: " + str(command.I) print "original J: " + str(command.J) RtoIJ(lastcommand.Placement.Base, command.Placement.Base , Rad) =========Macro============= =========output============= Calculated Radius: 13.9990260375 startpoint: Vector (-29.993, 36.941, 0.0) endpoint: Vector (-7.835, 37.212, 0.0) original I: 11.183 original J: -8.421 relative center: Vector (11.297333993057345, -17.716325159279247, 0.0) calculated I:11.2973339931 calculated J:-17.7163251593 absolute center: Vector (-18.695666006942652, 19.224674840720755, 0.0) =========output============= |
|
Hey @sliptonic what's the status of this ticket? Thanks. |
|
Found the minor math bug in the pythagorean calculation. Have added RtoIJ function in PathUtils. This should be closed with PR 3966 |
|
Fix committed to master branch. |
FreeCAD: master 01591044 2020-10-16 16:02:29 Details Diff |
add RtoIJ function to PathUtils. fixes 0002606 function is unused at this time. It should be used by preprocessor scripts like gcode_pre to convert radius mode arcs to IJ mode. |
Affected Issues 0002606 |
|
mod - src/Mod/Path/PathScripts/PathUtils.py | Diff File | ||
FreeCAD: master 3764b404 2020-10-18 19:28:12 Committer: GitHub Details Diff |
Merge pull request 0003966 from sliptonic/feature/RtoIJarcs [PATH] Add RtoIJ function to PathUtils. fixes 0002606 |
Affected Issues 0002606 |
|
mod - src/Mod/Path/PathScripts/PathUtils.py | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2016-06-29 13:43 | sliptonic | New Issue | |
2016-06-29 13:44 | sliptonic | Category | Bug => Feature |
2016-06-29 19:57 | yorik | Relationship added | related to 0002605 |
2016-06-29 19:59 | yorik | Note Added: 0007161 | |
2016-06-30 00:09 | yorik | Note Added: 0007162 | |
2016-06-30 00:23 | yorik | Note Added: 0007163 | |
2016-07-02 15:42 | sliptonic | Note Added: 0007166 | |
2017-01-29 21:45 | Kunda1 | Additional Information Updated | |
2018-02-08 15:36 | sliptonic | Product Version | 0.17 => 0.18 |
2018-02-08 15:36 | sliptonic | Target Version | 0.17 => 0.18 |
2019-01-22 05:14 | sliptonic | Status | new => feedback |
2019-01-22 05:14 | sliptonic | Target Version | 0.18 => 0.19 |
2020-01-06 16:29 | Kunda1 | Note Added: 0014001 | |
2020-10-16 16:38 | sliptonic | Note Added: 0014888 | |
2020-10-16 16:38 | sliptonic | Status | feedback => new |
2020-10-18 19:30 | sliptonic | Changeset attached | => FreeCAD master 3764b404 |
2020-10-18 19:30 | sliptonic | Changeset attached | => FreeCAD master 01591044 |
2020-10-18 19:30 | sliptonic | Note Added: 0014909 | |
2020-10-18 19:30 | sliptonic | Assigned To | => sliptonic |
2020-10-18 19:30 | sliptonic | Status | new => closed |
2020-10-18 19:30 | sliptonic | Resolution | open => fixed |