linuxcnc trajectory planner

More
09 Oct 2024 14:03 #311646 by Grotius
Hi all,

In this topic i want to discuss and keep updated development related to new linuxcnc trajectory planners.

For this there is a fresh repository : codeberg.org/skynet/linuxcnc_trajectory_planner
This repository include the latest source of the original linuxcnc repository hosted at github.

To start coding your own planner, you could use the template branch to get started.
This branch is a clean project.

In the source dir, there is a cmake directory producing 2 libraries  (motmod.so & tpmod.so) , involving the trajectory planners code.
These 2 libs, can be compiled and installed to replace (overwrite) the original libs.

Short briefing
Why do we need 2 libraries involving the trajectory planners code:
The motion controller component "motmod.so" wich handles a few things like jogging,
but also call's the trajectory component to add fresh gcode lines trough functions like : tpAddline();
~/cmake/motion

The trajectory planner component "tpmod" wich run's the gcode recieved by the motmod.so component.
The tpmod.so calculates the trajectory and does things like "look ahead", create path's, updates tool position etc.
~/cmake/planner

Repository cmake compile & install rtlib test
~/cmake mkdir build
~/cmake cd build
~/cmake cmake ..
~/cmake make
~/cmake make install

Repository linuxcnc run test
~/scripts . ./rip-environment
~/scripts linuxcnc

Ok so far we are on the right track. Above run's at my pc.

My investegation start's at the motion controller component motmod.so, the related file command.c
~/cmake/motion/command.c

In command.c, the function emcmotCommandHandler is runned every cycle. And check's what needs to be done.
It is responsible for adding lines & arc's to the trajectory planners tpmod.so component.

The emcmotCommandHandler function calls adding lines and arc's several times in the source file at different locations :
- Line 1027 tpAddLine
- Line 1437 tpAddLine
- Line 1088 tpAddCircle


Now i think a good strategy is to change a few tiny things to the current linuxcnc motion command flow:
1. Dont send tpAddLine and or tpAddCircle every cycle. Buffer this info into shared memory.
2. When the emcmotCommandHandler recieves a "run: command to execute the program,
     then *optimize the path given the buffer, also optimize the **look ahead for the path.
3. Send only optimized path's, including ***vo's & ve's to the trajectory component tpmod.so
4. The trajectory planners component tpmod.so is now very simple to code. As is no longer is required to do
complex calculations. It only has to have a scurve motion algo under the hood.

*optimize = G64 P.. Q.. remove tiny segments, add fillets, etc.
**look ahead = Run a forward & backward algo over the trajectory to optimize speeds based on curvature extrema, maxvel, maxacc, maxjerk.
***vo's & ve's = velocity begin, velocity end for a line or arc.

Todo coming time related to the scurve library:
Review the scurve library, some things can be cleaned up, and create a test environment to test millions of iterations.
The following user(s) said Thank You: pommen, Ritterchen, Aciera, nwallace, Unlogic

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

More
10 Oct 2024 06:34 #311699 by Aciera
Replied by Aciera on topic linuxcnc trajectory planner
Does not seem to work for me (missing 'config.h'):
user@user-iMac:~$ cd linuxcnc_trajectory_planner/
user@user-iMac:~/linuxcnc_trajectory_planner$ cd cmake/
user@user-iMac:~/linuxcnc_trajectory_planner/cmake$ cd build/
user@user-iMac:~/linuxcnc_trajectory_planner/cmake/build$ cmake ..
-- The CXX compiler identification is GNU 11.4.0
-- The C compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/linuxcnc_trajectory_planner/cmake/build
user@user-iMac:~/linuxcnc_trajectory_planner/cmake/build$ make
Consolidate compiler generated dependencies of target motmod
[  5%] Building C object motion/CMakeFiles/motmod.dir/home/user/linuxcnc_trajectory_planner/src/emc/kinematics/cubic.c.o
[ 10%] Building C object motion/CMakeFiles/motmod.dir/home/user/linuxcnc_trajectory_planner/src/emc/motion/axis.c.o
[ 15%] Building C object motion/CMakeFiles/motmod.dir/home/user/linuxcnc_trajectory_planner/src/emc/motion/motion.c.o
[ 20%] Building C object motion/CMakeFiles/motmod.dir/command.c.o
[ 25%] Building C object motion/CMakeFiles/motmod.dir/home/user/linuxcnc_trajectory_planner/src/emc/motion/control.c.o
/home/user/linuxcnc_trajectory_planner/src/emc/motion/control.c:31:10: fatal error: config.h: No such file or directory
   31 | #include "config.h"
      |          ^~~~~~~~~~
