LinuxCNC S-Curve Accelerations

More
21 Feb 2023 00:23 - 21 Feb 2023 00:25 #264924 by Grotius
Hi,

This is the front end interface in progress.

It sets up a scurve motion program, user can input the nr. of joints.
The ammount of joints is dynamicly loaded at startup.
User can set parameters for each joint by id.

Then to update the values, user can select a Joint id "j1, j2 etc.".
It's now limited up to 16 joints.
    sc_motion *motion = new sc_motion();
    sc_motion_in in;
    sc_motion_out out;
    sc_status status;

    motion->nr_of_joints(3);

    sc_motion_joint_id id=sc_motion_joint_id::id_J1;
    sc_motion_params params={a,dv};
    motion->set(id,params);

    in.curacc=acs;
    in.curpos=0;
    in.curvel=vo;
    in.endacc=ace;
    in.endpos=s;
    in.endvel=ve;
    in.maxvel=vm;

    //! From here runs in thread.
    status=motion->update(0.001,id,in,out);
    if(status==sc_status::Error){
        std::cerr<<"motion error"<<std::endl;
    }

    if(!out.finished){
        in.curvel=out.newvel;
        in.curpos=out.newpos;
        in.curacc=out.newacc;
    } else {
        //! Set new position.
    }


Now let's fix the rest of the code. I hope it won't take too long if we are lucky.
Last edit: 21 Feb 2023 00:25 by Grotius.

Please Log in or Create an account to join the conversation.

More
21 Feb 2023 12:12 #264948 by rmu
Replied by rmu on topic LinuxCNC S-Curve Accelerations
How would you program a linear move involving more than one joint?

Please Log in or Create an account to join the conversation.

More
21 Feb 2023 20:41 #264981 by Grotius
Hi,

Good question.

The code below is tested today. The logged peak is ms : 0.283687 ms in userland.
The input is more or less the same as the ruckig motion planner.

1. Set the nr. of joints.
2. Set the "a" acceleration and "dv" delta velocity.
The delta velocity value gives the "jm" value.
More precicely, Dv is from 0 acc to as and back to 0 acc. Where "as" is 2*a, this is at the scurve inflection point.
Sorry for the confustion.

3. Set the current joint values and target values.
4. Then in the servo cycle, the motion is updated every 1ms.
5. A new input will process a new motion.

motion->nr_of_joints(3);

motion->set(sc_motion_joint_id::id_J0,
            ui->doubleSpinBox_a->value(),
            ui->doubleSpinBox_dv->value());

motion->set(sc_motion_joint_id::id_J1,
            ui->doubleSpinBox_a->value(),
            ui->doubleSpinBox_dv->value());

motion->set(sc_motion_joint_id::id_J2,
            ui->doubleSpinBox_a->value(),
            ui->doubleSpinBox_dv->value());

in_J0.curacc=2
in_J0.curpos=0;
in_J0.curvel=22
in_J0.endacc=2
in_J0.endpos=1000
in_J0.endvel=5
in_J0.maxvel=50;

in_J1.curacc=0;
in_J1.curpos=0;
in_J1.curvel=2;
in_J1.endacc=0;
in_J1.endpos=150;
in_J1.endvel=0;
in_J1.maxvel=10;

in_J2.curacc=0;
in_J2.curpos=0;
in_J2.curvel=1;
in_J2.endacc=0;
in_J2.endpos=150;
in_J2.endvel=0;
in_J2.maxvel=12;
    
And in the servo cycle this is then updated every 1ms.

status=motion->update(0.001,sc_motion_joint_id::id_J0,in_J0,out_J0);
in_J0.curvel=out_J0.newvel;
in_J0.curpos=out_J0.newpos;
in_J0.curacc=out_J0.newacc;

status=motion->update(0.001,sc_motion_joint_id::id_J1,in_J1,out_J1);
in_J1.curvel=out_J1.newvel;
in_J1.curpos=out_J1.newpos;
in_J1.curacc=out_J1.newacc;

status=motion->update(0.001,sc_motion_joint_id::id_J2,in_J2,out_J2);
in_J2.curvel=out_J2.newvel;
in_J2.curpos=out_J2.newpos;
in_J2.curacc=out_J2.newacc;
 
The following user(s) said Thank You: Bari, itsme, Darium

Please Log in or Create an account to join the conversation.

More
22 Feb 2023 11:49 #265026 by rmu
Replied by rmu on topic LinuxCNC S-Curve Accelerations
So you are doing a move from (0/0/0) to (1000/150/150).

Maybe I'm missing something, but given that initial and terminal conditions for joints are wildly differing those joints will experience different accelerations for different amounts of time and resulting move will not be a straight line but something like a "curveball".

