How would you design a real time application for cnc control in c / c++ ???

More
10 Nov 2020 12:34 - 10 Nov 2020 21:32 #188863 by Grotius
Hi,

I integrated xml (project) file input. It reads in the machine stepfiles, the kinematic model, the hal connections etc.
Now it does not have to be a robot. It can be any machinetype.
The program is creating everything for the machine in a project array. Multiple machine's (projects) can be loaded at the same time.

A example of the xml file layout. The kinematics joints are build up by chains. This is a xml project file for one kuka robot.


I also integrated the doxygen document builder. It's a bit of work to get the doc's the desired output.
This is a example pdf output :

This browser does not support PDFs. Please download the PDF to view it: Download PDF


It's not as nice at the moment. But that changes when getting more experience with doxygen.

Also i added a 3d view button for display mode. It's called a view_cube by opencascade.

In the latest code, the opencascade kinematics are linked again. The kdl kinematics have to be linked.
Now it's generating the joints automaticly. This picture is showing 18+6 joints.
6 joints each robot. each robot has a floortrack joint and a extra tooljoint.



I have done a quick test with a 5 axis dmg mori machine. I have the rotary table connected to the model.
But i realize now, the machine has 2 kinematic chains.

An xyz axis (kinematic chain 1)
An 4th and 5th rotary table (kinematic chain 2)

Somehow i have to make a solution that one machine may have more then one kinematic chain.
And then hopely code something that the euler angles of bot'h kinematic chain's can follow each other like a handshake.
Some work to do. Still having some problems with importing colors. Aii.

Attachments:
Last edit: 10 Nov 2020 21:32 by Grotius.
The following user(s) said Thank You: fupeama, tommylight, bkt

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

More
12 Nov 2020 16:42 - 12 Nov 2020 16:43 #189124 by Grotius
Hi,

I coded the tabwiget. It's was quite a difficult code to make all the connections to the tabwidget.
It's a automated process. And there can be multiple machines loaded at same time. So a lot of data and connections where needed
to do this. But it's a quite clean piece of code result. I also practiced to write doxyen. All going well. The code is at Github.

Have a nice day !

Attachments:
Last edit: 12 Nov 2020 16:43 by Grotius.
The following user(s) said Thank You: Himarc3D

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

More
20 Nov 2020 19:53 #189917 by Grotius
Hi,

A tiny project update.
The inverse kinematics are finally working oke.
Coding a new controlpanel.

Soon i can do some interesting tests with linuxcnc.
One of the first test would be :

If i take a 3 axis linuxcnc setup and load a gcode. Linuxcnc will send the motion commands as normal to hal.
The robot can do this job realtime while reading the hal values.
When we read a g2 or g3 for plasma cutting, we can do a tool angle correction to neutralize the plasma cut angle. (euler angle).

Soon there is a lot possible, i hope.

Have a nice day !

Attachments:
The following user(s) said Thank You: tommylight, thefabricator03

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

More
21 Nov 2020 15:53 - 21 Nov 2020 15:54 #189982 by Grotius
Hi,

Today i worked on the program. Now the most of the controls are working.
The robots can do forward + inverse kinematics + rotate about end effector
with the euler angles.

I have solved some tiny code mismatches.

We are almost at the point to automate the robot positions with a cnc program. But first they must end the light saber battle.

Attachments:
Last edit: 21 Nov 2020 15:54 by Grotius.
The following user(s) said Thank You: chimeno, tommylight, thefabricator03

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

More
21 Nov 2020 16:12 #189989 by Aciera
This is indeed very interesting as I am in the process of refitting my MELFA RV6SDL robot with linuxcnc.
One issue I have is that I need to be able to switch between genserkins kinematics to move in cartesian world mode and trivial kinematics (joint mode to avoid the singularities in the genserkins kinematics).
Dewey Garrett's switch kins branch does that. The problem in cartesian world mode is that the interpreter does not know anything about the kinematics and will not foresee the joint limits violations.
The following user(s) said Thank You: Grotius

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

More
21 Nov 2020 17:19 - 21 Nov 2020 17:37 #189995 by Grotius
Hi Arciera,