compilation terminated.
make[2]: *** [motion/CMakeFiles/motmod.dir/build.make:132: motion/CMakeFiles/motmod.dir/home/user/linuxcnc_trajectory_planner/src/emc/motion/control.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:116: motion/CMakeFiles/motmod.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
The following user(s) said Thank You: Grotius

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

More
10 Oct 2024 06:47 #311700 by Aciera
Replied by Aciera on topic linuxcnc trajectory planner
Disregard the above. I was not aware that I needed to go through the usual linuxcnc build process before running the cmake build:
You now need to run 'sudo make setuid' in order to run in place with access to hardware.
user@user-iMac:~/linuxcnc_trajectory_planner/src$ cd ..
user@user-iMac:~/linuxcnc_trajectory_planner$ cd cmake/build/
user@user-iMac:~/linuxcnc_trajectory_planner/cmake/build$ make
Consolidate compiler generated dependencies of target motmod
[  5%] Linking C shared library motmod.so
[ 50%] Built target motmod
Consolidate compiler generated dependencies of target tpmod
[ 55%] Building C object planner/CMakeFiles/tpmod.dir/tpmod.c.o
[ 60%] Building C object planner/CMakeFiles/tpmod.dir/home/user/linuxcnc_trajectory_planner/src/emc/tp/tc.c.o
[ 65%] Building C object planner/CMakeFiles/tpmod.dir/home/user/linuxcnc_trajectory_planner/src/emc/tp/tcq.c.o
[ 70%] Building C object planner/CMakeFiles/tpmod.dir/tp.c.o
[ 75%] Building C object planner/CMakeFiles/tpmod.dir/home/user/linuxcnc_trajectory_planner/src/emc/tp/spherical_arc.c.o
[ 80%] Building C object planner/CMakeFiles/tpmod.dir/home/user/linuxcnc_trajectory_planner/src/emc/tp/blendmath.c.o
[ 85%] Building C object planner/CMakeFiles/tpmod.dir/home/user/linuxcnc_trajectory_planner/src/emc/nml_intf/emcpose.c.o
[ 90%] Building C object planner/CMakeFiles/tpmod.dir/home/user/linuxcnc_trajectory_planner/src/libnml/posemath/_posemath.c.o
[ 95%] Building C object planner/CMakeFiles/tpmod.dir/home/user/linuxcnc_trajectory_planner/src/libnml/posemath/sincos.c.o
[100%] Linking C shared library tpmod.so
[100%] Built target tpmod
user@user-iMac:~/linuxcnc_trajectory_planner/cmake/build$ 
The following user(s) said Thank You: Grotius

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

More
10 Oct 2024 07:16 #311704 by Aciera
Replied by Aciera on topic linuxcnc trajectory planner

Now i think a good strategy is to change a few tiny things to the current linuxcnc motion command flow:


sounds like a good starting point.
The following user(s) said Thank You: Grotius

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

More
10 Oct 2024 14:13 - 10 Oct 2024 14:15 #311728 by Grotius
Replied by Grotius on topic linuxcnc trajectory planner
Hi Arciera,

Yes, first build the linuxcnc as usual. Then overwrite it with the cmake build.

Another option, this i am using myself now :
When editing the cmake project in Qt, save your changes. "Cntr+s"
Then in terminal run the usual lcnc's make command $ ~linuxcnc_trajectory_planner/src/make then $ sudo make setuid
As i am editing the original source file's directly now. **Repository is updated with this change in used source files.

Ok i did some coding today.

There is now a new function added to the planner tpmod.so component.
I's called by the motion controller motmod.so.

When the entire gcode is loaded, the motion controller signals the trajectory planner
it can start processing the G64 P.. Q.. stuff for the trajectory.
int tpGcodeLoaded(TP_STRUCT * tp, int count);

Above function is now empty, but should start a new thread. This means heavy calculations
will not influence the current program cycle.
Last edit: 10 Oct 2024 14:15 by Grotius.
The following user(s) said Thank You: Lcvette, Aciera, Unlogic

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

More
10 Oct 2024 20:15 #311769 by Lcvette
Replied by Lcvette on topic linuxcnc trajectory planner

Ok i did some coding today.

 

Hurray!! \o/  great news to see this in motion once more! so excited!

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

Time to create page: 0.080 seconds
Powered by Kunena Forum