Request G6, Ellipse and G7, bezier curve
- Posts: 1073
- Karma: 10
- Thank you received: 509
I have a programmer request for adding a G6, Ellipse and a G7, Bezier curve to the Linuxcnc source code.
This request is done because the cubic spline G5, is already available for Linuxcnc. For my cam software i want
the possiblily to output G5, G6 and G7 code format's. This would be inline with a uniform program output.
At this moment i see a non uniform output for linuxcnc happening :
We can output a cam G5 for spline, but we can only output fragmented linestrips to cnc a Ellipse or Bezier curve.
Attached c/c++ basic function's that can be adapted to the Linuxcnc Gcode intepreter with minimal changes.
This tiny step forward in linuxcnc source code, is a huge step for cnc cam program's. The power of
a G6 and G7 output is that the cam program does not have to facetate a ellipse into a fragmented linestrip. This results in
thousand lines of code when the cam program's calculate a very accurate cnc path. Let linuxcnc do this real time calculation
while the machine is moving.
I hope some linuxcnc programmer will pick this up and put it in the next Linuxcnc release.
WIch Gcode Numbers are used, doesn't matter for me. G6 and G6.1 are fine for example. G7 is already used for lathe.
//ellipse center = xcen, ycen
//ellipse base right = xend, yend
//ellipse top point = xinput, yinput
double center_x = xcen;
double center_y = ycen;
//center point to endpoint mayor axis..
double radius_x = sqrt(pow(xend-xcen,2) + pow(yend-ycen,2));
//ratio minor axis to mayor axis..
double radius_y=0;
if(ratio==0){ //takes the controlpoint instead of ratio factor
radius_y = sqrt(pow(xinput-xcen,2) + pow(yinput-ycen,2));
}
if(ratio!=0){ //if ratio from dxf is available, it takes its value
radius_y = ratio*radius_x;
}
//calculate angle of ellipse
double x1=xend;
double y1=yend;
double radian = atan2(y1 - center_y, x1 - center_x);
double angle = radian * (180 / M_PI);
if (angle < 0.0)
angle += 360.0;
glColor4d(red,green,blue,alpha);
glBegin(GL_LINE_STRIP);
for(double j = pi_angle_start; j<pi_angle_end; j+=0.01)
{
//non rotated ellipse..
double non_rotated_x = /*center_x +*/ cos(j)*radius_x;
double non_rotated_y = /*center_y +*/ sin(j)*radius_y;
//glVertex2d(center_x + cos(j)*radius_x, center_y + sin(j)*radius_y);
//rotated ellipse..
double rotate_x = center_x + cos(angle * M_PI / 180.0 )* non_rotated_x - sin(angle * M_PI / 180.0 ) * non_rotated_y;
double rotate_y = center_y + sin(angle * M_PI / 180.0 )* non_rotated_x + cos(angle * M_PI / 180.0 ) * non_rotated_y;
glVertex2d(rotate_x, rotate_y);
}
glEnd();
}
glLineWidth(1);
glColor4d(red,green,blue,alpha);
glBegin(GL_LINE_STRIP);
for(double t = 0; t < 1; t+=0.01){
//Calculate Point E, on the line AB
double Ex = ((1-t) * xs) + (t * xcon0);
double Ey = ((1-t) * ys) + (t * ycon0);
double Ez = ((1-t) * zs) + (t * zcon0);
//Calculate Point F, on the line BC
double Fx = ((1-t) * xcon0) + (t * xcon1);
double Fy = ((1-t) * ycon0) + (t * ycon1);
double Fz = ((1-t) * zcon0) + (t * zcon1);
//Calculate Point G, on the line CD
double Gx = ((1-t) * xcon1) + (t * xend);
double Gy = ((1-t) * ycon1) + (t * yend);
double Gz = ((1-t) * zcon1) + (t * zend);
//Calculate Point Q, on the line EF
double Qx = ((1-t) * Ex) + (t * Fx);
double Qy = ((1-t) * Ey) + (t * Fy);
double Qz = ((1-t) * Ez) + (t * Fz);
//Calculate Point R, on the line FG
double Rx = ((1-t) * Fx) + (t * Gx);
double Ry = ((1-t) * Fy) + (t * Gy);
double Rz = ((1-t) * Fz) + (t * Gz);
//Calculate Point P, on the line QR
double Px = ((1-t) * Qx) + (t * Rx);
double Py = ((1-t) * Qy) + (t * Ry);
double Pz = ((1-t) * Qz) + (t * Rz);
glVertex3d(Px, Py, Pz); //draw linestrip..
}
glEnd();
}
Please Log in or Create an account to join the conversation.
Can you give some gcode examples of how you think these could be used in a Gcode file?
Please Log in or Create an account to join the conversation.
- Posts: 1073
- Karma: 10
- Thank you received: 509
Can you give some gcode examples of how you think these could be used in a Gcode file?
Sure,
Attached example is in line with current Gcode programming style.
For ellipse the example is an open ellipse, the ellipse itself is defined under a angle. So the most difficult ellipse example
can be done in 1 line of gcode.
For bezier curve the input is like the cubic spline. I,J are first control points. P,Q are second control points.
Gcode can be done in 1 line of gcode.
Attachments:
Please Log in or Create an account to join the conversation.
- Posts: 1073
- Karma: 10
- Thank you received: 509
After some research about the current linuxcnc G5 Cubic splines and G5.1 Quadratic splines i came to the conclusion yesterday this
type of splines are not compatible with following open source programs :
Freecad
Inkscape
Librecad (uses two types of splines)
Cadcam
The linuxcnc G5 Cubic splines and G5.1 Quadratic splines are in my opinion not preferred to use for robot trajectory.
The perfect spline to use to stay in line with above programs : mathworld.wolfram.com/CubicSpline.html
What we miss is the G code command for a Ellipse and Bezier curve and a Gcode command for
a cubic spline that is constructed of piecewise third-order polynomials.
So i can do 3 things.
1. Lean back in my chair and do nothing about it.
2. Post this on the forum and hope someone will add it to the source code.
3. Add it to the linuxcnc source code myself.
What would you do?
Imagine the above criteria is integrated in the linuxcnc source code. The G-code output will reduce with 80-96%.
The cnc machine will be more accurate to the path, because it no longer depends on interpolating the path over 1000+ line segments,
wich are not interpolated as should be in my opinion.
Please Log in or Create an account to join the conversation.
- tommylight
- Offline
- Moderator
- Posts: 7114
- Karma: 69
- Thank you received: 2115
webchat.freenode.net/?channels=%23linuxcnc
It requires registering the nic to be able to post, due to spammer protection.
Please Log in or Create an account to join the conversation.
Grotius wrote: Okey,
So i can do 3 things.
1. Lean back in my chair and do nothing about it.
2. Post this on the forum and hope someone will add it to the source code.
3. Add it to the linuxcnc source code myself.
.
In my experience, the only way to make it happen is option 3. But 1 is a lot easier.
I also want to make some changes to the core code. Maybe we can work together...
I think the new G code will need to align with an existing gcode flavour so that there is post processor support.
Please Log in or Create an account to join the conversation.
never have had any problem on this on freecad or sheetcam with imported DXF
freecad draft can also make you regular rad out of bezier
Please Log in or Create an account to join the conversation.
It seems to me that NURBS-interpolation has kind of fallen by the wayside in professional machine controllers due to the increase in processing speed and memory size.
What CAM can actually output the code required for NURBS interpolation on the controller?
Please Log in or Create an account to join the conversation.
- Posts: 1073
- Karma: 10
- Thank you received: 509
I also want to make some changes to the core code. Maybe we can work together...
Is oke for me. Did you already find out how to make a external c connection to hal?
If not, let me know over here. What change do you want to make?
I think the new G code will need to align with an existing gcode flavour so that there is post processor support.
I agree. But for 99% of the cam program's it will not work at this moment.
They have to improve their source code first.
For my CadCam program this new Gcode is working right away, this is how i would like to see a Cam program shitting out some gcode. High end gcode output. It opens more then only that. Pockets algoritmes, build up from splines. Wow.
@Aciera,
Sounds interesting BUT
It seems to me that NURBS-interpolation has kind of fallen by the wayside in professional machine controllers due to the increase in processing speed and memory size.
Nurbs are a kind of special. I never seen them around in dxf files. More common used one's are splines, ellipses and beziers.
I like the Nurbs idea and tested them yesterday in linuxcnc. A spline path instead of a nurb path can be considered as a good alternative.
What CAM can actually output the code required for NURBS interpolation on the controller?
That's the whole point. Now is the time to get Cam outputs in line with Cad data, and now is the time to get the EMC software up to date to do this job.
@bbsr,
most cam will split this bezier in 2-3 regulair radius ones
So far i know, sheetcam, dxf2gcode, pronest, etc will shit out thousands of line segments instead of one line of special G5 code.
And it is loosing path accuracy this way. For a cnc electron microscope, or a stealth fighter you can not interpolate this way.
never have had any problem on this on freecad or sheetcam with imported DXF
Actual, there is no real problem. There is a linuxcnc source code improvent request.
freecad draft can also make you regular rad out of bezier
But linuxcnc don't accepts this kind of shapes today. If linuxcnc has this option, you will see all cam program's will
improve their souce code.
Please Log in or Create an account to join the conversation.
I see you're an optimist! Good on ya!If linuxcnc has this option, you will see all cam program's will
improve their souce code.
Please Log in or Create an account to join the conversation.