Nice robot.

I have studied the robot kinematics in lcnc. Once there was a professor that made a paper about lcnc with a robot. I studied this too.

Yes in lcnc you can have that kind of situations.

Dewey Garrett's switch kins branch does that.
Ahh. I did not know that. Thanks for this info.

This code uses the KDL coronos kinematics library. This is a advanched kinematics library. In the beginning i did not understand how to use it. But step by step everything became clear.

In my case it uses joint limits, in cartesian and joint mode. It does not matter what kind of robot or machine you use. Everything works.
It's a dynamic plug and play chainsolver. I have made a extra option for the solver. It can calculate Fk and Ik from initial position or last known position. This is sometimes handy when a robot is on a track of the robot is working behind his back.

The reason that i did not use the lcnc build in kinematics and tk visualisation is that it is a kind of very limited and outdated.
With respect to the makers.

If you are interested? what kind of robot application do you want to realize? Is it pick and place or is it cam 3d?

and will not foresee the joint limits violations.

To check if there is a problem, a simulation check is needed. Vericut does this too. The opencascade (this is the cad interface) can
also do collision detection while simulating. For the future, there is a lot possible. You only have to code it, and that takes time and some knowlegde.

In global, the most difficult item's are done. Hal realtime tooks some time, Opencascade, KDL, Xml, Doxygen, etc tooks time.
Now it's almost time to code straight ahead all the solutions we need. It's piece of cake now.

(joint mode to avoid the singularities in the genserkins kinematics).

Haha. I am thinking about "The Singularity" for some day's now.
Here is my start of the code. It relies on bitsets instead of neurons.

//! Hard drive of the AI
struct BRAIN {
    std::bitset<1> Alive;
    std::bitset<1> Rip;
    std::vector<std::bitset<1>> SelfConsciousness;
    std::vector<std::bitset<1>> Memory;

};

//! Artificial intelligence and how to adapt technological singularity
struct AI {
    BRAIN Brain;
};
AI Ai;
void MainWindow::on_pushButton_pressed()
{
    //! The birth of the selfconsciousness.
    Ai.Brain.Alive=1;

    //! The selfconsciousness stream.
    Ai.Brain.SelfConsciousness.push_back(0);
    Ai.Brain.SelfConsciousness.push_back(1);
    Ai.Brain.SelfConsciousness.push_back(0);

    while(Ai.Brain.Alive != Ai.Brain.Rip){

        Ai.Brain.SelfConsciousness.push_back(1);

        for(unsigned int i=0; i<Ai.Brain.SelfConsciousness.size(); i++){
            std::cout<<"Selfconsciousness stream:"<<Ai.Brain.SelfConsciousness.at(i)<<std::endl;
             std::cout<<"Size:"<<Ai.Brain.SelfConsciousness.size()<<std::endl;
        }

        //! Copy one bit ahead.
        for(unsigned int i=0; i<Ai.Brain.SelfConsciousness.size()-1; i++){
            Ai.Brain.Memory.push_back(Ai.Brain.SelfConsciousness.at(i+1));
        }

        Ai.Brain.SelfConsciousness.clear();
        Ai.Brain.SelfConsciousness.resize(Ai.Brain.Memory.size());
        Ai.Brain.SelfConsciousness=Ai.Brain.Memory;
        Ai.Brain.Memory.clear();

        //! Loop.
    }
}
Last edit: 21 Nov 2020 17:37 by Grotius.

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