Please Log in or Create an account to join the conversation.

More
22 Feb 2023 23:01 #265075 by Grotius
Hi,

That's correct. Nice spot.

In the example no xyz interpolation and or synchronisation is done.
I have not coded that part yet.

A little update.

For a 9 axis machine i now reach 0.4 ms when curve needs to be sampled. (cpu intensive part).
When the curve is a normal curve, the time is about 0.02 ms for a 9 axis machine.
I think this is acceptable.

I tested it with this : curve

The planning is now finish the lib. I think a few day's from now, hopely without any problems.


 

Please Log in or Create an account to join the conversation.

More
24 Feb 2023 00:58 - 24 Feb 2023 01:08 #265183 by Grotius
Hi,

A little update.
Made some progress today. The live mode is working. Perfomance is ok.
Vm interupts are working. You see in the picture multiple keyboard interrupts ca 8x.
After some testing, i found some things to improve. But concept is working now.

You can see in red the velocity curve. It has linear acceleration stage in the scurve profile. t2.
And curve acc-dcc steepness is constant.
This all makes the machine move's more predictible then using a cubic spline scurve.

It's almost time to test some waypoints.
This is interesting because of the acc & dcc end values, where a new move has to start.

Performance for one axis:
peak time only at start of curve : 0.014069 ms.
 avarage cycle time : ~0.002 ms

Link to scurve video

Link to source code

File Attachment:
Last edit: 24 Feb 2023 01:08 by Grotius.
The following user(s) said Thank You: Darium

Please Log in or Create an account to join the conversation.

More
24 Feb 2023 05:16 #265202 by automata
I am excitedly following this topic.
For the multiaxis synchronized move, if the line/arc/curve can be paramaterized on distance travelled along the curve and represent it as "s", the same theory used for single axis planner is valid.
At everytime step, we can compute the multiaxis positions using the direction cosines of the line or other parameterized formula from the curve for the individual axes.
The part to take care of would be during setting the max acceleration "a" and max velocity "vm". Here we would have to take into account the limits of each individual axis involved in the move and pro-rate the values of max acceleration and velocity (again using direction cosines for a line) .
-automata

Please Log in or Create an account to join the conversation.

More
24 Feb 2023 09:05 #265210 by rmu
Replied by rmu on topic LinuxCNC S-Curve Accelerations

I am excitedly following this topic.
For the multiaxis synchronized move, if the line/arc/curve can be paramaterized on distance travelled along the curve and represent it as "s", the same theory used for single axis planner is valid.
At everytime step, we can compute the multiaxis positions using the direction cosines of the line or other parameterized formula from the curve for the individual axes.
The part to take care of would be during setting the max acceleration "a" and max velocity "vm". Here we would have to take into account the limits of each individual axis involved in the move and pro-rate the values of max acceleration and velocity (again using direction cosines for a line) .
-automata
 

jerk-limiting in "parameter-space" doesn't lead to jerk-limited joint movements, just consider tangential "blend" between straight line and circular arc, at the point the arc starts, centripetal acceleration appears as a step in acceleration perpendicular to the line pointing to center of arc. step in acceleration = infinite jerk. 

Please Log in or Create an account to join the conversation.

More
24 Feb 2023 09:16 #265212 by rodw
Replied by rodw on topic LinuxCNC S-Curve Accelerations
Isn't that where look ahead should come into play? You can calculate the centripetal velocity limit based on radius and machine accelaration so the look ahead might determine how far back along the line deceleration should commence to hit the target velocity when the tool arrives at the arc..

Please Log in or Create an account to join the conversation.

More
24 Feb 2023 09:29 #265213 by automata
@rmu
That is exactly correct.
As I have alluded to earlier in this thread that this method can only take care of jerk which is tangential to the path. Jerk component normal to the path will still be unlimited.
forum.linuxcnc.org/38-general-linuxcnc-q...ons?start=240#216588

Do you have any ideas to deal with jerk limitation for both normal and tangential directions simultaneously?
Maybe as rowd suggested, using look ahead, we should be able to optimize the max jerk value allowd per axis.

In grotius' approach, the jerk is specified as a "dv" value which decides the change in velocity during which the jerk limitation is applied. It does not specify the jerk value directly. If you ask me, finite jerk (even if it not limited to a particular value) is way better than infinite jerk.

For paths that are continuously changing direction like circles or nurbs OR any machine with non-trivial kinematics, the only viable method to limit the jerk on joints would be to sample the path at some small length and check for velocity acceleration and jerk constraints at those points.
-automata

Please Log in or Create an account to join the conversation.

Time to create page: 0.191 seconds
Powered by Kunena Forum