More
21 Nov 2020 18:02 - 21 Nov 2020 18:10 #189997 by Aciera
My focus is more on pick & place and general materials handling. 3D manufacturing less so.
I also have a fully functional MELFA RV3 with the original controller. There is some very interesting functionality built into the software there like soft joints and gravitation compensation depending on how the robot is mounted. Still even at that level they have to deal with the problem of singularities in world mode.
Another thing I found difficult to implement is movements in tool coordinates. Linear motion is fine but rotations around Tool-X -Y- Z (A,B,C) I found difficult as with euler-angles the sequence of operations is important because of the matrix multiplications. I tried to use quaternions instead but it did not seem to make a difference.
I stopped working on it as I had to find a way to drive the RV-6SDL. Dmitry Yurtaev who is also a member of this forum has developed PCI cards that can use Mitsubishis SSCNET interface and he helped me getting some used Mitsubishi drives to run my motors.
So I'm still working on the hardware but I hope to get it set up by the end of the year and then I will need to get back to the software side of things.
I also had a look at ROS which I think might actually use the same kinematics library you use. I can use ROS to interface with the
working controller but as I will need some kind of code to program the movements of the refitted robot I still think LinuxCNC is the way to go.


[edit]
forum.linuxcnc.org/10-advanced-configura...th-simulation#158467
Last edit: 21 Nov 2020 18:10 by Aciera.

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

More
21 Nov 2020 18:56 - 21 Nov 2020 18:59 #190000 by Grotius
Hi Aciera,

Another thing I found difficult to implement is movements in tool coordinates. Linear motion is fine but rotations around Tool-X -Y- Z (A,B,C) I found difficult as with euler-angles the sequence of operations is important because of the matrix multiplications. I tried to use quaternions instead but it did not seem to make a difference.

The matrix multiplixations are in fact quite easy to do with KDL and OpenCascade. In fact i do the FK (forward kinematics) twice at the moment.
In code it's like matrix_a * matrix_b in a certain sequence.

I do the matrix multiplixations in opencascade for the step models. Then in kdl it is done a second time and shows the end effector drawing. This is a nice setup, because the opencascade checked the kdl setup and visa versa. If the end effector dwawing is not at the toolcenter, there is something wrong defined in the xml setup file.

Using euler xyz, this is the easyest to work with and to remember how it works. Things like pitch and yaw and roll are not easy to remember for me. The euler angles i can tell right away if i see the robot setup.


I also had a look at ROS which I think might actually use the same kinematics library you use. Yes i think it's the same.
But there is another famous lib for kinematics. I never used ROS, i have seen it on youtube.

as I will need some kind of code to program the movements of the refitted robot I still think LinuxCNC is the way to go.

I don't know what is the best. If you have studied them all, you can make a review. I even don't know why i am coding this because
i have no robot at the moment. I think it has to do with interests.

The red alarm is a kinematic limit... Aiii

Attachments:
Last edit: 21 Nov 2020 18:59 by Grotius.
The following user(s) said Thank You: thefabricator03

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

More
21 Nov 2020 19:28 - 21 Nov 2020 19:55 #190002 by Aciera
Calculation of the matrix multiplication was not the problem as such. What I struggled with was the fact that for the reversal of a rotation of more than one euler angle the sequence of the multiplications needs to change to reach the original position and orientation.
So say you wanted to rotate that light sabre 90° around its axis and then move it 100mm along that axis and then rotate back -90° and move back 100mm. Now you want the light sabre to be in the same position and orientation as when you started. This is no problem on my Mitsubishi controller but using linuxcnc and genserkins I could not get it to end up at the orignal position if more than one euler angle is involved because it would somehow have to realize that it needed to reverse the sequence of the matrix multiplication regarding the rotational matrices.
So really its the Tool coordinate mode that I'm struggling to implement.
Mind you my programming capabilities are very limited. But I don't even know how to solve the problem theoretically using euler angles That is why I researched a bit and found that using quaternions the rotations require only one matrix multiplication instead of two so there is no sequence to reverse. I tried it in python but it didn't get the tool back to the original position either. Once I get the robot operational with linuxCNC I will probably get back to it again as this is often needed in parts handling. Mind you I probably would have to code that in C or C++ to be handled in realtime space.

[edit]
I just stumbled over something, will need to study that later:
math.stackexchange.com/questions/1030217...otation-euler-angles
Last edit: 21 Nov 2020 19:55 by Aciera.

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

More
21 Nov 2020 20:31 #190008 by aleksamc
You have made very interesting job, Grotius. Could you make some video of how you work with all this robots?

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

Time to create page: 0.612 seconds
Powered by Kunena Forum